aboutsummaryrefslogtreecommitdiff
path: root/lux-lua/source
diff options
context:
space:
mode:
authorEduardo Julian2022-03-16 08:37:23 -0400
committerEduardo Julian2022-03-16 08:37:23 -0400
commitbf53ee92fc3c33a4885aa227e55d24f7ba3cb2c4 (patch)
tree49683a62ae8e110c62b42a9a6386bb2ddb3c47c6 /lux-lua/source
parentd710d9f4fc098e7c243c8a5f23cd42683f13e07f (diff)
De-sigil-ification: prefix :
Diffstat (limited to 'lux-lua/source')
-rw-r--r--lux-lua/source/program.lux286
1 files changed, 143 insertions, 143 deletions
diff --git a/lux-lua/source/program.lux b/lux-lua/source/program.lux
index 74def59a7..3bcf4ccf9 100644
--- a/lux-lua/source/program.lux
+++ b/lux-lua/source/program.lux
@@ -184,32 +184,32 @@
(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)
- (net/sandius/rembulan/Table::get_key (:as java/lang/Object runtime.variant_value_field) host_object)]
+ (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)
+ (net/sandius/rembulan/Table::get_key (as java/lang/Object runtime.variant_value_field) host_object)]
(^.multi [{.#Some tag} ?flag {.#Some value}]
[(read value)
{try.#Success value}])
- {try.#Success [(: Any (|> tag
- (:as Int)
- ffi.as_long
- java/lang/Long::intValue
- (: java/lang/Integer)))
- (: Any (case ?flag
- {.#Some _} (: Any "")
- {.#None} (:as Any (ffi.null))))
- (: Any value)]}
+ {try.#Success [(is Any (|> tag
+ (as Int)
+ ffi.as_long
+ java/lang/Long::intValue
+ (is java/lang/Integer)))
+ (is Any (case ?flag
+ {.#Some _} (is Any "")
+ {.#None} (as Any (ffi.null))))
+ (is Any value)]}
_
- (exception.except ..unknown_kind_of_object [(:as java/lang/Object host_object)])))
+ (exception.except ..unknown_kind_of_object [(as java/lang/Object 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 [num_keys init_num_keys
idx 0
- output (: (Array java/lang/Object)
- (array.empty init_num_keys))]
+ output (is (Array java/lang/Object)
+ (array.empty init_num_keys))]
(if (n.< num_keys idx)
(case (net/sandius/rembulan/Table::get_idx (ffi.as_long (.int (++ idx))) host_object)
{.#None}
@@ -218,7 +218,7 @@
{.#Some member}
(case (read member)
{try.#Success parsed_member}
- (again num_keys (++ idx) (array.write! idx (:as java/lang/Object parsed_member) output))
+ (again num_keys (++ idx) (array.write! idx (as java/lang/Object parsed_member) output))
{try.#Failure error}
{try.#Failure error}))
@@ -262,7 +262,7 @@
(-> 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))))
+ (net/sandius/rembulan/runtime/ReturnBuffer::setTo (as java/lang/Object value))))
(def: (function/* arity)
(-> Nat Code)
@@ -301,8 +301,8 @@
(~~ (template [<arity>]
[(pattern (list (~~ (static.literals function.identity (..input/* <arity>)))))
- (in (to_host ((:as (~~ (static.literal function.identity (..function/* <arity>)))
- lux_function)
+ (in (to_host ((as (~~ (static.literal function.identity (..function/* <arity>)))
+ lux_function)
(~~ (static.literals function.identity (..input/* <arity>))))))]
[1]
@@ -313,21 +313,21 @@
))
(pattern (list& (~~ (static.literals function.identity (..input/* 5))) input/+))
- (again ((:as (~~ (static.literal function.identity (..function/* 5)))
- lux_function)
+ (again ((as (~~ (static.literal function.identity (..function/* 5)))
+ lux_function)
(~~ (static.literals function.identity (..input/* 5))))
input/+)
)))))))
(def: (lua_function to_host lux_function)
(-> (-> Any java/lang/Object) Any net/sandius/rembulan/runtime/LuaFunction)
- (<| (:as net/sandius/rembulan/runtime/LuaFunction)
+ (<| (as net/sandius/rembulan/runtime/LuaFunction)
(`` (`` (ffi.object [] net/sandius/rembulan/runtime/LuaFunction [LuxValue]
[]
... Methods
(LuxValue
[] (getValue self []) java/lang/Object
- (:as java/lang/Object lux_function))
+ (as java/lang/Object lux_function))
(net/sandius/rembulan/runtime/LuaFunction
[] (invoke self [% net/sandius/rembulan/runtime/ExecutionContext])
@@ -344,7 +344,7 @@
"throws" [net/sandius/rembulan/runtime/ResolvedControlThrowable]
(<| (..return %)
(apply/* to_host
- (ffi.:as net/sandius/rembulan/runtime/LuaFunction self)
+ (ffi.as net/sandius/rembulan/runtime/LuaFunction self)
(list (~~ (static.literals function.identity (..input/* <arity>))))
lux_function)))]
@@ -362,7 +362,7 @@
"throws" [net/sandius/rembulan/runtime/ResolvedControlThrowable]
(<| (..return %)
(apply/* to_host
- (ffi.:as net/sandius/rembulan/runtime/LuaFunction self)
+ (ffi.as net/sandius/rembulan/runtime/LuaFunction self)
(array.list {.#None} input/*)
lux_function)))
)))))
@@ -372,13 +372,13 @@
(def: (lux_structure to_host value)
(-> (-> Any java/lang/Object) (Array java/lang/Object) LuxValue)
- (<| (ffi.:as LuxValue)
+ (<| (ffi.as LuxValue)
(ffi.object [] net/sandius/rembulan/impl/DefaultTable [LuxValue]
[]
... Methods
(LuxValue
[] (getValue self []) java/lang/Object
- (:as java/lang/Object value))
+ (as java/lang/Object value))
(net/sandius/rembulan/impl/DefaultTable
[] (rawlen self []) long
@@ -401,8 +401,8 @@
(case (array.read! 0 value)
{.#Some it}
(|> it
- (:as java/lang/Integer)
- (ffi.:as java/lang/Object))
+ (as java/lang/Integer)
+ (ffi.as java/lang/Object))
{.#None}
(undefined))
@@ -410,7 +410,7 @@
(pattern (static runtime.variant_flag_field))
(case (array.read! 1 value)
{.#Some _}
- (:as java/lang/Object "")
+ (as java/lang/Object "")
{.#None}
(ffi.null))
@@ -426,10 +426,10 @@
array.size
.int
ffi.as_long
- (ffi.:as java/lang/Object))
+ (ffi.as java/lang/Object))
_
- (panic! (exception.error ..unknown_kind_of_object [(:as java/lang/Object field)])))
+ (panic! (exception.error ..unknown_kind_of_object [(as java/lang/Object field)])))
{.#None}
(case (ffi.check java/lang/Long field)
@@ -439,10 +439,10 @@
(to_host it)
{.#None}
- (: java/lang/Object (ffi.null)))
+ (is java/lang/Object (ffi.null)))
{.#None}
- (panic! (exception.error ..unknown_kind_of_object [(:as java/lang/Object field)])))))
+ (panic! (exception.error ..unknown_kind_of_object [(as java/lang/Object field)])))))
)))
(exception: (cannot_apply_a_non_function [object java/lang/Object])
@@ -451,7 +451,7 @@
(def: ensure_function
(-> Macro (Maybe net/sandius/rembulan/runtime/LuaFunction))
- (|>> (:as java/lang/Object)
+ (|>> (as java/lang/Object)
(ffi.check net/sandius/rembulan/runtime/LuaFunction)))
(type: Baggage
@@ -461,19 +461,19 @@
(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 (: (ffi.type [java/lang/Object])
- (|> (array.empty 2)
- (array.write! 0 ... (:as java/lang/Object inputs)
- ... (net/sandius/rembulan/impl/ImmutableTable$Builder::build (net/sandius/rembulan/impl/ImmutableTable$Builder::new))
- (:as java/lang/Object (lux_structure to_host (:as (Array java/lang/Object) inputs))))
- (array.write! 1 ... (:as java/lang/Object lux)
- ... (net/sandius/rembulan/impl/ImmutableTable$Builder::build (net/sandius/rembulan/impl/ImmutableTable$Builder::new))
- (:as java/lang/Object (lux_structure to_host (:as (Array java/lang/Object) lux))))))]
- output (net/sandius/rembulan/exec/DirectCallExecutor::call state_context (:as java/lang/Object macro) inputs executor)]
+ [.let [inputs (is (ffi.type [java/lang/Object])
+ (|> (array.empty 2)
+ (array.write! 0 ... (as java/lang/Object inputs)
+ ... (net/sandius/rembulan/impl/ImmutableTable$Builder::build (net/sandius/rembulan/impl/ImmutableTable$Builder::new))
+ (as java/lang/Object (lux_structure to_host (as (Array java/lang/Object) inputs))))
+ (array.write! 1 ... (as java/lang/Object lux)
+ ... (net/sandius/rembulan/impl/ImmutableTable$Builder::build (net/sandius/rembulan/impl/ImmutableTable$Builder::new))
+ (as java/lang/Object (lux_structure to_host (as (Array java/lang/Object) lux))))))]
+ output (net/sandius/rembulan/exec/DirectCallExecutor::call state_context (as java/lang/Object macro) inputs executor)]
(|> output
(array.read! 0)
maybe.trusted
- (:as java/lang/Object)
+ (as java/lang/Object)
..read)))
(def: (expander to_host baggage macro inputs lux)
@@ -483,21 +483,21 @@
(case (..call_macro to_host baggage inputs lux macro)
{try.#Success output}
(|> output
- (:as (Try [Lux (List Code)]))
+ (as (Try [Lux (List Code)]))
{try.#Success})
{try.#Failure error}
{try.#Failure error})
{.#None}
- (exception.except ..cannot_apply_a_non_function (:as java/lang/Object macro)))))]
+ (exception.except ..cannot_apply_a_non_function (as java/lang/Object macro)))))]
(for @.old (as_is <jvm>)
@.jvm (as_is <jvm>)
@.lua
(def: (expander macro inputs lux)
Expander
- {try.#Success ((:as Macro' macro) inputs lux)})))
+ {try.#Success ((as Macro' macro) inputs lux)})))
(with_expansions [<jvm> (as_is (with_expansions [$var_args (_.var "...")
$str_rel_to_abs (_.var "_utf8_str_rel_to_abs")
@@ -697,127 +697,127 @@
loader (net/sandius/rembulan/compiler/CompilerChunkLoader::of (ffi.as_string "_lux_definition"))
executor (net/sandius/rembulan/exec/DirectCallExecutor::newExecutor)
scheduling_context (net/sandius/rembulan/exec/DirectCallExecutor::schedulingContextFactory executor)
- run! (: (-> _.Statement (Try Any))
- (function (_ code)
- (do try.monad
- [lua_function (net/sandius/rembulan/load/ChunkLoader::loadTextChunk variable (ffi.as_string "lux compilation") (ffi.as_string (_.code code)) loader)
- output (net/sandius/rembulan/exec/DirectCallExecutor::call state_context (:as java/lang/Object lua_function) (array.empty 0)
- executor)]
- (case (array.read! 0 output)
- {.#None}
- (in [])
-
- {.#Some value}
- (read value)))))
+ run! (is (-> _.Statement (Try Any))
+ (function (_ code)
+ (do try.monad
+ [lua_function (net/sandius/rembulan/load/ChunkLoader::loadTextChunk variable (ffi.as_string "lux compilation") (ffi.as_string (_.code code)) loader)
+ output (net/sandius/rembulan/exec/DirectCallExecutor::call state_context (as java/lang/Object lua_function) (array.empty 0)
+ executor)]
+ (case (array.read! 0 output)
+ {.#None}
+ (in [])
+
+ {.#Some value}
+ (read value)))))
_ (try.trusted (run! ..rembulan_prelude))]
[[state_context executor]
- (: (Host _.Expression _.Statement)
- (implementation
- (def: (evaluate context [_ code])
- (run! (_.return code)))
-
- (def: execute run!)
-
- (def: (define context custom [_ input])
- (let [global (maybe.else (reference.artifact context)
- custom)
- @global (_.var global)
- definition (_.set (list @global) input)]
- (do try.monad
- [_ (run! definition)
- value (run! (_.return @global))]
- (in [global value definition]))))
-
- (def: (ingest context content)
- (|> content
- (# utf8.codec decoded)
- try.trusted
- (:as _.Statement)))
-
- (def: (re_learn context custom content)
- (run! content))
-
- (def: (re_load context custom content)
- (do try.monad
- [_ (run! content)]
- (run! (_.return (_.var (reference.artifact context))))))))]))))]
+ (is (Host _.Expression _.Statement)
+ (implementation
+ (def: (evaluate context [_ code])
+ (run! (_.return code)))
+
+ (def: execute run!)
+
+ (def: (define context custom [_ input])
+ (let [global (maybe.else (reference.artifact context)
+ custom)
+ @global (_.var global)
+ definition (_.set (list @global) input)]
+ (do try.monad
+ [_ (run! definition)
+ value (run! (_.return @global))]
+ (in [global value definition]))))
+
+ (def: (ingest context content)
+ (|> content
+ (# utf8.codec decoded)
+ try.trusted
+ (as _.Statement)))
+
+ (def: (re_learn context custom content)
+ (run! content))
+
+ (def: (re_load context custom content)
+ (do try.monad
+ [_ (run! content)]
+ (run! (_.return (_.var (reference.artifact context))))))))]))))]
(for @.old (as_is <jvm>)
@.jvm (as_is <jvm>)
@.lua (as_is (ffi.import: (load [ffi.String] "try" ffi.Function))
(def: host
(IO (Host _.Expression _.Statement))
- (io (let [run! (: (-> _.Statement (Try Any))
- (function (_ code)
- (do try.monad
- [lua_function (..load (_.code code))]
- (let [output ("lua apply" lua_function)]
- {try.#Success (if ("lua object nil?" output)
- []
- output)}))))]
- (: (Host _.Expression _.Statement)
- (implementation
- (def: (evaluate! context [_ code])
- (run! (_.return code)))
-
- (def: execute! run!)
-
- (def: (define! context custom [_ input])
- (let [global (maybe.else (reference.artifact context)
- custom)
- @global (_.var global)]
- (do try.monad
- [.let [definition (_.set (list @global) input)]
- _ (run! definition)
- value (run! (_.return @global))]
- (in [global value definition]))))
-
- (def: (ingest context content)
- (|> content (# utf8.codec decoded) try.trusted (:as _.Statement)))
-
- (def: (re_learn context custom content)
- (run! content))
-
- (def: (re_load context custom content)
- (do try.monad
- [_ (run! content)]
- (run! (_.return (_.var (reference.artifact context))))))))))))))
+ (io (let [run! (is (-> _.Statement (Try Any))
+ (function (_ code)
+ (do try.monad
+ [lua_function (..load (_.code code))]
+ (let [output ("lua apply" lua_function)]
+ {try.#Success (if ("lua object nil?" output)
+ []
+ output)}))))]
+ (is (Host _.Expression _.Statement)
+ (implementation
+ (def: (evaluate! context [_ code])
+ (run! (_.return code)))
+
+ (def: execute! run!)
+
+ (def: (define! context custom [_ input])
+ (let [global (maybe.else (reference.artifact context)
+ custom)
+ @global (_.var global)]
+ (do try.monad
+ [.let [definition (_.set (list @global) input)]
+ _ (run! definition)
+ value (run! (_.return @global))]
+ (in [global value definition]))))
+
+ (def: (ingest context content)
+ (|> content (# utf8.codec decoded) try.trusted (as _.Statement)))
+
+ (def: (re_learn context custom content)
+ (run! content))
+
+ (def: (re_load context custom content)
+ (do try.monad
+ [_ (run! content)]
+ (run! (_.return (_.var (reference.artifact context))))))))))))))
(with_expansions [<jvm> (as_is (def: (to_host it)
(-> Any java/lang/Object)
(`` (<| (~~ (template [<jvm> <lua>]
- [(case (ffi.check <jvm> (:as java/lang/Object it))
+ [(case (ffi.check <jvm> (as java/lang/Object it))
{.#Some it}
- (:as java/lang/Object
- (<lua> [(:expected it)]))
+ (as java/lang/Object
+ (<lua> [(as_expected it)]))
{.#None})]
[[java/lang/Object] (..lux_structure to_host)]
[library/lux/Function (..lua_function to_host)]
))
- (:as java/lang/Object it))))
+ (as java/lang/Object it))))
(def: (extender [state_context executor] phase_wrapper)
(-> Baggage (-> phase.Wrapper Extender))
... TODO: Stop relying on coercions ASAP.
- (<| (:as Extender)
+ (<| (as Extender)
(function (@self handler))
- (:as Handler)
+ (as Handler)
(function (@self name phase))
- (:as Phase)
+ (as Phase)
(function (@self archive parameters))
- (:as Operation)
+ (as Operation)
(function (@self state))
- (:as Try)
+ (as Try)
try.trusted
- (:as Try)
+ (as Try)
(do try.monad
[handler (try.of_maybe (..ensure_function handler))
output (net/sandius/rembulan/exec/DirectCallExecutor::call state_context
- (:as java/lang/Object handler)
+ (as java/lang/Object handler)
(|> (array.empty 5)
(array.write! 0 name)
- (array.write! 1 (:as java/lang/Object (phase_wrapper phase)))
+ (array.write! 1 (as java/lang/Object (phase_wrapper phase)))
(array.write! 2 (..to_host archive))
(array.write! 3 (..to_host parameters))
(array.write! 4 (..to_host state)))
@@ -825,7 +825,7 @@
(|> output
(array.read! 0)
maybe.trusted
- (:as java/lang/Object)
+ (as java/lang/Object)
..read)))))]
(for @.old (as_is <jvm>)
@.jvm (as_is <jvm>)
@@ -833,16 +833,16 @@
@.lua
(def: (extender phase_wrapper handler)
(-> phase.Wrapper Extender)
- (:expected handler))))
+ (as_expected handler))))
(def: (phase_wrapper archive)
(-> Archive (runtime.Operation phase.Wrapper))
(do phase.monad
[]
- (in (:as phase.Wrapper
- (for @.old (..lua_function ..to_host)
- @.jvm (..lua_function ..to_host)
- @.lua (|>>))))))
+ (in (as phase.Wrapper
+ (for @.old (..lua_function ..to_host)
+ @.jvm (..lua_function ..to_host)
+ @.lua (|>>))))))
(with_expansions [<jvm> (def: platform
(IO [Baggage (Platform [Register _.Label] _.Expression _.Statement)])