diff options
Diffstat (limited to 'stdlib/source/lux/tool/compiler/phase/translation')
5 files changed, 73 insertions, 14 deletions
diff --git a/stdlib/source/lux/tool/compiler/phase/translation/js/expression.lux b/stdlib/source/lux/tool/compiler/phase/translation/js/expression.lux new file mode 100644 index 000000000..76b206124 --- /dev/null +++ b/stdlib/source/lux/tool/compiler/phase/translation/js/expression.lux @@ -0,0 +1,59 @@ +(.module: + [lux #* + [control + [monad (#+ do)]]] + [// + [runtime (#+ Phase)] + ["." primitive] + ["." structure] + ["." reference] + ["." function] + ["." case] + ["." loop] + ["." /// + ["." synthesis] + ["." extension]]]) + +(def: #export (translate synthesis) + Phase + (case synthesis + (^template [<tag> <generator>] + (^ (<tag> value)) + (:: ///.monad wrap (<generator> value))) + ([synthesis.bit primitive.bit] + [synthesis.i64 primitive.i64] + [synthesis.f64 primitive.f64] + [synthesis.text primitive.text]) + + (^ (synthesis.variant variantS)) + (structure.variant translate variantS) + + (^ (synthesis.tuple members)) + (structure.tuple translate members) + + (#synthesis.Reference value) + (:: reference.system reference value) + + (^ (synthesis.branch/case case)) + (case.case translate case) + + (^ (synthesis.branch/let let)) + (case.let translate let) + + (^ (synthesis.branch/if if)) + (case.if translate if) + + (^ (synthesis.loop/scope scope)) + (loop.scope translate scope) + + (^ (synthesis.loop/recur updates)) + (loop.recur translate updates) + + (^ (synthesis.function/abstraction abstraction)) + (function.function translate abstraction) + + (^ (synthesis.function/apply application)) + (function.apply translate application) + + (#synthesis.Extension extension) + (extension.apply translate extension))) diff --git a/stdlib/source/lux/tool/compiler/phase/translation/js/primitive.lux b/stdlib/source/lux/tool/compiler/phase/translation/js/primitive.lux index 7b475c2e7..f2bee19c5 100644 --- a/stdlib/source/lux/tool/compiler/phase/translation/js/primitive.lux +++ b/stdlib/source/lux/tool/compiler/phase/translation/js/primitive.lux @@ -16,18 +16,18 @@ _.boolean) (def: high - (-> Int Int) + (-> (I64 Any) (I64 Any)) (i64.logic-right-shift 32)) (def: low - (-> Int Int) + (-> (I64 Any) (I64 Any)) (let [mask (dec (i64.left-shift 32 1))] (|>> (i64.and mask)))) (def: #export (i64 value) - (-> Int Expression) - (//runtime.i64//new (|> value ..high _.i32) - (|> value ..low _.i32))) + (-> (I64 Any) Expression) + (//runtime.i64//new (|> value ..high .int _.i32) + (|> value ..low .int _.i32))) (def: #export f64 (-> Frac Expression) diff --git a/stdlib/source/lux/tool/compiler/phase/translation/js/structure.lux b/stdlib/source/lux/tool/compiler/phase/translation/js/structure.lux index bac907bea..ec60f6292 100644 --- a/stdlib/source/lux/tool/compiler/phase/translation/js/structure.lux +++ b/stdlib/source/lux/tool/compiler/phase/translation/js/structure.lux @@ -27,6 +27,6 @@ (def: #export (variant translate [lefts right? valueS]) (-> Phase (Variant Synthesis) (Operation Expression)) - (do ////.monad - [valueT (translate valueS)] - (wrap (//runtime.variant (_.i32 (.int lefts)) (//runtime.flag right?) valueT)))) + (:: ////.monad map + (//runtime.variant (_.i32 (.int lefts)) (//runtime.flag right?)) + (translate valueS))) diff --git a/stdlib/source/lux/tool/compiler/phase/translation/scheme/expression.jvm.lux b/stdlib/source/lux/tool/compiler/phase/translation/scheme/expression.jvm.lux index c54311da0..76b206124 100644 --- a/stdlib/source/lux/tool/compiler/phase/translation/scheme/expression.jvm.lux +++ b/stdlib/source/lux/tool/compiler/phase/translation/scheme/expression.jvm.lux @@ -31,8 +31,8 @@ (^ (synthesis.tuple members)) (structure.tuple translate members) - (#synthesis.Reference reference) - (reference.reference reference) + (#synthesis.Reference value) + (:: reference.system reference value) (^ (synthesis.branch/case case)) (case.case translate case) diff --git a/stdlib/source/lux/tool/compiler/phase/translation/scheme/primitive.jvm.lux b/stdlib/source/lux/tool/compiler/phase/translation/scheme/primitive.jvm.lux index dff6cd644..d53a0691e 100644 --- a/stdlib/source/lux/tool/compiler/phase/translation/scheme/primitive.jvm.lux +++ b/stdlib/source/lux/tool/compiler/phase/translation/scheme/primitive.jvm.lux @@ -8,8 +8,8 @@ (-> <type> Expression) <code>)] - [bit Bit _.bool] - [i64 Int _.int] - [f64 Frac _.float] - [text Text _.string] + [bit Bit _.bool] + [i64 (I64 Any) (|>> .int _.int)] + [f64 Frac _.float] + [text Text _.string] ) |