Skip to content

Commit

Permalink
Adapting to new List type (part 7).
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoejp committed Mar 19, 2024
1 parent d69eacf commit 06c182d
Show file tree
Hide file tree
Showing 203 changed files with 5,749 additions and 5,713 deletions.
26 changes: 15 additions & 11 deletions lux-js/source/program.lux
Original file line number Diff line number Diff line change
Expand Up @@ -671,12 +671,13 @@
(_.and (_.its "argv" @process)))
node_js_inputs (|> @process
(_.its "argv")
(_.do "slice" (stack (_.int +2))))
no_inputs (_.array (stack))]
(_.; (_.apply_1 (_.apply_1 program (runtime.lux//program_args (_.? on_node_js?
node_js_inputs
no_inputs)))
(_.string "")))))
(_.do "slice" (list (_.int +2))))
no_inputs (_.array (list))]
(_.; (|> program
(_.on (list (runtime.lux//program_args (_.? on_node_js?
node_js_inputs
no_inputs))))
(_.on (list (_.string "")))))))

(for .jvm
(the extender
Expand Down Expand Up @@ -713,13 +714,16 @@
(|>> as_expected)))

(the (declare_success! _)
(-> Any (Future Any))
(-> Any
(Future Any))
(future.soon (by environment.default exit +0)))

(the (scope body)
(-> _.Statement _.Statement)
(_.; (_.apply (_.closure (stack) body)
(stack))))
(the scope
(-> _.Statement
_.Statement)
(|>> (_.closure (list))
(_.on (list))
_.;))

(the (lux_compiler it)
(-> Any platform.Custom)
Expand Down
95 changes: 49 additions & 46 deletions lux-lua/source/program.lux

Large diffs are not rendered by default.

68 changes: 34 additions & 34 deletions lux-ruby/source/program.lux
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
["[0]" utf8]]]
[collection
["[0]" array (.only Array)]
["[0]" stack (.use "[1]#[0]" functor)]]]
["[0]" list (.use "[1]#[0]" functor)]]]
[math
[number (.only hex)
["n" natural]
Expand Down Expand Up @@ -401,40 +401,40 @@
(try.trusted
(do [! try.monad]
[args (|> arity
stack.indices
(stack#each (function (_ index)
(ffi.read! index args)))
(stack.each' ! (|>> (ffi.is java/lang/Object) ..read)))
list.indices
(list#each (function (_ index)
(ffi.read! index args)))
(list.each' ! (|>> (ffi.is java/lang/Object) ..read)))
output (when args
(stack arg/0)
(list arg/0)
(in ((as (-> Any java/lang/Object) value)
arg/0))

(stack arg/0 arg/1)
(list arg/0 arg/1)
(in ((as (-> Any Any java/lang/Object) value)
arg/0 arg/1))

(stack arg/0 arg/1 arg/2)
(list arg/0 arg/1 arg/2)
(in ((as (-> Any Any Any java/lang/Object) value)
arg/0 arg/1 arg/2))

(stack arg/0 arg/1 arg/2 arg/3)
(list arg/0 arg/1 arg/2 arg/3)
(in ((as (-> Any Any Any Any java/lang/Object) value)
arg/0 arg/1 arg/2 arg/3))

(stack arg/0 arg/1 arg/2 arg/3 arg/4)
(list arg/0 arg/1 arg/2 arg/3 arg/4)
(in ((as (-> Any Any Any Any Any java/lang/Object) value)
arg/0 arg/1 arg/2 arg/3 arg/4))

(stack arg/0 arg/1 arg/2 arg/3 arg/4 arg/5)
(list arg/0 arg/1 arg/2 arg/3 arg/4 arg/5)
(in ((as (-> Any Any Any Any Any Any java/lang/Object) value)
arg/0 arg/1 arg/2 arg/3 arg/4 arg/5))

(stack arg/0 arg/1 arg/2 arg/3 arg/4 arg/5 arg/6)
(list arg/0 arg/1 arg/2 arg/3 arg/4 arg/5 arg/6)
(in ((as (-> Any Any Any Any Any Any Any java/lang/Object) value)
arg/0 arg/1 arg/2 arg/3 arg/4 arg/5 arg/6))

(stack arg/0 arg/1 arg/2 arg/3 arg/4 arg/5 arg/6 arg/7)
(list arg/0 arg/1 arg/2 arg/3 arg/4 arg/5 arg/6 arg/7)
(in ((as (-> Any Any Any Any Any Any Any Any java/lang/Object) value)
arg/0 arg/1 arg/2 arg/3 arg/4 arg/5 arg/6 arg/7))

Expand Down Expand Up @@ -766,7 +766,7 @@
custom)
@global (_.global global)]
(do try.monad
[.let [definition (_.; (_.set (stack @global) input))]
[.let [definition (_.; (_.set (list @global) input))]
value (value definition)]
(in [global value definition]))))

Expand All @@ -785,10 +785,10 @@
(value (_.global (reference.artifact context))))))))))

(for .jvm (these (exception.the .public (invaid_phase_application [partial_application arity])
(Exception [(Stack Any) (Stack Any)])
(Exception [(List Any) (List Any)])
(exception.report
(list ["Partial Application" (%.natural (stack.size partial_application))]
["Arity" (%.natural (stack.size arity))])))
(list ["Partial Application" (%.natural (list.size partial_application))]
["Arity" (%.natural (list.size arity))])))

