diff options
Diffstat (limited to 'lux-lua/source')
-rw-r--r-- | lux-lua/source/program.lux | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/lux-lua/source/program.lux b/lux-lua/source/program.lux index 7a2f2712e..152d4d3e5 100644 --- a/lux-lua/source/program.lux +++ b/lux-lua/source/program.lux @@ -182,7 +182,7 @@ (type: Translator (-> java/lang/Object (Try Any))) - (def: (read_variant read host_object) + (def (read_variant read host_object) (-> Translator net/sandius/rembulan/impl/DefaultTable (Try Any)) (case [(net/sandius/rembulan/Table::get_key (as java/lang/Object runtime.variant_tag_field) host_object) (net/sandius/rembulan/Table::get_key (as java/lang/Object runtime.variant_flag_field) host_object) @@ -203,7 +203,7 @@ _ (exception.except ..unknown_kind_of_object [(as java/lang/Object host_object)]))) - (def: (read_tuple read host_object) + (def (read_tuple read host_object) (-> Translator net/sandius/rembulan/impl/DefaultTable (Try Any)) (let [init_num_keys (.nat (ffi.of_long (net/sandius/rembulan/Table::rawlen host_object)))] (loop (again [num_keys init_num_keys @@ -226,7 +226,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 [])) @@ -258,37 +258,37 @@ (exception.except ..unknown_kind_of_object [host_object]) ))) - (def: (return ec value) + (def (return ec value) (-> net/sandius/rembulan/runtime/ExecutionContext Any Any) (|> ec net/sandius/rembulan/runtime/ExecutionContext::getReturnBuffer (net/sandius/rembulan/runtime/ReturnBuffer::setTo (as java/lang/Object value)))) - (def: (function/* arity) + (def (function/* arity) (-> Nat Code) (` (.-> (~+ (list.repeated arity (` .Any))) .Any))) - (def: input/* + (def input/* (-> Nat (List Code)) (|>> list.indices (list#each (|>> %.nat (format "input/") code.local)))) - (def: declaration/* + (def declaration/* (-> Nat (List Code)) (|>> ..input/* (list#each (function (_ $input) (list $input (' java/lang/Object)))) list#conjoint)) - (def: read/* + (def read/* (-> Nat (List Code)) (|>> ..input/* (list#each (function (_ $input) (list $input (` (..read (~ $input)))))) list#conjoint)) - (def: (apply/* to_host self parameters abstraction) + (def (apply/* to_host self parameters abstraction) (-> (-> Any java/lang/Object) net/sandius/rembulan/runtime/LuaFunction (List java/lang/Object) Any Any) (<| try.trusted (do [! try.monad] @@ -319,7 +319,7 @@ input/+) ))))))) - (def: (lua_function to_host lux_function) + (def (lua_function to_host lux_function) (-> (-> Any java/lang/Object) Any net/sandius/rembulan/runtime/LuaFunction) (<| (as net/sandius/rembulan/runtime/LuaFunction) (`` (`` (ffi.object [] net/sandius/rembulan/runtime/LuaFunction [LuxValue] @@ -370,7 +370,7 @@ (ffi.import library/lux/Function "[1]::[0]") - (def: (lux_structure to_host value) + (def (lux_structure to_host value) (-> (-> Any java/lang/Object) (Array java/lang/Object) LuxValue) (<| (ffi.is LuxValue) (ffi.object [] net/sandius/rembulan/impl/DefaultTable [LuxValue] @@ -449,7 +449,7 @@ (exception.report "Non-function" (ffi.of_string (java/lang/Object::toString object)))) - (def: ensure_function + (def ensure_function (-> Macro (Maybe net/sandius/rembulan/runtime/LuaFunction)) (|>> (as java/lang/Object) (ffi.as net/sandius/rembulan/runtime/LuaFunction))) @@ -458,7 +458,7 @@ [net/sandius/rembulan/StateContext net/sandius/rembulan/exec/DirectCallExecutor]) - (def: (call_macro to_host [state_context executor] inputs lux macro) + (def (call_macro to_host [state_context executor] inputs lux macro) (-> (-> Any java/lang/Object) Baggage (List Code) Lux net/sandius/rembulan/runtime/LuaFunction (Try Any)) (do try.monad [.let [inputs (is (ffi.type [java/lang/Object]) @@ -476,7 +476,7 @@ (as java/lang/Object) ..read))) - (def: (expander to_host baggage macro inputs lux) + (def (expander to_host baggage macro inputs lux) (-> (-> Any java/lang/Object) Baggage Expander) (case (..ensure_function macro) {.#Some macro} @@ -495,7 +495,7 @@ @.jvm (these <jvm>) @.lua - (def: (expander macro inputs lux) + (def (expander macro inputs lux) Expander {try.#Success ((as Macro' macro) inputs lux)}))) @@ -513,7 +513,7 @@ (_.bit_shr (_.int <shift>)) (_.bit_and (!int <and>)) (_.bit_or (!int <or>)))])] - (these (def: rembulan//char + (these (def rembulan//char (let [$buffer (_.var "buffer") $k (_.var "k") $v (_.var "v") @@ -562,7 +562,7 @@ (_.return (_.apply (list $buffer (_.string "")) (_.var "table.concat"))) )))) - ... (def: rembulan//str_rel_to_abs + ... (def rembulan//str_rel_to_abs ... (let [$string (_.var "string") ... $args (_.var "args") ... $k (_.var "k") @@ -582,7 +582,7 @@ ... (_.return (_.apply (list $args) (_.var "table.unpack"))) ... )))) - ... (def: rembulan//decode + ... (def rembulan//decode ... (let [$string (_.var "string") ... $start (_.var "start") ... $b1 (_.var "b1") @@ -619,7 +619,7 @@ ... )) ... )))) - ... (def: rembulan//codes + ... (def rembulan//codes ... (let [$string (_.var "string") ... $i (_.var "i") ... $start (_.var "start") @@ -641,7 +641,7 @@ ... )))) ... )))) - ... (def: rembulan//len + ... (def rembulan//len ... (let [$string (_.var "string") ... $start (_.var "start") ... $end (_.var "_end") @@ -666,11 +666,11 @@ ... (_.return $size) ... )))) - ... (def: rembulan//charpattern + ... (def rembulan//charpattern ... (_.set (list (_.var "utf8.charpattern")) ... (_.string "[%z\x01-\x7F\xC2-\xF4][\x80-\xBF]*"))) - (def: rembulan_prelude + (def rembulan_prelude _.Statement (all _.then (_.function (_.var "os.time") (list) @@ -685,7 +685,7 @@ ... ..rembulan//charpattern ))))) - (def: host + (def host (IO [Baggage (Host _.Expression _.Statement)]) (io (let [runtime_env (net/sandius/rembulan/env/RuntimeEnvironments::system) std_lib (net/sandius/rembulan/lib/StandardLibrary::in runtime_env) @@ -711,12 +711,12 @@ [[state_context executor] (is (Host _.Expression _.Statement) (implementation - (def: (evaluate context [_ code]) + (def (evaluate context [_ code]) (run! (_.return 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 (_.var global) @@ -726,23 +726,23 @@ value (run! (_.return @global))] (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! (_.return (_.var (reference.artifact context))))))))]))))] (for @.old (these <jvm>) @.jvm (these <jvm>) @.lua (these (ffi.import (load [ffi.String] "try" ffi.Function)) - (def: host + (def host (IO (Host _.Expression _.Statement)) (io (let [run! (is (-> _.Statement (Try Any)) (function (_ code) @@ -754,12 +754,12 @@ output)}))))] (is (Host _.Expression _.Statement) (implementation - (def: (evaluate! context [_ code]) + (def (evaluate! context [_ code]) (run! (_.return 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 (_.var global)] @@ -769,18 +769,18 @@ value (run! (_.return @global))] (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! (_.return (_.var (reference.artifact context)))))))))))))) -(with_expansions [<jvm> (these (def: (to_host it) +(with_expansions [<jvm> (these (def (to_host it) (-> Any java/lang/Object) (`` (<| (~~ (with_template [<jvm> <lua>] [(case (ffi.as <jvm> (as java/lang/Object it)) @@ -795,7 +795,7 @@ )) (as java/lang/Object it)))) - (def: (extender [state_context executor] phase_wrapper) + (def (extender [state_context executor] phase_wrapper) (-> Baggage (-> phase.Wrapper Extender)) ... TODO: Stop relying on coercions ASAP. (<| (as Extender) @@ -829,11 +829,11 @@ @.jvm (these <jvm>) @.lua - (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)) (do phase.monad [] @@ -842,7 +842,7 @@ @.jvm (..lua_function ..to_host) @.lua (|>>)))))) -(with_expansions [<jvm> (def: platform +(with_expansions [<jvm> (def platform (IO [Baggage (Platform [Register _.Label] _.Expression _.Statement)]) (do io.monad [[baggage host] ..host] @@ -855,7 +855,7 @@ platform.#write (|>> _.code (at utf8.codec encoded))]])))] (for @.old <jvm> @.jvm <jvm> - @.lua (def: platform + @.lua (def platform (IO (Platform [Register _.Label] _.Expression _.Statement)) (do io.monad [host ..host] @@ -866,18 +866,18 @@ platform.#phase_wrapper ..phase_wrapper platform.#write (|>> _.code (at utf8.codec encoded))]))))) -(def: (program context program) +(def (program context program) (Program _.Expression _.Statement) (let [$program (_.var (reference.artifact context))] (_.statement (_.apply (list (runtime.lux//program_args (_.var "arg")) runtime.unit) 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)) |