diff options
author | Eduardo Julian | 2022-08-11 04:15:07 -0400 |
---|---|---|
committer | Eduardo Julian | 2022-08-11 04:15:07 -0400 |
commit | 065e8a4d8122d4616b570496915d2c0e2c78cd6b (patch) | |
tree | f2bbdc3e40b796b34026ab04c9a478d8a3f082d5 /lux-js/source/program.lux | |
parent | 68d78235694c633c956bb9e8a007cad7d65370bc (diff) |
Re-named the "case" macro to "when".
Diffstat (limited to '')
-rw-r--r-- | lux-js/source/program.lux | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/lux-js/source/program.lux b/lux-js/source/program.lux index b7053d6e9..233db1518 100644 --- a/lux-js/source/program.lux +++ b/lux-js/source/program.lux @@ -71,7 +71,7 @@ ["/" compositor]]) (exception (null_has_no_lux_representation [code (Maybe _.Expression)]) - (case code + (when code {.#Some code} (_.code code) @@ -176,7 +176,7 @@ (ffi.is java/lang/Object (ffi.as_long value))) (org/openjdk/nashorn/api/scripting/AbstractJSObject [] (getMember self [member java/lang/String]) java/lang/Object - (case (ffi.of_string member) + (when (ffi.of_string member) runtime.i64_high_field (|> value .nat @@ -242,14 +242,14 @@ (-> (Array java/lang/Object) org/openjdk/nashorn/api/scripting/JSObject) (let [js_object (is (-> java/lang/Object org/openjdk/nashorn/api/scripting/JSObject) (function (_ sub_value) - (<| (case (ffi.as [java/lang/Object] sub_value) + (<| (when (ffi.as [java/lang/Object] sub_value) {.#Some sub_value} (|> sub_value (as (Array java/lang/Object)) js_structure) {.#None}) - (case (ffi.as java/lang/Long sub_value) + (when (ffi.as java/lang/Long sub_value) {.#Some sub_value} (|> sub_value ffi.of_long @@ -273,7 +273,7 @@ (org/openjdk/nashorn/api/scripting/AbstractJSObject [] (getMember self [member java/lang/String]) java/lang/Object - (case (ffi.of_string member) + (when (ffi.of_string member) (^.or "toJSON" "toString") (|> (::toString value) (ffi.is java/lang/Object)) @@ -294,7 +294,7 @@ maybe.trusted) runtime.variant_flag_field - (case (array.item 1 value) + (when (array.item 1 value) {.#Some set!} set! @@ -326,7 +326,7 @@ (exception.report (list ["Class" (ffi.of_string (java/lang/Object::toString (java/lang/Object::getClass object)))] ["Object" (ffi.of_string (java/lang/Object::toString object))] - ["Keys" (case (ffi.as org/openjdk/nashorn/api/scripting/ScriptObjectMirror object) + ["Keys" (when (ffi.as org/openjdk/nashorn/api/scripting/ScriptObjectMirror object) {.#Some object} (|> object (org/openjdk/nashorn/api/scripting/ScriptObjectMirror::getOwnKeys true) @@ -347,7 +347,7 @@ (def (check_int js_object) (-> org/openjdk/nashorn/api/scripting/ScriptObjectMirror (Maybe Int)) - (case [(..i32 runtime.i64_high_field js_object) + (when [(..i32 runtime.i64_high_field js_object) (..i32 runtime.i64_low_field js_object)] [{.#Some high} {.#Some low}] {.#Some (.int (n.+ (|> high .nat (i64.left_shifted 32)) @@ -362,7 +362,7 @@ (-> (-> java/lang/Object (Try Any)) org/openjdk/nashorn/api/scripting/ScriptObjectMirror (Maybe Any)) - (case [(org/openjdk/nashorn/api/scripting/JSObject::getMember [(ffi.as_string runtime.variant_tag_field)] js_object) + (when [(org/openjdk/nashorn/api/scripting/JSObject::getMember [(ffi.as_string runtime.variant_tag_field)] js_object) (org/openjdk/nashorn/api/scripting/JSObject::getMember [(ffi.as_string runtime.variant_flag_field)] js_object) (org/openjdk/nashorn/api/scripting/JSObject::getMember [(ffi.as_string runtime.variant_value_field)] js_object)] (^.multi [{.#Some tag} ?flag {.#Some value}] @@ -385,14 +385,14 @@ output (is (Array java/lang/Object) (array.empty num_keys))]) (if (n.< num_keys idx) - (case (org/openjdk/nashorn/api/scripting/JSObject::getMember (ffi.as_string (%.nat idx)) js_object) + (when (org/openjdk/nashorn/api/scripting/JSObject::getMember (ffi.as_string (%.nat idx)) js_object) {.#Some member} - (case (ffi.as org/openjdk/nashorn/internal/runtime/Undefined member) + (when (ffi.as org/openjdk/nashorn/internal/runtime/Undefined member) {.#Some _} (again (++ idx) output) {.#None} - (case (lux_object member) + (when (lux_object member) {try.#Success parsed_member} (again (++ idx) (array.has! idx (as java/lang/Object parsed_member) output)) @@ -408,13 +408,13 @@ (-> java/lang/Object (Try Any)) (`` (<| (if (ffi.null? js_object) (exception.except ..null_has_no_lux_representation [{.#None}])) - (case (ffi.as org/openjdk/nashorn/internal/runtime/Undefined js_object) + (when (ffi.as org/openjdk/nashorn/internal/runtime/Undefined js_object) {.#Some _} (exception.except ..undefined_has_no_lux_representation []) {.#None}) (,, (with_template [<class>] - [(case (ffi.as <class> js_object) + [(when (ffi.as <class> js_object) {.#Some js_object} {try.#Success js_object} @@ -422,7 +422,7 @@ [java/lang/Boolean] [java/lang/String])) (,, (with_template [<class> <method>] - [(case (ffi.as <class> js_object) + [(when (ffi.as <class> js_object) {.#Some js_object} {try.#Success (<method> js_object)} @@ -431,19 +431,19 @@ [java/lang/Number java/lang/Number::doubleValue] [StructureValue StructureValue::getValue] [IntValue IntValue::getValue])) - (case (ffi.as org/openjdk/nashorn/api/scripting/ScriptObjectMirror js_object) + (when (ffi.as org/openjdk/nashorn/api/scripting/ScriptObjectMirror js_object) {.#Some js_object} - (case (check_int js_object) + (when (check_int js_object) {.#Some value} {try.#Success value} {.#None} - (case (check_variant lux_object js_object) + (when (check_variant lux_object js_object) {.#Some value} {try.#Success value} {.#None} - (case (check_tuple lux_object js_object) + (when (check_tuple lux_object js_object) {.#Some value} {try.#Success value} @@ -492,9 +492,9 @@ (def (expander macro inputs lux) Expander - (case (..ensure_function macro) + (when (..ensure_function macro) {.#Some macro} - (case (call_macro inputs lux macro) + (when (call_macro inputs lux macro) {try.#Success output} (|> output (as java/lang/Object) @@ -519,7 +519,7 @@ (-> javax/script/ScriptEngine unit.ID _.Expression (Try Any)) (do try.monad [?output (javax/script/ScriptEngine::eval (ffi.as_string (_.code input)) interpreter)] - (case ?output + (when ?output {.#Some output} (..lux_object output) @@ -580,7 +580,7 @@ (-> unit.ID _.Expression (Try Any)) (do try.monad [?output (..eval (_.code input))] - (case ?output + (when ?output {.#Some output} (in output) |