aboutsummaryrefslogtreecommitdiff
path: root/lux-js/source
diff options
context:
space:
mode:
Diffstat (limited to 'lux-js/source')
-rw-r--r--lux-js/source/program.lux204
1 files changed, 102 insertions, 102 deletions
diff --git a/lux-js/source/program.lux b/lux-js/source/program.lux
index 7a27e7172..5e7cdd72f 100644
--- a/lux-js/source/program.lux
+++ b/lux-js/source/program.lux
@@ -166,32 +166,32 @@
(def: (js_int value)
(-> Int org/openjdk/nashorn/api/scripting/JSObject)
- (<| (ffi.:as org/openjdk/nashorn/api/scripting/JSObject)
+ (<| (ffi.as org/openjdk/nashorn/api/scripting/JSObject)
(ffi.object [] org/openjdk/nashorn/api/scripting/AbstractJSObject [IntValue]
[]
... Methods
(IntValue
[] (getValue self []) java/lang/Object
- (ffi.:as java/lang/Object (ffi.as_long value)))
+ (ffi.as java/lang/Object (ffi.as_long value)))
(org/openjdk/nashorn/api/scripting/AbstractJSObject
[] (getMember self [member java/lang/String]) java/lang/Object
(case (ffi.of_string member)
(pattern (static runtime.i64_high_field))
(|> value .nat runtime.high jvm_int
- (ffi.:as java/lang/Object))
+ (ffi.as java/lang/Object))
(pattern (static runtime.i64_low_field))
(|> value .nat runtime.low jvm_int
- (ffi.:as java/lang/Object))
+ (ffi.as java/lang/Object))
_
(panic! (exception.error ..unknown_member [(ffi.of_string member)
- (ffi.:as java/lang/Object (ffi.as_long value))]))))
+ (ffi.as java/lang/Object (ffi.as_long value))]))))
)))
(def: (::toString js_object)
(-> Any org/openjdk/nashorn/api/scripting/JSObject)
- (<| (ffi.:as org/openjdk/nashorn/api/scripting/JSObject)
+ (<| (ffi.as org/openjdk/nashorn/api/scripting/JSObject)
(ffi.object [] org/openjdk/nashorn/api/scripting/AbstractJSObject []
[]
(org/openjdk/nashorn/api/scripting/AbstractJSObject
@@ -204,12 +204,12 @@
(|> js_object
debug.inspection
ffi.as_string
- (ffi.:as java/lang/Object)))
+ (ffi.as java/lang/Object)))
)))
(def: (::slice js_object value)
(-> (-> java/lang/Object org/openjdk/nashorn/api/scripting/JSObject) (Array java/lang/Object) org/openjdk/nashorn/api/scripting/JSObject)
- (<| (ffi.:as org/openjdk/nashorn/api/scripting/JSObject)
+ (<| (ffi.as org/openjdk/nashorn/api/scripting/JSObject)
(ffi.object [] org/openjdk/nashorn/api/scripting/AbstractJSObject []
[]
(org/openjdk/nashorn/api/scripting/AbstractJSObject
@@ -223,37 +223,37 @@
(|> args
(array.read! 0)
maybe.trusted
- (:as Int)
+ (as Int)
ffi.as_int)
(ffi.as_int (.int (array.size value))))
- (:as java/lang/Object)
+ (as java/lang/Object)
js_object
- (ffi.:as java/lang/Object)))
+ (ffi.as java/lang/Object)))
)))
(def: (js_structure value)
(-> (Array java/lang/Object) org/openjdk/nashorn/api/scripting/JSObject)
- (let [js_object (: (-> java/lang/Object org/openjdk/nashorn/api/scripting/JSObject)
- (function (_ sub_value)
- (<| (case (ffi.check [java/lang/Object] sub_value)
- {.#Some sub_value}
- (|> sub_value (:as (Array java/lang/Object)) js_structure)
-
- {.#None})
- (case (ffi.check java/lang/Long sub_value)
- {.#Some sub_value}
- (|> sub_value ffi.of_long js_int)
-
- {.#None})
- ... else
- (:as org/openjdk/nashorn/api/scripting/JSObject sub_value))))]
- (<| (ffi.:as org/openjdk/nashorn/api/scripting/JSObject)
+ (let [js_object (is (-> java/lang/Object org/openjdk/nashorn/api/scripting/JSObject)
+ (function (_ sub_value)
+ (<| (case (ffi.check [java/lang/Object] sub_value)
+ {.#Some sub_value}
+ (|> sub_value (as (Array java/lang/Object)) js_structure)
+
+ {.#None})
+ (case (ffi.check java/lang/Long sub_value)
+ {.#Some sub_value}
+ (|> sub_value ffi.of_long js_int)
+
+ {.#None})
+ ... else
+ (as org/openjdk/nashorn/api/scripting/JSObject sub_value))))]
+ (<| (ffi.as org/openjdk/nashorn/api/scripting/JSObject)
(ffi.object [] org/openjdk/nashorn/api/scripting/AbstractJSObject [StructureValue]
[]
... Methods
(StructureValue
[] (getValue self []) java/lang/Object
- (ffi.:as java/lang/Object value))
+ (ffi.as java/lang/Object value))
(org/openjdk/nashorn/api/scripting/AbstractJSObject
[] (isArray self []) boolean
(ffi.as_boolean #1))
@@ -263,17 +263,17 @@
(case (ffi.of_string member)
(^.or "toJSON" "toString")
(|> (::toString value)
- (ffi.:as java/lang/Object))
+ (ffi.as java/lang/Object))
"length"
(|> value
array.size
jvm_int
- (ffi.:as java/lang/Object))
+ (ffi.as java/lang/Object))
"slice"
(|> (::slice js_object value)
- (ffi.:as java/lang/Object))
+ (ffi.as java/lang/Object))
(pattern (static runtime.variant_tag_field))
(|> value
@@ -293,18 +293,18 @@
(array.read! 2)
maybe.trusted
js_object
- (ffi.:as java/lang/Object))
+ (ffi.as java/lang/Object))
_
- (panic! (exception.error ..unknown_member [(:as Text member) (:as java/lang/Object value)])))
+ (panic! (exception.error ..unknown_member [(as Text member) (as java/lang/Object value)])))
)
(org/openjdk/nashorn/api/scripting/AbstractJSObject
[] (getSlot self [idx int]) java/lang/Object
(|> value
- (array.read! (|> idx java/lang/Integer::longValue (:as Nat)))
+ (array.read! (|> idx java/lang/Integer::longValue (as Nat)))
maybe.trusted
js_object
- (:as java/lang/Object)))
+ (as java/lang/Object)))
))))
(exception: undefined_has_no_lux_representation)
@@ -355,7 +355,7 @@
(^.multi [{.#Some tag} ?flag {.#Some value}]
[[(ffi.check java/lang/Number tag) (lux_object value)]
[{.#Some tag} {try.#Success value}]])
- {.#Some [(java/lang/Number::intValue (:as java/lang/Number tag))
+ {.#Some [(java/lang/Number::intValue (as java/lang/Number tag))
(maybe.else (ffi.null) ?flag)
value]}
@@ -369,8 +369,8 @@
(if (ffi.of_boolean (org/openjdk/nashorn/api/scripting/JSObject::isArray js_object))
(let [num_keys (.nat (ffi.of_int (org/openjdk/nashorn/api/scripting/ScriptObjectMirror::size js_object)))]
(loop [idx 0
- output (: (Array java/lang/Object)
- (array.empty num_keys))]
+ output (is (Array java/lang/Object)
+ (array.empty num_keys))]
(if (n.< num_keys idx)
(case (org/openjdk/nashorn/api/scripting/JSObject::getMember (ffi.as_string (%.nat idx)) js_object)
{.#Some member}
@@ -381,7 +381,7 @@
{.#None}
(case (lux_object member)
{try.#Success parsed_member}
- (again (++ idx) (array.write! idx (:as java/lang/Object parsed_member) output))
+ (again (++ idx) (array.write! idx (as java/lang/Object parsed_member) output))
{try.#Failure error}
{.#None}))
@@ -437,12 +437,12 @@
{.#None}
(if (ffi.of_boolean (org/openjdk/nashorn/api/scripting/JSObject::isFunction js_object))
{try.#Success js_object}
- ... (exception.except ..unknown_kind_of_host_object [(:as java/lang/Object js_object)])
+ ... (exception.except ..unknown_kind_of_host_object [(as java/lang/Object js_object)])
{try.#Success js_object}
))))
{.#None})
... else
- ... (exception.except ..unknown_kind_of_host_object [(:as java/lang/Object js_object)])
+ ... (exception.except ..unknown_kind_of_host_object [(as java/lang/Object js_object)])
{try.#Success js_object}
)))
@@ -450,7 +450,7 @@
(-> Any (Maybe org/openjdk/nashorn/api/scripting/JSObject))
(do maybe.monad
[function (|> function
- (:as java/lang/Object)
+ (as java/lang/Object)
(ffi.check org/openjdk/nashorn/api/scripting/JSObject))]
(if (ffi.of_boolean (org/openjdk/nashorn/api/scripting/JSObject::isFunction function))
{.#Some function}
@@ -463,12 +463,12 @@
(for @.jvm
(as_is (def: (call_macro inputs lux macro)
(-> (List Code) Lux org/openjdk/nashorn/api/scripting/JSObject (Try (Try [Lux (List Code)])))
- (let [to_js (: (-> Any java/lang/Object)
- (|>> (:as (Array java/lang/Object)) js_structure (:as java/lang/Object)))]
- (<| (:as (Try (Try [Lux (List Code)])))
+ (let [to_js (is (-> Any java/lang/Object)
+ (|>> (as (Array java/lang/Object)) js_structure (as java/lang/Object)))]
+ (<| (as (Try (Try [Lux (List Code)])))
(org/openjdk/nashorn/api/scripting/JSObject::call {.#None}
(|> (array.empty 2)
- (: (Array java/lang/Object))
+ (is (Array java/lang/Object))
(array.write! 0 (to_js inputs))
(array.write! 1 (to_js lux)))
macro))))
@@ -484,21 +484,21 @@
(case (call_macro inputs lux macro)
{try.#Success output}
(|> output
- (:as java/lang/Object)
+ (as java/lang/Object)
lux_object
- (:as (Try (Try [Lux (List Code)]))))
+ (as (Try (Try [Lux (List Code)]))))
{try.#Failure error}
{try.#Failure error})
{.#None}
- (exception.except ..cannot_apply_a_non_function (:as java/lang/Object macro))))
+ (exception.except ..cannot_apply_a_non_function (as java/lang/Object macro))))
)
@.js
(def: (expander macro inputs lux)
Expander
- {try.#Success ((:as Macro' macro) inputs lux)})
+ {try.#Success ((as Macro' macro) inputs lux)})
)
(for @.jvm
@@ -534,22 +534,22 @@
(IO (Host _.Expression _.Statement))
(io (let [interpreter (javax/script/ScriptEngineFactory::getScriptEngine
(org/openjdk/nashorn/api/scripting/NashornScriptEngineFactory::new))]
- (: (Host _.Expression _.Statement)
- (implementation
- (def: (evaluate alias [_ input]) (..evaluate! interpreter alias input))
- (def: execute (..execute! interpreter))
- (def: (define context custom [_ input]) (..define! interpreter context custom input))
+ (is (Host _.Expression _.Statement)
+ (implementation
+ (def: (evaluate alias [_ input]) (..evaluate! interpreter alias input))
+ (def: execute (..execute! interpreter))
+ (def: (define context custom [_ input]) (..define! interpreter context custom input))
- (def: (ingest context content)
- (|> content (# utf8.codec decoded) try.trusted (:as _.Statement)))
+ (def: (ingest context content)
+ (|> content (# utf8.codec decoded) try.trusted (as _.Statement)))
- (def: (re_learn context custom content)
- (..execute! interpreter content))
-
- (def: (re_load context custom content)
- (do try.monad
- [_ (..execute! interpreter content)]
- (..evaluate! interpreter context (_.var (reference.artifact context))))))))))
+ (def: (re_learn context custom content)
+ (..execute! interpreter content))
+
+ (def: (re_load context custom content)
+ (do try.monad
+ [_ (..execute! interpreter content)]
+ (..evaluate! interpreter context (_.var (reference.artifact context))))))))))
)
@.js
@@ -593,39 +593,39 @@
(def: host
(IO (Host _.Expression _.Statement))
- (io (: (Host _.Expression _.Statement)
- (implementation
- (def: (evaluate alias [_ input]) (..evaluate! alias input))
- (def: execute ..execute!)
- (def: (define context custom [_ input]) (..define! context custom input))
-
- (def: (ingest context content)
- (|> content (# utf8.codec decoded) try.trusted (:as _.Statement)))
-
- (def: (re_learn context custom content)
- (..execute! content))
-
- (def: (re_load context custom content)
- (do try.monad
- [_ (..execute! content)]
- (..evaluate! context (_.var (reference.artifact context)))))))))
+ (io (is (Host _.Expression _.Statement)
+ (implementation
+ (def: (evaluate alias [_ input]) (..evaluate! alias input))
+ (def: execute ..execute!)
+ (def: (define context custom [_ input]) (..define! context custom input))
+
+ (def: (ingest context content)
+ (|> content (# utf8.codec decoded) try.trusted (as _.Statement)))
+
+ (def: (re_learn context custom content)
+ (..execute! content))
+
+ (def: (re_load context custom content)
+ (do try.monad
+ [_ (..execute! content)]
+ (..evaluate! context (_.var (reference.artifact context)))))))))
))
(def: (phase_wrapper archive)
(-> Archive (runtime.Operation phase.Wrapper))
(do phase.monad
[]
- (in (:as phase.Wrapper
- (for @.jvm
- ... The implementation for @.jvm is technically incorrect.
- ... However, the JS compiler runs fast enough on Node to be fully hosted there.
- ... And running the JS compiler on the JVM (on top of Nashorn) is impractically slow.
- ... This means that in practice, only the @.js implementation matters.
- ... And since no cross-language boundary needs to be handled, it's a correct implementation.
- (|>>)
-
- @.js
- (|>>))))))
+ (in (as phase.Wrapper
+ (for @.jvm
+ ... The implementation for @.jvm is technically incorrect.
+ ... However, the JS compiler runs fast enough on Node to be fully hosted there.
+ ... And running the JS compiler on the JVM (on top of Nashorn) is impractically slow.
+ ... This means that in practice, only the @.js implementation matters.
+ ... And since no cross-language boundary needs to be handled, it's a correct implementation.
+ (|>>)
+
+ @.js
+ (|>>))))))
(def: platform
(IO (Platform [Register Text] _.Expression _.Statement))
@@ -663,36 +663,36 @@
(def: (extender phase_wrapper)
(-> phase.Wrapper Extender)
... TODO: Stop relying on coercions ASAP.
- (<| (:as Extender)
+ (<| (as Extender)
(function (@self handler))
- (:as Handler)
+ (as Handler)
(function (@self name phase))
- (:as Phase)
+ (as Phase)
(function (@self archive parameters))
- (:as Operation)
+ (as Operation)
(function (@self state))
- (:as Try)
+ (as Try)
try.trusted
- (:as Try)
+ (as Try)
(do try.monad
[handler (try.of_maybe (..ensure_function handler))
- .let [to_js (: (-> Any java/lang/Object)
- (|>> (:as (Array java/lang/Object)) js_structure (:as java/lang/Object)))]
+ .let [to_js (is (-> Any java/lang/Object)
+ (|>> (as (Array java/lang/Object)) js_structure (as java/lang/Object)))]
output (org/openjdk/nashorn/api/scripting/JSObject::call {.#None}
(|> (array.empty 5)
- (: (Array java/lang/Object))
+ (is (Array java/lang/Object))
(array.write! 0 name)
- (array.write! 1 (:as java/lang/Object (extender phase)))
+ (array.write! 1 (as java/lang/Object (extender phase)))
(array.write! 2 (to_js archive))
(array.write! 3 (to_js parameters))
(array.write! 4 (to_js state)))
handler)]
- (lux_object (:as java/lang/Object output)))))
+ (lux_object (as java/lang/Object output)))))
@.js
(def: (extender phase_wrapper handler)
(-> phase.Wrapper Extender)
- (:expected handler)))
+ (as_expected handler)))
(def: (declare_success! _)
(-> Any (Async Any))