diff options
Diffstat (limited to '')
-rw-r--r-- | lux-r/source/program.lux | 48 | ||||
-rw-r--r-- | lux-ruby/source/program.lux | 82 |
2 files changed, 65 insertions, 65 deletions
diff --git a/lux-r/source/program.lux b/lux-r/source/program.lux index 4a85f2c0c..1a7dbe7f4 100644 --- a/lux-r/source/program.lux +++ b/lux-r/source/program.lux @@ -181,16 +181,16 @@ [cannot_apply_a_non_function] ) -... (def: host_bit +... (def host_bit ... (-> Bit org/armedbear/lisp/LispObject) ... (|>> (pipe.case #0 (org/armedbear/lisp/Nil::NIL) ... #1 (org/armedbear/lisp/Symbol::T)))) -(def: %%code +(def %%code (syntax (_ [term <code>.any]) (wrap (list (code.text (%.code term)))))) -(def: (host_value value) +(def (host_value value) (-> Any org/renjin/sexp/SEXP) (let [... to_sub (is (-> Any org/armedbear/lisp/LispObject) ... (function (_ sub_value) @@ -356,7 +356,7 @@ (type: (Reader a) (-> a (Try Any))) -(def: (read_variant read host_object) +(def (read_variant read host_object) (-> (Reader java/lang/Object) (Reader org/renjin/sexp/ListVector)) (do try.monad [tag (|> host_object @@ -378,7 +378,7 @@ (is Any synthesis.unit)) value]))) -(def: (read_i64 host_object) +(def (read_i64 host_object) (Reader org/renjin/sexp/ListVector) (case [(|> host_object (org/renjin/sexp/ListVector::get_field runtime.i64_high_field) @@ -393,7 +393,7 @@ _ {try.#Failure ""})) -(def: (read_tuple read host_object) +(def (read_tuple read host_object) (-> (Reader java/lang/Object) (Reader org/renjin/sexp/ListVector)) (let [size (.nat (org/renjin/sexp/ListVector::length host_object))] (loop (again [idx 0 @@ -407,7 +407,7 @@ (again (++ idx) (array.write! idx (as Any member) output))) {try.#Success output})))) -(def: (field_class field host_object) +(def (field_class field host_object) (-> Text org/renjin/sexp/ListVector Text) (|> host_object (org/renjin/sexp/ListVector::get_field field) @@ -415,7 +415,7 @@ java/lang/Object::toString (as Text))) -(def: (read host_object) +(def (read host_object) (Reader java/lang/Object) (exec ... ("lux io log" (exception.construct ..unknown_kind_of_object [host_object])) @@ -454,11 +454,11 @@ (exception.throw ..unknown_kind_of_object [host_object]) )))) -(def: ensure_macro +(def ensure_macro (-> Macro (Maybe org/renjin/sexp/Closure)) (|>> (as java/lang/Object) (ffi.as org/renjin/sexp/Closure))) -(def: (call_macro interpreter inputs lux macro) +(def (call_macro interpreter inputs lux macro) (-> org/renjin/script/RenjinScriptEngine (List Code) Lux org/renjin/sexp/Closure (Try (Try [Lux (List Code)]))) (let [_ ("lux io log" "@call_macro 0") r_inputs (is org/renjin/sexp/PairList @@ -487,7 +487,7 @@ (as (Try (Try [Lux (List Code)])) (..read (as java/lang/Object raw_output)))))) -(def: (expander interpreter macro inputs lux) +(def (expander interpreter macro inputs lux) (-> org/renjin/script/RenjinScriptEngine Expander) (case (ensure_macro macro) {.#Some macro} @@ -496,7 +496,7 @@ {.#None} (exception.throw ..cannot_apply_a_non_function [(as java/lang/Object macro)]))) -(def: host +(def host (IO [org/renjin/script/RenjinScriptEngine (Host _.Expression _.Expression)]) (io (let [interpreter (|> (org/renjin/script/RenjinScriptEngineFactory::new) @@ -509,17 +509,17 @@ [(as org/renjin/script/RenjinScriptEngine interpreter) (is (Host _.Expression _.Expression) (structure - (def: (evaluate! context code) + (def (evaluate! context code) (exec ("lux io log" "@evaluate!") (run! code))) - (def: (execute! input) + (def (execute! input) (exec ("lux io log" "@execute!") ... ("lux io log" (_.code input)) (javax/script/ScriptEngine::eval (_.code input) interpreter))) - (def: (define! context input) + (def (define! context input) (let [global (reference.artifact context) $global (_.var global)] (do try.monad @@ -533,19 +533,19 @@ #let [_ ("lux io log" "@define! 2")]] (wrap [global value definition])))) - (def: (ingest context content) + (def (ingest context content) (|> content (at utf8.codec decoded) try.trusted (as _.Expression))) - (def: (re_learn context content) + (def (re_learn context content) (run! content)) - (def: (re_load context content) + (def (re_load context content) (do try.monad [_ (run! content)] (run! (_.var (reference.artifact context))))) ))]))) -(def: platform +(def platform (IO [org/renjin/script/RenjinScriptEngine (Platform _.SVar _.Expression _.Expression)]) (do io.monad @@ -557,12 +557,12 @@ platform.#runtime runtime.generate platform.#write (|>> _.code (at utf8.codec encoded))]]))) -(def: (program context program) +(def (program context program) (Program _.Expression _.Expression) (_.apply/2 program [(runtime.lux::program_args (_.commandArgs/0 [])) _.null])) (for @.old - (def: extender + (def extender Extender ... TODO: Stop relying on coercions ASAP. (<| (as Extender) @@ -581,15 +581,15 @@ {try.#Failure "TODO: Extender"}))) @.r - (def: (extender handler) + (def (extender handler) Extender (as_expected handler))) -(def: (declare_success! _) +(def (declare_success! _) (-> Any (Promise Any)) (promise.future (at world/program.default exit +0))) -(def: (scope body) +(def (scope body) (-> _.Expression _.Expression) (let [$program (_.var "lux_program")] (all _.then diff --git a/lux-ruby/source/program.lux b/lux-ruby/source/program.lux index 83a565329..41f03bb56 100644 --- a/lux-ruby/source/program.lux +++ b/lux-ruby/source/program.lux @@ -151,21 +151,21 @@ (getProvider [] org/jruby/embed/internal/LocalContextProvider)) ... TODO; Figure out a way to not need "interpreter" to be a global variable. -(def: interpreter +(def interpreter (org/jruby/embed/ScriptingContainer::new)) -(def: !ruby_runtime +(def !ruby_runtime (template (!ruby_runtime) [(|> ..interpreter org/jruby/embed/ScriptingContainer::getProvider org/jruby/embed/internal/LocalContextProvider::getRuntime)])) -(def: !ruby_thread_context +(def !ruby_thread_context (template (!ruby_thread_context) [(|> (!ruby_runtime) org/jruby/Ruby::getCurrentContext)])) -(def: initial_ruby_runtime +(def initial_ruby_runtime (!ruby_runtime)) (import org/jruby/java/proxies/JavaProxy @@ -231,7 +231,7 @@ (type: Translator (-> java/lang/Object (Try Any))) -(def: (read_tuple read host_object) +(def (read_tuple read host_object) (-> Translator (org/jruby/RubyArray org/jruby/runtime/builtin/IRubyObject) (Try Any)) (let [size (.nat (ffi.of_int (org/jruby/RubyArray::getLength host_object)))] (loop (again [idx 0 @@ -256,7 +256,7 @@ "Class" (ffi.of_string (java/lang/Object::toString (java/lang/Object::getClass object))) "Object" (ffi.of_string (java/lang/Object::toString object)))) -(def: (read_variant read host_object) +(def (read_variant read host_object) (-> Translator org/jruby/RubyHash (Try Any)) (case [(org/jruby/RubyHash::get (ffi.as_string runtime.variant_tag_field) host_object) (org/jruby/RubyHash::get (ffi.as_string runtime.variant_flag_field) host_object) @@ -282,7 +282,7 @@ (exception: .public nil_has_no_lux_representation) -(def: (read host_object) +(def (read host_object) Translator (`` (<| (if (ffi.null? host_object) (exception.except ..nil_has_no_lux_representation [])) @@ -310,16 +310,16 @@ {try.#Success host_object} ))) -(def: ruby_nil +(def ruby_nil org/jruby/runtime/builtin/IRubyObject (org/jruby/Ruby::getNil ..initial_ruby_runtime)) -(def: lux_unit +(def lux_unit org/jruby/runtime/builtin/IRubyObject (<| (ffi.is org/jruby/runtime/builtin/IRubyObject) (org/jruby/RubyString::newInternalFromJavaExternal ..initial_ruby_runtime (ffi.as_string "")))) -(def: (wrapped_lux_value useful_object_class lux_structure) +(def (wrapped_lux_value useful_object_class lux_structure) (-> (-> (-> java/lang/Object org/jruby/runtime/builtin/IRubyObject) (Array java/lang/Object) org/jruby/RubyClass) @@ -370,7 +370,7 @@ (exception.report "Arity" (%.nat arity))) -(def: (::call useful_object_class lux_structure value) +(def (::call useful_object_class lux_structure value) (-> (-> (-> (Array java/lang/Object) org/jruby/runtime/builtin/IRubyObject) (Array java/lang/Object) org/jruby/RubyClass) @@ -438,7 +438,7 @@ (exception.except ..invalid_arity [arity]))] (in (wrapped_lux_value (as_expected useful_object_class) lux_structure output))))))))) -(def: (::access useful_object_class lux_structure value) +(def (::access useful_object_class lux_structure value) (-> (-> (-> (Array java/lang/Object) org/jruby/runtime/builtin/IRubyObject) (Array java/lang/Object) org/jruby/RubyClass) @@ -519,7 +519,7 @@ {.#None}) (panic! (exception.error ..invalid_index [(ffi.is java/lang/Object member)])))))))) -(def: (::= value) +(def (::= value) (-> (Array java/lang/Object) org/jruby/internal/runtime/methods/DynamicMethod) (<| (ffi.is org/jruby/internal/runtime/methods/DynamicMethod) (ffi.object [] org/jruby/internal/runtime/methods/DynamicMethod [] @@ -551,7 +551,7 @@ {try.#Failure error} false)))))) -(def: (::length value) +(def (::length value) (-> (Array java/lang/Object) org/jruby/internal/runtime/methods/DynamicMethod) (<| (ffi.is org/jruby/internal/runtime/methods/DynamicMethod) (ffi.object [] org/jruby/internal/runtime/methods/DynamicMethod [] @@ -577,7 +577,7 @@ (org/jruby/RubyFixnum::new ..initial_ruby_runtime) (ffi.is org/jruby/runtime/builtin/IRubyObject)))))) -(def: (::to_s value) +(def (::to_s value) (-> (Array java/lang/Object) org/jruby/internal/runtime/methods/DynamicMethod) (<| (ffi.is org/jruby/internal/runtime/methods/DynamicMethod) (ffi.object [] org/jruby/internal/runtime/methods/DynamicMethod [] @@ -606,7 +606,7 @@ (exception.report "Method" (%.text method))) -(def: (::respond_to? value) +(def (::respond_to? value) (-> (Array java/lang/Object) org/jruby/internal/runtime/methods/DynamicMethod) (<| (ffi.is org/jruby/internal/runtime/methods/DynamicMethod) (ffi.object [] org/jruby/internal/runtime/methods/DynamicMethod [] @@ -652,7 +652,7 @@ (exception.report "Method" (%.text method))) -(def: (useful_object_class lux_structure value) +(def (useful_object_class lux_structure value) (-> (-> (Array java/lang/Object) org/jruby/runtime/builtin/IRubyObject) (Array java/lang/Object) org/jruby/RubyClass) @@ -685,7 +685,7 @@ method (panic! (exception.error ..unknown_method [method]))))))) -(def: (lux_structure value) +(def (lux_structure value) (-> (Array java/lang/Object) org/jruby/runtime/builtin/IRubyObject) (<| (ffi.is org/jruby/runtime/builtin/IRubyObject) (org/jruby/java/proxies/JavaProxy::new ..initial_ruby_runtime @@ -696,17 +696,17 @@ (exception.report "Non-function" (ffi.of_string (java/lang/Object::toString object)))) -(def: macro! +(def macro! (-> Macro (Maybe org/jruby/RubyProc)) (|>> (as java/lang/Object) (ffi.as org/jruby/RubyProc))) -(def: to_host +(def to_host (-> Any org/jruby/runtime/builtin/IRubyObject) (|>> (as (Array java/lang/Object)) ..lux_structure)) -(def: (call_macro inputs lux macro) +(def (call_macro inputs lux macro) (-> (List Code) Lux org/jruby/RubyProc (Try (Try [Lux (List Code)]))) (as_expected (do try.monad @@ -717,7 +717,7 @@ macro)] (..read (ffi.is java/lang/Object expansion))))) -(def: (expander macro inputs lux) +(def (expander macro inputs lux) Expander (case (macro! macro) {.#Some macro} @@ -734,7 +734,7 @@ {.#None} (exception.except ..cannot_apply_a_non_function [(as java/lang/Object macro)]))) -(def: host +(def host (IO (Host _.Expression _.Statement)) (io (let [run! (is (-> (_.Code Any) (Try Any)) (function (_ code) @@ -744,12 +744,12 @@ output)))))] (is (Host _.Expression _.Statement) (implementation - (def: (evaluate context [_ code]) + (def (evaluate context [_ code]) (run! code)) - (def: execute run!) + (def execute run!) - (def: (define context custom [_ input]) + (def (define context custom [_ input]) (let [global (maybe.else (reference.artifact context) custom) @global (_.global global)] @@ -758,16 +758,16 @@ value (run! definition)] (in [global value definition])))) - (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) (run! content)) - (def: (re_load context custom content) + (def (re_load context custom content) (do try.monad [_ (run! content)] (run! (_.global (reference.artifact context)))))))))) @@ -778,21 +778,21 @@ "Partial Application" (%.nat (list.size partial_application)) "Arity" (%.nat (list.size arity)))) - (def: proc_type + (def proc_type org/jruby/runtime/Block$Type (|> (org/jruby/runtime/Block::NULL_BLOCK) (org/jruby/runtime/Block::type))) - (def: phase_block_signature + (def phase_block_signature org/jruby/runtime/Signature (org/jruby/runtime/Signature::THREE_ARGUMENTS)) - (def: dummy_static_scope + (def dummy_static_scope org/jruby/parser/StaticScope (|> (org/jruby/parser/StaticScopeFactory::new (!ruby_runtime)) (org/jruby/parser/StaticScopeFactory::getDummyScope))) - (def: phase_block_body + (def phase_block_body org/jruby/runtime/BlockBody (<| (ffi.is org/jruby/runtime/BlockBody) (ffi.object [] org/jruby/runtime/BlockBody [] @@ -834,7 +834,7 @@ (undefined)) ))) - (def: (host_phase partial_application phase) + (def (host_phase partial_application phase) (All (_ s i o) (-> (List Any) (Phase [extension.Bundle s] i o) org/jruby/RubyProc)) @@ -917,7 +917,7 @@ (exception.except ..invaid_phase_application [partial_application inputs])))))] (org/jruby/RubyProc::newProc (!ruby_runtime) block ..proc_type))) - (def: (extender phase_wrapper) + (def (extender phase_wrapper) (-> phase.Wrapper Extender) ... TODO: Stop relying on coercions ASAP. (<| (as Extender) @@ -945,18 +945,18 @@ (..read (ffi.is java/lang/Object output)))))) @.ruby - (def: (extender phase_wrapper handler) + (def (extender phase_wrapper handler) (-> phase.Wrapper Extender) (as_expected handler))) -(def: (phase_wrapper archive) +(def (phase_wrapper archive) (-> Archive (runtime.Operation phase.Wrapper)) (<| phase#in (as phase.Wrapper) (for @.jvm (..host_phase (list)) @.ruby (|>>)))) -(def: platform +(def platform (IO (Platform Register _.Expression _.Statement)) (do io.monad [host ..host] @@ -967,7 +967,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 [normal_runtime? (_.do "const_defined?" (list (_.string (_.code _.command_line_arguments))) @@ -980,11 +980,11 @@ _.nil) program)))) -(def: (declare_success! _) +(def (declare_success! _) (-> Any (Async Any)) (async.future (at world/program.default exit +0))) -(def: (lux_compiler it) +(def (lux_compiler it) (-> Any platform.Custom) (undefined)) |