diff options
author | Eduardo Julian | 2022-03-30 15:25:06 -0400 |
---|---|---|
committer | Eduardo Julian | 2022-03-30 15:25:06 -0400 |
commit | 9df5ff6abc6e95c766d1907c5a9fee00730e749a (patch) | |
tree | 8614095c2c2a3a5cd195f9e6da53f47c88891381 | |
parent | 8ebc505f1be8e103039d220b2d824dd687777f24 (diff) |
Re-named ffi.as to "is", and ffi.check to "as", to line the names up with normal type-annotation macros.
-rw-r--r-- | .github/workflows/setup_aedifex/action.yml (renamed from .github/workflows/setup_aedifex.yml) | 0 | ||||
-rw-r--r-- | .github/workflows/test.yml | 4 | ||||
-rw-r--r-- | lux-cl/source/program.lux | 10 | ||||
-rw-r--r-- | lux-js/source/program.lux | 52 | ||||
-rw-r--r-- | lux-lua/source/program.lux | 22 | ||||
-rw-r--r-- | lux-php/source/program.lux | 26 | ||||
-rw-r--r-- | lux-python/source/program.lux | 20 | ||||
-rw-r--r-- | lux-r/source/program.lux | 14 | ||||
-rw-r--r-- | lux-ruby/source/program.lux | 82 | ||||
-rw-r--r-- | lux-scheme/source/program.lux | 18 | ||||
-rw-r--r-- | stdlib/source/library/lux/debug.lux | 6 | ||||
-rw-r--r-- | stdlib/source/library/lux/ffi.jvm.lux | 350 | ||||
-rw-r--r-- | stdlib/source/library/lux/ffi.old.lux | 220 | ||||
-rw-r--r-- | stdlib/source/library/lux/target/jvm/reflection.lux | 22 | ||||
-rw-r--r-- | stdlib/source/test/lux/ffi.jvm.lux | 16 | ||||
-rw-r--r-- | stdlib/source/test/lux/ffi.old.lux | 10 |
16 files changed, 436 insertions, 436 deletions
diff --git a/.github/workflows/setup_aedifex.yml b/.github/workflows/setup_aedifex/action.yml index 5afa83812..5afa83812 100644 --- a/.github/workflows/setup_aedifex.yml +++ b/.github/workflows/setup_aedifex/action.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index dfdeff165..6bd9c1012 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,23 +4,23 @@ jobs: test_stdlib_on_jvm: runs-on: ubuntu-latest steps: + - uses: actions/checkout@v2 - uses: ./.github/workflows/setup_aedifex # https://github.com/actions/setup-java - uses: actions/setup-java@v2 with: distribution: 'temurin' java-version: '17' - - uses: actions/checkout@v2 - run: cd ./stdlib/ && ../lux.sh with jvm with bibliotheca test test_stdlib_on_node_js: runs-on: ubuntu-latest steps: + - uses: actions/checkout@v2 - uses: ./.github/workflows/setup_aedifex # https://github.com/actions/setup-node - uses: actions/setup-node@v2 with: node-version: '14' - - uses: actions/checkout@v2 - run: cd ./stdlib/ && ../lux.sh with js with bibliotheca test # test_stdlib: # runs-on: ubuntu-latest diff --git a/lux-cl/source/program.lux b/lux-cl/source/program.lux index 0a57c9350..67735f838 100644 --- a/lux-cl/source/program.lux +++ b/lux-cl/source/program.lux @@ -173,7 +173,7 @@ (function (_ sub_value) (let [sub_value (as java/lang/Object sub_value)] (`` (<| (~~ (template [<type> <then>] - [(case (ffi.check <type> sub_value) + [(case (ffi.is <type> sub_value) {.#Some sub_value} (`` (|> sub_value (~~ (template.splice <then>)))) @@ -229,7 +229,7 @@ [tag (read (org/armedbear/lisp/LispObject::NTH +0 host_object)) value (read (org/armedbear/lisp/LispObject::NTH +2 host_object))] (wrap [(java/lang/Long::intValue (as java/lang/Long tag)) - (case (ffi.check org/armedbear/lisp/Nil (org/armedbear/lisp/LispObject::NTH +1 host_object)) + (case (ffi.is org/armedbear/lisp/Nil (org/armedbear/lisp/LispObject::NTH +1 host_object)) {.#Some _} (is Any (ffi.null)) @@ -255,7 +255,7 @@ (def: (read host_object) (Reader org/armedbear/lisp/LispObject) (`` (<| (~~ (template [<class> <post_processing>] - [(case (ffi.check <class> host_object) + [(case (ffi.is <class> host_object) {.#Some host_object} (`` (|> host_object (~~ (template.splice <post_processing>)))) @@ -270,7 +270,7 @@ [org/armedbear/lisp/Nil [(pipe.new {try.#Success false} [])]] [org/armedbear/lisp/Closure [{try.#Success}]] [program/LuxADT [program/LuxADT::getValue {try.#Success}]])) - (case (ffi.check org/armedbear/lisp/Symbol host_object) + (case (ffi.is org/armedbear/lisp/Symbol host_object) {.#Some host_object} (if (same? (org/armedbear/lisp/Symbol::T) host_object) {try.#Success true} @@ -283,7 +283,7 @@ (def: ensure_macro (-> Macro (Maybe org/armedbear/lisp/Closure)) - (|>> (as java/lang/Object) (ffi.check org/armedbear/lisp/Closure))) + (|>> (as java/lang/Object) (ffi.is org/armedbear/lisp/Closure))) (def: (call_macro inputs lux macro) (-> (List Code) Lux org/armedbear/lisp/Closure (Try (Try [Lux (List Code)]))) diff --git a/lux-js/source/program.lux b/lux-js/source/program.lux index 9be0834a6..0156887b7 100644 --- a/lux-js/source/program.lux +++ b/lux-js/source/program.lux @@ -166,32 +166,32 @@ (def: (js_int value) (-> Int org/openjdk/nashorn/api/scripting/JSObject) - (<| (ffi.as org/openjdk/nashorn/api/scripting/JSObject) + (<| (ffi.is org/openjdk/nashorn/api/scripting/JSObject) (ffi.object [] org/openjdk/nashorn/api/scripting/AbstractJSObject [IntValue] [] ... Methods (IntValue [] (getValue self []) java/lang/Object - (ffi.as java/lang/Object (ffi.as_long value))) + (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) (pattern (static runtime.i64_high_field)) (|> value .nat runtime.high jvm_int - (ffi.as java/lang/Object)) + (ffi.is java/lang/Object)) (pattern (static runtime.i64_low_field)) (|> value .nat runtime.low jvm_int - (ffi.as java/lang/Object)) + (ffi.is java/lang/Object)) _ (panic! (exception.error ..unknown_member [(ffi.of_string member) - (ffi.as java/lang/Object (ffi.as_long value))])))) + (ffi.is java/lang/Object (ffi.as_long value))])))) ))) (def: (::toString js_object) (-> Any org/openjdk/nashorn/api/scripting/JSObject) - (<| (ffi.as org/openjdk/nashorn/api/scripting/JSObject) + (<| (ffi.is org/openjdk/nashorn/api/scripting/JSObject) (ffi.object [] org/openjdk/nashorn/api/scripting/AbstractJSObject [] [] (org/openjdk/nashorn/api/scripting/AbstractJSObject @@ -204,12 +204,12 @@ (|> js_object debug.inspection ffi.as_string - (ffi.as java/lang/Object))) + (ffi.is java/lang/Object))) ))) (def: (::slice js_object value) (-> (-> java/lang/Object org/openjdk/nashorn/api/scripting/JSObject) (Array java/lang/Object) org/openjdk/nashorn/api/scripting/JSObject) - (<| (ffi.as org/openjdk/nashorn/api/scripting/JSObject) + (<| (ffi.is org/openjdk/nashorn/api/scripting/JSObject) (ffi.object [] org/openjdk/nashorn/api/scripting/AbstractJSObject [] [] (org/openjdk/nashorn/api/scripting/AbstractJSObject @@ -228,32 +228,32 @@ (ffi.as_int (.int (array.size value)))) (as java/lang/Object) js_object - (ffi.as java/lang/Object))) + (ffi.is java/lang/Object))) ))) (def: (js_structure value) (-> (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.check [java/lang/Object] sub_value) + (<| (case (ffi.is [java/lang/Object] sub_value) {.#Some sub_value} (|> sub_value (as (Array java/lang/Object)) js_structure) {.#None}) - (case (ffi.check java/lang/Long sub_value) + (case (ffi.is java/lang/Long sub_value) {.#Some sub_value} (|> sub_value ffi.of_long js_int) {.#None}) ... else (as org/openjdk/nashorn/api/scripting/JSObject sub_value))))] - (<| (ffi.as org/openjdk/nashorn/api/scripting/JSObject) + (<| (ffi.is org/openjdk/nashorn/api/scripting/JSObject) (ffi.object [] org/openjdk/nashorn/api/scripting/AbstractJSObject [StructureValue] [] ... Methods (StructureValue [] (getValue self []) java/lang/Object - (ffi.as java/lang/Object value)) + (ffi.is java/lang/Object value)) (org/openjdk/nashorn/api/scripting/AbstractJSObject [] (isArray self []) boolean (ffi.as_boolean #1)) @@ -263,17 +263,17 @@ (case (ffi.of_string member) (^.or "toJSON" "toString") (|> (::toString value) - (ffi.as java/lang/Object)) + (ffi.is java/lang/Object)) "length" (|> value array.size jvm_int - (ffi.as java/lang/Object)) + (ffi.is java/lang/Object)) "slice" (|> (::slice js_object value) - (ffi.as java/lang/Object)) + (ffi.is java/lang/Object)) (pattern (static runtime.variant_tag_field)) (|> value @@ -293,7 +293,7 @@ (array.read! 2) maybe.trusted js_object - (ffi.as java/lang/Object)) + (ffi.is java/lang/Object)) _ (panic! (exception.error ..unknown_member [(as Text member) (as java/lang/Object value)]))) @@ -313,7 +313,7 @@ (exception.report "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.check org/openjdk/nashorn/api/scripting/ScriptObjectMirror object) + "Keys" (case (ffi.is org/openjdk/nashorn/api/scripting/ScriptObjectMirror object) {.#Some object} (|> object (org/openjdk/nashorn/api/scripting/ScriptObjectMirror::getOwnKeys true) @@ -327,7 +327,7 @@ (-> Text org/openjdk/nashorn/api/scripting/ScriptObjectMirror (Maybe Int)) (|> i64 (org/openjdk/nashorn/api/scripting/JSObject::getMember [(ffi.as_string half)]) - (maybe#each (|>> (ffi.check java/lang/Number))) + (maybe#each (|>> (ffi.is java/lang/Number))) maybe#conjoint (maybe#each (|>> java/lang/Number::longValue ffi.of_long)))) @@ -353,7 +353,7 @@ (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}] - [[(ffi.check java/lang/Number tag) (lux_object value)] + [[(ffi.is java/lang/Number tag) (lux_object value)] [{.#Some tag} {try.#Success value}]]) {.#Some [(java/lang/Number::intValue (as java/lang/Number tag)) (maybe.else (ffi.null) ?flag) @@ -374,7 +374,7 @@ (if (n.< num_keys idx) (case (org/openjdk/nashorn/api/scripting/JSObject::getMember (ffi.as_string (%.nat idx)) js_object) {.#Some member} - (case (ffi.check org/openjdk/nashorn/internal/runtime/Undefined member) + (case (ffi.is org/openjdk/nashorn/internal/runtime/Undefined member) {.#Some _} (again (++ idx) output) @@ -395,13 +395,13 @@ (-> java/lang/Object (Try Any)) (`` (<| (if (ffi.null? js_object) (exception.except ..null_has_no_lux_representation [{.#None}])) - (case (ffi.check org/openjdk/nashorn/internal/runtime/Undefined js_object) + (case (ffi.is org/openjdk/nashorn/internal/runtime/Undefined js_object) {.#Some _} (exception.except ..undefined_has_no_lux_representation []) {.#None}) (~~ (template [<class>] - [(case (ffi.check <class> js_object) + [(case (ffi.is <class> js_object) {.#Some js_object} {try.#Success js_object} @@ -409,7 +409,7 @@ [java/lang/Boolean] [java/lang/String])) (~~ (template [<class> <method>] - [(case (ffi.check <class> js_object) + [(case (ffi.is <class> js_object) {.#Some js_object} {try.#Success (<method> js_object)} @@ -418,7 +418,7 @@ [java/lang/Number java/lang/Number::doubleValue] [StructureValue StructureValue::getValue] [IntValue IntValue::getValue])) - (case (ffi.check org/openjdk/nashorn/api/scripting/ScriptObjectMirror js_object) + (case (ffi.is org/openjdk/nashorn/api/scripting/ScriptObjectMirror js_object) {.#Some js_object} (case (check_int js_object) {.#Some value} @@ -451,7 +451,7 @@ (do maybe.monad [function (|> function (as java/lang/Object) - (ffi.check org/openjdk/nashorn/api/scripting/JSObject))] + (ffi.is org/openjdk/nashorn/api/scripting/JSObject))] (if (ffi.of_boolean (org/openjdk/nashorn/api/scripting/JSObject::isFunction function)) {.#Some function} {.#None}))) diff --git a/lux-lua/source/program.lux b/lux-lua/source/program.lux index c3acbb560..983f35ee0 100644 --- a/lux-lua/source/program.lux +++ b/lux-lua/source/program.lux @@ -231,7 +231,7 @@ (`` (<| (if (ffi.null? host_object) (exception.except ..nil_has_no_lux_representation [])) (~~ (template [<class> <post_processing>] - [(case (ffi.check <class> host_object) + [(case (ffi.as <class> host_object) {.#Some typed_object} (|> typed_object <post_processing>) @@ -245,7 +245,7 @@ [net/sandius/rembulan/ByteString (<| {try.#Success} net/sandius/rembulan/ByteString::decode)] [net/sandius/rembulan/runtime/LuaFunction {try.#Success}] )) - (case (ffi.check net/sandius/rembulan/impl/DefaultTable host_object) + (case (ffi.as net/sandius/rembulan/impl/DefaultTable host_object) {.#Some typed_object} (case (read_variant read typed_object) {try.#Failure error} @@ -344,7 +344,7 @@ "throws" [net/sandius/rembulan/runtime/ResolvedControlThrowable] (<| (..return %) (apply/* to_host - (ffi.as net/sandius/rembulan/runtime/LuaFunction self) + (ffi.is 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.is net/sandius/rembulan/runtime/LuaFunction self) (array.list {.#None} input/*) lux_function))) ))))) @@ -372,7 +372,7 @@ (def: (lux_structure to_host value) (-> (-> Any java/lang/Object) (Array java/lang/Object) LuxValue) - (<| (ffi.as LuxValue) + (<| (ffi.is LuxValue) (ffi.object [] net/sandius/rembulan/impl/DefaultTable [LuxValue] [] ... Methods @@ -394,7 +394,7 @@ (net/sandius/rembulan/impl/DefaultTable [] (rawget self [field java/lang/Object]) java/lang/Object - (case (ffi.check net/sandius/rembulan/ByteString field) + (case (ffi.as net/sandius/rembulan/ByteString field) {.#Some field} (case (ffi.of_string (net/sandius/rembulan/ByteString::decode field)) (pattern (static runtime.variant_tag_field)) @@ -402,7 +402,7 @@ {.#Some it} (|> it (as java/lang/Integer) - (ffi.as java/lang/Object)) + (ffi.is java/lang/Object)) {.#None} (undefined)) @@ -426,13 +426,13 @@ array.size .int ffi.as_long - (ffi.as java/lang/Object)) + (ffi.is java/lang/Object)) _ (panic! (exception.error ..unknown_kind_of_object [(as java/lang/Object field)]))) {.#None} - (case (ffi.check java/lang/Long field) + (case (ffi.as java/lang/Long field) {.#Some idx} (case (array.read! (|> idx ffi.of_long .nat --) value) {.#Some it} @@ -452,7 +452,7 @@ (def: ensure_function (-> Macro (Maybe net/sandius/rembulan/runtime/LuaFunction)) (|>> (as java/lang/Object) - (ffi.check net/sandius/rembulan/runtime/LuaFunction))) + (ffi.as net/sandius/rembulan/runtime/LuaFunction))) (type: Baggage [net/sandius/rembulan/StateContext @@ -785,7 +785,7 @@ (with_expansions [<jvm> (these (def: (to_host it) (-> Any java/lang/Object) (`` (<| (~~ (template [<jvm> <lua>] - [(case (ffi.check <jvm> (as java/lang/Object it)) + [(case (ffi.as <jvm> (as java/lang/Object it)) {.#Some it} (as java/lang/Object (<lua> [(as_expected it)])) diff --git a/lux-php/source/program.lux b/lux-php/source/program.lux index 08bad8d41..b12d19917 100644 --- a/lux-php/source/program.lux +++ b/lux-php/source/program.lux @@ -189,34 +189,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.check java/lang/Boolean value) + (case (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.check java/lang/Long value) + (case (ffi.as java/lang/Long value) {.#Some value} (php/runtime/memory/LongMemory::new value) {.#None}) - (case (ffi.check java/lang/Double value) + (case (ffi.as java/lang/Double value) {.#Some value} (php/runtime/memory/DoubleMemory::new value) {.#None}) - (case (ffi.check java/lang/String value) + (case (ffi.as java/lang/String value) {.#Some value} (php/runtime/memory/StringMemory::new value) {.#None}) - (case (ffi.check [java/lang/Object] value) + (case (ffi.as [java/lang/Object] value) {.#Some value} (lux_structure (as (Array java/lang/Object) value)) {.#None}) - (case (ffi.check php/runtime/memory/ObjectMemory value) + (case (ffi.as php/runtime/memory/ObjectMemory value) {.#Some value} value @@ -247,7 +247,7 @@ index php/runtime/Memory]) php/runtime/Memory (`` (<| (~~ (template [<class> <method> <extractor>] - [(case (ffi.check <class> index) + [(case (ffi.as <class> index) {.#Some index} (<method> trace (<extractor> index) self) @@ -321,7 +321,7 @@ maybe.trusted (as php/runtime/memory/ReferenceMemory) php/runtime/memory/ReferenceMemory::getValue)] - (case (ffi.check php/runtime/memory/NullMemory value) + (case (ffi.as php/runtime/memory/NullMemory value) {.#Some _} (again (++ idx) output) @@ -361,7 +361,7 @@ maybe.trusted (as php/runtime/memory/ReferenceMemory) php/runtime/memory/ReferenceMemory::getValue - (ffi.check php/runtime/memory/NullMemory)) + (ffi.as php/runtime/memory/NullMemory)) {.#Some _} (ffi.null) @@ -380,7 +380,7 @@ (def: (read host_object) Reader (`` (<| (~~ (template [<class> <constant>] - [(case (ffi.check <class> host_object) + [(case (ffi.as <class> host_object) {.#Some _} {try.#Success <constant>} @@ -390,7 +390,7 @@ [php/runtime/memory/TrueMemory true] )) (~~ (template [<class> <post>] - [(case (ffi.check <class> host_object) + [(case (ffi.as <class> host_object) {.#Some value} (`` (|> value (~~ (template.splice <post>)))) @@ -403,7 +403,7 @@ [php/runtime/memory/ReferenceMemory [php/runtime/memory/ReferenceMemory::getValue read]] [php/runtime/memory/ObjectMemory [{try.#Success}]] )) - (case (ffi.check php/runtime/memory/ArrayMemory host_object) + (case (ffi.as php/runtime/memory/ArrayMemory host_object) {.#Some value} (if (|> value (php/runtime/memory/ArrayMemory::get ..tuple_size_field) @@ -432,7 +432,7 @@ (-> Macro (Maybe php/runtime/memory/ObjectMemory)) (|> macro (as java/lang/Object) - (ffi.check php/runtime/memory/ObjectMemory))) + (ffi.as php/runtime/memory/ObjectMemory))) (def: interpreter (org/develnext/jphp/scripting/JPHPScriptEngine::new)) diff --git a/lux-python/source/program.lux b/lux-python/source/program.lux index 6f145bbbd..25a2131c5 100644 --- a/lux-python/source/program.lux +++ b/lux-python/source/program.lux @@ -187,8 +187,8 @@ {try.#Success value}]) {try.#Success [tag (is Any - (case (ffi.check org/python/core/PyNone - (as java/lang/Object flag)) + (case (ffi.as org/python/core/PyNone + (as java/lang/Object flag)) {.#Some _} (as Any (ffi.null)) @@ -209,7 +209,7 @@ (def: (read host_object) Translator (`` (<| (~~ (template [<class> <processing>] - [(case (ffi.check <class> (as <class> host_object)) + [(case (ffi.as <class> (as <class> host_object)) {.#Some host_object} {try.#Success (`` (|> host_object (~~ (template.spliced <processing>))))} @@ -218,8 +218,8 @@ [LuxValue [LuxValue::value]] [org/python/core/PyNone [(pipe.new [] [])]] [org/python/core/PyBoolean [org/python/core/PyObject::__nonzero__]] - ... [org/python/core/PyInteger [(ffi.as org/python/core/PyObject) org/python/core/PyObject::asInt]] - [org/python/core/PyInteger [(ffi.as org/python/core/PyObject) + ... [org/python/core/PyInteger [(ffi.is org/python/core/PyObject) org/python/core/PyObject::asInt]] + [org/python/core/PyInteger [(ffi.is org/python/core/PyObject) ("jvm member invoke virtual" [] "org.python.core.PyObject" "asInt" []) "jvm object cast" (is (Primitive "java.lang.Integer"))]] @@ -231,7 +231,7 @@ [[java/lang/Object] [(|>)]] )) (~~ (template [<class> <processing>] - [(case (ffi.check <class> host_object) + [(case (ffi.as <class> host_object) {.#Some host_object} (<| <processing> (as org/python/core/PyObject) host_object) @@ -319,12 +319,12 @@ (::super! [index']) {.#Some it} - (<| (case (ffi.check [java/lang/Object] (as java/lang/Object it)) + (<| (case (ffi.as [java/lang/Object] (as java/lang/Object it)) {.#Some it} (to_host it) {.#None}) - (case (ffi.check library/lux/Function (as java/lang/Object it)) + (case (ffi.as library/lux/Function (as java/lang/Object it)) {.#Some it} (pseudo_function to_host it) @@ -335,7 +335,7 @@ (def: (to_host it) (-> Any org/python/core/PyObject) (`` (<| (~~ (template [<jvm> <python>] - [(case (ffi.check <jvm> (as java/lang/Object it)) + [(case (ffi.as <jvm> (as java/lang/Object it)) {.#Some it} (as org/python/core/PyObject (<python> [it])) @@ -368,7 +368,7 @@ (def: python_function! (-> Any (Maybe org/python/core/PyFunction)) (|>> (as java/lang/Object) - (ffi.check org/python/core/PyFunction))) + (ffi.as org/python/core/PyFunction))) (exception: (cannot_apply_a_non_function [object java/lang/Object]) (exception.report diff --git a/lux-r/source/program.lux b/lux-r/source/program.lux index 0dd304ee0..3fa4acc3c 100644 --- a/lux-r/source/program.lux +++ b/lux-r/source/program.lux @@ -195,7 +195,7 @@ ... (function (_ sub_value) ... (let [sub_value (as java/lang/Object sub_value)] ... (`` (<| (~~ (template [<type> <then>] - ... [(case (ffi.check <type> sub_value) + ... [(case (ffi.as <type> sub_value) ... {.#Some sub_value} ... (`` (|> sub_value (~~ (template.splice <then>)))) ... {.#None})] @@ -369,7 +369,7 @@ (wrap [(|> tag (as java/lang/Long) java/lang/Long::intValue) (case (|> host_object (org/renjin/sexp/ListVector::get_field runtime.variant_flag_field) - (ffi.check org/renjin/sexp/Null)) + (ffi.as org/renjin/sexp/Null)) {.#Some _} (is Any (ffi.null)) @@ -381,10 +381,10 @@ (Reader org/renjin/sexp/ListVector) (case [(|> host_object (org/renjin/sexp/ListVector::get_field runtime.i64_high_field) - (ffi.check org/renjin/sexp/IntArrayVector)) + (ffi.as org/renjin/sexp/IntArrayVector)) (|> host_object (org/renjin/sexp/ListVector::get_field runtime.i64_low_field) - (ffi.check org/renjin/sexp/IntArrayVector))] + (ffi.as org/renjin/sexp/IntArrayVector))] [{.#Some high} {.#Some low}] {try.#Success (runtime.lux_i64 (org/renjin/sexp/SEXP::asInt high) (org/renjin/sexp/SEXP::asInt low))} @@ -418,7 +418,7 @@ (Reader java/lang/Object) (exec ... ("lux io log" (exception.construct ..unknown_kind_of_object [host_object])) - (`` (<| (case (ffi.check org/renjin/sexp/ListVector host_object) + (`` (<| (case (ffi.as org/renjin/sexp/ListVector host_object) {.#Some host_object} (<| (case (..read_variant read host_object) {try.#Success output} @@ -434,7 +434,7 @@ {.#None}) (~~ (template [<class> <post_processing>] - [(case (ffi.check <class> host_object) + [(case (ffi.as <class> host_object) {.#Some host_object} (`` (|> host_object (~~ (template.splice <post_processing>)))) @@ -455,7 +455,7 @@ (def: ensure_macro (-> Macro (Maybe org/renjin/sexp/Closure)) - (|>> (as java/lang/Object) (ffi.check org/renjin/sexp/Closure))) + (|>> (as java/lang/Object) (ffi.as org/renjin/sexp/Closure))) (def: (call_macro interpreter inputs lux macro) (-> org/renjin/script/RenjinScriptEngine (List Code) Lux org/renjin/sexp/Closure (Try (Try [Lux (List Code)]))) diff --git a/lux-ruby/source/program.lux b/lux-ruby/source/program.lux index 6270cba1c..5b4da0caa 100644 --- a/lux-ruby/source/program.lux +++ b/lux-ruby/source/program.lux @@ -279,7 +279,7 @@ (is Any value)])) _ - (exception.except ..unknown_kind_of_object [(ffi.as java/lang/Object host_object)]))) + (exception.except ..unknown_kind_of_object [(ffi.is java/lang/Object host_object)]))) (exception: .public nil_has_no_lux_representation) @@ -288,7 +288,7 @@ (`` (<| (if (ffi.null? host_object) (exception.except ..nil_has_no_lux_representation [])) (~~ (template [<class> <post_processing>] - [(case (ffi.check <class> host_object) + [(case (ffi.as <class> host_object) {.#Some typed_object} (`` (|> typed_object (~~ (template.spliced <post_processing>)))) @@ -317,7 +317,7 @@ (def: lux_unit org/jruby/runtime/builtin/IRubyObject - (<| (ffi.as org/jruby/runtime/builtin/IRubyObject) + (<| (ffi.is org/jruby/runtime/builtin/IRubyObject) (org/jruby/RubyString::newInternalFromJavaExternal ..initial_ruby_runtime (ffi.as_string "")))) (def: (wrapped_lux_value useful_object_class lux_structure) @@ -328,11 +328,11 @@ (-> java/lang/Object org/jruby/runtime/builtin/IRubyObject)) (function (again value) (`` (<| (~~ (template [<when> <then>] - [(case (ffi.check <when> value) + [(case (ffi.as <when> value) {.#Some value} (|> value <then> - (ffi.as org/jruby/runtime/builtin/IRubyObject)) + (ffi.is org/jruby/runtime/builtin/IRubyObject)) {.#None})] @@ -344,10 +344,10 @@ [org/jruby/runtime/builtin/IRubyObject (<|)] )) ... (as org/jruby/runtime/builtin/IRubyObject value) - (<| (ffi.as org/jruby/runtime/builtin/IRubyObject) + (<| (ffi.is org/jruby/runtime/builtin/IRubyObject) (org/jruby/java/proxies/JavaProxy::new ..initial_ruby_runtime (useful_object_class again (as (Array java/lang/Object) value)) - (ffi.as java/lang/Object value))))))) + (ffi.is java/lang/Object value))))))) (exception: (invalid_variant_access [field Text]) (exception.report @@ -377,7 +377,7 @@ org/jruby/RubyClass) (-> (Array java/lang/Object) org/jruby/runtime/builtin/IRubyObject) (-> (Array java/lang/Object) org/jruby/internal/runtime/methods/DynamicMethod)) - (<| (ffi.as org/jruby/internal/runtime/methods/DynamicMethod) + (<| (ffi.is org/jruby/internal/runtime/methods/DynamicMethod) (ffi.object [] org/jruby/internal/runtime/methods/DynamicMethod [] [java/lang/String (ffi.as_string "call")] @@ -401,7 +401,7 @@ list.indices (list#each (function (_ index) (ffi.read! index args))) - (monad.each ! (|>> (ffi.as java/lang/Object) ..read))) + (monad.each ! (|>> (ffi.is java/lang/Object) ..read))) output (case args (pattern (list arg/0)) (in ((as (-> Any java/lang/Object) value) @@ -445,7 +445,7 @@ org/jruby/RubyClass) (-> (Array java/lang/Object) org/jruby/runtime/builtin/IRubyObject) (-> (Array java/lang/Object) org/jruby/internal/runtime/methods/DynamicMethod)) - (<| (ffi.as org/jruby/internal/runtime/methods/DynamicMethod) + (<| (ffi.is org/jruby/internal/runtime/methods/DynamicMethod) (ffi.object [] org/jruby/internal/runtime/methods/DynamicMethod [] [java/lang/String (ffi.as_string "[]")] @@ -463,7 +463,7 @@ block org/jruby/runtime/Block]) org/jruby/runtime/builtin/IRubyObject (let [member (ffi.read! 0 args)] - (<| (case (ffi.check org/jruby/RubyFixnum member) + (<| (case (ffi.as org/jruby/RubyFixnum member) {.#Some member} (case (array.read! (.nat (ffi.of_long (org/jruby/RubyFixnum::getLongValue member))) value) {.#Some value} @@ -473,7 +473,7 @@ ..ruby_nil) {.#None}) - (case (ffi.check org/jruby/RubyString member) + (case (ffi.as org/jruby/RubyString member) {.#Some member} (case (ffi.of_string (org/jruby/RubyString::asJavaString member)) (pattern (static runtime.variant_tag_field)) @@ -483,7 +483,7 @@ (as java/lang/Integer) java/lang/Integer::longValue (org/jruby/RubyFixnum::new ..initial_ruby_runtime) - (ffi.as org/jruby/runtime/builtin/IRubyObject)) + (ffi.is org/jruby/runtime/builtin/IRubyObject)) (pattern (static runtime.variant_flag_field)) (case (array.read! 1 value) @@ -505,24 +505,24 @@ (panic! (exception.error ..invalid_variant_access [field]))) {.#None}) - (case (ffi.check org/jruby/RubyRange member) + (case (ffi.as org/jruby/RubyRange member) {.#Some member} - (case [(|> member (org/jruby/RubyRange::first thread_context) (ffi.check org/jruby/RubyFixnum)) - (|> member (org/jruby/RubyRange::size thread_context) (ffi.check org/jruby/RubyFixnum))] + (case [(|> member (org/jruby/RubyRange::first thread_context) (ffi.as org/jruby/RubyFixnum)) + (|> member (org/jruby/RubyRange::size thread_context) (ffi.as org/jruby/RubyFixnum))] [{.#Some first} {.#Some size}] (let [first (ffi.of_long (org/jruby/RubyFixnum::getLongValue first)) size (ffi.of_long (org/jruby/RubyFixnum::getLongValue size))] (lux_structure (java/util/Arrays::copyOfRange value (ffi.as_int first) (ffi.as_int (i.+ first size))))) _ - (panic! (exception.error ..invalid_index [(ffi.as java/lang/Object member)]))) + (panic! (exception.error ..invalid_index [(ffi.is java/lang/Object member)]))) {.#None}) - (panic! (exception.error ..invalid_index [(ffi.as java/lang/Object member)])))))))) + (panic! (exception.error ..invalid_index [(ffi.is java/lang/Object member)])))))))) (def: (::= value) (-> (Array java/lang/Object) org/jruby/internal/runtime/methods/DynamicMethod) - (<| (ffi.as org/jruby/internal/runtime/methods/DynamicMethod) + (<| (ffi.is org/jruby/internal/runtime/methods/DynamicMethod) (ffi.object [] org/jruby/internal/runtime/methods/DynamicMethod [] [java/lang/String (ffi.as_string "==")] @@ -539,12 +539,12 @@ args [org/jruby/runtime/builtin/IRubyObject] block org/jruby/runtime/Block]) org/jruby/runtime/builtin/IRubyObject - (<| (ffi.as org/jruby/runtime/builtin/IRubyObject) + (<| (ffi.is org/jruby/runtime/builtin/IRubyObject) (org/jruby/RubyBoolean::newBoolean ..initial_ruby_runtime) ffi.as_boolean (case (|> args (ffi.read! 0) - (ffi.as java/lang/Object) + (ffi.is java/lang/Object) ..read) {try.#Success reference} (same? (is Any reference) (is Any value)) @@ -554,7 +554,7 @@ (def: (::length value) (-> (Array java/lang/Object) org/jruby/internal/runtime/methods/DynamicMethod) - (<| (ffi.as org/jruby/internal/runtime/methods/DynamicMethod) + (<| (ffi.is org/jruby/internal/runtime/methods/DynamicMethod) (ffi.object [] org/jruby/internal/runtime/methods/DynamicMethod [] [java/lang/String (ffi.as_string "length")] @@ -576,11 +576,11 @@ .int ffi.as_long (org/jruby/RubyFixnum::new ..initial_ruby_runtime) - (ffi.as org/jruby/runtime/builtin/IRubyObject)))))) + (ffi.is org/jruby/runtime/builtin/IRubyObject)))))) (def: (::to_s value) (-> (Array java/lang/Object) org/jruby/internal/runtime/methods/DynamicMethod) - (<| (ffi.as org/jruby/internal/runtime/methods/DynamicMethod) + (<| (ffi.is org/jruby/internal/runtime/methods/DynamicMethod) (ffi.object [] org/jruby/internal/runtime/methods/DynamicMethod [] [java/lang/String (ffi.as_string "to_s")] @@ -601,7 +601,7 @@ debug.inspection ffi.as_string (org/jruby/RubyString::newInternalFromJavaExternal ..initial_ruby_runtime) - (ffi.as org/jruby/runtime/builtin/IRubyObject)))))) + (ffi.is org/jruby/runtime/builtin/IRubyObject)))))) (exception: (invalid_operation [method Text]) (exception.report @@ -609,7 +609,7 @@ (def: (::respond_to? value) (-> (Array java/lang/Object) org/jruby/internal/runtime/methods/DynamicMethod) - (<| (ffi.as org/jruby/internal/runtime/methods/DynamicMethod) + (<| (ffi.is org/jruby/internal/runtime/methods/DynamicMethod) (ffi.object [] org/jruby/internal/runtime/methods/DynamicMethod [] [java/lang/String (ffi.as_string "respond_to?")] @@ -628,7 +628,7 @@ org/jruby/runtime/builtin/IRubyObject (case (|> args (ffi.read! 0) - (ffi.check org/jruby/RubySymbol)) + (ffi.as org/jruby/RubySymbol)) {.#Some method} (|> (case (|> method org/jruby/RubySymbol::asJavaString @@ -644,7 +644,7 @@ false) ffi.as_boolean (org/jruby/RubyBoolean::newBoolean ..initial_ruby_runtime) - (ffi.as org/jruby/runtime/builtin/IRubyObject)) + (ffi.is org/jruby/runtime/builtin/IRubyObject)) {.#None} (panic! (exception.error ..invalid_operation ["respond_to?"]))))))) @@ -657,7 +657,7 @@ (-> (-> (Array java/lang/Object) org/jruby/runtime/builtin/IRubyObject) (Array java/lang/Object) org/jruby/RubyClass) - (<| (ffi.as org/jruby/RubyClass) + (<| (ffi.is org/jruby/RubyClass) (ffi.object [] org/jruby/RubyClass [] [org/jruby/Ruby ..initial_ruby_runtime] @@ -688,10 +688,10 @@ (def: (lux_structure value) (-> (Array java/lang/Object) org/jruby/runtime/builtin/IRubyObject) - (<| (ffi.as org/jruby/runtime/builtin/IRubyObject) + (<| (ffi.is org/jruby/runtime/builtin/IRubyObject) (org/jruby/java/proxies/JavaProxy::new ..initial_ruby_runtime (useful_object_class lux_structure value) - (ffi.as java/lang/Object value)))) + (ffi.is java/lang/Object value)))) (exception: (cannot_apply_a_non_function [object java/lang/Object]) (exception.report @@ -700,7 +700,7 @@ (def: macro! (-> Macro (Maybe org/jruby/RubyProc)) (|>> (as java/lang/Object) - (ffi.check org/jruby/RubyProc))) + (ffi.as org/jruby/RubyProc))) (def: to_host (-> Any org/jruby/runtime/builtin/IRubyObject) @@ -716,7 +716,7 @@ (ffi.write! 0 (..to_host inputs)) (ffi.write! 1 (..to_host lux))) macro)] - (..read (ffi.as java/lang/Object expansion))))) + (..read (ffi.is java/lang/Object expansion))))) (def: (expander macro inputs lux) Expander @@ -795,7 +795,7 @@ (def: phase_block_body org/jruby/runtime/BlockBody - (<| (ffi.as org/jruby/runtime/BlockBody) + (<| (ffi.is org/jruby/runtime/BlockBody) (ffi.object [] org/jruby/runtime/BlockBody [] [org/jruby/runtime/Signature ..phase_block_signature] ... Methods @@ -851,7 +851,7 @@ (do [! try.monad] [inputs (|> inputs (array.list {.#None}) - (monad.each ! (|>> (ffi.as java/lang/Object) ..read)))]) + (monad.each ! (|>> (ffi.is java/lang/Object) ..read)))]) (case inputs ... It seems that org/jruby/runtime/Block::call can misbehave when getting called with a Lux state value. (pattern (list info source location current_module modules scopes type_context expected seed scope_type_vars extensions eval host)) @@ -866,17 +866,17 @@ (exception.except ..invaid_phase_application [partial_application inputs])) (pattern (list)) - {try.#Success (<| (ffi.as org/jruby/runtime/builtin/IRubyObject) + {try.#Success (<| (ffi.is org/jruby/runtime/builtin/IRubyObject) (host_phase partial_application phase))} (pattern (list input/0)) (case partial_application (pattern (list)) - (in (<| (ffi.as org/jruby/runtime/builtin/IRubyObject) + (in (<| (ffi.is org/jruby/runtime/builtin/IRubyObject) (host_phase (list input/0) phase))) (pattern (list partial/0)) - (in (<| (ffi.as org/jruby/runtime/builtin/IRubyObject) + (in (<| (ffi.is org/jruby/runtime/builtin/IRubyObject) (host_phase (list partial/0 input/0) phase))) (pattern (list partial/0 partial/1)) @@ -891,7 +891,7 @@ (pattern (list input/0 input/1)) (case partial_application (pattern (list)) - (in (<| (ffi.as org/jruby/runtime/builtin/IRubyObject) + (in (<| (ffi.is org/jruby/runtime/builtin/IRubyObject) (host_phase (list input/0 input/1) phase))) (pattern (list partial/0)) @@ -936,14 +936,14 @@ [handler (try.of_maybe (..macro! handler)) output (org/jruby/RubyProc::call (!ruby_thread_context) (|> (ffi.array org/jruby/runtime/builtin/IRubyObject 5) - (ffi.write! 0 (<| (ffi.as org/jruby/runtime/builtin/IRubyObject) + (ffi.write! 0 (<| (ffi.is org/jruby/runtime/builtin/IRubyObject) (org/jruby/RubyString::newInternalFromJavaExternal (!ruby_runtime) (ffi.as_string name)))) (ffi.write! 1 (as org/jruby/runtime/builtin/IRubyObject (phase_wrapper phase))) (ffi.write! 2 (..to_host archive)) (ffi.write! 3 (..to_host parameters)) (ffi.write! 4 (..to_host state))) handler)] - (..read (ffi.as java/lang/Object output)))))) + (..read (ffi.is java/lang/Object output)))))) @.ruby (def: (extender phase_wrapper handler) diff --git a/lux-scheme/source/program.lux b/lux-scheme/source/program.lux index 78d96e962..7d116dfb6 100644 --- a/lux-scheme/source/program.lux +++ b/lux-scheme/source/program.lux @@ -139,14 +139,14 @@ (def: (variant? value) (-> Any Bit) - (case (ffi.check [java/lang/Object] (as java/lang/Object value)) + (case (ffi.as [java/lang/Object] (as java/lang/Object value)) {.#Some array} ... TODO: Get rid of this coercion ASAP. (let [array (as (Array java/lang/Object) array)] (and (n.= 3 (array.size array)) (case (array.read! 0 array) {.#Some tag} - (case (ffi.check java/lang/Integer tag) + (case (ffi.as java/lang/Integer tag) {.#Some _} true @@ -248,7 +248,7 @@ (def: (lux_value value) (-> java/lang/Object java/lang/Object) - (<| (case (ffi.check [java/lang/Object] value) + (<| (case (ffi.as [java/lang/Object] value) {.#Some value} ... TODO: Get rid of the coercions below. (if (variant? value) @@ -275,7 +275,7 @@ (do try.monad [tag (read (gnu/lists/Pair::getCar host_object)) #let [host_object (as gnu/lists/Pair (gnu/lists/Pair::getCdr host_object)) - flag (case (ffi.check java/lang/Boolean (gnu/lists/Pair::getCar host_object)) + flag (case (ffi.as java/lang/Boolean (gnu/lists/Pair::getCar host_object)) {.#Some flag} (as Bit flag) @@ -302,7 +302,7 @@ (def: (read host_object) (Reader java/lang/Object) (`` (<| (~~ (template [<class>] - [(case (ffi.check <class> host_object) + [(case (ffi.as <class> host_object) {.#Some host_object} {try.#Success host_object} @@ -312,7 +312,7 @@ [gnu/mapping/Procedure] [gnu/lists/U8Vector] )) (~~ (template [<class> <processing>] - [(case (ffi.check <class> host_object) + [(case (ffi.as <class> host_object) {.#Some host_object} {try.#Success (<| <processing> host_object)} @@ -329,12 +329,12 @@ [program/VariantValue program/VariantValue::getValue] [program/TupleValue program/TupleValue::getValue] )) - (case (ffi.check gnu/lists/Pair host_object) + (case (ffi.as gnu/lists/Pair host_object) {.#Some host_object} (read_variant read host_object) {.#None}) - (case (ffi.check gnu/lists/FVector host_object) + (case (ffi.as gnu/lists/FVector host_object) {.#Some host_object} (read_tuple read (as (gnu/lists/FVector java/lang/Object) host_object)) @@ -344,7 +344,7 @@ (def: ensure_macro (-> Macro (Maybe gnu/mapping/Procedure)) - (|>> (as java/lang/Object) (ffi.check gnu/mapping/Procedure))) + (|>> (as java/lang/Object) (ffi.as gnu/mapping/Procedure))) (def: (expander macro inputs lux) Expander diff --git a/stdlib/source/library/lux/debug.lux b/stdlib/source/library/lux/debug.lux index ddc343061..14399ccad 100644 --- a/stdlib/source/library/lux/debug.lux +++ b/stdlib/source/library/lux/debug.lux @@ -147,7 +147,7 @@ Inspector (with_expansions [<jvm> (let [object (as java/lang/Object value)] (`` (<| (~~ (template [<class> <processing>] - [(case (ffi.check <class> object) + [(case (ffi.as <class> object) {.#Some value} (`` (|> value (~~ (template.spliced <processing>)))) @@ -158,12 +158,12 @@ [java/lang/Number [java/lang/Number::doubleValue ffi.of_double %.frac]] [java/lang/String [ffi.of_string %.text]] )) - (case (ffi.check [java/lang/Object] object) + (case (ffi.as [java/lang/Object] object) {.#Some value} (let [value (as (array.Array java/lang/Object) value)] (case (array.read! 0 value) (^.multi {.#Some tag} - [(ffi.check java/lang/Integer tag) + [(ffi.as java/lang/Integer tag) {.#Some tag}] [[(array.read! 1 value) (array.read! 2 value)] [last? {.#Some choice}]]) diff --git a/stdlib/source/library/lux/ffi.jvm.lux b/stdlib/source/library/lux/ffi.jvm.lux index 6b0c04c63..5b5e96a9c 100644 --- a/stdlib/source/library/lux/ffi.jvm.lux +++ b/stdlib/source/library/lux/ffi.jvm.lux @@ -1,6 +1,6 @@ (.using [library - [lux {"-" Primitive Type type int char as} + [lux {"-" Primitive Type type int char is as} ["[0]" meta] [abstract ["[0]" monad {"+" do}]] @@ -115,9 +115,9 @@ (-> (Type Value) Text Code Code) (let [unboxed (..reflection unboxed)] (` (|> (~ raw) - (is (.Primitive (~ (code.text <pre>)))) + (.is (.Primitive (~ (code.text <pre>)))) "jvm object cast" - (is (.Primitive (~ (code.text <post>))))))))] + (.is (.Primitive (~ (code.text <post>))))))))] [unbox boxed unboxed] [box unboxed boxed] @@ -126,11 +126,11 @@ (template [<name> <op> <from> <to>] [(template: .public (<name> value) [(|> value - (is <from>) + (.is <from>) "jvm object cast" <op> "jvm object cast" - (is <to>))])] + (.is <to>))])] [byte_to_long "jvm conversion byte-to-long" ..Byte ..Long] @@ -424,8 +424,8 @@ (-> Text Text Text (Parser Code)) (do <>.monad [.let [dotted_name (format "::" field_name)] - [_ _ value] (is (Parser [Any Any Code]) - (<code>.form ($_ <>.and (<code>.this (' :=)) (<code>.this (code.symbol ["" dotted_name])) <code>.any)))] + [_ _ value] (.is (Parser [Any Any Code]) + (<code>.form ($_ <>.and (<code>.this (' :=)) (<code>.this (code.symbol ["" dotted_name])) <code>.any)))] (in (`' ("jvm member put virtual" (~ (code.text class_name)) (~ (code.text field_name)) @@ -472,9 +472,9 @@ (def: (constructor_parser class_name arguments) (-> Text (List Argument) (Parser Code)) (do <>.monad - [args (is (Parser (List Code)) - (<code>.form (<>.after (<code>.this (' ::new!)) - (<code>.tuple (<>.exactly (list.size arguments) <code>.any)))))] + [args (.is (Parser (List Code)) + (<code>.form (<>.after (<code>.this (' ::new!)) + (<code>.tuple (<>.exactly (list.size arguments) <code>.any)))))] (in (` ("jvm member invoke constructor" (~ (code.text class_name)) (~+ (|> args (list.zipped/2 (list#each product.right arguments)) @@ -484,9 +484,9 @@ (-> Text Text (List Argument) (Parser Code)) (do <>.monad [.let [dotted_name (format "::" method_name "!")] - args (is (Parser (List Code)) - (<code>.form (<>.after (<code>.this (code.symbol ["" dotted_name])) - (<code>.tuple (<>.exactly (list.size arguments) <code>.any)))))] + args (.is (Parser (List Code)) + (<code>.form (<>.after (<code>.this (code.symbol ["" dotted_name])) + (<code>.tuple (<>.exactly (list.size arguments) <code>.any)))))] (in (` ("jvm member invoke static" (~ (code.text class_name)) (~ (code.text method_name)) (~+ (|> args (list.zipped/2 (list#each product.right arguments)) @@ -497,9 +497,9 @@ (-> (List (Type Var)) Text (List (Type Var)) Text (List Argument) Text (Parser Code)) (do <>.monad [.let [dotted_name (format "::" method_name "!")] - args (is (Parser (List Code)) - (<code>.form (<>.after (<code>.this (code.symbol ["" dotted_name])) - (<code>.tuple (<>.exactly (list.size arguments) <code>.any)))))] + args (.is (Parser (List Code)) + (<code>.form (<>.after (<code>.this (code.symbol ["" dotted_name])) + (<code>.tuple (<>.exactly (list.size arguments) <code>.any)))))] (in (` (<jvm_op> [(~+ (list#each (|>> ..signature code.text) class_vars))] (~ (code.text class_name)) (~ (code.text method_name)) [(~+ (list#each (|>> ..signature code.text) type_vars))] @@ -582,10 +582,10 @@ (-> (List (Type Var)) (Parser (Type Class)))) (do <>.monad [.let [class_name^ (..valid_class_name type_vars)] - [name parameters] (is (Parser [External (List (Type Parameter))]) - ($_ <>.either - (<>.and class_name^ (<>#in (list))) - (<code>.form (<>.and class_name^ (<>.some (parameter^ type_vars))))))] + [name parameters] (.is (Parser [External (List (Type Parameter))]) + ($_ <>.either + (<>.and class_name^ (<>#in (list))) + (<code>.form (<>.and class_name^ (<>.some (parameter^ type_vars))))))] (in (jvm.class (name.safe name) parameters)))) (exception: .public (unknown_type_variable [name Text @@ -691,12 +691,12 @@ (def: declaration^ (Parser (Type Declaration)) (do <>.monad - [[name variables] (is (Parser [External (List (Type Var))]) - (<>.either (<>.and (..valid_class_name (list)) - (<>#in (list))) - (<code>.form (<>.and (..valid_class_name (list)) - (<>.some var^))) - ))] + [[name variables] (.is (Parser [External (List (Type Var))]) + (<>.either (<>.and (..valid_class_name (list)) + (<>#in (list))) + (<code>.form (<>.and (..valid_class_name (list)) + (<>.some var^))) + ))] (in (jvm.declaration name variables)))) (def: (class^ type_vars) @@ -964,9 +964,9 @@ []]}) )) (<code>.form (do <>.monad - [kind (is (Parser ImportMethodKind) - (<>.or (<code>.this (' "static")) - (in []))) + [kind (.is (Parser ImportMethodKind) + (<>.or (<code>.this (' "static")) + (in []))) tvars (<>.else (list) ..vars^) name <code>.local ?alias import_member_alias^ @@ -1209,10 +1209,10 @@ methods (<>.some (..method_def^ class_vars))]) (do meta.monad [.let [fully_qualified_class_name full_class_name - method_parser (is (Parser Code) - (|> methods - (list#each (method->parser class_vars fully_qualified_class_name)) - (list#mix <>.either (<>.failure ""))))]] + method_parser (.is (Parser Code) + (|> methods + (list#each (method->parser class_vars fully_qualified_class_name)) + (list#mix <>.either (<>.failure ""))))]] (in (list (` ("jvm class" (~ (declaration$ (jvm.declaration full_class_name class_vars))) (~ (class$ super)) @@ -1271,8 +1271,8 @@ {.#None} ("jvm object null"))))))) -(syntax: .public (check [class (..type^ (list)) - unchecked (<>.maybe <code>.any)]) +(syntax: .public (as [class (..type^ (list)) + unchecked (<>.maybe <code>.any)]) (with_symbols [g!_ g!unchecked] (let [class_name (..reflection class) class_type (` (.Primitive (~ (code.text class_name)))) @@ -1283,14 +1283,14 @@ {.#None}))] (case unchecked {.#Some unchecked} - (in (list (` (is (~ check_type) - (let [(~ g!unchecked) (~ unchecked)] - (~ check_code)))))) + (in (list (` (.is (~ check_type) + (let [(~ g!unchecked) (~ unchecked)] + (~ check_code)))))) {.#None} - (in (list (` (is (-> (.Primitive "java.lang.Object") (~ check_type)) - (function ((~ g!_) (~ g!unchecked)) - (~ check_code)))))) + (in (list (` (.is (-> (.Primitive "java.lang.Object") (~ check_type)) + (function ((~ g!_) (~ g!unchecked)) + (~ check_code)))))) )))) (syntax: .public (synchronized [lock <code>.any @@ -1340,18 +1340,18 @@ (let [(open "[0]") commons] (do [! meta.monad] [arg_inputs (monad.each ! - (is (-> [Bit (Type Value)] (Meta [Bit Code])) - (function (_ [maybe? _]) - (with_symbols [arg_name] - (in [maybe? arg_name])))) + (.is (-> [Bit (Type Value)] (Meta [Bit Code])) + (function (_ [maybe? _]) + (with_symbols [arg_name] + (in [maybe? arg_name])))) #import_member_args) .let [input_jvm_types (list#each product.right #import_member_args) - arg_types (list#each (is (-> [Bit (Type Value)] Code) - (function (_ [maybe? arg]) - (let [arg_type (value_type (the #import_member_mode commons) arg)] - (if maybe? - (` (Maybe (~ arg_type))) - arg_type)))) + arg_types (list#each (.is (-> [Bit (Type Value)] Code) + (function (_ [maybe? arg]) + (let [arg_type (value_type (the #import_member_mode commons) arg)] + (if maybe? + (` (Maybe (~ arg_type))) + arg_type)))) #import_member_args)]] (in [arg_inputs input_jvm_types arg_types]))) @@ -1399,28 +1399,28 @@ (template [<input?> <name> <unbox/box> <special+>] [(def: (<name> mode [unboxed raw]) (-> Primitive_Mode [(Type Value) Code] Code) - (let [[unboxed refined post] (is [(Type Value) Code (List Code)] - (case mode - {#ManualPrM} - [unboxed raw (list)] - - {#AutoPrM} - (with_expansions [<special+>' (template.spliced <special+>) - <cond_cases> (template [<primitive> <pre> <post>] - [(# jvm.equivalence = <primitive> unboxed) - (with_expansions [<post>' (template.spliced <post>)] - [<primitive> - (` (.|> (~ raw) (~+ <pre>))) - (list <post>')])] - - <special+>')] - (cond <cond_cases> - ... else - [unboxed - (if <input?> - (` ("jvm object cast" (~ raw))) - raw) - (list)])))) + (let [[unboxed refined post] (.is [(Type Value) Code (List Code)] + (case mode + {#ManualPrM} + [unboxed raw (list)] + + {#AutoPrM} + (with_expansions [<special+>' (template.spliced <special+>) + <cond_cases> (template [<primitive> <pre> <post>] + [(# jvm.equivalence = <primitive> unboxed) + (with_expansions [<post>' (template.spliced <post>)] + [<primitive> + (` (.|> (~ raw) (~+ <pre>))) + (list <post>')])] + + <special+>')] + (cond <cond_cases> + ... else + [unboxed + (if <input?> + (` ("jvm object cast" (~ raw))) + raw) + (list)])))) unboxed/boxed (case (dictionary.value unboxed ..boxes) {.#Some boxed} (<unbox/box> unboxed boxed refined) @@ -1464,8 +1464,8 @@ (list.zipped/2 classes) (list#each (function (_ [class [maybe? input]]) (|> (if maybe? - (` (is (.Primitive (~ (code.text (..reflection class)))) - ((~! !!!) (~ (..un_quoted input))))) + (` (.is (.Primitive (~ (code.text (..reflection class)))) + ((~! !!!) (~ (..un_quoted input))))) (..un_quoted input)) [class] (with_automatic_input_conversion mode)))))) @@ -1489,21 +1489,21 @@ {#EnumDecl enum_members} (with_symbols [g!_] (do meta.monad - [.let [enum_type (is Code - (case class_tvars - {.#End} - (` (.Primitive (~ (code.text full_name)))) - - _ - (let [=class_tvars (list#each ..var$' class_tvars)] - (` (All ((~ g!_) (~+ =class_tvars)) - (.Primitive (~ (code.text full_name)) [(~+ =class_tvars)])))))) - getter_interop (is (-> Text Code) - (function (_ name) - (let [getter_name (code.symbol ["" (..import_name import_format method_prefix name)])] - (` (def: (~ getter_name) - (~ enum_type) - (~ (get_static_field full_name name)))))))]] + [.let [enum_type (.is Code + (case class_tvars + {.#End} + (` (.Primitive (~ (code.text full_name)))) + + _ + (let [=class_tvars (list#each ..var$' class_tvars)] + (` (All ((~ g!_) (~+ =class_tvars)) + (.Primitive (~ (code.text full_name)) [(~+ =class_tvars)])))))) + getter_interop (.is (-> Text Code) + (function (_ name) + (let [getter_name (code.symbol ["" (..import_name import_format method_prefix name)])] + (` (def: (~ getter_name) + (~ enum_type) + (~ (get_static_field full_name name)))))))]] (in (list#each getter_interop enum_members)))) {#ConstructorDecl [commons _]} @@ -1531,51 +1531,51 @@ [.let [def_name (code.symbol ["" (..import_name import_format method_prefix (the #import_member_alias commons))]) (open "[0]") commons (open "[0]") method - [jvm_op object_ast] (is [Text (List Code)] - (case #import_member_kind - {#StaticIMK} - ["jvm member invoke static" - (list)] - - {#VirtualIMK} - (case kind - {#Class} - ["jvm member invoke virtual" - (list g!obj)] - - {#Interface} - ["jvm member invoke interface" - (list g!obj)] - ))) + [jvm_op object_ast] (.is [Text (List Code)] + (case #import_member_kind + {#StaticIMK} + ["jvm member invoke static" + (list)] + + {#VirtualIMK} + (case kind + {#Class} + ["jvm member invoke virtual" + (list g!obj)] + + {#Interface} + ["jvm member invoke interface" + (list g!obj)] + ))) method_return (the #import_method_return method) - callC (is Code - (` ((~ (code.text jvm_op)) - [(~+ (list#each ..var$ class_tvars))] - (~ (code.text full_name)) - (~ (code.text #import_method_name)) - [(~+ (list#each ..var$ (the #import_member_tvars commons)))] - (~+ (|> object_ast - (list#each ..un_quoted) - (list.zipped/2 (list (jvm.class full_name (list)))) - (list#each (with_automatic_input_conversion (the #import_member_mode commons))))) - (~+ (|> (jvm_invoke_inputs (the #import_member_mode commons) input_jvm_types arg_function_inputs) - (list.zipped/2 input_jvm_types) - (list#each ..decorate_input)))))) - jvm_interop (is Code - (case (jvm.void? method_return) - {.#Left method_return} - (|> [method_return - callC] - (with_automatic_output_conversion (the #import_member_mode commons)) - (with_return_maybe member false method_return) - (with_return_try member) - (with_return_io member)) - - - {.#Right method_return} - (|> callC - (with_return_try member) - (with_return_io member))))]] + callC (.is Code + (` ((~ (code.text jvm_op)) + [(~+ (list#each ..var$ class_tvars))] + (~ (code.text full_name)) + (~ (code.text #import_method_name)) + [(~+ (list#each ..var$ (the #import_member_tvars commons)))] + (~+ (|> object_ast + (list#each ..un_quoted) + (list.zipped/2 (list (jvm.class full_name (list)))) + (list#each (with_automatic_input_conversion (the #import_member_mode commons))))) + (~+ (|> (jvm_invoke_inputs (the #import_member_mode commons) input_jvm_types arg_function_inputs) + (list.zipped/2 input_jvm_types) + (list#each ..decorate_input)))))) + jvm_interop (.is Code + (case (jvm.void? method_return) + {.#Left method_return} + (|> [method_return + callC] + (with_automatic_output_conversion (the #import_member_mode commons)) + (with_return_maybe member false method_return) + (with_return_try member) + (with_return_io member)) + + + {.#Right method_return} + (|> callC + (with_return_try member) + (with_return_io member))))]] (in (list (` ((~! syntax:) ((~ def_name) [(~+ (syntax_inputs (list#each product.right arg_function_inputs))) (~+ (syntax_inputs object_ast))]) ((~' in) (.list (.` (~ jvm_interop)))))))))) @@ -1602,27 +1602,27 @@ getter_body)] (in (` ((~! syntax:) (~ getter_call) ((~' in) (.list (.` (~ getter_body))))))))) - setter_interop (is (Meta (List Code)) - (if _#import_field_setter? - (with_symbols [g!obj g!value] - (let [setter_call (if _#import_field_static? - (` ((~ setter_name) [(~ g!value) (~! <code>.any)])) - (` ((~ setter_name) [(~ g!value) (~! <code>.any) - (~ g!obj) (~! <code>.any)]))) - setter_value (|> [_#import_field_type (..un_quoted g!value)] - (with_automatic_input_conversion _#import_field_mode)) - setter_value (if _#import_field_maybe? - (` ((~! !!!) (~ setter_value))) - setter_value) - setter_command (format (if _#import_field_static? "jvm putstatic" "jvm putfield") - ":" full_name ":" _#import_field_name) - g!obj+ (is (List Code) - (if _#import_field_static? - (list) - (list (..un_quoted g!obj))))] - (in (list (` ((~! syntax:) (~ setter_call) - ((~' in) (.list (.` ((~! io.io) ((~ (code.text setter_command)) (~+ g!obj+) (~ setter_value)))))))))))) - (in (list))))] + setter_interop (.is (Meta (List Code)) + (if _#import_field_setter? + (with_symbols [g!obj g!value] + (let [setter_call (if _#import_field_static? + (` ((~ setter_name) [(~ g!value) (~! <code>.any)])) + (` ((~ setter_name) [(~ g!value) (~! <code>.any) + (~ g!obj) (~! <code>.any)]))) + setter_value (|> [_#import_field_type (..un_quoted g!value)] + (with_automatic_input_conversion _#import_field_mode)) + setter_value (if _#import_field_maybe? + (` ((~! !!!) (~ setter_value))) + setter_value) + setter_command (format (if _#import_field_static? "jvm putstatic" "jvm putfield") + ":" full_name ":" _#import_field_name) + g!obj+ (.is (List Code) + (if _#import_field_static? + (list) + (list (..un_quoted g!obj))))] + (in (list (` ((~! syntax:) (~ setter_call) + ((~' in) (.list (.` ((~! io.io) ((~ (code.text setter_command)) (~+ g!obj+) (~ setter_value)))))))))))) + (in (list))))] (in (list& getter_interop setter_interop))) ))) @@ -1638,7 +1638,7 @@ (All (_ a) (-> (.Primitive "java.lang.Class" [a]) Bit)) (|>> ("jvm member invoke virtual" [] "java.lang.Class" "isInterface" []) "jvm object cast" - (is ..Boolean) + (.is ..Boolean) (.as Bit))) (def: load_class @@ -1691,8 +1691,8 @@ [jvm.double "jvm array new double"] [jvm.char "jvm array new char"])) ... else - (in (list (` (is (~ (value_type {#ManualPrM} (jvm.array type))) - ("jvm array new object" (~ g!size)))))))))) + (in (list (` (.is (~ (value_type {#ManualPrM} (jvm.array type))) + ("jvm array new object" (~ g!size)))))))))) (exception: .public (cannot_convert_to_jvm_type [type .Type]) (exception.report @@ -1762,18 +1762,18 @@ ... else (# meta.monad each (jvm.class name) - (is (Meta (List (Type Parameter))) - (monad.each meta.monad - (function (_ paramLT) - (do meta.monad - [paramJT (lux_type->jvm_type context paramLT)] - (case (parser.parameter? paramJT) - {.#Some paramJT} - (in paramJT) - - {.#None} - <failure>))) - params))))) + (.is (Meta (List (Type Parameter))) + (monad.each meta.monad + (function (_ paramLT) + (do meta.monad + [paramJT (lux_type->jvm_type context paramLT)] + (case (parser.parameter? paramJT) + {.#Some paramJT} + (in paramJT) + + {.#None} + <failure>))) + params))))) {.#Apply A F} (case (type.applied (list A) F) @@ -1921,7 +1921,7 @@ "Signature" (..signature type) "Reflection" (..reflection type))) -(syntax: .public (as [type (..type^ (list)) +(syntax: .public (is [type (..type^ (list)) object <code>.any]) (case [(parser.array? type) (parser.class? type)] @@ -1934,10 +1934,10 @@ (template [<forward> <from> <to> <backward>] [(template: .public (<forward> it) - [(|> it (is <from>) (as <to>))]) + [(|> it (.is <from>) (.as <to>))]) (template: .public (<backward> it) - [(|> it (is <to>) (as <from>))])] + [(|> it (.is <to>) (.as <from>))])] [as_boolean .Bit ..Boolean of_boolean] [as_long .Int ..Long of_long] @@ -1947,10 +1947,10 @@ (template [<forward> <from> <$> <mid> <$'> <to> <backward>] [(template: .public (<forward> it) - [(|> it (is <from>) (as <mid>) <$> (is <to>))]) + [(|> it (.is <from>) (.as <mid>) <$> (.is <to>))]) (template: .public (<backward> it) - [(|> it (is <to>) <$'> (is <mid>) (as <from>))])] + [(|> it (.is <to>) <$'> (.is <mid>) (.as <from>))])] [as_byte .Int ..long_to_byte ..Long ..byte_to_long ..Byte of_byte] [as_short .Int ..long_to_short ..Long ..short_to_long ..Short of_short] diff --git a/stdlib/source/library/lux/ffi.old.lux b/stdlib/source/library/lux/ffi.old.lux index f6822f72a..0479558f9 100644 --- a/stdlib/source/library/lux/ffi.old.lux +++ b/stdlib/source/library/lux/ffi.old.lux @@ -1,6 +1,6 @@ (.using [library - [lux {"-" as type} + [lux {"-" is as type} ["[0]" type ("[1]#[0]" equivalence)] [abstract ["[0]" monad {"+" Monad do}] @@ -65,10 +65,10 @@ (template [<forward> <from> <to> <backward>] [(template: .public (<forward> it) - [(|> it (is <from>) (.as (Primitive <to>)))]) + [(|> it (.is <from>) (.as (Primitive <to>)))]) (template: .public (<backward> it) - [(|> it (is (Primitive <to>)) (.as <from>))])] + [(|> it (.is (Primitive <to>)) (.as <from>))])] [as_boolean .Bit "java.lang.Boolean" of_boolean] [as_long .Int "java.lang.Long" of_long] @@ -78,10 +78,10 @@ (template [<forward> <from> <$> <mid> <$'> <to> <backward>] [(template: .public (<forward> it) - [(|> it (is <from>) (.as (Primitive <mid>)) <$> (is (Primitive <to>)))]) + [(|> it (.is <from>) (.as (Primitive <mid>)) <$> (.is (Primitive <to>)))]) (template: .public (<backward> it) - [(|> it (is (Primitive <to>)) <$'> (is (Primitive <mid>)) (.as <from>))])] + [(|> it (.is (Primitive <to>)) <$'> (.is (Primitive <mid>)) (.as <from>))])] [as_byte .Int ..long_to_byte "java.lang.Long" ..byte_to_long "java.lang.Byte" of_byte] [as_short .Int ..long_to_short "java.lang.Long" ..short_to_long "java.lang.Short" of_short] @@ -380,14 +380,14 @@ (def: (class_decl_type$ (open "[0]")) (-> Class_Declaration Code) - (let [=params (list#each (is (-> Type_Parameter Code) - (function (_ [pname pbounds]) - (case pbounds - {.#End} - (code.symbol ["" pname]) - - {.#Item bound1 _} - (class_type {#ManualPrM} #class_params bound1)))) + (let [=params (list#each (.is (-> Type_Parameter Code) + (function (_ [pname pbounds]) + (case pbounds + {.#End} + (code.symbol ["" pname]) + + {.#Item bound1 _} + (class_type {#ManualPrM} #class_params bound1)))) #class_params)] (` (Primitive (~ (code.text (safe #class_name))) [(~+ =params)])))) @@ -457,8 +457,8 @@ (-> Text Text (Parser Code)) (do <>.monad [.let [dotted_name (format "::" field_name)] - [_ _ value] (is (Parser [Any Any Code]) - (<code>.form ($_ <>.and (<code>.this (' :=)) (<code>.this (code.symbol ["" dotted_name])) <code>.any)))] + [_ _ value] (.is (Parser [Any Any Code]) + (<code>.form ($_ <>.and (<code>.this (' :=)) (<code>.this (code.symbol ["" dotted_name])) <code>.any)))] (in (`' ((~ (code.text (format "jvm putfield" ":" class_name ":" field_name))) _jvm_this (~ value)))))) (def: (pre_walk_replace f input) @@ -497,10 +497,10 @@ (def: (constructor_parser params class_name arg_decls) (-> (List Type_Parameter) Text (List ArgDecl) (Parser Code)) (do <>.monad - [args (is (Parser (List Code)) - (<code>.form (<>.after (<code>.this (' ::new!)) - (<code>.tuple (<>.exactly (list.size arg_decls) <code>.any))))) - .let [arg_decls' (is (List Text) (list#each (|>> product.right (simple_class$ params)) arg_decls))]] + [args (.is (Parser (List Code)) + (<code>.form (<>.after (<code>.this (' ::new!)) + (<code>.tuple (<>.exactly (list.size arg_decls) <code>.any))))) + .let [arg_decls' (.is (List Text) (list#each (|>> product.right (simple_class$ params)) arg_decls))]] (in (` ((~ (code.text (format "jvm new" ":" class_name ":" (text.interposed "," arg_decls')))) (~+ args)))))) @@ -508,10 +508,10 @@ (-> (List Type_Parameter) Text Text (List ArgDecl) (Parser Code)) (do <>.monad [.let [dotted_name (format "::" method_name "!")] - args (is (Parser (List Code)) - (<code>.form (<>.after (<code>.this (code.symbol ["" dotted_name])) - (<code>.tuple (<>.exactly (list.size arg_decls) <code>.any))))) - .let [arg_decls' (is (List Text) (list#each (|>> product.right (simple_class$ params)) arg_decls))]] + args (.is (Parser (List Code)) + (<code>.form (<>.after (<code>.this (code.symbol ["" dotted_name])) + (<code>.tuple (<>.exactly (list.size arg_decls) <code>.any))))) + .let [arg_decls' (.is (List Text) (list#each (|>> product.right (simple_class$ params)) arg_decls))]] (in (`' ((~ (code.text (format "jvm invokestatic" ":" class_name ":" method_name ":" (text.interposed "," arg_decls')))) (~+ args)))))) @@ -520,10 +520,10 @@ (-> (List Type_Parameter) Text Text (List ArgDecl) (Parser Code)) (do <>.monad [.let [dotted_name (format "::" method_name "!")] - args (is (Parser (List Code)) - (<code>.form (<>.after (<code>.this (code.symbol ["" dotted_name])) - (<code>.tuple (<>.exactly (list.size arg_decls) <code>.any))))) - .let [arg_decls' (is (List Text) (list#each (|>> product.right (simple_class$ params)) arg_decls))]] + args (.is (Parser (List Code)) + (<code>.form (<>.after (<code>.this (code.symbol ["" dotted_name])) + (<code>.tuple (<>.exactly (list.size arg_decls) <code>.any))))) + .let [arg_decls' (.is (List Text) (list#each (|>> product.right (simple_class$ params)) arg_decls))]] (in (`' ((~ (code.text (format <jvm_op> ":" class_name ":" method_name ":" (text.interposed "," arg_decls')))) (~' _jvm_this) (~+ args))))))] @@ -933,9 +933,9 @@ #import_member_io? io?] []]}))) (<code>.form (do <>.monad - [kind (is (Parser ImportMethodKind) - (<>.or (<code>.this (' "static")) - (in []))) + [kind (.is (Parser ImportMethodKind) + (<>.or (<code>.this (' "static")) + (in []))) tvars ..type_params^ name <code>.local ?alias import_member_alias^ @@ -1128,8 +1128,8 @@ (let [super_replacer (parser_replacer (<code>.form (do <>.monad [_ (<code>.this (' ::super!)) args (<code>.tuple (<>.exactly (list.size arg_decls) <code>.any)) - .let [arg_decls' (is (List Text) (list#each (|>> product.right (simple_class$ (list))) - arg_decls))]] + .let [arg_decls' (.is (List Text) (list#each (|>> product.right (simple_class$ (list))) + arg_decls))]] (in (`' ((~ (code.text (format "jvm invokespecial" ":" (the #super_class_name super_class) ":" name @@ -1277,8 +1277,8 @@ {.#None} ("jvm object null"))))))) -(syntax: .public (check [class (..generic_type^ (list)) - unchecked (<>.maybe <code>.any)]) +(syntax: .public (as [class (..generic_type^ (list)) + unchecked (<>.maybe <code>.any)]) (with_symbols [g!_ g!unchecked] (let [class_name (simple_class$ (list) class) class_type (` (.Primitive (~ (code.text class_name)))) @@ -1289,14 +1289,14 @@ {.#None}))] (case unchecked {.#Some unchecked} - (in (list (` (is (~ check_type) - (let [(~ g!unchecked) (~ unchecked)] - (~ check_code)))))) + (in (list (` (.is (~ check_type) + (let [(~ g!unchecked) (~ unchecked)] + (~ check_code)))))) {.#None} - (in (list (` (is (-> (Primitive "java.lang.Object") (~ check_type)) - (function ((~ g!_) (~ g!unchecked)) - (~ check_code)))))) + (in (list (` (.is (-> (Primitive "java.lang.Object") (~ check_type)) + (function ((~ g!_) (~ g!unchecked)) + (~ check_code)))))) )))) (syntax: .public (synchronized [lock <code>.any @@ -1344,20 +1344,20 @@ (let [(open "[0]") commons] (do [! meta.monad] [arg_inputs (monad.each ! - (is (-> [Bit GenericType] (Meta [Bit Code])) - (function (_ [maybe? _]) - (with_symbols [arg_name] - (in [maybe? arg_name])))) + (.is (-> [Bit GenericType] (Meta [Bit Code])) + (function (_ [maybe? _]) + (with_symbols [arg_name] + (in [maybe? arg_name])))) #import_member_args) - .let [arg_classes (is (List Text) - (list#each (|>> product.right (simple_class$ (list#composite type_params #import_member_tvars))) - #import_member_args)) - arg_types (list#each (is (-> [Bit GenericType] Code) - (function (_ [maybe? arg]) - (let [arg_type (class_type (the #import_member_mode commons) type_params arg)] - (if maybe? - (` (Maybe (~ arg_type))) - arg_type)))) + .let [arg_classes (.is (List Text) + (list#each (|>> product.right (simple_class$ (list#composite type_params #import_member_tvars))) + #import_member_args)) + arg_types (list#each (.is (-> [Bit GenericType] Code) + (function (_ [maybe? arg]) + (let [arg_type (class_type (the #import_member_mode commons) type_params arg)] + (if maybe? + (` (Maybe (~ arg_type))) + arg_type)))) #import_member_args)]] (in [arg_inputs arg_classes arg_types]))) @@ -1459,22 +1459,22 @@ {#EnumDecl enum_members} (macro.with_symbols [g!_] (do [! meta.monad] - [.let [enum_type (is Code - (case class_tvars - {.#End} - (` (Primitive (~ (code.text full_name)))) - - _ - (let [=class_tvars (|> class_tvars - (list.only free_type_param?) - (list#each lux_type_parameter))] - (` (All ((~ g!_) (~+ =class_tvars)) (Primitive (~ (code.text full_name)) [(~+ =class_tvars)])))))) - getter_interop (is (-> Text Code) - (function (_ name) - (let [getter_name (code.symbol ["" (..import_name import_format method_prefix name)])] - (` (def: (~ getter_name) - (~ enum_type) - ((~ (code.text (format "jvm getstatic" ":" full_name ":" name)))))))))]] + [.let [enum_type (.is Code + (case class_tvars + {.#End} + (` (Primitive (~ (code.text full_name)))) + + _ + (let [=class_tvars (|> class_tvars + (list.only free_type_param?) + (list#each lux_type_parameter))] + (` (All ((~ g!_) (~+ =class_tvars)) (Primitive (~ (code.text full_name)) [(~+ =class_tvars)])))))) + getter_interop (.is (-> Text Code) + (function (_ name) + (let [getter_name (code.symbol ["" (..import_name import_format method_prefix name)])] + (` (def: (~ getter_name) + (~ enum_type) + ((~ (code.text (format "jvm getstatic" ":" full_name ":" name)))))))))]] (in (list#each getter_interop enum_members)))) {#ConstructorDecl [commons _]} @@ -1495,22 +1495,22 @@ [.let [def_name (code.symbol ["" (..import_name import_format method_prefix (the #import_member_alias commons))]) (open "[0]") commons (open "[0]") method - [jvm_op object_ast] (is [Text (List Code)] - (case #import_member_kind - {#StaticIMK} - ["invokestatic" - (list)] - - {#VirtualIMK} - (case kind - {#Class} - ["invokevirtual" - (list g!obj)] - - {#Interface} - ["invokeinterface" - (list g!obj)] - ))) + [jvm_op object_ast] (.is [Text (List Code)] + (case #import_member_kind + {#StaticIMK} + ["invokestatic" + (list)] + + {#VirtualIMK} + (case kind + {#Class} + ["invokevirtual" + (list g!obj)] + + {#Interface} + ["invokeinterface" + (list g!obj)] + ))) jvm_extension (code.text (format "jvm " jvm_op ":" full_name ":" #import_method_name ":" (text.interposed "," arg_classes))) jvm_interop (|> [(simple_class$ (list) (the #import_method_return method)) (` ((~ jvm_extension) (~+ (list#each un_quote object_ast)) @@ -1531,10 +1531,10 @@ typeC (if #import_field_maybe? (` (Maybe (~ base_gtype))) base_gtype) - tvar_asts (is (List Code) - (|> class_tvars - (list.only free_type_param?) - (list#each lux_type_parameter))) + tvar_asts (.is (List Code) + (|> class_tvars + (list.only free_type_param?) + (list#each lux_type_parameter))) getter_name (code.symbol ["" (..import_name import_format method_prefix #import_field_name)]) setter_name (code.symbol ["" (..import_name import_format method_prefix (format #import_field_name "!"))])] getter_interop (with_symbols [g!obj] @@ -1556,27 +1556,27 @@ getter_body)] (in (` ((~! syntax:) (~ getter_call) ((~' in) (.list (.` (~ getter_body))))))))) - setter_interop (is (Meta (List Code)) - (if #import_field_setter? - (with_symbols [g!obj g!value] - (let [setter_call (if #import_field_static? - (` ((~ setter_name) [(~ g!value) (~! <code>.any)])) - (` ((~ setter_name) [(~ g!value) (~! <code>.any) - (~ g!obj) (~! <code>.any)]))) - setter_value (auto_convert_input #import_field_mode - [(simple_class$ (list) #import_field_type) (un_quote g!value)]) - setter_value (if #import_field_maybe? - (` ((~! !!!) (~ setter_value))) - setter_value) - setter_command (format (if #import_field_static? "jvm putstatic" "jvm putfield") - ":" full_name ":" #import_field_name) - g!obj+ (is (List Code) - (if #import_field_static? - (list) - (list (un_quote g!obj))))] - (in (list (` ((~! syntax:) (~ setter_call) - ((~' in) (.list (.` ((~! io.io) ((~ (code.text setter_command)) (~+ g!obj+) (~ setter_value)))))))))))) - (in (list))))] + setter_interop (.is (Meta (List Code)) + (if #import_field_setter? + (with_symbols [g!obj g!value] + (let [setter_call (if #import_field_static? + (` ((~ setter_name) [(~ g!value) (~! <code>.any)])) + (` ((~ setter_name) [(~ g!value) (~! <code>.any) + (~ g!obj) (~! <code>.any)]))) + setter_value (auto_convert_input #import_field_mode + [(simple_class$ (list) #import_field_type) (un_quote g!value)]) + setter_value (if #import_field_maybe? + (` ((~! !!!) (~ setter_value))) + setter_value) + setter_command (format (if #import_field_static? "jvm putstatic" "jvm putfield") + ":" full_name ":" #import_field_name) + g!obj+ (.is (List Code) + (if #import_field_static? + (list) + (list (un_quote g!obj))))] + (in (list (` ((~! syntax:) (~ setter_call) + ((~' in) (.list (.` ((~! io.io) ((~ (code.text setter_command)) (~+ g!obj+) (~ setter_value)))))))))))) + (in (list))))] (in (list& getter_interop setter_interop))) ))) diff --git a/stdlib/source/library/lux/target/jvm/reflection.lux b/stdlib/source/library/lux/target/jvm/reflection.lux index 94ca109a2..44c4bda89 100644 --- a/stdlib/source/library/lux/target/jvm/reflection.lux +++ b/stdlib/source/library/lux/target/jvm/reflection.lux @@ -130,7 +130,7 @@ (-> (-> java/lang/reflect/Type (Try (/.Type Parameter))) java/lang/reflect/Type (Try (/.Type Class))) - (<| (case (ffi.check java/lang/Class reflection) + (<| (case (ffi.as java/lang/Class reflection) {.#Some class} (let [class_name (|> class (as (java/lang/Class java/lang/Object)) @@ -151,10 +151,10 @@ (exception.except ..not_a_class [reflection]) {try.#Success (/.class class_name (list))}))) _) - (case (ffi.check java/lang/reflect/ParameterizedType reflection) + (case (ffi.as java/lang/reflect/ParameterizedType reflection) {.#Some reflection} (let [raw (java/lang/reflect/ParameterizedType::getRawType reflection)] - (case (ffi.check java/lang/Class raw) + (case (ffi.as java/lang/Class raw) {.#Some raw'} (let [! try.monad] (|> reflection @@ -175,11 +175,11 @@ (def: .public (parameter type reflection) (-> (-> java/lang/reflect/Type (Try (/.Type Value))) (-> java/lang/reflect/Type (Try (/.Type Parameter)))) - (<| (case (ffi.check java/lang/reflect/TypeVariable reflection) + (<| (case (ffi.as java/lang/reflect/TypeVariable reflection) {.#Some reflection} {try.#Success (/.var (java/lang/reflect/TypeVariable::getName reflection))} _) - (case (ffi.check java/lang/reflect/WildcardType reflection) + (case (ffi.as java/lang/reflect/WildcardType reflection) {.#Some reflection} ... TODO: Instead of having single lower/upper bounds, should ... allow for multiple ones. @@ -187,7 +187,7 @@ (array.read! 0 (java/lang/reflect/WildcardType::getUpperBounds reflection))] (^.template [<pattern> <kind>] [<pattern> - (case (ffi.check java/lang/reflect/GenericArrayType bound) + (case (ffi.as java/lang/reflect/GenericArrayType bound) {.#Some it} ... TODO: Array bounds should not be "erased" as they ... are right now. @@ -201,14 +201,14 @@ _ {try.#Success /.wildcard}) _) - (case (ffi.check java/lang/reflect/GenericArrayType reflection) + (case (ffi.as java/lang/reflect/GenericArrayType reflection) {.#Some reflection} (|> reflection java/lang/reflect/GenericArrayType::getGenericComponentType type (# try.monad each /.array)) _) - (case (ffi.check java/lang/Class reflection) + (case (ffi.as java/lang/Class reflection) {.#Some class} (if (java/lang/Class::isArray class) (|> class @@ -221,7 +221,7 @@ (def: .public (type reflection) (-> java/lang/reflect/Type (Try (/.Type Value))) - (<| (case (ffi.check java/lang/Class reflection) + (<| (case (ffi.as java/lang/Class reflection) {.#Some reflection} (let [class_name (|> reflection (as (java/lang/Class java/lang/Object)) @@ -254,7 +254,7 @@ (def: .public (return reflection) (-> java/lang/reflect/Type (Try (/.Type Return))) (with_expansions [<else> (these (..type reflection))] - (case (ffi.check java/lang/Class reflection) + (case (ffi.as java/lang/Class reflection) {.#Some class} (let [class_name (|> reflection (as (java/lang/Class java/lang/Object)) @@ -362,7 +362,7 @@ (def: .public deprecated? (-> (array.Array java/lang/annotation/Annotation) Bit) (|>> (array.list {.#None}) - (list.all (|>> (ffi.check java/lang/Deprecated))) + (list.all (|>> (ffi.as java/lang/Deprecated))) list.empty? not)) diff --git a/stdlib/source/test/lux/ffi.jvm.lux b/stdlib/source/test/lux/ffi.jvm.lux index abdc297c7..2db7c0bc3 100644 --- a/stdlib/source/test/lux/ffi.jvm.lux +++ b/stdlib/source/test/lux/ffi.jvm.lux @@ -165,11 +165,11 @@ bit/0 random.bit] ($_ _.and - (_.cover [/.check] - (and (case (/.check java/lang/String sample) {.#Some _} true {.#None} false) - (case (/.check java/lang/Long sample) {.#Some _} false {.#None} true) - (case (/.check java/lang/Object sample) {.#Some _} true {.#None} false) - (case (/.check java/lang/Object (/.null)) {.#Some _} false {.#None} true))) + (_.cover [/.as] + (and (case (/.as java/lang/String sample) {.#Some _} true {.#None} false) + (case (/.as java/lang/Long sample) {.#Some _} false {.#None} true) + (case (/.as java/lang/Object sample) {.#Some _} true {.#None} false) + (case (/.as java/lang/Object (/.null)) {.#Some _} false {.#None} true))) (_.cover [/.synchronized] (/.synchronized sample #1)) (_.cover [/.class_for] @@ -237,10 +237,10 @@ (text#= it)))) (_.cover [/.cannot_cast_to_non_object] (text.contains? (the exception.#label /.cannot_cast_to_non_object) - (macro_error (/.as boolean (is /.Boolean boolean))))) - (_.cover [/.as] + (macro_error (/.is boolean (is /.Boolean boolean))))) + (_.cover [/.is] (|> string - (/.as java/lang/Object) + (/.is java/lang/Object) (same? (as java/lang/Object string)))) (_.cover [/.type] (and (and (type#= /.Boolean (/.type java/lang/Boolean)) diff --git a/stdlib/source/test/lux/ffi.old.lux b/stdlib/source/test/lux/ffi.old.lux index f452cf5a1..2b50f700c 100644 --- a/stdlib/source/test/lux/ffi.old.lux +++ b/stdlib/source/test/lux/ffi.old.lux @@ -201,11 +201,11 @@ counter random.int increase random.int] ($_ _.and - (_.cover [/.check] - (and (case (/.check java/lang/String sample) {.#Some _} true {.#None} false) - (case (/.check java/lang/Long sample) {.#Some _} false {.#None} true) - (case (/.check java/lang/Object sample) {.#Some _} true {.#None} false) - (case (/.check java/lang/Object (/.null)) {.#Some _} false {.#None} true))) + (_.cover [/.as] + (and (case (/.as java/lang/String sample) {.#Some _} true {.#None} false) + (case (/.as java/lang/Long sample) {.#Some _} false {.#None} true) + (case (/.as java/lang/Object sample) {.#Some _} true {.#None} false) + (case (/.as java/lang/Object (/.null)) {.#Some _} false {.#None} true))) (_.cover [/.synchronized] (/.synchronized sample #1)) (_.cover [/.class_for /.import:] |