diff options
Diffstat (limited to '')
-rw-r--r-- | lux-r/source/luxc/lang/synthesis/variable.lux | 101 | ||||
-rw-r--r-- | lux-r/source/program.lux | 44 | ||||
-rw-r--r-- | lux-ruby/source/program.lux | 62 |
3 files changed, 53 insertions, 154 deletions
diff --git a/lux-r/source/luxc/lang/synthesis/variable.lux b/lux-r/source/luxc/lang/synthesis/variable.lux deleted file mode 100644 index 82478a2d6..000000000 --- a/lux-r/source/luxc/lang/synthesis/variable.lux +++ /dev/null @@ -1,101 +0,0 @@ -(.module: - lux - (lux (data [number] - (coll [list "list/" Mix<List> Monoid<List>] - ["s" set]))) - (luxc (lang ["la" analysis] - ["ls" synthesis] - ["[0]L" variable {"+" [Variable]}]))) - -(def: (bound-vars path) - (-> ls.Path (List Variable)) - (case path - (#ls.BindP register) - (list (.int register)) - - (^or (#ls.SeqP pre post) (#ls.AltP pre post)) - (list/composite (bound-vars pre) (bound-vars post)) - - _ - (list))) - -(def: (path-bodies path) - (-> ls.Path (List ls.Synthesis)) - (case path - (#ls.ExecP body) - (list body) - - (#ls.SeqP pre post) - (path-bodies post) - - (#ls.AltP pre post) - (list/composite (path-bodies pre) (path-bodies post)) - - _ - (list))) - -(def: (non-arg? arity var) - (-> ls.Arity Variable Bit) - (and (variableL.local? var) - (n/> arity (.nat var)))) - -(type: Tracker - (s.Set Variable)) - -(def: init-tracker - Tracker - (s.new number.Hash<Int>)) - -(def: (unused-vars current-arity bound exprS) - (-> ls.Arity (List Variable) ls.Synthesis (List Variable)) - (let [tracker (loop [exprS exprS - tracker (list/mix s.has init-tracker bound)] - (case exprS - (#ls.Variable var) - (if (non-arg? current-arity var) - (s.lacks var tracker) - tracker) - - (#ls.Variant tag last? memberS) - (recur memberS tracker) - - (#ls.Tuple membersS) - (list/mix recur tracker membersS) - - (#ls.Call funcS argsS) - (list/mix recur (recur funcS tracker) argsS) - - (^or (#ls.Recur argsS) - (#ls.Procedure name argsS)) - (list/mix recur tracker argsS) - - (#ls.Let offset inputS outputS) - (|> tracker (recur inputS) (recur outputS)) - - (#ls.If testS thenS elseS) - (|> tracker (recur testS) (recur thenS) (recur elseS)) - - (#ls.Loop offset initsS bodyS) - (recur bodyS (list/mix recur tracker initsS)) - - (#ls.Case inputS outputPS) - (let [tracker' (list/mix s.has - (recur inputS tracker) - (bound-vars outputPS))] - (list/mix recur tracker' (path-bodies outputPS))) - - (#ls.Function arity env bodyS) - (list/mix s.lacks tracker env) - - _ - tracker - ))] - (s.to-list tracker))) - -... (def: (optimize-register-use current-arity [pathS bodyS]) -... (-> ls.Arity [ls.Path ls.Synthesis] [ls.Path ls.Synthesis]) -... (let [bound (bound-vars pathS) -... unused (unused-vars current-arity bound bodyS) -... adjusted (adjust-vars unused bound)] -... [(|> pathS (clean-pattern adjusted) simplify-pattern) -... (clean-expression adjusted bodyS)])) diff --git a/lux-r/source/program.lux b/lux-r/source/program.lux index ec77f8c0d..990fb6dbc 100644 --- a/lux-r/source/program.lux +++ b/lux-r/source/program.lux @@ -188,7 +188,7 @@ ... (let [sub_value (:as java/lang/Object sub_value)] ... (`` (<| (~~ (template [<type> <then>] ... [(case (ffi.check <type> sub_value) - ... (#.Some sub_value) + ... {#.Some sub_value} ... (`` (|> sub_value (~~ (template.splice <then>)))) ... #.None)] @@ -362,7 +362,7 @@ (case (|> host_object (org/renjin/sexp/ListVector::get_field runtime.variant_flag_field) (ffi.check org/renjin/sexp/Null)) - (#.Some _) + {#.Some _} (: Any (ffi.null)) _ @@ -377,12 +377,12 @@ (|> host_object (org/renjin/sexp/ListVector::get_field runtime.i64_low_field) (ffi.check org/renjin/sexp/IntArrayVector))] - [(#.Some high) (#.Some low)] - (#try.Success (runtime.lux_i64 (org/renjin/sexp/SEXP::asInt high) - (org/renjin/sexp/SEXP::asInt low))) + [{#.Some high} {#.Some low}] + {#try.Success (runtime.lux_i64 (org/renjin/sexp/SEXP::asInt high) + (org/renjin/sexp/SEXP::asInt low))} _ - (#try.Failure ""))) + {#try.Failure ""})) (def: (read_tuple read host_object) (-> (Reader java/lang/Object) (Reader org/renjin/sexp/ListVector)) @@ -391,12 +391,12 @@ output (:as (Array Any) (array.new size))] (if (n.< size idx) (case (|> host_object (org/renjin/sexp/ListVector::get_index (.int idx)) (:as java/lang/Object) read) - (#try.Failure error) - (#try.Failure error) + {#try.Failure error} + {#try.Failure error} - (#try.Success member) + {#try.Success member} (recur (++ idx) (array.write! idx (:as Any member) output))) - (#try.Success output))))) + {#try.Success output})))) (def: (field_class field host_object) (-> Text org/renjin/sexp/ListVector Text) @@ -411,23 +411,23 @@ (exec ... ("lux io log" (exception.construct ..unknown_kind_of_object [host_object])) (`` (<| (case (ffi.check org/renjin/sexp/ListVector host_object) - (#.Some host_object) + {#.Some host_object} (<| (case (..read_variant read host_object) - (#try.Success output) - (#try.Success output) + {#try.Success output} + {#try.Success output} - (#try.Failure _)) + {#try.Failure _}) (case (..read_i64 host_object) - (#try.Success output) - (#try.Success output) + {#try.Success output} + {#try.Success output} - (#try.Failure _)) + {#try.Failure _}) (..read_tuple read host_object)) #.None) (~~ (template [<class> <post_processing>] [(case (ffi.check <class> host_object) - (#.Some host_object) + {#.Some host_object} (`` (|> host_object (~~ (template.splice <post_processing>)))) #.None)] @@ -458,10 +458,10 @@ (org/renjin/sexp/PairList$Builder::add (..host_value lux)) org/renjin/sexp/PairList$Builder::build (:as org/renjin/sexp/PairList))) - (#try.Success r_inputs) + {#try.Success r_inputs} r_inputs - (#try.Failure error) + {#try.Failure error} (exec ("lux io log" error) (panic! error)))) @@ -481,7 +481,7 @@ (def: (expander interpreter macro inputs lux) (-> org/renjin/script/RenjinScriptEngine Expander) (case (ensure_macro macro) - (#.Some macro) + {#.Some macro} (call_macro interpreter inputs lux macro) #.None @@ -569,7 +569,7 @@ (:as Try) (exec ("lux io log" "TODO: Extender") - (#try.Failure "TODO: Extender")))) + {#try.Failure "TODO: Extender"}))) @.r (def: (extender handler) diff --git a/lux-ruby/source/program.lux b/lux-ruby/source/program.lux index 25e3cc2ab..37713dfdb 100644 --- a/lux-ruby/source/program.lux +++ b/lux-ruby/source/program.lux @@ -242,14 +242,14 @@ #.None (recur (++ idx) output) - (#.Some value) + {#.Some value} (case (read value) - (#try.Failure error) - (#try.Failure error) + {#try.Failure error} + {#try.Failure error} - (#try.Success lux_value) + {#try.Success lux_value} (recur (++ idx) (array.write! idx lux_value output)))) - (#try.Success output))))) + {#try.Success output})))) (exception: (unknown_kind_of_object [object java/lang/Object]) (exception.report @@ -261,18 +261,18 @@ (case [(org/jruby/RubyHash::get (:as java/lang/String runtime.variant_tag_field) host_object) (org/jruby/RubyHash::get (:as java/lang/String runtime.variant_flag_field) host_object) (org/jruby/RubyHash::get (:as java/lang/String runtime.variant_value_field) host_object)] - (^multi [(#.Some tag) ?flag (#.Some value)] + (^multi [{#.Some tag} ?flag {#.Some value}] [(read value) - (#try.Success value)]) - (#try.Success [(:as Any (java/lang/Long::intValue (:as java/lang/Long tag))) + {#try.Success value}]) + {#try.Success [(:as Any (java/lang/Long::intValue (:as java/lang/Long tag))) (:as Any (case ?flag - (#.Some _) + {#.Some _} "" #.None (ffi.null))) - (:as Any value)]) + (:as Any value)]} _ (exception.except ..unknown_kind_of_object [(:as java/lang/Object host_object)]))) @@ -285,7 +285,7 @@ (exception.except ..nil_has_no_lux_representation [])) (~~ (template [<class> <post_processing>] [(case (ffi.check <class> host_object) - (#.Some typed_object) + {#.Some typed_object} (`` (|> typed_object (~~ (template.spliced <post_processing>)))) _)] @@ -316,27 +316,27 @@ (-> (-> (Array java/lang/Object) org/jruby/runtime/builtin/IRubyObject) (-> java/lang/Object org/jruby/runtime/builtin/IRubyObject)) (<| (case (ffi.check [java/lang/Object] value) - (#.Some value) + {#.Some value} (|> value (:as (Array java/lang/Object)) lux_structure) #.None) (case (ffi.check java/lang/Boolean value) - (#.Some value) + {#.Some value} (org/jruby/RubyBoolean::newBoolean ..initial_ruby_runtime value) #.None) (case (ffi.check java/lang/Long value) - (#.Some value) + {#.Some value} (org/jruby/RubyFixnum::new ..initial_ruby_runtime value) #.None) (case (ffi.check java/lang/Double value) - (#.Some value) + {#.Some value} (org/jruby/RubyFloat::new ..initial_ruby_runtime value) #.None) (case (ffi.check java/lang/String value) - (#.Some value) + {#.Some value} (org/jruby/RubyString::newInternalFromJavaExternal ..initial_ruby_runtime value) #.None) @@ -378,9 +378,9 @@ org/jruby/runtime/builtin/IRubyObject (let [member (ffi.read! 0 args)] (<| (case (ffi.check org/jruby/RubyFixnum member) - (#.Some member) + {#.Some member} (case (array.read! (org/jruby/RubyFixnum::getLongValue member) value) - (#.Some value) + {#.Some value} (wrapped_lux_value lux_structure value) #.None @@ -388,7 +388,7 @@ #.None) (case (ffi.check org/jruby/RubyString member) - (#.Some member) + {#.Some member} (case (:as Text (org/jruby/RubyString::asJavaString member)) (^ (static runtime.variant_tag_field)) (|> value @@ -403,12 +403,12 @@ #.None ..ruby_nil - (#.Some flag) + {#.Some flag} ..lux_unit) (^ (static runtime.variant_value_field)) (case (array.read! 2 value) - (#.Some value) + {#.Some value} (wrapped_lux_value lux_structure value) #.None @@ -419,10 +419,10 @@ #.None) (case (ffi.check org/jruby/RubyRange member) - (#.Some member) + {#.Some member} (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)] + [{#.Some first} {#.Some size}] (let [first (org/jruby/RubyFixnum::getLongValue first) size (org/jruby/RubyFixnum::getLongValue size)] (lux_structure (java/util/Arrays::copyOfRange value first (i.+ first size)))) @@ -448,10 +448,10 @@ org/jruby/runtime/builtin/IRubyObject (let [reference (ffi.read! 0 args)] (case (..read (:as java/lang/Object reference)) - (#try.Success reference) + {#try.Success reference} (org/jruby/RubyBoolean::newBoolean ..initial_ruby_runtime (same? (: Any reference) (: Any value))) - (#try.Failure error) + {#try.Failure error} (org/jruby/RubyBoolean::newBoolean ..initial_ruby_runtime false)))))) (def: (lux_wrapper_length value) @@ -508,7 +508,7 @@ (case (|> args (ffi.read! 0) (ffi.check org/jruby/RubySymbol)) - (#.Some method) + {#.Some method} (|> (case (|> method org/jruby/RubySymbol::asJavaString (:as Text)) @@ -585,16 +585,16 @@ (def: (expander macro inputs lux) Expander (case (ensure_macro macro) - (#.Some macro) + {#.Some macro} (case (call_macro inputs lux macro) - (#try.Success output) + {#try.Success output} (|> output (:as java/lang/Object) ..read (:as (Try (Try [Lux (List Code)])))) - (#try.Failure error) - (#try.Failure error)) + {#try.Failure error} + {#try.Failure error}) #.None (exception.except ..cannot_apply_a_non_function [(:as java/lang/Object macro)]))) @@ -692,7 +692,7 @@ (let [inputs (array.list #.None inputs)]) (case inputs (^ (list)) - (#try.Success (host_phase partial_application phase)) + {#try.Success (host_phase partial_application phase)} (^ (list input/0)) (do try.monad |