(the proc_type
org/jruby/runtime/Block$Type
Expand Down Expand Up @@ -861,11 +861,11 @@
(<| try.trusted
(do [! try.monad]
[inputs (|> inputs
(array.stack {.#None})
(stack.each' ! (|>> (ffi.is java/lang/Object) ..read)))])
(list.of_array {.#None})
(list.each' ! (|>> (ffi.is java/lang/Object) ..read)))])
(when inputs
... It seems that org/jruby/runtime/Block::call can misbehave when getting called with a Lux state value.
(stack info source provenance current_module modules scopes type_context expected seed scope_type_vars extensions eval host)
(list info source provenance current_module modules scopes type_context expected seed scope_type_vars extensions eval host)
(when partial_application
(stack partial/0 partial/1)
(in (..to_host ((as (-> Any Any Any Any) phase)
Expand All @@ -874,13 +874,13 @@
[info source provenance current_module modules scopes type_context expected seed scope_type_vars extensions eval host])))

_
(exception.except ..invaid_phase_application [partial_application inputs]))
(exception.except ..invaid_phase_application [(list.of_stack partial_application) inputs]))

(stack)
(list)
{try.#Success (<| (ffi.is org/jruby/runtime/builtin/IRubyObject)
(host_phase partial_application phase))}

(stack input/0)
(list input/0)
(when partial_application
(stack)
(in (<| (ffi.is org/jruby/runtime/builtin/IRubyObject)
Expand All @@ -897,9 +897,9 @@
input/0)))

_
(exception.except ..invaid_phase_application [partial_application inputs]))
(exception.except ..invaid_phase_application [(list.of_stack partial_application) inputs]))

(stack input/0 input/1)
(list input/0 input/1)
(when partial_application
(stack)
(in (<| (ffi.is org/jruby/runtime/builtin/IRubyObject)
Expand All @@ -912,9 +912,9 @@
input/1)))

_
(exception.except ..invaid_phase_application [partial_application inputs]))
(exception.except ..invaid_phase_application [(list.of_stack partial_application) inputs]))

(stack input/0 input/1 input/2)
(list input/0 input/1 input/2)
(when partial_application
(stack)
(in (..to_host ((as (-> Any Any Any Any) phase)
Expand All @@ -923,10 +923,10 @@
input/2)))

_
(exception.except ..invaid_phase_application [partial_application inputs]))
(exception.except ..invaid_phase_application [(list.of_stack partial_application) inputs]))

_
(exception.except ..invaid_phase_application [partial_application inputs])))))]
(exception.except ..invaid_phase_application [(list.of_stack partial_application) inputs])))))]
(org/jruby/RubyProc::newProc [(!ruby_runtime) block ..proc_type])))

(the phase_wrapper
Expand Down Expand Up @@ -979,13 +979,13 @@
(the (lux_program context program)
(Program _.Expression _.Statement)
(let [normal_runtime? (_.do "const_defined?"
(stack (_.string (_.code _.command_line_arguments)))
(list (_.string (_.code _.command_line_arguments)))
{.#None}
(is _.CVar (_.manual "Object")))]
(_.; (_.apply_lambda (stack (runtime.lux//program_args (_.? normal_runtime?
_.command_line_arguments
(_.array (stack))))
_.nil)
(_.; (_.apply_lambda (list (runtime.lux//program_args (_.? normal_runtime?
_.command_line_arguments
(_.array (list))))
_.nil)
program))))

(the (declare_success! _)
Expand Down
4 changes: 3 additions & 1 deletion stdlib/source/injection/lux/data/text.lux
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
["[0]" product]
["[0]" text (.only Injection)]
[collection
["[0]" list (.use "[1]#[0]" monad)]
["[0]" stack (.use "[1]#[0]" monad)]]]
[math
["[0]" unit]
Expand Down Expand Up @@ -102,7 +103,8 @@
(for_any (_ it)
(-> (Injection it)
(Injection (Stack it))))
(|>> (stack#each (|>> as (.text " ")))
(|>> list.of_stack
(list#each (|>> as (.text " ")))
text.together
(text.enclosed ["(stack" ")"])))

Expand Down
12 changes: 6 additions & 6 deletions stdlib/source/library/lux/compiler/default/init.lux
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@

(the (begin dependencies hash input all_extensions)
(for_any (_ anchor expression declaration)
(-> (List descriptor.Module) Natural ///.Input
(-> (Stack descriptor.Module) Natural ///.Input
(Extensions anchor expression declaration)
(///declaration.Operation anchor expression declaration
[Source (Payload declaration)])))
Expand All @@ -193,7 +193,7 @@
_ (with_defaults module all_extensions)]
(///declaration.of_analysis
(do [! phase.monad]
[_ (list.each' ! moduleA.import dependencies)
[_ (stack.each' ! moduleA.import dependencies)
.let [source (///analysis.source (its ///.#module input) (its ///.#code input))]
_ (///analysis.set_source_code source)]
(in [source [///translation.empty_buffer
Expand Down Expand Up @@ -277,10 +277,10 @@

(the (default_dependencies prelude input)
(-> descriptor.Module ///.Input
(List descriptor.Module))
(Stack descriptor.Module))
(if (text.= prelude (its ///.#module input))
(list descriptor.runtime)
(list descriptor.runtime prelude)))
(stack descriptor.runtime)
(stack descriptor.runtime prelude)))

(the module_aliases
(-> .Module Aliases)
Expand Down Expand Up @@ -344,7 +344,7 @@
.let [descriptor [descriptor.#hash hash
descriptor.#name module
descriptor.#file (its ///.#file input)
descriptor.#references (set.of_list text.hash dependencies)
descriptor.#references (set.of_list text.hash (list.of_stack dependencies))
descriptor.#state {.#Compiled}]]]
(in [state
{.#Right [[moduleM.#id (try.else moduleM.runtime (archive.id module archive))
Expand Down
Loading

0 comments on commit 06c182d

Please sign in to comment.