diff options
Diffstat (limited to 'lux-js')
-rw-r--r-- | lux-js/project.clj | 5 | ||||
-rw-r--r-- | lux-js/source/program.lux | 406 |
2 files changed, 212 insertions, 199 deletions
diff --git a/lux-js/project.clj b/lux-js/project.clj index 29b1800f8..28fcfff87 100644 --- a/lux-js/project.clj +++ b/lux-js/project.clj @@ -20,8 +20,9 @@ ["snapshots" {:url ~sonatype-snapshots :creds :gpg}]] :plugins [[com.github.luxlang/lein-luxc ~version]] - :dependencies [[com.github.luxlang/luxc-jvm ~version] - [com.github.luxlang/stdlib ~version]] + :dependencies [[com.github.luxlang/lux-bootstrapper ~version] + [com.github.luxlang/stdlib ~version] + [org.openjdk.nashorn/nashorn-core "15.0"]] :manifest {"lux" ~version} :source-paths ["source"] diff --git a/lux-js/source/program.lux b/lux-js/source/program.lux index f75a78c97..e402a550f 100644 --- a/lux-js/source/program.lux +++ b/lux-js/source/program.lux @@ -1,5 +1,6 @@ (.module: [lux #* + [program (#+ program:)] ["." host (#+ import:)] ["." debug] [abstract @@ -9,17 +10,11 @@ ["." exception (#+ exception:)] ["." io (#+ IO io)] ["." function] - [parser - [cli (#+ program:)]] [concurrency ["." promise (#+ Promise)]]] [data ["." product] ["." maybe] - [number - ["." i64] - ["n" nat] - ["i" int]] [text ["%" format (#+ format)] ["." encoding]] @@ -27,8 +22,14 @@ ["." array (#+ Array)]]] [macro ["." template]] - [world - ["." file]] + [math + [number + ["n" nat] + ["i" int] + ["." i64]]] + ["." world #_ + ["." file] + ["#/." program]] ["@" target ["_" js]] [tool @@ -63,7 +64,7 @@ ["/." cli] ["/." static]]]) -(exception: (null-has-no-lux-representation {code (Maybe _.Expression)}) +(exception: (null_has_no_lux_representation {code (Maybe _.Expression)}) (case code (#.Some code) (_.code code) @@ -72,147 +73,158 @@ "???")) (for {@.old - (as-is (import: #long java/lang/String) + (as_is (import: java/lang/String) - (import: #long (java/lang/Class a)) + (import: (java/lang/Class a)) - (import: #long java/lang/Object - (toString [] java/lang/String) - (getClass [] (java/lang/Class java/lang/Object))) + (import: java/lang/Object + ["#::." + (toString [] java/lang/String) + (getClass [] (java/lang/Class java/lang/Object))]) - (import: #long java/lang/Long - (intValue [] java/lang/Integer)) + (import: java/lang/Long + ["#::." + (intValue [] java/lang/Integer)]) - (import: #long java/lang/Integer - (longValue [] long)) + (import: java/lang/Integer + ["#::." + (longValue [] long)]) - (import: #long java/lang/Number - (intValue [] java/lang/Integer) - (longValue [] long) - (doubleValue [] double)) + (import: java/lang/Number + ["#::." + (intValue [] java/lang/Integer) + (longValue [] long) + (doubleValue [] double)]) - (import: #long java/util/Arrays - (#static [t] copyOfRange [[t] int int] [t])) + (import: java/util/Arrays + ["#::." + (#static [t] copyOfRange [[t] int int] [t])]) - (import: #long javax/script/ScriptEngine - (eval [java/lang/String] #try #? java/lang/Object)) + (import: javax/script/ScriptEngine + ["#::." + (eval [java/lang/String] #try #? java/lang/Object)]) - (import: #long javax/script/ScriptEngineFactory - (getScriptEngine [] javax/script/ScriptEngine)) + (import: javax/script/ScriptEngineFactory + ["#::." + (getScriptEngine [] javax/script/ScriptEngine)]) - (import: #long jdk/nashorn/api/scripting/NashornScriptEngineFactory - (new [])) + (import: org/openjdk/nashorn/api/scripting/NashornScriptEngineFactory + ["#::." + (new [])]) - (import: #long jdk/nashorn/api/scripting/JSObject - (isArray [] boolean) - (isFunction [] boolean) - (getSlot [int] #? java/lang/Object) - (getMember [java/lang/String] #? java/lang/Object) - (hasMember [java/lang/String] boolean) - (call [#? java/lang/Object [java/lang/Object]] #try java/lang/Object)) + (import: org/openjdk/nashorn/api/scripting/JSObject + ["#::." + (isArray [] boolean) + (isFunction [] boolean) + (getSlot [int] #? java/lang/Object) + (getMember [java/lang/String] #? java/lang/Object) + (hasMember [java/lang/String] boolean) + (call [#? java/lang/Object [java/lang/Object]] #try java/lang/Object)]) - (import: #long jdk/nashorn/api/scripting/AbstractJSObject) + (import: org/openjdk/nashorn/api/scripting/AbstractJSObject) - (import: #long jdk/nashorn/api/scripting/ScriptObjectMirror - (size [] int) - (toString [] java/lang/String)) + (import: org/openjdk/nashorn/api/scripting/ScriptObjectMirror + ["#::." + (size [] int) + (toString [] java/lang/String)]) - (import: #long jdk/nashorn/internal/runtime/Undefined) + (import: org/openjdk/nashorn/internal/runtime/Undefined) (template [<name>] [(host.interface: <name> (getValue [] java/lang/Object)) (`` (import: (~~ (template.identifier ["program/" <name>])) - (getValue [] java/lang/Object)))] + ["#::." + (getValue [] java/lang/Object)]))] [IntValue] [StructureValue] ) - (exception: (unknown-member {member Text} + (exception: (unknown_member {member Text} {object java/lang/Object}) (exception.report ["Member" member] ["Object" (debug.inspect object)])) - (def: jvm-int + (def: jvm_int (-> (I64 Any) java/lang/Integer) (|>> (:coerce java/lang/Long) java/lang/Long::intValue)) - (def: (js-int value) - (-> Int jdk/nashorn/api/scripting/JSObject) - (host.object [] jdk/nashorn/api/scripting/AbstractJSObject [program/IntValue] + (def: (js_int value) + (-> Int org/openjdk/nashorn/api/scripting/JSObject) + (host.object [] org/openjdk/nashorn/api/scripting/AbstractJSObject [program/IntValue] [] ## Methods (program/IntValue [] (getValue self) java/lang/Object (:coerce java/lang/Object value)) - (jdk/nashorn/api/scripting/AbstractJSObject + (org/openjdk/nashorn/api/scripting/AbstractJSObject [] (getMember self {member java/lang/String}) java/lang/Object (case member - (^ (static runtime.i64-high-field)) - (|> value .nat runtime.high jvm-int) + (^ (static runtime.i64_high_field)) + (|> value .nat runtime.high jvm_int) - (^ (static runtime.i64-low-field)) - (|> value .nat runtime.low jvm-int) + (^ (static runtime.i64_low_field)) + (|> value .nat runtime.low jvm_int) _ - (error! (exception.construct ..unknown-member [member (:coerce java/lang/Object value)])))) + (error! (exception.construct ..unknown_member [member (:coerce java/lang/Object value)])))) )) - (def: (::toString js-object) - (-> Any jdk/nashorn/api/scripting/JSObject) - (host.object [] jdk/nashorn/api/scripting/AbstractJSObject [] + (def: (::toString js_object) + (-> Any org/openjdk/nashorn/api/scripting/JSObject) + (host.object [] org/openjdk/nashorn/api/scripting/AbstractJSObject [] [] - (jdk/nashorn/api/scripting/AbstractJSObject + (org/openjdk/nashorn/api/scripting/AbstractJSObject [] (isFunction self) boolean #1) - (jdk/nashorn/api/scripting/AbstractJSObject + (org/openjdk/nashorn/api/scripting/AbstractJSObject [] (call self {this java/lang/Object} {args [java/lang/Object]}) java/lang/Object - (debug.inspect js-object)) + (debug.inspect js_object)) )) - (def: (::slice js-object value) - (-> (-> java/lang/Object jdk/nashorn/api/scripting/JSObject) (Array java/lang/Object) jdk/nashorn/api/scripting/JSObject) - (host.object [] jdk/nashorn/api/scripting/AbstractJSObject [] + (def: (::slice js_object value) + (-> (-> java/lang/Object org/openjdk/nashorn/api/scripting/JSObject) (Array java/lang/Object) org/openjdk/nashorn/api/scripting/JSObject) + (host.object [] org/openjdk/nashorn/api/scripting/AbstractJSObject [] [] - (jdk/nashorn/api/scripting/AbstractJSObject + (org/openjdk/nashorn/api/scripting/AbstractJSObject [] (isFunction self) boolean #1) - (jdk/nashorn/api/scripting/AbstractJSObject + (org/openjdk/nashorn/api/scripting/AbstractJSObject [] (call self {this java/lang/Object} {args [java/lang/Object]}) java/lang/Object (|> (java/util/Arrays::copyOfRange value (|> args (array.read 0) maybe.assume (:coerce Int)) (.int (array.size value))) - js-object + js_object (:coerce java/lang/Object))) )) - (def: (js-structure value) - (-> (Array java/lang/Object) jdk/nashorn/api/scripting/JSObject) - (let [js-object (: (-> java/lang/Object jdk/nashorn/api/scripting/JSObject) - (function (_ sub-value) - (<| (case (host.check [java/lang/Object] sub-value) - (#.Some sub-value) - (|> sub-value (:coerce (Array java/lang/Object)) js-structure) + (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 (host.check [java/lang/Object] sub_value) + (#.Some sub_value) + (|> sub_value (:coerce (Array java/lang/Object)) js_structure) #.None) - (case (host.check java/lang/Long sub-value) - (#.Some sub-value) - (|> sub-value (:coerce Int) js-int) + (case (host.check java/lang/Long sub_value) + (#.Some sub_value) + (|> sub_value (:coerce Int) js_int) #.None) ## else - (:coerce jdk/nashorn/api/scripting/JSObject sub-value))))] - (host.object [] jdk/nashorn/api/scripting/AbstractJSObject [program/StructureValue] + (:coerce org/openjdk/nashorn/api/scripting/JSObject sub_value))))] + (host.object [] org/openjdk/nashorn/api/scripting/AbstractJSObject [program/StructureValue] [] ## Methods (program/StructureValue [] (getValue self) java/lang/Object (:coerce (Array java/lang/Object) value)) - (jdk/nashorn/api/scripting/AbstractJSObject + (org/openjdk/nashorn/api/scripting/AbstractJSObject [] (isArray self) boolean #1) - (jdk/nashorn/api/scripting/AbstractJSObject + (org/openjdk/nashorn/api/scripting/AbstractJSObject [] (getMember self {member java/lang/String}) java/lang/Object (case member (^or "toJSON" "toString") @@ -220,16 +232,16 @@ (::toString value)) "length" - (jvm-int (array.size value)) + (jvm_int (array.size value)) "slice" (:coerce java/lang/Object - (::slice js-object value)) + (::slice js_object value)) - (^ (static runtime.variant-tag-field)) + (^ (static runtime.variant_tag_field)) (|> value (array.read 0) maybe.assume) - (^ (static runtime.variant-flag-field)) + (^ (static runtime.variant_flag_field)) (case (array.read 1 value) (#.Some set!) set! @@ -237,33 +249,33 @@ _ (host.null)) - (^ (static runtime.variant-value-field)) - (|> value (array.read 2) maybe.assume js-object (:coerce java/lang/Object)) + (^ (static runtime.variant_value_field)) + (|> value (array.read 2) maybe.assume js_object (:coerce java/lang/Object)) _ - (error! (exception.construct ..unknown-member [(:coerce Text member) (:coerce java/lang/Object value)]))) + (error! (exception.construct ..unknown_member [(:coerce Text member) (:coerce java/lang/Object value)]))) ) - (jdk/nashorn/api/scripting/AbstractJSObject + (org/openjdk/nashorn/api/scripting/AbstractJSObject [] (getSlot self {idx int}) java/lang/Object (|> value (array.read (|> idx java/lang/Integer::longValue (:coerce Nat))) maybe.assume - js-object + js_object (:coerce java/lang/Object))) ))) - (exception: undefined-has-no-lux-representation) + (exception: undefined_has_no_lux_representation) - (exception: (unknown-kind-of-host-object {object java/lang/Object}) + (exception: (unknown_kind_of_host_object {object java/lang/Object}) (exception.report ["Class" (java/lang/Object::toString (java/lang/Object::getClass object))] ["Object" (java/lang/Object::toString object)])) - (def: (check-int js-object) - (-> jdk/nashorn/api/scripting/ScriptObjectMirror + (def: (check_int js_object) + (-> org/openjdk/nashorn/api/scripting/ScriptObjectMirror (Maybe Int)) - (case [(jdk/nashorn/api/scripting/JSObject::getMember [runtime.i64-high-field] js-object) - (jdk/nashorn/api/scripting/JSObject::getMember [runtime.i64-low-field] js-object)] + (case [(org/openjdk/nashorn/api/scripting/JSObject::getMember [runtime.i64_high_field] js_object) + (org/openjdk/nashorn/api/scripting/JSObject::getMember [runtime.i64_low_field] js_object)] (^multi [(#.Some high) (#.Some low)] [[(host.check java/lang/Number high) (host.check java/lang/Number low)] @@ -271,25 +283,25 @@ [[(java/lang/Number::longValue high) (java/lang/Number::longValue low)] [high low]]) - (#.Some (.int (n.+ (|> high .nat (i64.left-shift 32)) + (#.Some (.int (n.+ (|> high .nat (i64.left_shift 32)) (if (i.< +0 (.int low)) - (|> low .nat (i64.left-shift 32) (i64.logic-right-shift 32)) + (|> low .nat (i64.left_shift 32) (i64.logic_right_shift 32)) (.nat low))))) _ #.None)) - (def: (check-variant lux-object js-object) + (def: (check_variant lux_object js_object) (-> (-> java/lang/Object (Try Any)) - jdk/nashorn/api/scripting/ScriptObjectMirror + org/openjdk/nashorn/api/scripting/ScriptObjectMirror (Maybe Any)) - (case [(jdk/nashorn/api/scripting/JSObject::getMember [runtime.variant-tag-field] js-object) - (jdk/nashorn/api/scripting/JSObject::getMember [runtime.variant-flag-field] js-object) - (jdk/nashorn/api/scripting/JSObject::getMember [runtime.variant-value-field] js-object)] + (case [(org/openjdk/nashorn/api/scripting/JSObject::getMember [runtime.variant_tag_field] js_object) + (org/openjdk/nashorn/api/scripting/JSObject::getMember [runtime.variant_flag_field] js_object) + (org/openjdk/nashorn/api/scripting/JSObject::getMember [runtime.variant_value_field] js_object)] (^multi [(#.Some tag) ?flag (#.Some value)] [(host.check java/lang/Number tag) (#.Some tag)] - [(lux-object value) + [(lux_object value) (#.Some value)]) (#.Some [(java/lang/Number::intValue tag) (maybe.default (host.null) ?flag) @@ -298,26 +310,26 @@ _ #.None)) - (def: (check-array lux-object js-object) + (def: (check_array lux_object js_object) (-> (-> java/lang/Object (Try Any)) - jdk/nashorn/api/scripting/ScriptObjectMirror + org/openjdk/nashorn/api/scripting/ScriptObjectMirror (Maybe (Array java/lang/Object))) - (if (jdk/nashorn/api/scripting/JSObject::isArray js-object) - (let [num-keys (.nat (jdk/nashorn/api/scripting/ScriptObjectMirror::size js-object))] + (if (org/openjdk/nashorn/api/scripting/JSObject::isArray js_object) + (let [num_keys (.nat (org/openjdk/nashorn/api/scripting/ScriptObjectMirror::size js_object))] (loop [idx 0 output (: (Array java/lang/Object) - (array.new num-keys))] - (if (n.< num-keys idx) - (case (jdk/nashorn/api/scripting/JSObject::getMember (%.nat idx) js-object) + (array.new num_keys))] + (if (n.< num_keys idx) + (case (org/openjdk/nashorn/api/scripting/JSObject::getMember (%.nat idx) js_object) (#.Some member) - (case (host.check jdk/nashorn/internal/runtime/Undefined member) + (case (host.check org/openjdk/nashorn/internal/runtime/Undefined member) (#.Some _) (recur (inc idx) output) #.None - (case (lux-object member) - (#try.Success parsed-member) - (recur (inc idx) (array.write idx (:coerce java/lang/Object parsed-member) output)) + (case (lux_object member) + (#try.Success parsed_member) + (recur (inc idx) (array.write! idx (:coerce java/lang/Object parsed_member) output)) (#try.Failure error) #.None)) @@ -327,102 +339,102 @@ (#.Some output)))) #.None)) - (def: (lux-object js-object) + (def: (lux_object js_object) (-> java/lang/Object (Try Any)) - (`` (<| (if (host.null? js-object) - (exception.throw ..null-has-no-lux-representation [#.None])) - (case (host.check jdk/nashorn/internal/runtime/Undefined js-object) + (`` (<| (if (host.null? js_object) + (exception.throw ..null_has_no_lux_representation [#.None])) + (case (host.check org/openjdk/nashorn/internal/runtime/Undefined js_object) (#.Some _) - (exception.throw ..undefined-has-no-lux-representation []) + (exception.throw ..undefined_has_no_lux_representation []) #.None) (~~ (template [<class>] - [(case (host.check <class> js-object) - (#.Some js-object) - (exception.return js-object) + [(case (host.check <class> js_object) + (#.Some js_object) + (exception.return js_object) #.None)] [java/lang/Boolean] [java/lang/String])) (~~ (template [<class> <method>] - [(case (host.check <class> js-object) - (#.Some js-object) - (exception.return (<method> js-object)) + [(case (host.check <class> js_object) + (#.Some js_object) + (exception.return (<method> js_object)) #.None)] [java/lang/Number java/lang/Number::doubleValue] - [StructureValue StructureValue::getValue] - [IntValue IntValue::getValue])) - (case (host.check jdk/nashorn/api/scripting/ScriptObjectMirror js-object) - (#.Some js-object) - (case (check-int js-object) + [program/StructureValue program/StructureValue::getValue] + [program/IntValue program/IntValue::getValue])) + (case (host.check org/openjdk/nashorn/api/scripting/ScriptObjectMirror js_object) + (#.Some js_object) + (case (check_int js_object) (#.Some value) (exception.return value) #.None - (case (check-variant lux-object js-object) + (case (check_variant lux_object js_object) (#.Some value) (exception.return value) #.None - (case (check-array lux-object js-object) + (case (check_array lux_object js_object) (#.Some value) (exception.return value) #.None - (if (jdk/nashorn/api/scripting/JSObject::isFunction js-object) - (exception.return js-object) - (exception.throw ..unknown-kind-of-host-object (:coerce java/lang/Object js-object)))))) + (if (org/openjdk/nashorn/api/scripting/JSObject::isFunction js_object) + (exception.return js_object) + (exception.throw ..unknown_kind_of_host_object (:coerce java/lang/Object js_object)))))) #.None) ## else - (exception.throw ..unknown-kind-of-host-object (:coerce java/lang/Object js-object)) + (exception.throw ..unknown_kind_of_host_object (:coerce java/lang/Object js_object)) ))) - (def: (ensure-function function) - (-> Any (Maybe jdk/nashorn/api/scripting/JSObject)) + (def: (ensure_function function) + (-> Any (Maybe org/openjdk/nashorn/api/scripting/JSObject)) (do maybe.monad [function (|> function (:coerce java/lang/Object) - (host.check jdk/nashorn/api/scripting/JSObject))] - (if (jdk/nashorn/api/scripting/JSObject::isFunction function) + (host.check org/openjdk/nashorn/api/scripting/JSObject))] + (if (org/openjdk/nashorn/api/scripting/JSObject::isFunction function) (#.Some function) #.None))) ) @.js - (as-is)}) + (as_is)}) (for {@.old - (as-is (def: (call-macro inputs lux macro) - (-> (List Code) Lux jdk/nashorn/api/scripting/JSObject (Try (Try [Lux (List Code)]))) - (let [to-js (: (-> Any java/lang/Object) - (|>> (:coerce (Array java/lang/Object)) js-structure (:coerce java/lang/Object)))] + (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) + (|>> (:coerce (Array java/lang/Object)) js_structure (:coerce java/lang/Object)))] (<| (:coerce (Try (Try [Lux (List Code)]))) - (jdk/nashorn/api/scripting/JSObject::call #.None - (|> (array.new 2) - (: (Array java/lang/Object)) - (array.write 0 (to-js inputs)) - (array.write 1 (to-js lux))) - macro)))) - - (exception: (cannot-apply-a-non-function {object java/lang/Object}) + (org/openjdk/nashorn/api/scripting/JSObject::call #.None + (|> (array.new 2) + (: (Array java/lang/Object)) + (array.write! 0 (to_js inputs)) + (array.write! 1 (to_js lux))) + macro)))) + + (exception: (cannot_apply_a_non_function {object java/lang/Object}) (exception.report ["Object" (java/lang/Object::toString object)])) (def: (expander macro inputs lux) Expander - (case (..ensure-function macro) + (case (..ensure_function macro) (#.Some macro) - (case (call-macro inputs lux macro) + (case (call_macro inputs lux macro) (#try.Success output) (|> output (:coerce java/lang/Object) - lux-object + lux_object (:coerce (Try (Try [Lux (List Code)])))) (#try.Failure error) (#try.Failure error)) #.None - (exception.throw ..cannot-apply-a-non-function (:coerce java/lang/Object macro)))) + (exception.throw ..cannot_apply_a_non_function (:coerce java/lang/Object macro)))) ) @.js @@ -432,16 +444,16 @@ }) (for {@.old - (as-is (def: (evaluate! interpreter alias input) + (as_is (def: (evaluate! interpreter alias input) (-> javax/script/ScriptEngine Context _.Expression (Try Any)) (do try.monad [?output (javax/script/ScriptEngine::eval (_.code input) interpreter)] (case ?output (#.Some output) - (..lux-object output) + (..lux_object output) #.None - (exception.throw ..null-has-no-lux-representation [(#.Some input)])))) + (exception.throw ..null_has_no_lux_representation [(#.Some input)])))) (def: (execute! interpreter input) (-> javax/script/ScriptEngine _.Statement (Try Any)) @@ -462,7 +474,7 @@ (def: host (IO (Host _.Expression _.Statement)) (io (let [interpreter (javax/script/ScriptEngineFactory::getScriptEngine - (jdk/nashorn/api/scripting/NashornScriptEngineFactory::new))] + (org/openjdk/nashorn/api/scripting/NashornScriptEngineFactory::new))] (: (Host _.Expression _.Statement) (structure (def: evaluate! (..evaluate! interpreter)) @@ -470,19 +482,19 @@ (def: define! (..define! interpreter)) (def: (ingest context content) - (|> content encoding.from-utf8 try.assume (:coerce _.Statement))) + (|> content (\ encoding.utf8 decode) try.assume (:coerce _.Statement))) - (def: (re-learn context content) + (def: (re_learn context content) (..execute! interpreter content)) - (def: (re-load context content) + (def: (re_load context content) (do try.monad [_ (..execute! interpreter content)] (..evaluate! interpreter context (_.var (reference.artifact context)))))))))) ) @.js - (as-is (def: (eval code) + (as_is (def: (eval code) (-> Text (Maybe Any)) ## Note: I have to call "eval" this way ## in order to avoid a quirk of calling eval in Node @@ -501,7 +513,7 @@ (wrap output) #.None - (exception.throw ..null-has-no-lux-representation [(#.Some input)])))) + (exception.throw ..null_has_no_lux_representation [(#.Some input)])))) (def: (execute! input) (-> _.Statement (Try Any)) @@ -528,12 +540,12 @@ (def: define! ..define!) (def: (ingest context content) - (|> content encoding.from-utf8 try.assume (:coerce _.Statement))) + (|> content encoding.from_utf8 try.assume (:coerce _.Statement))) - (def: (re-learn context content) + (def: (re_learn context content) (..execute! content)) - (def: (re-load context content) + (def: (re_load context content) (do try.monad [_ (..execute! content)] (..evaluate! context (_.var (reference.artifact context))))))))) @@ -543,22 +555,22 @@ (IO (Platform [Register Text] _.Expression _.Statement)) (do io.monad [host ..host] - (wrap {#platform.&file-system (file.async file.system) + (wrap {#platform.&file_system (file.async file.default) #platform.host host #platform.phase js.generate #platform.runtime runtime.generate - #platform.write (|>> _.code encoding.to-utf8)}))) + #platform.write (|>> _.code (\ encoding.utf8 encode))}))) (def: (program namer context program) (-> (-> Context Text) (Program _.Expression _.Statement)) (let [@process (_.var "process") - on-node-js? (|> (|> @process _.type-of (_.= (_.string "undefined")) _.not) + on_node_js? (|> (|> @process _.type_of (_.= (_.string "undefined")) _.not) (_.and (|> @process (_.the "argv")))) - node-js-inputs (|> @process (_.the "argv") (_.do "slice" (list (_.int +2)))) - no-inputs (_.array (list))] - (_.statement (_.apply/1 (_.apply/1 program (runtime.lux//program-args (_.? on-node-js? - node-js-inputs - no-inputs))) + node_js_inputs (|> @process (_.the "argv") (_.do "slice" (list (_.int +2)))) + no_inputs (_.array (list))] + (_.statement (_.apply/1 (_.apply/1 program (runtime.lux//program_args (_.? on_node_js? + node_js_inputs + no_inputs))) (_.string ""))))) (for {@.old @@ -577,35 +589,35 @@ try.assume (:coerce Try) (do try.monad - [handler (try.from-maybe (..ensure-function handler)) - #let [to-js (: (-> Any java/lang/Object) - (|>> (:coerce (Array java/lang/Object)) js-structure (:coerce java/lang/Object)))] - output (jdk/nashorn/api/scripting/JSObject::call #.None - (|> (array.new 5) - (: (Array java/lang/Object)) - (array.write 0 name) - (array.write 1 (to-js phase)) - (array.write 2 (to-js archive)) - (array.write 3 (to-js parameters)) - (array.write 4 (to-js state))) - handler)] - (lux-object (:coerce java/lang/Object output))))) + [handler (try.from_maybe (..ensure_function handler)) + #let [to_js (: (-> Any java/lang/Object) + (|>> (:coerce (Array java/lang/Object)) js_structure (:coerce java/lang/Object)))] + output (org/openjdk/nashorn/api/scripting/JSObject::call #.None + (|> (array.new 5) + (: (Array java/lang/Object)) + (array.write! 0 name) + (array.write! 1 (to_js phase)) + (array.write! 2 (to_js archive)) + (array.write! 3 (to_js parameters)) + (array.write! 4 (to_js state))) + handler)] + (lux_object (:coerce java/lang/Object output))))) @.js (def: (extender handler) Extender (:assume handler))}) -(def: (declare-success! _) +(def: (declare_success! _) (-> Any (Promise Any)) - (promise.future (io.exit +0))) + (promise.future (\ world/program.default exit +0))) (program: [{service /cli.service}] (exec (do promise.monad [_ (/.compiler {#/static.host @.js - #/static.host-module-extension ".js" + #/static.host_module_extension ".js" #/static.target (/cli.target service) - #/static.artifact-extension ".js"} + #/static.artifact_extension ".js"} ..expander analysis.bundle ..platform @@ -615,7 +627,7 @@ [(& Register Text) _.Expression _.Statement] ..extender service - [(packager.package _.use-strict _.code _.then) - (format (/cli.target service) (:: file.system separator) "program.js")])] - (..declare-success! [])) + [(packager.package _.use_strict _.code _.then) + (format (/cli.target service) (\ file.default separator) "program.js")])] + (..declare_success! [])) (io.io []))) |