diff options
author | Eduardo Julian | 2016-09-23 18:50:07 -0400 |
---|---|---|
committer | Eduardo Julian | 2016-09-23 18:50:07 -0400 |
commit | 757fecf16811f10ad83752b592987202f9dbc5d2 (patch) | |
tree | 24a639a36023bc6e351bc62f6a8137e14936dd42 | |
parent | 344110bb2a2b22ab593abb40bf8f7a18119e14a6 (diff) |
- Added conversions between byte/short and long.
- Also added conversions between Char and Nat.
-rw-r--r-- | src/lux/analyser/host.clj | 22 | ||||
-rw-r--r-- | src/lux/compiler/host.clj | 64 |
2 files changed, 61 insertions, 25 deletions
diff --git a/src/lux/analyser/host.clj b/src/lux/analyser/host.clj index c444006c3..19971d95a 100644 --- a/src/lux/analyser/host.clj +++ b/src/lux/analyser/host.clj @@ -465,11 +465,17 @@ ^:private analyse-jvm-l2d "l2d" "java.lang.Long" "java.lang.Double" ^:private analyse-jvm-l2f "l2f" "java.lang.Long" "java.lang.Float" ^:private analyse-jvm-l2i "l2i" "java.lang.Long" "java.lang.Integer" + ^:private analyse-jvm-l2s "l2i" "java.lang.Long" "java.lang.Short" + ^:private analyse-jvm-l2b "l2i" "java.lang.Long" "java.lang.Byte" ^:private analyse-jvm-c2b "c2b" "java.lang.Character" "java.lang.Byte" ^:private analyse-jvm-c2s "c2s" "java.lang.Character" "java.lang.Short" ^:private analyse-jvm-c2i "c2i" "java.lang.Character" "java.lang.Integer" ^:private analyse-jvm-c2l "c2l" "java.lang.Character" "java.lang.Long" + + ^:private analyse-jvm-s2l "s2l" "java.lang.Short" "java.lang.Long" + + ^:private analyse-jvm-b2l "b2l" "java.lang.Byte" "java.lang.Long" ) (do-template [<name> <proc> <v1-class> <v2-class> <to-class>] @@ -1111,8 +1117,10 @@ (return (&/|list (&&/|meta <to-type> _cursor (&&/$proc (&/T <op>) (&/|list =x) (&/|list))))))) - ^:private analyse-nat-to-int &type/Nat &type/Int ["nat" "to-int"] - ^:private analyse-int-to-nat &type/Int &type/Nat ["int" "to-nat"] + ^:private analyse-nat-to-int &type/Nat &type/Int ["nat" "to-int"] + ^:private analyse-nat-to-char &type/Nat &type/Char ["nat" "to-char"] + ^:private analyse-int-to-nat &type/Int &type/Nat ["int" "to-nat"] + ^:private analyse-char-to-nat &type/Char &type/Nat ["char" "to-nat"] ) (defn analyse-host [analyse exo-type compilers category proc ?values] @@ -1154,12 +1162,18 @@ "min-value" (analyse-nat-min-value analyse exo-type ?values) "max-value" (analyse-nat-max-value analyse exo-type ?values) "to-int" (analyse-nat-to-int analyse exo-type ?values) + "to-char" (analyse-nat-to-char analyse exo-type ?values) ) "int" (case proc "to-nat" (analyse-int-to-nat analyse exo-type ?values) ) + + "char" + (case proc + "to-nat" (analyse-char-to-nat analyse exo-type ?values) + ) "jvm" (case proc @@ -1244,10 +1258,14 @@ "l2d" (analyse-jvm-l2d analyse exo-type ?values) "l2f" (analyse-jvm-l2f analyse exo-type ?values) "l2i" (analyse-jvm-l2i analyse exo-type ?values) + "l2s" (analyse-jvm-l2s analyse exo-type ?values) + "l2b" (analyse-jvm-l2b analyse exo-type ?values) "c2b" (analyse-jvm-c2b analyse exo-type ?values) "c2s" (analyse-jvm-c2s analyse exo-type ?values) "c2i" (analyse-jvm-c2i analyse exo-type ?values) "c2l" (analyse-jvm-c2l analyse exo-type ?values) + "b2l" (analyse-jvm-b2l analyse exo-type ?values) + "s2l" (analyse-jvm-s2l analyse exo-type ?values) ;; else (->> (&/fail-with-loc (str "[Analyser Error] Unknown host procedure: " [category proc])) (if-let [[_ _def-code] (re-find #"^interface:(.*)$" proc)] diff --git a/src/lux/compiler/host.clj b/src/lux/compiler/host.clj index b6cd643d6..e143ff92b 100644 --- a/src/lux/compiler/host.clj +++ b/src/lux/compiler/host.clj @@ -894,29 +894,35 @@ (.visitMethodInsn Opcodes/INVOKESPECIAL (&host-generics/->bytecode-class-name <to-class>) init-method <to-sig>))]] (return nil))) - ^:private compile-jvm-d2f Opcodes/D2F "java.lang.Double" "doubleValue" "()D" "java.lang.Float" "(F)V" - ^:private compile-jvm-d2i Opcodes/D2I "java.lang.Double" "doubleValue" "()D" "java.lang.Integer" "(I)V" - ^:private compile-jvm-d2l Opcodes/D2L "java.lang.Double" "doubleValue" "()D" "java.lang.Long" "(J)V" - - ^:private compile-jvm-f2d Opcodes/F2D "java.lang.Float" "floatValue" "()F" "java.lang.Double" "(D)V" - ^:private compile-jvm-f2i Opcodes/F2I "java.lang.Float" "floatValue" "()F" "java.lang.Integer" "(I)V" - ^:private compile-jvm-f2l Opcodes/F2L "java.lang.Float" "floatValue" "()F" "java.lang.Long" "(J)V" - - ^:private compile-jvm-i2b Opcodes/I2B "java.lang.Integer" "intValue" "()I" "java.lang.Byte" "(B)V" - ^:private compile-jvm-i2c Opcodes/I2C "java.lang.Integer" "intValue" "()I" "java.lang.Character" "(C)V" - ^:private compile-jvm-i2d Opcodes/I2D "java.lang.Integer" "intValue" "()I" "java.lang.Double" "(D)V" - ^:private compile-jvm-i2f Opcodes/I2F "java.lang.Integer" "intValue" "()I" "java.lang.Float" "(F)V" - ^:private compile-jvm-i2l Opcodes/I2L "java.lang.Integer" "intValue" "()I" "java.lang.Long" "(J)V" - ^:private compile-jvm-i2s Opcodes/I2S "java.lang.Integer" "intValue" "()I" "java.lang.Short" "(S)V" - - ^:private compile-jvm-l2d Opcodes/L2D "java.lang.Long" "longValue" "()J" "java.lang.Double" "(D)V" - ^:private compile-jvm-l2f Opcodes/L2F "java.lang.Long" "longValue" "()J" "java.lang.Float" "(F)V" - ^:private compile-jvm-l2i Opcodes/L2I "java.lang.Long" "longValue" "()J" "java.lang.Integer" "(I)V" - - ^:private compile-jvm-c2b Opcodes/I2B "java.lang.Character" "charValue" "()C" "java.lang.Byte" "(B)V" - ^:private compile-jvm-c2s Opcodes/I2S "java.lang.Character" "charValue" "()C" "java.lang.Short" "(S)V" - ^:private compile-jvm-c2i Opcodes/NOP "java.lang.Character" "charValue" "()C" "java.lang.Integer" "(I)V" - ^:private compile-jvm-c2l Opcodes/I2L "java.lang.Character" "charValue" "()C" "java.lang.Long" "(J)V" + ^:private compile-jvm-d2f Opcodes/D2F "java.lang.Double" "doubleValue" "()D" "java.lang.Float" "(F)V" + ^:private compile-jvm-d2i Opcodes/D2I "java.lang.Double" "doubleValue" "()D" "java.lang.Integer" "(I)V" + ^:private compile-jvm-d2l Opcodes/D2L "java.lang.Double" "doubleValue" "()D" "java.lang.Long" "(J)V" + + ^:private compile-jvm-f2d Opcodes/F2D "java.lang.Float" "floatValue" "()F" "java.lang.Double" "(D)V" + ^:private compile-jvm-f2i Opcodes/F2I "java.lang.Float" "floatValue" "()F" "java.lang.Integer" "(I)V" + ^:private compile-jvm-f2l Opcodes/F2L "java.lang.Float" "floatValue" "()F" "java.lang.Long" "(J)V" + + ^:private compile-jvm-i2b Opcodes/I2B "java.lang.Integer" "intValue" "()I" "java.lang.Byte" "(B)V" + ^:private compile-jvm-i2c Opcodes/I2C "java.lang.Integer" "intValue" "()I" "java.lang.Character" "(C)V" + ^:private compile-jvm-i2d Opcodes/I2D "java.lang.Integer" "intValue" "()I" "java.lang.Double" "(D)V" + ^:private compile-jvm-i2f Opcodes/I2F "java.lang.Integer" "intValue" "()I" "java.lang.Float" "(F)V" + ^:private compile-jvm-i2l Opcodes/I2L "java.lang.Integer" "intValue" "()I" "java.lang.Long" "(J)V" + ^:private compile-jvm-i2s Opcodes/I2S "java.lang.Integer" "intValue" "()I" "java.lang.Short" "(S)V" + + ^:private compile-jvm-l2d Opcodes/L2D "java.lang.Long" "longValue" "()J" "java.lang.Double" "(D)V" + ^:private compile-jvm-l2f Opcodes/L2F "java.lang.Long" "longValue" "()J" "java.lang.Float" "(F)V" + ^:private compile-jvm-l2i Opcodes/L2I "java.lang.Long" "longValue" "()J" "java.lang.Integer" "(I)V" + ^:private compile-jvm-l2s Opcodes/L2I "java.lang.Long" "longValue" "()J" "java.lang.Short" "(S)V" + ^:private compile-jvm-l2b Opcodes/L2I "java.lang.Long" "longValue" "()J" "java.lang.Byte" "(B)V" + + ^:private compile-jvm-c2b Opcodes/I2B "java.lang.Character" "charValue" "()C" "java.lang.Byte" "(B)V" + ^:private compile-jvm-c2s Opcodes/I2S "java.lang.Character" "charValue" "()C" "java.lang.Short" "(S)V" + ^:private compile-jvm-c2i Opcodes/NOP "java.lang.Character" "charValue" "()C" "java.lang.Integer" "(I)V" + ^:private compile-jvm-c2l Opcodes/I2L "java.lang.Character" "charValue" "()C" "java.lang.Long" "(J)V" + + ^:private compile-jvm-s2l Opcodes/I2L "java.lang.Short" "shortValue" "()S" "java.lang.Long" "(J)V" + + ^:private compile-jvm-b2l Opcodes/I2L "java.lang.Byte" "byteValue" "()B" "java.lang.Long" "(J)V" ) (do-template [<name> <op> <from1-method> <from1-sig> <from1-class> <from2-method> <from2-sig> <from2-class> <to-class> <to-sig>] @@ -1609,6 +1615,8 @@ ^:private compile-nat-to-int ^:private compile-int-to-nat + ^:private compile-nat-to-char + ^:private compile-char-to-nat ) (defn compile-host [compile proc-category proc-name ?values special-args] @@ -1645,12 +1653,18 @@ "max-value" (compile-nat-max-value compile ?values special-args) "min-value" (compile-nat-min-value compile ?values special-args) "to-int" (compile-nat-to-int compile ?values special-args) + "to-char" (compile-nat-to-char compile ?values special-args) ) "int" (case proc-name "to-nat" (compile-int-to-nat compile ?values special-args) ) + + "char" + (case proc-name + "to-nat" (compile-char-to-nat compile ?values special-args) + ) "jvm" (case proc-name @@ -1745,10 +1759,14 @@ "l2d" (compile-jvm-l2d compile ?values special-args) "l2f" (compile-jvm-l2f compile ?values special-args) "l2i" (compile-jvm-l2i compile ?values special-args) + "l2s" (compile-jvm-l2s compile ?values special-args) + "l2b" (compile-jvm-l2b compile ?values special-args) "c2b" (compile-jvm-c2b compile ?values special-args) "c2s" (compile-jvm-c2s compile ?values special-args) "c2i" (compile-jvm-c2i compile ?values special-args) "c2l" (compile-jvm-c2l compile ?values special-args) + "s2l" (compile-jvm-s2l compile ?values special-args) + "b2l" (compile-jvm-b2l compile ?values special-args) ;; else (fail (str "[Compiler Error] Unknown host procedure: " [proc-category proc-name]))) |