diff options
author | Eduardo Julian | 2019-06-16 04:06:47 -0400 |
---|---|---|
committer | Eduardo Julian | 2019-06-16 04:06:47 -0400 |
commit | 4bf2dce01f51a5b0be76a587f877d1227c3982ae (patch) | |
tree | 8a3a31be070e3ba04fc5e79b9c17c151f90677a6 /stdlib/source/lux/tool/compiler/phase/extension/analysis/js.lux | |
parent | 0cc98bbe9cae3fd9fc50d8c78c1deaba7e557531 (diff) |
Fixes and adaptations for the JavaScript compiler.
Diffstat (limited to 'stdlib/source/lux/tool/compiler/phase/extension/analysis/js.lux')
-rw-r--r-- | stdlib/source/lux/tool/compiler/phase/extension/analysis/js.lux | 66 |
1 files changed, 53 insertions, 13 deletions
diff --git a/stdlib/source/lux/tool/compiler/phase/extension/analysis/js.lux b/stdlib/source/lux/tool/compiler/phase/extension/analysis/js.lux index d8285532b..d04e04ec9 100644 --- a/stdlib/source/lux/tool/compiler/phase/extension/analysis/js.lux +++ b/stdlib/source/lux/tool/compiler/phase/extension/analysis/js.lux @@ -15,7 +15,7 @@ [target ["_" js]]] ["." // #_ - ["#." lux (#+ custom)] + ["/" lux (#+ custom)] ["/#" // ["#." bundle] ["/#" // ("#@." monad) @@ -103,6 +103,57 @@ (///bundle.install "delete" array::delete) ))) +(def: object::new + Handler + (custom + [($_ <>.and <c>.any (<c>.tuple (<>.some <c>.any))) + (function (_ extension phase [constructorC inputsC]) + (do ////.monad + [constructorA (typeA.with-type Any + (phase constructorC)) + inputsA (monad.map @ (|>> phase (typeA.with-type Any)) inputsC) + _ (typeA.infer .Any)] + (wrap (#/////analysis.Extension extension (list& constructorA inputsA)))))])) + +(def: object::get + Handler + (custom + [($_ <>.and <c>.text <c>.any) + (function (_ extension phase [fieldC objectC]) + (do ////.monad + [objectA (typeA.with-type Any + (phase objectC)) + _ (typeA.infer .Any)] + (wrap (#/////analysis.Extension extension (list (/////analysis.text fieldC) + objectA)))))])) + +(def: object::do + Handler + (custom + [($_ <>.and <c>.text <c>.any (<c>.tuple (<>.some <c>.any))) + (function (_ extension phase [methodC objectC inputsC]) + (do ////.monad + [objectA (typeA.with-type Any + (phase objectC)) + inputsA (monad.map @ (|>> phase (typeA.with-type Any)) inputsC) + _ (typeA.infer .Any)] + (wrap (#/////analysis.Extension extension (list& (/////analysis.text methodC) + objectA + inputsA)))))])) + +(def: bundle::object + Bundle + (<| (///bundle.prefix "object") + (|> ///bundle.empty + (///bundle.install "new" object::new) + (///bundle.install "get" object::get) + (///bundle.install "do" object::do) + (///bundle.install "null" (/.nullary Any)) + (///bundle.install "null?" (/.unary Any Bit)) + (///bundle.install "undefined" (/.nullary Any)) + (///bundle.install "undefined?" (/.unary Any Bit)) + ))) + (def: js::constant Handler (custom @@ -124,23 +175,12 @@ _ (typeA.infer Any)] (wrap (#/////analysis.Extension extension (list& abstractionA inputsA)))))])) -(def: js::undefined? - Handler - (custom - [<c>.any - (function (_ extension phase [valueC]) - (do ////.monad - [valueA (typeA.with-type Any - (phase valueC)) - _ (typeA.infer Bit)] - (wrap (#/////analysis.Extension extension (list valueA)))))])) - (def: #export bundle Bundle (<| (///bundle.prefix "js") (|> ///bundle.empty (///bundle.install "constant" js::constant) (///bundle.install "apply" js::apply) - (///bundle.install "undefined?" js::undefined?) (dictionary.merge bundle::array) + (dictionary.merge bundle::object) ))) |