diff options
Diffstat (limited to 'lux-ruby')
-rw-r--r-- | lux-ruby/commands.md | 2 | ||||
-rw-r--r-- | lux-ruby/source/program.lux | 77 |
2 files changed, 40 insertions, 39 deletions
diff --git a/lux-ruby/commands.md b/lux-ruby/commands.md index 957640abb..6c4e929dd 100644 --- a/lux-ruby/commands.md +++ b/lux-ruby/commands.md @@ -28,7 +28,7 @@ cd ~/lux/lux-ruby/ \ ## Compile Lux's Standard Library's tests using a JVM-based compiler. cd ~/lux/stdlib/ \ && lein clean \ -&& time java -jar ~/lux/lux-ruby/target/program.jar build --source ~/lux/stdlib/source --target ~/lux/stdlib/target --module test/lux +&& time java -jar ~/lux/lux-ruby/jvm_based_compiler.jar build --source ~/lux/stdlib/source --target ~/lux/stdlib/target --module test/lux RUBY_THREAD_VM_STACK_SIZE=15700000 ruby ~/lux/stdlib/target/program.rb ``` diff --git a/lux-ruby/source/program.lux b/lux-ruby/source/program.lux index 64a34c003..6bfae1f33 100644 --- a/lux-ruby/source/program.lux +++ b/lux-ruby/source/program.lux @@ -2,7 +2,7 @@ [lux #* [program (#+ program:)] ["." debug] - ["." host (#+ import:)] + ["." ffi (#+ import:)] ["." meta] [abstract ["." monad (#+ do)]] @@ -19,7 +19,8 @@ ["." maybe] ["." text ("#\." hash) ["%" format (#+ format)] - ["." encoding]] + [encoding + ["." utf8]]] [collection ["." array (#+ Array)]]] ["." macro @@ -121,7 +122,7 @@ (size [org/jruby/runtime/ThreadContext] org/jruby/runtime/builtin/IRubyObject)]) (template [<name>] - [(host.interface: <name> + [(ffi.interface: <name> (getValue [] java/lang/Object)) (`` (import: (~~ (template.identifier ["program/" <name>])) @@ -243,7 +244,7 @@ "" #.None - (host.null))) + (ffi.null))) value]) _ @@ -253,10 +254,10 @@ (def: (read host_object) Translator - (`` (<| (if (host.null? host_object) + (`` (<| (if (ffi.null? host_object) (exception.throw ..nil_has_no_lux_representation [])) (~~ (template [<class> <post_processing>] - [(case (host.check <class> host_object) + [(case (ffi.check <class> host_object) (#.Some typed_object) (|> typed_object <post_processing>) @@ -286,27 +287,27 @@ (def: (wrapped_lux_value lux_structure value) (-> (-> (Array java/lang/Object) org/jruby/runtime/builtin/IRubyObject) (-> java/lang/Object org/jruby/runtime/builtin/IRubyObject)) - (<| (case (host.check [java/lang/Object] value) + (<| (case (ffi.check [java/lang/Object] value) (#.Some value) (|> value (:coerce (Array java/lang/Object)) lux_structure) #.None) - (case (host.check java/lang/Boolean value) + (case (ffi.check java/lang/Boolean value) (#.Some value) (org/jruby/RubyBoolean::newBoolean ..initial_ruby_runtime value) #.None) - (case (host.check java/lang/Long value) + (case (ffi.check java/lang/Long value) (#.Some value) (org/jruby/RubyFixnum::new ..initial_ruby_runtime value) #.None) - (case (host.check java/lang/Double value) + (case (ffi.check java/lang/Double value) (#.Some value) (org/jruby/RubyFloat::new ..initial_ruby_runtime value) #.None) - (case (host.check java/lang/String value) + (case (ffi.check java/lang/String value) (#.Some value) (org/jruby/RubyString::newInternalFromJavaExternal ..initial_ruby_runtime value) @@ -336,7 +337,7 @@ (def: (lux_wrapper_access lux_structure value) (-> (-> (Array java/lang/Object) org/jruby/runtime/builtin/IRubyObject) (-> (Array java/lang/Object) org/jruby/internal/runtime/methods/DynamicMethod)) - (host.object [] org/jruby/internal/runtime/methods/DynamicMethod [] + (ffi.object [] org/jruby/internal/runtime/methods/DynamicMethod [] [{java/lang/String "[]"}] (org/jruby/internal/runtime/methods/DynamicMethod @@ -348,8 +349,8 @@ {args [org/jruby/runtime/builtin/IRubyObject]} {block org/jruby/runtime/Block}) org/jruby/runtime/builtin/IRubyObject - (let [member (host.array_read 0 args)] - (<| (case (host.check org/jruby/RubyFixnum member) + (let [member (ffi.array_read 0 args)] + (<| (case (ffi.check org/jruby/RubyFixnum member) (#.Some member) (case (array.read (org/jruby/RubyFixnum::getLongValue member) value) (#.Some value) @@ -359,7 +360,7 @@ (error! (exception.construct ..invalid_tuple_access [(org/jruby/RubyFixnum::getLongValue member)]))) #.None) - (case (host.check org/jruby/RubyString member) + (case (ffi.check org/jruby/RubyString member) (#.Some member) (case (:coerce Text (org/jruby/RubyString::asJavaString member)) (^ (static runtime.variant_tag_field)) @@ -390,10 +391,10 @@ (error! (exception.construct ..invalid_variant_access [field]))) #.None) - (case (host.check org/jruby/RubyRange member) + (case (ffi.check org/jruby/RubyRange member) (#.Some member) - (case [(|> member (org/jruby/RubyRange::first thread_context) (host.check org/jruby/RubyFixnum)) - (|> member (org/jruby/RubyRange::size thread_context) (host.check org/jruby/RubyFixnum))] + (case [(|> member (org/jruby/RubyRange::first thread_context) (ffi.check org/jruby/RubyFixnum)) + (|> member (org/jruby/RubyRange::size thread_context) (ffi.check org/jruby/RubyFixnum))] [(#.Some first) (#.Some size)] (let [first (org/jruby/RubyFixnum::getLongValue first) size (org/jruby/RubyFixnum::getLongValue size)] @@ -407,7 +408,7 @@ (def: (lux_wrapper_equality value) (-> (Array java/lang/Object) org/jruby/internal/runtime/methods/DynamicMethod) - (host.object [] org/jruby/internal/runtime/methods/DynamicMethod [] + (ffi.object [] org/jruby/internal/runtime/methods/DynamicMethod [] [{java/lang/String "=="}] (org/jruby/internal/runtime/methods/DynamicMethod @@ -419,7 +420,7 @@ {args [org/jruby/runtime/builtin/IRubyObject]} {block org/jruby/runtime/Block}) org/jruby/runtime/builtin/IRubyObject - (let [reference (host.array_read 0 args)] + (let [reference (ffi.array_read 0 args)] (case (..read (:coerce java/lang/Object reference)) (#try.Success reference) (org/jruby/RubyBoolean::newBoolean ..initial_ruby_runtime (is? (: Any reference) (: Any value))) @@ -429,7 +430,7 @@ (def: (lux_wrapper_length value) (-> (Array java/lang/Object) org/jruby/internal/runtime/methods/DynamicMethod) - (host.object [] org/jruby/internal/runtime/methods/DynamicMethod [] + (ffi.object [] org/jruby/internal/runtime/methods/DynamicMethod [] [{java/lang/String "length"}] (org/jruby/internal/runtime/methods/DynamicMethod @@ -447,7 +448,7 @@ (def: (lux_wrapper_to_s value) (-> (Array java/lang/Object) org/jruby/internal/runtime/methods/DynamicMethod) - (host.object [] org/jruby/internal/runtime/methods/DynamicMethod [] + (ffi.object [] org/jruby/internal/runtime/methods/DynamicMethod [] [{java/lang/String "to_s"}] (org/jruby/internal/runtime/methods/DynamicMethod @@ -469,7 +470,7 @@ (def: (lux_wrapper_respond_to? value) (-> (Array java/lang/Object) org/jruby/internal/runtime/methods/DynamicMethod) - (host.object [] org/jruby/internal/runtime/methods/DynamicMethod [] + (ffi.object [] org/jruby/internal/runtime/methods/DynamicMethod [] [{java/lang/String "respond_to?"}] (org/jruby/internal/runtime/methods/DynamicMethod @@ -482,8 +483,8 @@ {block org/jruby/runtime/Block}) org/jruby/runtime/builtin/IRubyObject (case (|> args - (host.array_read 0) - (host.check org/jruby/RubySymbol)) + (ffi.array_read 0) + (ffi.check org/jruby/RubySymbol)) (#.Some method) (|> (case (|> method org/jruby/RubySymbol::asJavaString @@ -508,7 +509,7 @@ (def: (lux_structure value) (-> (Array java/lang/Object) org/jruby/runtime/builtin/IRubyObject) - (let [meta_class (host.object [] org/jruby/RubyClass [] + (let [meta_class (ffi.object [] org/jruby/RubyClass [] [{org/jruby/Ruby ..initial_ruby_runtime}] @@ -542,7 +543,7 @@ (def: ensure_macro (-> Macro (Maybe org/jruby/RubyProc)) - (|>> (:coerce java/lang/Object) (host.check org/jruby/RubyProc))) + (|>> (:coerce java/lang/Object) (ffi.check org/jruby/RubyProc))) (def: to_host (-> Any org/jruby/runtime/builtin/IRubyObject) @@ -554,9 +555,9 @@ (:assume (do try.monad [expansion (org/jruby/RubyProc::call (!ruby_thread_context) - (|> (host.array org/jruby/runtime/builtin/IRubyObject 2) - (host.array_write 0 (..to_host inputs)) - (host.array_write 1 (..to_host lux))) + (|> (ffi.array org/jruby/runtime/builtin/IRubyObject 2) + (ffi.array_write 0 (..to_host inputs)) + (ffi.array_write 1 (..to_host lux))) macro)] (..read (:coerce java/lang/Object expansion))))) @@ -604,7 +605,7 @@ (def: (ingest context content) (|> content - (\ encoding.utf8 decode) + (\ utf8.codec decode) try.assume (:coerce _.Statement))) @@ -624,7 +625,7 @@ #platform.host host #platform.phase ruby.generate #platform.runtime runtime.generate - #platform.write (|>> _.code (\ encoding.utf8 encode))}))) + #platform.write (|>> _.code (\ utf8.codec encode))}))) (def: (program context program) (Program _.Expression _.Statement) @@ -649,12 +650,12 @@ (do try.monad [handler (try.from_maybe (..ensure_macro handler)) output (org/jruby/RubyProc::call (!ruby_thread_context) - (|> (host.array org/jruby/runtime/builtin/IRubyObject 5) - (host.array_write 0 (org/jruby/RubyString::newInternalFromJavaExternal (!ruby_runtime) name)) - (host.array_write 1 (..to_host phase)) - (host.array_write 2 (..to_host archive)) - (host.array_write 3 (..to_host parameters)) - (host.array_write 4 (..to_host state))) + (|> (ffi.array org/jruby/runtime/builtin/IRubyObject 5) + (ffi.array_write 0 (org/jruby/RubyString::newInternalFromJavaExternal (!ruby_runtime) name)) + (ffi.array_write 1 (..to_host phase)) + (ffi.array_write 2 (..to_host archive)) + (ffi.array_write 3 (..to_host parameters)) + (ffi.array_write 4 (..to_host state))) handler)] (..read (:coerce java/lang/Object output))))) |