diff options
author | Eduardo Julian | 2019-05-16 23:17:07 -0400 |
---|---|---|
committer | Eduardo Julian | 2019-05-16 23:17:07 -0400 |
commit | 9b59f66c8d8115a67d6eee1e7a38aa39823db222 (patch) | |
tree | 8bceefa49df4c01c304d68b0ff766c424cd6b538 /new-luxc/source/luxc/lang/translation/jvm/procedure | |
parent | ea0cff44a5f003f8956ffbce9ea5f6957fdf4c92 (diff) |
Some type casting/coercion automation.
Diffstat (limited to '')
-rw-r--r-- | new-luxc/source/luxc/lang/translation/jvm/procedure/host.lux | 144 |
1 files changed, 72 insertions, 72 deletions
diff --git a/new-luxc/source/luxc/lang/translation/jvm/procedure/host.lux b/new-luxc/source/luxc/lang/translation/jvm/procedure/host.lux index be2a0bace..e1e6b3c47 100644 --- a/new-luxc/source/luxc/lang/translation/jvm/procedure/host.lux +++ b/new-luxc/source/luxc/lang/translation/jvm/procedure/host.lux @@ -181,7 +181,7 @@ [double::% _.DREM] ) -(def: boolean-class (jvm.class "java.lang.Boolean" (list))) +(def: boolean-class (jvm.class jvm.boolean-box (list))) (def: falseI (_.GETSTATIC "java.lang.Boolean" "FALSE" boolean-class)) (def: trueI (_.GETSTATIC "java.lang.Boolean" "TRUE" boolean-class)) @@ -234,7 +234,7 @@ (def: int Bundle - (<| (bundle.prefix "int") + (<| (bundle.prefix jvm.int-reflection) (|> (: Bundle bundle.empty) (bundle.install "+" (binary int::+)) (bundle.install "-" (binary int::-)) @@ -253,7 +253,7 @@ (def: long Bundle - (<| (bundle.prefix "long") + (<| (bundle.prefix jvm.long-reflection) (|> (: Bundle bundle.empty) (bundle.install "+" (binary long::+)) (bundle.install "-" (binary long::-)) @@ -272,7 +272,7 @@ (def: float Bundle - (<| (bundle.prefix "float") + (<| (bundle.prefix jvm.float-reflection) (|> (: Bundle bundle.empty) (bundle.install "+" (binary float::+)) (bundle.install "-" (binary float::-)) @@ -285,7 +285,7 @@ (def: double Bundle - (<| (bundle.prefix "double") + (<| (bundle.prefix jvm.double-reflection) (|> (: Bundle bundle.empty) (bundle.install "+" (binary double::+)) (bundle.install "-" (binary double::-)) @@ -298,7 +298,7 @@ (def: char Bundle - (<| (bundle.prefix "char") + (<| (bundle.prefix jvm.char-reflection) (|> (: Bundle bundle.empty) (bundle.install "=" (binary char::=)) (bundle.install "<" (binary char::<)) @@ -308,14 +308,14 @@ (-> Nat Text Type) (jvm.array nesting (case elem-class - "boolean" jvm.boolean - "byte" jvm.byte - "short" jvm.short - "int" jvm.int - "long" jvm.long - "float" jvm.float - "double" jvm.double - "char" jvm.char + (^ (static jvm.boolean-reflection)) jvm.boolean + (^ (static jvm.byte-reflection)) jvm.byte + (^ (static jvm.short-reflection)) jvm.short + (^ (static jvm.int-reflection)) jvm.int + (^ (static jvm.long-reflection)) jvm.long + (^ (static jvm.float-reflection)) jvm.float + (^ (static jvm.double-reflection)) jvm.double + (^ (static jvm.char-reflection)) jvm.char _ (jvm.class elem-class (list))))) (def: (primitive-array-length-handler jvm-primitive) @@ -451,47 +451,47 @@ (|> bundle.empty (dictionary.merge (<| (bundle.prefix "length") (|> bundle.empty - (bundle.install "boolean" (primitive-array-length-handler jvm.boolean)) - (bundle.install "byte" (primitive-array-length-handler jvm.byte)) - (bundle.install "short" (primitive-array-length-handler jvm.short)) - (bundle.install "int" (primitive-array-length-handler jvm.int)) - (bundle.install "long" (primitive-array-length-handler jvm.long)) - (bundle.install "float" (primitive-array-length-handler jvm.float)) - (bundle.install "double" (primitive-array-length-handler jvm.double)) - (bundle.install "char" (primitive-array-length-handler jvm.char)) + (bundle.install jvm.boolean-reflection (primitive-array-length-handler jvm.boolean)) + (bundle.install jvm.byte-reflection (primitive-array-length-handler jvm.byte)) + (bundle.install jvm.short-reflection (primitive-array-length-handler jvm.short)) + (bundle.install jvm.int-reflection (primitive-array-length-handler jvm.int)) + (bundle.install jvm.long-reflection (primitive-array-length-handler jvm.long)) + (bundle.install jvm.float-reflection (primitive-array-length-handler jvm.float)) + (bundle.install jvm.double-reflection (primitive-array-length-handler jvm.double)) + (bundle.install jvm.char-reflection (primitive-array-length-handler jvm.char)) (bundle.install "object" array::length::object)))) (dictionary.merge (<| (bundle.prefix "new") (|> bundle.empty - (bundle.install "boolean" (new-primitive-array-handler jvm.boolean)) - (bundle.install "byte" (new-primitive-array-handler jvm.byte)) - (bundle.install "short" (new-primitive-array-handler jvm.short)) - (bundle.install "int" (new-primitive-array-handler jvm.int)) - (bundle.install "long" (new-primitive-array-handler jvm.long)) - (bundle.install "float" (new-primitive-array-handler jvm.float)) - (bundle.install "double" (new-primitive-array-handler jvm.double)) - (bundle.install "char" (new-primitive-array-handler jvm.char)) + (bundle.install jvm.boolean-reflection (new-primitive-array-handler jvm.boolean)) + (bundle.install jvm.byte-reflection (new-primitive-array-handler jvm.byte)) + (bundle.install jvm.short-reflection (new-primitive-array-handler jvm.short)) + (bundle.install jvm.int-reflection (new-primitive-array-handler jvm.int)) + (bundle.install jvm.long-reflection (new-primitive-array-handler jvm.long)) + (bundle.install jvm.float-reflection (new-primitive-array-handler jvm.float)) + (bundle.install jvm.double-reflection (new-primitive-array-handler jvm.double)) + (bundle.install jvm.char-reflection (new-primitive-array-handler jvm.char)) (bundle.install "object" array::new::object)))) (dictionary.merge (<| (bundle.prefix "read") (|> bundle.empty - (bundle.install "boolean" (read-primitive-array-handler jvm.boolean _.BALOAD)) - (bundle.install "byte" (read-primitive-array-handler jvm.byte _.BALOAD)) - (bundle.install "short" (read-primitive-array-handler jvm.short _.SALOAD)) - (bundle.install "int" (read-primitive-array-handler jvm.int _.IALOAD)) - (bundle.install "long" (read-primitive-array-handler jvm.long _.LALOAD)) - (bundle.install "float" (read-primitive-array-handler jvm.float _.FALOAD)) - (bundle.install "double" (read-primitive-array-handler jvm.double _.DALOAD)) - (bundle.install "char" (read-primitive-array-handler jvm.char _.CALOAD)) + (bundle.install jvm.boolean-reflection (read-primitive-array-handler jvm.boolean _.BALOAD)) + (bundle.install jvm.byte-reflection (read-primitive-array-handler jvm.byte _.BALOAD)) + (bundle.install jvm.short-reflection (read-primitive-array-handler jvm.short _.SALOAD)) + (bundle.install jvm.int-reflection (read-primitive-array-handler jvm.int _.IALOAD)) + (bundle.install jvm.long-reflection (read-primitive-array-handler jvm.long _.LALOAD)) + (bundle.install jvm.float-reflection (read-primitive-array-handler jvm.float _.FALOAD)) + (bundle.install jvm.double-reflection (read-primitive-array-handler jvm.double _.DALOAD)) + (bundle.install jvm.char-reflection (read-primitive-array-handler jvm.char _.CALOAD)) (bundle.install "object" array::read::object)))) (dictionary.merge (<| (bundle.prefix "write") (|> bundle.empty - (bundle.install "boolean" (write-primitive-array-handler jvm.boolean _.BASTORE)) - (bundle.install "byte" (write-primitive-array-handler jvm.byte _.BASTORE)) - (bundle.install "short" (write-primitive-array-handler jvm.short _.SASTORE)) - (bundle.install "int" (write-primitive-array-handler jvm.int _.IASTORE)) - (bundle.install "long" (write-primitive-array-handler jvm.long _.LASTORE)) - (bundle.install "float" (write-primitive-array-handler jvm.float _.FASTORE)) - (bundle.install "double" (write-primitive-array-handler jvm.double _.DASTORE)) - (bundle.install "char" (write-primitive-array-handler jvm.char _.CASTORE)) + (bundle.install jvm.boolean-reflection (write-primitive-array-handler jvm.boolean _.BASTORE)) + (bundle.install jvm.byte-reflection (write-primitive-array-handler jvm.byte _.BASTORE)) + (bundle.install jvm.short-reflection (write-primitive-array-handler jvm.short _.SASTORE)) + (bundle.install jvm.int-reflection (write-primitive-array-handler jvm.int _.IASTORE)) + (bundle.install jvm.long-reflection (write-primitive-array-handler jvm.long _.LASTORE)) + (bundle.install jvm.float-reflection (write-primitive-array-handler jvm.float _.FASTORE)) + (bundle.install jvm.double-reflection (write-primitive-array-handler jvm.double _.DASTORE)) + (bundle.install jvm.char-reflection (write-primitive-array-handler jvm.char _.CASTORE)) (bundle.install "object" array::write::object)))) ))) @@ -563,19 +563,19 @@ (case [from to] ## Wrap (^template [<primitive> <object> <type>] - [<primitive> <object>] + (^ [(static <primitive>) (static <object>)]) (wrap (|>> valueI (_.wrap <type>))) - [<object> <primitive>] + (^ [(static <object>) (static <primitive>)]) (wrap (|>> valueI (_.unwrap <type>)))) - (["boolean" "java.lang.Boolean" #jvm.Boolean] - ["byte" "java.lang.Byte" #jvm.Byte] - ["short" "java.lang.Short" #jvm.Short] - ["int" "java.lang.Integer" #jvm.Int] - ["long" "java.lang.Long" #jvm.Long] - ["float" "java.lang.Float" #jvm.Float] - ["double" "java.lang.Double" #jvm.Double] - ["char" "java.lang.Character" #jvm.Char]) + ([jvm.boolean-reflection jvm.boolean-box #jvm.Boolean] + [jvm.byte-reflection jvm.byte-box #jvm.Byte] + [jvm.short-reflection jvm.short-box #jvm.Short] + [jvm.int-reflection jvm.int-box #jvm.Int] + [jvm.long-reflection jvm.long-box #jvm.Long] + [jvm.float-reflection jvm.float-box #jvm.Float] + [jvm.double-reflection jvm.double-box #jvm.Double] + [jvm.char-reflection jvm.char-box #jvm.Char]) _ (wrap valueI))) @@ -598,14 +598,14 @@ (def: primitives (Dictionary Text Primitive) - (|> (list ["boolean" #jvm.Boolean] - ["byte" #jvm.Byte] - ["short" #jvm.Short] - ["int" #jvm.Int] - ["long" #jvm.Long] - ["float" #jvm.Float] - ["double" #jvm.Double] - ["char" #jvm.Char]) + (|> (list [jvm.boolean-reflection #jvm.Boolean] + [jvm.byte-reflection #jvm.Byte] + [jvm.short-reflection #jvm.Short] + [jvm.int-reflection #jvm.Int] + [jvm.long-reflection #jvm.Long] + [jvm.float-reflection #jvm.Float] + [jvm.double-reflection #jvm.Double] + [jvm.char-reflection #jvm.Char]) (dictionary.from-list text.hash))) (def: (static::get extension-name generate inputs) @@ -841,14 +841,14 @@ (def: primitive (<s>.Parser Primitive) ($_ <>.or - (<s>.constant! ["" "boolean"]) - (<s>.constant! ["" "byte"]) - (<s>.constant! ["" "short"]) - (<s>.constant! ["" "int"]) - (<s>.constant! ["" "long"]) - (<s>.constant! ["" "float"]) - (<s>.constant! ["" "double"]) - (<s>.constant! ["" "char"]) + (<s>.constant! ["" jvm.boolean-reflection]) + (<s>.constant! ["" jvm.byte-reflection]) + (<s>.constant! ["" jvm.short-reflection]) + (<s>.constant! ["" jvm.int-reflection]) + (<s>.constant! ["" jvm.long-reflection]) + (<s>.constant! ["" jvm.float-reflection]) + (<s>.constant! ["" jvm.double-reflection]) + (<s>.constant! ["" jvm.char-reflection]) )) (def: jvm-type |