diff options
Diffstat (limited to 'lux-php/source')
-rw-r--r-- | lux-php/source/program.lux | 157 |
1 files changed, 79 insertions, 78 deletions
diff --git a/lux-php/source/program.lux b/lux-php/source/program.lux index 73c278858..47edfa25c 100644 --- a/lux-php/source/program.lux +++ b/lux-php/source/program.lux @@ -1,64 +1,65 @@ (.require - [lux (.except) - [program (.only program)] - ["[0]" ffi] - ["[0]" debug] - [abstract - ["[0]" monad (.only do)]] - [control - ["[0]" pipe] - ["[0]" maybe] - ["[0]" try (.only Try)] - ["[0]" exception (.only exception)] - ["[0]" io (.only IO io)] - [concurrency - ["[0]" promise (.only Promise)]]] - [data - ["[0]" text (.use "[1]#[0]" hash) - ["%" \\format (.only format)] - [encoding - ["[0]" utf8]]] - [collection - ["[0]" array (.only Array)]]] - [macro - ["[0]" template]] - [math - [number (.only hex) - ["n" nat] - ["[0]" i64]]] - ["[0]" world - ["[0]" file] - ["[1]/[0]" program]] - ["@" target - ["_" php]] - [meta - [compiler - [phase (.only Operation Phase)] - [reference - [variable (.only Register)]] - [language - [lux - [program (.only Program)] - [generation (.only Context Host)] - ["[0]" synthesis] - [analysis - [macro (.only Expander)]] - [phase - ["[0]" extension (.only Extender Handler) - ["[1]/[0]" bundle] - ["[0]" analysis - ["[1]" php]] - ["[0]" generation - ["[1]" php]]] - [generation - ["[0]" reference] - ["[0]" php - ["[0]" runtime]]]]]] - [default - ["[0]" platform (.only Platform)]] - [meta - ["[0]" packager - ["[1]" script]]]]]] + [library + [lux (.except) + [program (.only program)] + ["[0]" ffi] + ["[0]" debug] + [abstract + ["[0]" monad (.only do)]] + [control + ["[0]" pipe] + ["[0]" maybe] + ["[0]" try (.only Try)] + ["[0]" exception (.only exception)] + ["[0]" io (.only IO io)] + [concurrency + ["[0]" promise (.only Promise)]]] + [data + ["[0]" text (.use "[1]#[0]" hash) + ["%" \\format (.only format)] + [encoding + ["[0]" utf8]]] + [collection + ["[0]" array (.only Array)]]] + [macro + ["[0]" template]] + [math + [number (.only hex) + ["n" nat] + ["[0]" i64]]] + ["[0]" world + ["[0]" file] + ["[1]/[0]" program]] + ["@" target + ["_" php]] + [meta + [compiler + [phase (.only Operation Phase)] + [reference + [variable (.only Register)]] + [language + [lux + [program (.only Program)] + [generation (.only Context Host)] + ["[0]" synthesis] + [analysis + [macro (.only Expander)]] + [phase + ["[0]" extension (.only Extender Handler) + ["[1]/[0]" bundle] + ["[0]" analysis + ["[1]" php]] + ["[0]" generation + ["[1]" php]]] + [generation + ["[0]" reference] + ["[0]" php + ["[0]" runtime]]]]]] + [default + ["[0]" platform (.only Platform)]] + [meta + ["[0]" packager + ["[1]" script]]]]]]] [program ["/" compositor ["[1][0]" cli] @@ -189,34 +190,34 @@ (-> (-> (Array java/lang/Object) php/runtime/Memory) java/lang/Object php/runtime/Memory) (<| (if (ffi.null? value) (php/runtime/memory/NullMemory::INSTANCE)) - (case (ffi.as java/lang/Boolean value) + (when (ffi.as java/lang/Boolean value) {.#Some value} (if (as Bit value) (php/runtime/memory/TrueMemory::INSTANCE) (php/runtime/memory/FalseMemory::INSTANCE)) {.#None}) - (case (ffi.as java/lang/Long value) + (when (ffi.as java/lang/Long value) {.#Some value} (php/runtime/memory/LongMemory::new value) {.#None}) - (case (ffi.as java/lang/Double value) + (when (ffi.as java/lang/Double value) {.#Some value} (php/runtime/memory/DoubleMemory::new value) {.#None}) - (case (ffi.as java/lang/String value) + (when (ffi.as java/lang/String value) {.#Some value} (php/runtime/memory/StringMemory::new value) {.#None}) - (case (ffi.as [java/lang/Object] value) + (when (ffi.as [java/lang/Object] value) {.#Some value} (lux_structure (as (Array java/lang/Object) value)) {.#None}) - (case (ffi.as php/runtime/memory/ObjectMemory value) + (when (ffi.as php/runtime/memory/ObjectMemory value) {.#Some value} value @@ -247,7 +248,7 @@ index php/runtime/Memory]) php/runtime/Memory (`` (<| (,, (with_template [<class> <method> <extractor>] - [(case (ffi.as <class> index) + [(when (ffi.as <class> index) {.#Some index} (<method> trace (<extractor> index) self) @@ -278,7 +279,7 @@ [] (valueOfIndex self [trace php/runtime/env/TraceInfo index java/lang/String]) php/runtime/Memory - (case (as Text index) + (when (as Text index) runtime.variant_tag_field (|> value (array.read! 0) @@ -287,7 +288,7 @@ php/runtime/memory/LongMemory::valueOf) runtime.variant_flag_field - (case (array.read! 1 value) + (when (array.read! 1 value) {.#None} (php/runtime/memory/NullMemory::INSTANCE) @@ -321,12 +322,12 @@ maybe.trusted (as php/runtime/memory/ReferenceMemory) php/runtime/memory/ReferenceMemory::getValue)] - (case (ffi.as php/runtime/memory/NullMemory value) + (when (ffi.as php/runtime/memory/NullMemory value) {.#Some _} (again (++ idx) output) {.#None} - (case (read value) + (when (read value) {try.#Success lux_value} (again (++ idx) (array.write! idx lux_value output)) @@ -345,7 +346,7 @@ (def (read_variant read host_object) (-> Reader php/runtime/memory/ArrayMemory (Try Any)) - (case [(|> host_object + (when [(|> host_object (php/runtime/memory/ArrayMemory::get ..variant_tag_field) maybe.trusted read) @@ -356,7 +357,7 @@ [{try.#Success tag} {try.#Success value}] {try.#Success [(java/lang/Long::intValue (as java/lang/Long tag)) (is Any - (case (|> host_object + (when (|> host_object (php/runtime/memory/ArrayMemory::get ..variant_flag_field) maybe.trusted (as php/runtime/memory/ReferenceMemory) @@ -380,7 +381,7 @@ (def (read host_object) Reader (`` (<| (,, (with_template [<class> <constant>] - [(case (ffi.as <class> host_object) + [(when (ffi.as <class> host_object) {.#Some _} {try.#Success <constant>} @@ -390,7 +391,7 @@ [php/runtime/memory/TrueMemory true] )) (,, (with_template [<class> <post>] - [(case (ffi.as <class> host_object) + [(when (ffi.as <class> host_object) {.#Some value} (`` (|> value (,, (template.splice <post>)))) @@ -403,11 +404,11 @@ [php/runtime/memory/ReferenceMemory [php/runtime/memory/ReferenceMemory::getValue read]] [php/runtime/memory/ObjectMemory [{try.#Success}]] )) - (case (ffi.as php/runtime/memory/ArrayMemory host_object) + (when (ffi.as php/runtime/memory/ArrayMemory host_object) {.#Some value} (if (|> value (php/runtime/memory/ArrayMemory::get ..tuple_size_field) - (pipe.case {.#Some _} false {.#None} true)) + (pipe.when {.#Some _} false {.#None} true)) (read_variant read value) (read_tuple read value)) @@ -461,7 +462,7 @@ (def (expander macro inputs lux) Expander - (case (ensure_macro macro) + (when (ensure_macro macro) {.#Some macro} (call_macro inputs lux macro) |