aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/tool/compiler/phase/extension/analysis/js.lux
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/tool/compiler/phase/extension/analysis/js.lux66
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)
)))