diff options
author | Eduardo Julian | 2022-01-25 21:26:50 -0400 |
---|---|---|
committer | Eduardo Julian | 2022-01-25 21:26:50 -0400 |
commit | 7661faaa22a253bb4703992b638038d96ead0ade (patch) | |
tree | 748bca72a2aad0d33a4268ad0d0d39fa4e24b384 /lux-ruby | |
parent | 9a08039adfe40f76b9d5a5351005671c15b557bf (diff) |
Bug fixes for eval in general and in Lux/Ruby.
Diffstat (limited to 'lux-ruby')
-rw-r--r-- | lux-ruby/source/program.lux | 107 |
1 files changed, 57 insertions, 50 deletions
diff --git a/lux-ruby/source/program.lux b/lux-ruby/source/program.lux index 3a55ccafc..cd037a5b1 100644 --- a/lux-ruby/source/program.lux +++ b/lux-ruby/source/program.lux @@ -288,6 +288,7 @@ [java/lang/Long [{try.#Success}]] [java/lang/Double [{try.#Success}]] [java/lang/String [{try.#Success}]] + [org/jruby/RubyFixnum [org/jruby/RubyFixnum::getLongValue {try.#Success}]] [org/jruby/RubyString [org/jruby/RubyString::asJavaString {try.#Success}]] [[java/lang/Object] [{try.#Success}]] [org/jruby/RubyArray [(read_tuple read)]] @@ -708,10 +709,10 @@ (for [@.old (as_is (exception: .public (invaid_phase_application [partial_application (List Any) - arity Nat]) + arity (List Any)]) (exception.report ["Partial Application" (%.nat (list.size partial_application))] - ["Arity" (%.nat arity)])) + ["Arity" (%.nat (list.size arity))])) (def: proc_type org/jruby/runtime/Block$Type @@ -758,64 +759,70 @@ _ org/jruby/runtime/Block]) org/jruby/runtime/builtin/IRubyObject (<| try.trusted - (let [inputs (array.list {.#None} inputs)]) + (do [! try.monad] + [inputs (|> inputs + (array.list {.#None}) + (monad.each ! (|>> (:as java/lang/Object) ..read)))]) (case inputs + ... It seems that org/jruby/runtime/Block::call can misbehave when getting called with a Lux state value. + (^ (list info source location current_module modules scopes type_context expected seed scope_type_vars extensions eval host)) + (case partial_application + (^ (list partial/0 partial/1)) + (in (..to_host ((:as (-> Any Any Any Any) phase) + partial/0 + partial/1 + [info source location current_module modules scopes type_context expected seed scope_type_vars extensions eval host]))) + + _ + (exception.except ..invaid_phase_application [partial_application inputs])) + (^ (list)) {try.#Success (host_phase partial_application phase)} (^ (list input/0)) - (do try.monad - [input/0 (..read (:as java/lang/Object input/0))] - (case partial_application - (^ (list)) - (in (host_phase (list input/0) phase)) - - (^ (list partial/0)) - (in (host_phase (list partial/0 input/0) phase)) - - (^ (list partial/0 partial/1)) - (in (..to_host ((:as (-> Any Any Any Any) phase) - partial/0 - partial/1 - input/0))) - - _ - (exception.except ..invaid_phase_application [partial_application (list.size inputs)]))) + (case partial_application + (^ (list)) + (in (host_phase (list input/0) phase)) + + (^ (list partial/0)) + (in (host_phase (list partial/0 input/0) phase)) + + (^ (list partial/0 partial/1)) + (in (..to_host ((:as (-> Any Any Any Any) phase) + partial/0 + partial/1 + input/0))) + + _ + (exception.except ..invaid_phase_application [partial_application inputs])) (^ (list input/0 input/1)) - (do try.monad - [input/0 (..read (:as java/lang/Object input/0)) - input/1 (..read (:as java/lang/Object input/1))] - (case partial_application - (^ (list)) - (in (host_phase (list input/0 input/1) phase)) - - (^ (list partial/0)) - (in (..to_host ((:as (-> Any Any Any Any) phase) - partial/0 - input/0 - input/1))) - - _ - (exception.except ..invaid_phase_application [partial_application (list.size inputs)]))) + (case partial_application + (^ (list)) + (in (host_phase (list input/0 input/1) phase)) + + (^ (list partial/0)) + (in (..to_host ((:as (-> Any Any Any Any) phase) + partial/0 + input/0 + input/1))) + + _ + (exception.except ..invaid_phase_application [partial_application inputs])) (^ (list input/0 input/1 input/2)) - (do try.monad - [input/0 (..read (:as java/lang/Object input/0)) - input/1 (..read (:as java/lang/Object input/1)) - input/2 (..read (:as java/lang/Object input/2))] - (case partial_application - (^ (list)) - (in (..to_host ((:as (-> Any Any Any Any) phase) - input/0 - input/1 - input/2))) - - _ - (exception.except ..invaid_phase_application [partial_application (list.size inputs)]))) + (case partial_application + (^ (list)) + (in (..to_host ((:as (-> Any Any Any Any) phase) + input/0 + input/1 + input/2))) + + _ + (exception.except ..invaid_phase_application [partial_application inputs])) _ - (exception.except ..invaid_phase_application [partial_application (list.size inputs)])))))] + (exception.except ..invaid_phase_application [partial_application inputs])))))] (org/jruby/RubyProc::newProc (!ruby_runtime) block ..proc_type))) (def: (extender phase_wrapper) @@ -873,7 +880,7 @@ (let [normal_runtime? (_.do "const_defined?" (list (_.string (_.code _.command_line_arguments))) {.#None} - (_.local "Object"))] + (: _.CVar (_.manual "Object")))] (_.statement (_.apply_lambda/* (list (runtime.lux//program_args (_.? normal_runtime? _.command_line_arguments |