aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lux/analyser.clj12
-rw-r--r--src/lux/analyser/base.clj5
-rw-r--r--src/lux/analyser/host.clj41
-rw-r--r--src/lux/compiler.clj12
-rw-r--r--src/lux/compiler/host.clj29
-rw-r--r--src/lux/optimizer.clj19
-rw-r--r--src/lux/type.clj4
7 files changed, 91 insertions, 31 deletions
diff --git a/src/lux/analyser.clj b/src/lux/analyser.clj
index d4b90cc3a..80c8ef2ec 100644
--- a/src/lux/analyser.clj
+++ b/src/lux/analyser.clj
@@ -300,6 +300,18 @@
(&/$FormS (&/$Cons [_ (&/$SymbolS _ "_jvm_l2i")] (&/$Cons ?value (&/$Nil))))
(&&host/analyse-jvm-l2i analyse exo-type ?value)
+ (&/$FormS (&/$Cons [_ (&/$SymbolS _ "_jvm_c2b")] (&/$Cons ?value (&/$Nil))))
+ (&&host/analyse-jvm-c2b analyse exo-type ?value)
+
+ (&/$FormS (&/$Cons [_ (&/$SymbolS _ "_jvm_c2s")] (&/$Cons ?value (&/$Nil))))
+ (&&host/analyse-jvm-c2s analyse exo-type ?value)
+
+ (&/$FormS (&/$Cons [_ (&/$SymbolS _ "_jvm_c2i")] (&/$Cons ?value (&/$Nil))))
+ (&&host/analyse-jvm-c2i analyse exo-type ?value)
+
+ (&/$FormS (&/$Cons [_ (&/$SymbolS _ "_jvm_c2l")] (&/$Cons ?value (&/$Nil))))
+ (&&host/analyse-jvm-c2l analyse exo-type ?value)
+
_
(aba6 analyse eval! compile-module compile-token exo-type token)))
diff --git a/src/lux/analyser/base.clj b/src/lux/analyser/base.clj
index 7634ce74b..130f238da 100644
--- a/src/lux/analyser/base.clj
+++ b/src/lux/analyser/base.clj
@@ -136,6 +136,11 @@
("jvm-l2f" 1)
("jvm-l2i" 1)
+ ("jvm-c2b" 1)
+ ("jvm-c2s" 1)
+ ("jvm-c2i" 1)
+ ("jvm-c2l" 1)
+
("jvm-iand" 1)
("jvm-ior" 1)
("jvm-ixor" 1)
diff --git a/src/lux/analyser/host.clj b/src/lux/analyser/host.clj
index 18b4a9dd6..c4b77cfdd 100644
--- a/src/lux/analyser/host.clj
+++ b/src/lux/analyser/host.clj
@@ -833,24 +833,29 @@
_cursor &/cursor]
(return (&/|list (&&/|meta output-type _cursor (<tag> =value)))))))
- analyse-jvm-d2f &&/$jvm-d2f "java.lang.Double" "java.lang.Float"
- analyse-jvm-d2i &&/$jvm-d2i "java.lang.Double" "java.lang.Integer"
- analyse-jvm-d2l &&/$jvm-d2l "java.lang.Double" "java.lang.Long"
-
- analyse-jvm-f2d &&/$jvm-f2d "java.lang.Float" "java.lang.Double"
- analyse-jvm-f2i &&/$jvm-f2i "java.lang.Float" "java.lang.Integer"
- analyse-jvm-f2l &&/$jvm-f2l "java.lang.Float" "java.lang.Long"
-
- analyse-jvm-i2b &&/$jvm-i2b "java.lang.Integer" "java.lang.Byte"
- analyse-jvm-i2c &&/$jvm-i2c "java.lang.Integer" "java.lang.Character"
- analyse-jvm-i2d &&/$jvm-i2d "java.lang.Integer" "java.lang.Double"
- analyse-jvm-i2f &&/$jvm-i2f "java.lang.Integer" "java.lang.Float"
- analyse-jvm-i2l &&/$jvm-i2l "java.lang.Integer" "java.lang.Long"
- analyse-jvm-i2s &&/$jvm-i2s "java.lang.Integer" "java.lang.Short"
-
- analyse-jvm-l2d &&/$jvm-l2d "java.lang.Long" "java.lang.Double"
- analyse-jvm-l2f &&/$jvm-l2f "java.lang.Long" "java.lang.Float"
- analyse-jvm-l2i &&/$jvm-l2i "java.lang.Long" "java.lang.Integer"
+ analyse-jvm-d2f &&/$jvm-d2f "java.lang.Double" "java.lang.Float"
+ analyse-jvm-d2i &&/$jvm-d2i "java.lang.Double" "java.lang.Integer"
+ analyse-jvm-d2l &&/$jvm-d2l "java.lang.Double" "java.lang.Long"
+
+ analyse-jvm-f2d &&/$jvm-f2d "java.lang.Float" "java.lang.Double"
+ analyse-jvm-f2i &&/$jvm-f2i "java.lang.Float" "java.lang.Integer"
+ analyse-jvm-f2l &&/$jvm-f2l "java.lang.Float" "java.lang.Long"
+
+ analyse-jvm-i2b &&/$jvm-i2b "java.lang.Integer" "java.lang.Byte"
+ analyse-jvm-i2c &&/$jvm-i2c "java.lang.Integer" "java.lang.Character"
+ analyse-jvm-i2d &&/$jvm-i2d "java.lang.Integer" "java.lang.Double"
+ analyse-jvm-i2f &&/$jvm-i2f "java.lang.Integer" "java.lang.Float"
+ analyse-jvm-i2l &&/$jvm-i2l "java.lang.Integer" "java.lang.Long"
+ analyse-jvm-i2s &&/$jvm-i2s "java.lang.Integer" "java.lang.Short"
+
+ analyse-jvm-l2d &&/$jvm-l2d "java.lang.Long" "java.lang.Double"
+ analyse-jvm-l2f &&/$jvm-l2f "java.lang.Long" "java.lang.Float"
+ analyse-jvm-l2i &&/$jvm-l2i "java.lang.Long" "java.lang.Integer"
+
+ analyse-jvm-c2b &&/$jvm-c2b "java.lang.Character" "java.lang.Byte"
+ analyse-jvm-c2s &&/$jvm-c2s "java.lang.Character" "java.lang.Short"
+ analyse-jvm-c2i &&/$jvm-c2i "java.lang.Character" "java.lang.Integer"
+ analyse-jvm-c2l &&/$jvm-c2l "java.lang.Character" "java.lang.Long"
)
(do-template [<name> <tag> <from-class> <to-class>]
diff --git a/src/lux/compiler.clj b/src/lux/compiler.clj
index 885344e37..ec8786ecc 100644
--- a/src/lux/compiler.clj
+++ b/src/lux/compiler.clj
@@ -378,6 +378,18 @@
(&o/$jvm-l2i ?value)
(&&host/compile-jvm-l2i compile-expression ?value)
+ (&o/$jvm-c2b ?value)
+ (&&host/compile-jvm-c2b compile-expression ?value)
+
+ (&o/$jvm-c2s ?value)
+ (&&host/compile-jvm-c2s compile-expression ?value)
+
+ (&o/$jvm-c2i ?value)
+ (&&host/compile-jvm-c2i compile-expression ?value)
+
+ (&o/$jvm-c2l ?value)
+ (&&host/compile-jvm-c2l compile-expression ?value)
+
(&o/$jvm-iand ?x ?y)
(&&host/compile-jvm-iand compile-expression ?x ?y)
diff --git a/src/lux/compiler/host.clj b/src/lux/compiler/host.clj
index ebac433f2..05080c3ed 100644
--- a/src/lux/compiler/host.clj
+++ b/src/lux/compiler/host.clj
@@ -140,11 +140,11 @@
(defn <name> [compile ?x ?y]
(|do [:let [+wrapper-class+ (&host-generics/->bytecode-class-name <wrapper-class>)]
^MethodVisitor *writer* &/get-writer
- _ (compile ?y)
+ _ (compile ?x)
:let [_ (doto *writer*
(.visitTypeInsn Opcodes/CHECKCAST +wrapper-class+)
(.visitMethodInsn Opcodes/INVOKEVIRTUAL +wrapper-class+ <value-method> <value-method-sig>))]
- _ (compile ?x)
+ _ (compile ?y)
:let [_ (doto *writer*
(.visitTypeInsn Opcodes/CHECKCAST +wrapper-class+)
(.visitMethodInsn Opcodes/INVOKEVIRTUAL +wrapper-class+ <value-method> <value-method-sig>))
@@ -152,10 +152,10 @@
$end (new Label)
_ (doto *writer*
(.visitJumpInsn <opcode> $then)
- (.visitFieldInsn Opcodes/GETSTATIC (&host-generics/->bytecode-class-name "java.lang.Boolean") "TRUE" (&host-generics/->type-signature "java.lang.Boolean"))
+ (.visitFieldInsn Opcodes/GETSTATIC (&host-generics/->bytecode-class-name "java.lang.Boolean") "FALSE" (&host-generics/->type-signature "java.lang.Boolean"))
(.visitJumpInsn Opcodes/GOTO $end)
(.visitLabel $then)
- (.visitFieldInsn Opcodes/GETSTATIC (&host-generics/->bytecode-class-name "java.lang.Boolean") "FALSE" (&host-generics/->type-signature "java.lang.Boolean"))
+ (.visitFieldInsn Opcodes/GETSTATIC (&host-generics/->bytecode-class-name "java.lang.Boolean") "TRUE" (&host-generics/->type-signature "java.lang.Boolean"))
(.visitLabel $end))]]
(return nil)))
@@ -172,11 +172,11 @@
(defn <name> [compile ?x ?y]
(|do [:let [+wrapper-class+ (&host-generics/->bytecode-class-name <wrapper-class>)]
^MethodVisitor *writer* &/get-writer
- _ (compile ?y)
+ _ (compile ?x)
:let [_ (doto *writer*
(.visitTypeInsn Opcodes/CHECKCAST +wrapper-class+)
(.visitMethodInsn Opcodes/INVOKEVIRTUAL +wrapper-class+ <value-method> <value-method-sig>))]
- _ (compile ?x)
+ _ (compile ?y)
:let [_ (doto *writer*
(.visitTypeInsn Opcodes/CHECKCAST +wrapper-class+)
(.visitMethodInsn Opcodes/INVOKEVIRTUAL +wrapper-class+ <value-method> <value-method-sig>))
@@ -194,16 +194,16 @@
(return nil)))
compile-jvm-leq Opcodes/LCMP 0 "java.lang.Long" "longValue" "()J"
- compile-jvm-llt Opcodes/LCMP 1 "java.lang.Long" "longValue" "()J"
- compile-jvm-lgt Opcodes/LCMP -1 "java.lang.Long" "longValue" "()J"
+ compile-jvm-llt Opcodes/LCMP -1 "java.lang.Long" "longValue" "()J"
+ compile-jvm-lgt Opcodes/LCMP 1 "java.lang.Long" "longValue" "()J"
compile-jvm-feq Opcodes/FCMPG 0 "java.lang.Float" "floatValue" "()F"
- compile-jvm-flt Opcodes/FCMPG 1 "java.lang.Float" "floatValue" "()F"
- compile-jvm-fgt Opcodes/FCMPG -1 "java.lang.Float" "floatValue" "()F"
+ compile-jvm-flt Opcodes/FCMPG -1 "java.lang.Float" "floatValue" "()F"
+ compile-jvm-fgt Opcodes/FCMPG 1 "java.lang.Float" "floatValue" "()F"
compile-jvm-deq Opcodes/DCMPG 0 "java.lang.Double" "doubleValue" "()D"
- compile-jvm-dlt Opcodes/DCMPG 1 "java.lang.Double" "doubleValue" "()D"
- compile-jvm-dgt Opcodes/FCMPG -1 "java.lang.Double" "doubleValue" "()D"
+ compile-jvm-dlt Opcodes/DCMPG -1 "java.lang.Double" "doubleValue" "()D"
+ compile-jvm-dgt Opcodes/FCMPG 1 "java.lang.Double" "doubleValue" "()D"
)
(defn compile-jvm-invokestatic [compile ?class ?method ?classes ?args ?output-type]
@@ -1084,6 +1084,11 @@
compile-jvm-l2d Opcodes/L2D "java.lang.Long" "longValue" "()J" "java.lang.Double" "(D)V"
compile-jvm-l2f Opcodes/L2F "java.lang.Long" "longValue" "()J" "java.lang.Float" "(F)V"
compile-jvm-l2i Opcodes/L2I "java.lang.Long" "longValue" "()J" "java.lang.Integer" "(I)V"
+
+ compile-jvm-c2b Opcodes/I2B "java.lang.Character" "charValue" "()C" "java.lang.Byte" "(B)V"
+ compile-jvm-c2s Opcodes/I2S "java.lang.Character" "charValue" "()C" "java.lang.Short" "(S)V"
+ compile-jvm-c2i Opcodes/NOP "java.lang.Character" "charValue" "()C" "java.lang.Integer" "(I)V"
+ compile-jvm-c2l Opcodes/I2L "java.lang.Character" "charValue" "()C" "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>]
diff --git a/src/lux/optimizer.clj b/src/lux/optimizer.clj
index 8f4625c6b..48db1e2cf 100644
--- a/src/lux/optimizer.clj
+++ b/src/lux/optimizer.clj
@@ -135,6 +135,11 @@
("jvm-l2f" 1)
("jvm-l2i" 1)
+ ("jvm-c2b" 1)
+ ("jvm-c2s" 1)
+ ("jvm-c2i" 1)
+ ("jvm-c2l" 1)
+
("jvm-iand" 1)
("jvm-ior" 1)
("jvm-ixor" 1)
@@ -490,7 +495,19 @@
(&-base/$jvm-l2i value)
(return ($jvm-l2i value))
-
+
+ (&-base/$jvm-c2b value)
+ (return ($jvm-c2b value))
+
+ (&-base/$jvm-c2s value)
+ (return ($jvm-c2s value))
+
+ (&-base/$jvm-c2i value)
+ (return ($jvm-c2i value))
+
+ (&-base/$jvm-c2l value)
+ (return ($jvm-c2l value))
+
(&-base/$jvm-iand value)
(return ($jvm-iand value))
diff --git a/src/lux/type.clj b/src/lux/type.clj
index 224308f0f..b09db681d 100644
--- a/src/lux/type.clj
+++ b/src/lux/type.clj
@@ -576,6 +576,10 @@
(&/$ExT id)
(return (&/$AppT type-fn param))
+
+ (&/$VarT id)
+ (|do [=type-fun (deref id)]
+ (apply-type =type-fun param))
_
(fail (str "[Type System] Not a type function:\n" (show-type type-fn) "\n"))))