diff options
Diffstat (limited to '')
-rw-r--r-- | lux-js/source/program.lux | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/lux-js/source/program.lux b/lux-js/source/program.lux index 52f5d49ef..ad1f53ba3 100644 --- a/lux-js/source/program.lux +++ b/lux-js/source/program.lux @@ -158,13 +158,13 @@ "Member" member "Object" (debug.inspection object))) - (def: jvm_int + (def jvm_int (-> (I64 Any) java/lang/Integer) (|>> .int ffi.as_long java/lang/Long::intValue)) - (def: (js_int value) + (def (js_int value) (-> Int org/openjdk/nashorn/api/scripting/JSObject) (<| (ffi.is org/openjdk/nashorn/api/scripting/JSObject) (ffi.object [] org/openjdk/nashorn/api/scripting/AbstractJSObject [IntValue] @@ -189,7 +189,7 @@ (ffi.is java/lang/Object (ffi.as_long value))])))) ))) - (def: (::toString js_object) + (def (::toString js_object) (-> Any org/openjdk/nashorn/api/scripting/JSObject) (<| (ffi.is org/openjdk/nashorn/api/scripting/JSObject) (ffi.object [] org/openjdk/nashorn/api/scripting/AbstractJSObject [] @@ -207,7 +207,7 @@ (ffi.is java/lang/Object))) ))) - (def: (::slice js_object value) + (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.is org/openjdk/nashorn/api/scripting/JSObject) (ffi.object [] org/openjdk/nashorn/api/scripting/AbstractJSObject [] @@ -231,7 +231,7 @@ (ffi.is java/lang/Object))) ))) - (def: (js_structure value) + (def (js_structure value) (-> (Array java/lang/Object) org/openjdk/nashorn/api/scripting/JSObject) (let [js_object (is (-> java/lang/Object org/openjdk/nashorn/api/scripting/JSObject) (function (_ sub_value) @@ -323,7 +323,7 @@ {.#None} "???"))) - (def: (i32 half i64) + (def (i32 half i64) (-> Text org/openjdk/nashorn/api/scripting/ScriptObjectMirror (Maybe Int)) (|> i64 (org/openjdk/nashorn/api/scripting/JSObject::getMember [(ffi.as_string half)]) @@ -331,7 +331,7 @@ maybe#conjoint (maybe#each (|>> java/lang/Number::longValue ffi.of_long)))) - (def: (check_int js_object) + (def (check_int js_object) (-> org/openjdk/nashorn/api/scripting/ScriptObjectMirror (Maybe Int)) (case [(..i32 runtime.i64_high_field js_object) @@ -345,7 +345,7 @@ _ {.#None})) - (def: (check_variant lux_object js_object) + (def (check_variant lux_object js_object) (-> (-> java/lang/Object (Try Any)) org/openjdk/nashorn/api/scripting/ScriptObjectMirror (Maybe Any)) @@ -362,7 +362,7 @@ _ {.#None})) - (def: (check_tuple lux_object js_object) + (def (check_tuple lux_object js_object) (-> (-> java/lang/Object (Try Any)) org/openjdk/nashorn/api/scripting/ScriptObjectMirror (Maybe (Array java/lang/Object))) @@ -391,7 +391,7 @@ {.#Some output}))) {.#None})) - (def: (lux_object js_object) + (def (lux_object js_object) (-> java/lang/Object (Try Any)) (`` (<| (if (ffi.null? js_object) (exception.except ..null_has_no_lux_representation [{.#None}])) @@ -446,7 +446,7 @@ {try.#Success js_object} ))) - (def: (ensure_function function) + (def (ensure_function function) (-> Any (Maybe org/openjdk/nashorn/api/scripting/JSObject)) (do maybe.monad [function (|> function @@ -461,7 +461,7 @@ (these)) (for @.jvm - (these (def: (call_macro inputs lux macro) + (these (def (call_macro inputs lux macro) (-> (List Code) Lux org/openjdk/nashorn/api/scripting/JSObject (Try (Try [Lux (List Code)]))) (let [to_js (is (-> Any java/lang/Object) (|>> (as (Array java/lang/Object)) js_structure (as java/lang/Object)))] @@ -477,7 +477,7 @@ (exception.report "Object" (ffi.of_string (java/lang/Object::toString object)))) - (def: (expander macro inputs lux) + (def (expander macro inputs lux) Expander (case (..ensure_function macro) {.#Some macro} @@ -496,13 +496,13 @@ ) @.js - (def: (expander macro inputs lux) + (def (expander macro inputs lux) Expander {try.#Success ((as Macro' macro) inputs lux)}) ) (for @.jvm - (these (def: (evaluate! interpreter alias input) + (these (def (evaluate! interpreter alias input) (-> javax/script/ScriptEngine unit.ID _.Expression (Try Any)) (do try.monad [?output (javax/script/ScriptEngine::eval (ffi.as_string (_.code input)) interpreter)] @@ -513,13 +513,13 @@ {.#None} (exception.except ..null_has_no_lux_representation [{.#Some input}])))) - (def: (execute! interpreter input) + (def (execute! interpreter input) (-> javax/script/ScriptEngine _.Statement (Try Any)) (do try.monad [?output (javax/script/ScriptEngine::eval (ffi.as_string (_.code input)) interpreter)] (in []))) - (def: (define! interpreter context custom input) + (def (define! interpreter context custom input) (-> javax/script/ScriptEngine unit.ID (Maybe Text) _.Expression (Try [Text Any _.Statement])) (let [global (maybe.else (reference.artifact context) custom) @@ -530,30 +530,30 @@ value (evaluate! interpreter context @global)] (in [global value definition])))) - (def: host + (def host (IO (Host _.Expression _.Statement)) (io (let [interpreter (javax/script/ScriptEngineFactory::getScriptEngine (org/openjdk/nashorn/api/scripting/NashornScriptEngineFactory::new))] (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 (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) + (def (ingest context content) (|> content (at utf8.codec decoded) try.trusted (as _.Statement))) - (def: (re_learn context custom content) + (def (re_learn context custom content) (..execute! interpreter content)) - (def: (re_load context custom content) + (def (re_load context custom content) (do try.monad [_ (..execute! interpreter content)] (..evaluate! interpreter context (_.var (reference.artifact context)))))))))) ) @.js - (these (def: (eval code) + (these (def (eval code) (-> Text (Try (Maybe Any))) ... Note: I have to call "eval" this way ... in order to avoid a quirk of calling eval in Node @@ -563,7 +563,7 @@ {.#None} {.#Some return})))) - (def: (evaluate! alias input) + (def (evaluate! alias input) (-> unit.ID _.Expression (Try Any)) (do try.monad [?output (..eval (_.code input))] @@ -574,13 +574,13 @@ {.#None} (exception.except ..null_has_no_lux_representation [{.#Some input}])))) - (def: (execute! input) + (def (execute! input) (-> _.Statement (Try Any)) (do try.monad [?output (..eval (_.code input))] (in []))) - (def: (define! context custom input) + (def (define! context custom input) (-> unit.ID (Maybe Text) _.Expression (Try [Text Any _.Statement])) (let [global (maybe.else (reference.artifact context) custom) @@ -591,27 +591,27 @@ value (..evaluate! context @global)] (in [global value definition])))) - (def: host + (def host (IO (Host _.Expression _.Statement)) (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 (evaluate alias [_ input]) (..evaluate! alias input)) + (def execute ..execute!) + (def (define context custom [_ input]) (..define! context custom input)) - (def: (ingest context content) + (def (ingest context content) (|> content (at utf8.codec decoded) try.trusted (as _.Statement))) - (def: (re_learn context custom content) + (def (re_learn context custom content) (..execute! content)) - (def: (re_load context custom content) + (def (re_load context custom content) (do try.monad [_ (..execute! content)] (..evaluate! context (_.var (reference.artifact context))))))))) )) -(def: (phase_wrapper archive) +(def (phase_wrapper archive) (-> Archive (runtime.Operation phase.Wrapper)) (do phase.monad [] @@ -627,7 +627,7 @@ @.js (|>>)))))) -(def: platform +(def platform (IO (Platform [Register Text] _.Expression _.Statement)) (do io.monad [host ..host] @@ -642,7 +642,7 @@ platform.#phase_wrapper ..phase_wrapper platform.#write (|>> _.code (at utf8.codec encoded))]))) -(def: (program context program) +(def (program context program) (Program _.Expression _.Statement) (let [@process (_.var "process") on_node_js? (|> @process @@ -660,7 +660,7 @@ (_.string ""))))) (for @.jvm - (def: (extender phase_wrapper) + (def (extender phase_wrapper) (-> phase.Wrapper Extender) ... TODO: Stop relying on coercions ASAP. (<| (as Extender) @@ -690,20 +690,20 @@ (lux_object (as java/lang/Object output))))) @.js - (def: (extender phase_wrapper handler) + (def (extender phase_wrapper handler) (-> phase.Wrapper Extender) (as_expected handler))) -(def: (declare_success! _) +(def (declare_success! _) (-> Any (Async Any)) (async.future (at world/program.default exit +0))) -(def: (scope body) +(def (scope body) (-> _.Statement _.Statement) (_.statement (_.apply (_.closure (list) body) (list)))) -(def: (lux_compiler it) +(def (lux_compiler it) (-> Any platform.Custom) (undefined)) |