aboutsummaryrefslogtreecommitdiff
path: root/lux-ruby/source
diff options
context:
space:
mode:
authorEduardo Julian2022-04-06 16:07:22 -0400
committerEduardo Julian2022-04-06 16:07:22 -0400
commita0ed5fd377daf5754697636504de8e180abf9ec0 (patch)
tree8cc47f78ac6557c4ba233e6debd7b836adfb65b1 /lux-ruby/source
parent0494295b95c5c44ef389f1259e408f9445cfe0a1 (diff)
More efficient binary parsing.
Diffstat (limited to 'lux-ruby/source')
-rw-r--r--lux-ruby/source/program.lux26
1 files changed, 13 insertions, 13 deletions
diff --git a/lux-ruby/source/program.lux b/lux-ruby/source/program.lux
index 5b4da0caa..1e06e6664 100644
--- a/lux-ruby/source/program.lux
+++ b/lux-ruby/source/program.lux
@@ -114,10 +114,10 @@
(import: org/jruby/RubyClass
"[1]::[0]")
-(import: org/jruby/RubyArray
+(import: (org/jruby/RubyArray a)
"[1]::[0]"
(getLength [] int)
- (get [int] "?" Object))
+ (get [int] "?" java/lang/Object))
(import: org/jruby/RubyHash
"[1]::[0]"
@@ -233,7 +233,7 @@
(-> java/lang/Object (Try Any)))
(def: (read_tuple read host_object)
- (-> Translator org/jruby/RubyArray (Try Any))
+ (-> 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
output (is (Array Any)
@@ -245,11 +245,11 @@
{.#Some value}
(case (read value)
- {try.#Failure error}
- {try.#Failure error}
-
{try.#Success lux_value}
- (again (++ idx) (array.write! idx lux_value output))))
+ (again (++ idx) (array.has! idx lux_value output))
+
+ failure
+ failure))
{try.#Success output}))))
(exception: (unknown_kind_of_object [object java/lang/Object])
@@ -301,7 +301,7 @@
[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)]]
+ [org/jruby/RubyArray [(as (org/jruby/RubyArray org/jruby/runtime/builtin/IRubyObject)) (read_tuple read)]]
[org/jruby/RubyHash [(read_variant read)]]
[org/jruby/RubySymbol [{try.#Success}]]
[org/jruby/RubyProc [{try.#Success}]]
@@ -465,7 +465,7 @@
(let [member (ffi.read! 0 args)]
(<| (case (ffi.as org/jruby/RubyFixnum member)
{.#Some member}
- (case (array.read! (.nat (ffi.of_long (org/jruby/RubyFixnum::getLongValue member))) value)
+ (case (array.item (.nat (ffi.of_long (org/jruby/RubyFixnum::getLongValue member))) value)
{.#Some value}
(wrapped_lux_value (as_expected useful_object_class) lux_structure value)
@@ -478,7 +478,7 @@
(case (ffi.of_string (org/jruby/RubyString::asJavaString member))
(pattern (static runtime.variant_tag_field))
(|> value
- (array.read! 0)
+ (array.item 0)
maybe.trusted
(as java/lang/Integer)
java/lang/Integer::longValue
@@ -486,7 +486,7 @@
(ffi.is org/jruby/runtime/builtin/IRubyObject))
(pattern (static runtime.variant_flag_field))
- (case (array.read! 1 value)
+ (case (array.item 1 value)
{.#None}
..ruby_nil
@@ -494,7 +494,7 @@
..lux_unit)
(pattern (static runtime.variant_value_field))
- (case (array.read! 2 value)
+ (case (array.item 2 value)
{.#Some value}
(wrapped_lux_value (as_expected useful_object_class) lux_structure value)
@@ -691,7 +691,7 @@
(<| (ffi.is org/jruby/runtime/builtin/IRubyObject)
(org/jruby/java/proxies/JavaProxy::new ..initial_ruby_runtime
(useful_object_class lux_structure value)
- (ffi.is java/lang/Object value))))
+ (as java/lang/Object value))))
(exception: (cannot_apply_a_non_function [object java/lang/Object])
(exception.report