aboutsummaryrefslogtreecommitdiff
path: root/luxc
diff options
context:
space:
mode:
authorEduardo Julian2016-12-06 21:39:26 -0400
committerEduardo Julian2016-12-06 21:39:26 -0400
commit75a02fc2df03a21df044d35115ac72149524ca7a (patch)
tree84292b8de5f7e1f400641d7061ff6d5617d9b792 /luxc
parent3a32ba13ae6507c0b842853cc9a83fb443c2f480 (diff)
- Updated lux/host tests.
- Fixed a bug in the way the [jvm l2b] and [jvm l2s] procedures worked. - Fixed a bug in interface definition. - Relaxed the syntacting requirements of class/interface/anonymous-class definition macros.
Diffstat (limited to '')
-rw-r--r--luxc/src/lux/analyser/host.clj4
-rw-r--r--luxc/src/lux/analyser/parser.clj3
-rw-r--r--luxc/src/lux/compiler/host.clj22
3 files changed, 25 insertions, 4 deletions
diff --git a/luxc/src/lux/analyser/host.clj b/luxc/src/lux/analyser/host.clj
index 6aea46cab..6dd7f3da8 100644
--- a/luxc/src/lux/analyser/host.clj
+++ b/luxc/src/lux/analyser/host.clj
@@ -466,8 +466,8 @@
^: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-l2s "l2s" "java.lang.Long" "java.lang.Short"
+ ^:private analyse-jvm-l2b "l2b" "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"
diff --git a/luxc/src/lux/analyser/parser.clj b/luxc/src/lux/analyser/parser.clj
index e60f28a02..586806942 100644
--- a/luxc/src/lux/analyser/parser.clj
+++ b/luxc/src/lux/analyser/parser.clj
@@ -428,10 +428,13 @@
(def parse-interface-def
(|do [=gclass-decl parse-gclass-decl
+ _ _space_
=supers (with-brackets
(spaced parse-gclass-super))
+ _ _space_
=anns (with-brackets
(spaced parse-ann))
+ _ _space_
=methods (spaced parse-method-decl)]
(return (&/T [=gclass-decl =supers =anns =methods]))))
diff --git a/luxc/src/lux/compiler/host.clj b/luxc/src/lux/compiler/host.clj
index eccfef089..3d4172110 100644
--- a/luxc/src/lux/compiler/host.clj
+++ b/luxc/src/lux/compiler/host.clj
@@ -1523,8 +1523,6 @@
^: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"
@@ -1536,6 +1534,26 @@
^:private compile-jvm-b2l Opcodes/I2L "java.lang.Byte" "byteValue" "()B" "java.lang.Long" "(J)V"
)
+(do-template [<name> <op> <from-class> <from-method> <from-sig> <to-class> <to-sig>]
+ (defn <name> [compile _?value special-args]
+ (|do [:let [(&/$Cons ?value (&/$Nil)) _?value]
+ ^MethodVisitor *writer* &/get-writer
+ :let [_ (doto *writer*
+ (.visitTypeInsn Opcodes/NEW (&host-generics/->bytecode-class-name <to-class>))
+ (.visitInsn Opcodes/DUP))]
+ _ (compile ?value)
+ :let [_ (doto *writer*
+ (.visitTypeInsn Opcodes/CHECKCAST (&host-generics/->bytecode-class-name <from-class>))
+ (.visitMethodInsn Opcodes/INVOKEVIRTUAL (&host-generics/->bytecode-class-name <from-class>) <from-method> <from-sig>)
+ (.visitInsn Opcodes/L2I)
+ (.visitInsn <op>)
+ (.visitMethodInsn Opcodes/INVOKESPECIAL (&host-generics/->bytecode-class-name <to-class>) init-method <to-sig>))]]
+ (return nil)))
+
+ ^:private compile-jvm-l2s Opcodes/I2S "java.lang.Long" "longValue" "()J" "java.lang.Short" "(S)V"
+ ^:private compile-jvm-l2b Opcodes/I2B "java.lang.Long" "longValue" "()J" "java.lang.Byte" "(B)V"
+ )
+
(do-template [<name> <op> <from1-method> <from1-sig> <from1-class> <from2-method> <from2-sig> <from2-class> <to-class> <to-sig>]
(defn <name> [compile ?values special-args]
(|do [:let [(&/$Cons ?x (&/$Cons ?y (&/$Nil))) ?values]