diff options
Diffstat (limited to 'new-luxc/source/luxc/lang/translation/lua')
7 files changed, 39 insertions, 26 deletions
diff --git a/new-luxc/source/luxc/lang/translation/lua/case.jvm.lux b/new-luxc/source/luxc/lang/translation/lua/case.jvm.lux index bce4d7bff..1853338b4 100644 --- a/new-luxc/source/luxc/lang/translation/lua/case.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/lua/case.jvm.lux @@ -34,7 +34,7 @@ (Meta Expression)) (do macro.Monad<Meta> [valueO (translate valueS)] - (wrap (list/fold (function [[idx tail?] source] + (wrap (list/fold (function (_ [idx tail?] source) (let [method (if tail? runtimeT.product//right runtimeT.product//left)] @@ -81,7 +81,8 @@ Expression (lua.string "PM-ERROR")) -(exception: #export Unrecognized-Path) +(exception: #export (Unrecognized-Path {message Text}) + message) (def: (translate-pattern-matching' translate path) (-> (-> ls.Synthesis (Meta Expression)) Code (Meta Expression)) diff --git a/new-luxc/source/luxc/lang/translation/lua/eval.jvm.lux b/new-luxc/source/luxc/lang/translation/lua/eval.jvm.lux index c42ba0668..8be5667e9 100644 --- a/new-luxc/source/luxc/lang/translation/lua/eval.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/lua/eval.jvm.lux @@ -11,6 +11,15 @@ (lang (host [lua #+ Lua Expression Statement]))) [//]) +(do-template [<name>] + [(exception: #export (<name> {message Text}) + message)] + + [Unknown-Kind-Of-Host-Object] + [Null-Has-No-Lux-Representation] + [Cannot-Evaluate] + ) + (host.import java/lang/Object (toString [] String) (getClass [] (Class Object))) @@ -64,9 +73,6 @@ (recur num-keys (n/inc idx) output)) (#.Some output))))) -(exception: #export Unknown-Kind-Of-Host-Object) -(exception: #export Null-Has-No-Lux-Representation) - (def: (lux-object host-object) (-> Object (Error Top)) (`` (cond (host.null? host-object) @@ -99,11 +105,9 @@ (ex.throw Unknown-Kind-Of-Host-Object (format "FIRST " (Object::toString [] (:! Object host-object)))) ))) -(exception: #export Cannot-Evaluate) - (def: #export (eval code) (-> Expression (Meta Top)) - (function [compiler] + (function (_ compiler) (let [interpreter (|> compiler (get@ #.host) (:! //.Host) (get@ #//.interpreter))] (case (interpreter (format "return " code ";")) (#e.Error error) diff --git a/new-luxc/source/luxc/lang/translation/lua/expression.jvm.lux b/new-luxc/source/luxc/lang/translation/lua/expression.jvm.lux index d3d336420..e2c626e83 100644 --- a/new-luxc/source/luxc/lang/translation/lua/expression.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/lua/expression.jvm.lux @@ -22,8 +22,13 @@ [".T" case] [".T" procedure])) -(exception: #export Invalid-Function-Syntax) -(exception: #export Unrecognized-Synthesis) +(do-template [<name>] + [(exception: #export (<name> {message Text}) + message)] + + [Invalid-Function-Syntax] + [Unrecognized-Synthesis] + ) (def: #export (translate synthesis) (-> ls.Synthesis (Meta Expression)) diff --git a/new-luxc/source/luxc/lang/translation/lua/function.jvm.lux b/new-luxc/source/luxc/lang/translation/lua/function.jvm.lux index 1750cd3eb..042ddd824 100644 --- a/new-luxc/source/luxc/lang/translation/lua/function.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/lua/function.jvm.lux @@ -72,7 +72,7 @@ (let [unpack (|>> (list) (lua.apply "table.unpack")) recur (|>> (list) (lua.apply function-name))] (lua.if! (lua.> arityO "num_args") - (let [slice (function [from to] + (let [slice (function (_ from to) (runtimeT.array//sub "curried" from to)) arity-args (unpack (slice (lua.int 1) arityO)) output-func-args (unpack (slice (lua.+ (lua.int 1) arityO) "num_args"))] diff --git a/new-luxc/source/luxc/lang/translation/lua/procedure.jvm.lux b/new-luxc/source/luxc/lang/translation/lua/procedure.jvm.lux index e25050ede..9b5cb6475 100644 --- a/new-luxc/source/luxc/lang/translation/lua/procedure.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/lua/procedure.jvm.lux @@ -12,7 +12,8 @@ (/ ["/." common] ["/." host])) -(exception: #export Unknown-Procedure) +(exception: #export (Unknown-Procedure {message Text}) + message) (def: procedures /common.Bundle diff --git a/new-luxc/source/luxc/lang/translation/lua/procedure/common.jvm.lux b/new-luxc/source/luxc/lang/translation/lua/procedure/common.jvm.lux index 77e57a5db..9d0e22f78 100644 --- a/new-luxc/source/luxc/lang/translation/lua/procedure/common.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/lua/procedure/common.jvm.lux @@ -51,7 +51,7 @@ (-> Text Bundle Bundle) (|> bundle dict.entries - (list/map (function [[key val]] [(format prefix " " key) val])) + (list/map (function (_ [key val]) [(format prefix " " key) val])) (dict.from-list text.Hash<Text>))) (def: (wrong-arity proc expected actual) @@ -61,19 +61,19 @@ " Actual: " (|> actual nat-to-int %i))) (syntax: (arity: [name s.local-symbol] [arity s.nat]) - (with-gensyms [g!proc g!name g!translate g!inputs] + (with-gensyms [g_ g!proc g!name g!translate g!inputs] (do @ [g!input+ (monad.seq @ (list.repeat arity (macro.gensym "input")))] (wrap (list (` (def: #export ((~ (code.local-symbol name)) (~ g!proc)) (-> (-> (..Vector (~ (code.nat arity)) Expression) Expression) (-> Text ..Proc)) - (function [(~ g!name)] - (function [(~ g!translate) (~ g!inputs)] + (function ((~ g_ ) (~ g!name)) + (function ((~ g_ ) (~ g!translate) (~ g!inputs)) (case (~ g!inputs) (^ (list (~+ g!input+))) (do macro.Monad<Meta> [(~+ (|> g!input+ - (list/map (function [g!input] + (list/map (function (_ g!input) (list g!input (` ((~ g!translate) (~ g!input)))))) list.concat))] ((~' wrap) ((~ g!proc) [(~+ g!input+)]))) @@ -88,8 +88,8 @@ (def: #export (variadic proc) (-> Variadic (-> Text Proc)) - (function [proc-name] - (function [translate inputsS] + (function (_ proc-name) + (function (_ translate inputsS) (do macro.Monad<Meta> [inputsI (monad.map @ translate inputsS)] (wrap (proc inputsI)))))) @@ -112,7 +112,9 @@ Unary valueO) -(exception: #export Wrong-Syntax) +(exception: #export (Wrong-Syntax {message Text}) + message) + (def: #export (wrong-syntax procedure args) (-> Text (List ls.Synthesis) Text) (format "Procedure: " procedure "\n" @@ -120,8 +122,8 @@ (def: lux//loop (-> Text Proc) - (function [proc-name] - (function [translate inputsS] + (function (_ proc-name) + (function (_ translate inputsS) (case (s.run inputsS ($_ p.seq s.nat (s.tuple (p.many s.any)) s.any)) (#e.Success [offset initsS+ bodyS]) (loopT.translate-loop translate offset initsS+ bodyS) @@ -132,8 +134,8 @@ (def: lux//recur (-> Text Proc) - (function [proc-name] - (function [translate inputsS] + (function (_ proc-name) + (function (_ translate inputsS) (loopT.translate-recur translate inputsS)))) ## [[Bits]] diff --git a/new-luxc/source/luxc/lang/translation/lua/runtime.jvm.lux b/new-luxc/source/luxc/lang/translation/lua/runtime.jvm.lux index 50b8008dd..137e5d4ab 100644 --- a/new-luxc/source/luxc/lang/translation/lua/runtime.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/lua/runtime.jvm.lux @@ -77,7 +77,7 @@ _ (` (let [(~' @) (~ runtime) (~+ (|> (list.zip2 argsC+ argsLC+) - (list/map (function [[left right]] (list left right))) + (list/map (function (_ [left right]) (list left right))) list/join))] (lua.function! (~ runtime) (list (~+ argsLC+)) (~ definition)))))))))))) @@ -95,7 +95,7 @@ (lua.return! "temp")))) (runtime: (array//concat left right) - (let [copy! (function [input output] + (let [copy! (function (_ input output) (lua.for-step! "idx" (lua.int 1) (format input ".n") (lua.int 1) (lua.apply "table.insert" (list output (lua.nth "idx" input)))))] (lua.block! (list (lua.local! "temp" (#.Some (lua.array (list)))) |