aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/generator/host/jvm/inst.lux
diff options
context:
space:
mode:
Diffstat (limited to 'new-luxc/source/luxc/generator/host/jvm/inst.lux')
-rw-r--r--new-luxc/source/luxc/generator/host/jvm/inst.lux151
1 files changed, 138 insertions, 13 deletions
diff --git a/new-luxc/source/luxc/generator/host/jvm/inst.lux b/new-luxc/source/luxc/generator/host/jvm/inst.lux
index f340be055..82b360883 100644
--- a/new-luxc/source/luxc/generator/host/jvm/inst.lux
+++ b/new-luxc/source/luxc/generator/host/jvm/inst.lux
@@ -18,25 +18,80 @@
(#static T_INT int)
(#static T_LONG int)
+ (#static CHECKCAST int)
+ (#static NEW int)
+ (#static NEWARRAY int)
+ (#static ANEWARRAY int)
+
(#static DUP int)
- (#static RETURN int)
- (#static ARETURN int)
+ (#static DUP2_X1 int)
+ (#static POP int)
+ (#static POP2 int)
+
+ (#static IF_ICMPEQ int)
+ (#static IF_ACMPEQ int)
+ (#static IFNULL int)
+ (#static GOTO int)
+
(#static ACONST_NULL int)
+
(#static ILOAD int)
(#static ALOAD int)
- (#static NEWARRAY int)
- (#static ANEWARRAY int)
+
+ (#static IADD int)
+
+ (#static LAND int)
+ (#static LOR int)
+ (#static LXOR int)
+ (#static LSHL int)
+ (#static LSHR int)
+ (#static LUSHR int)
+
+ (#static LADD int)
+ (#static LSUB int)
+ (#static LMUL int)
+ (#static LDIV int)
+ (#static LREM int)
+ (#static LCMP int)
+
+ (#static DADD int)
+ (#static DSUB int)
+ (#static DMUL int)
+ (#static DDIV int)
+ (#static DREM int)
+ (#static DCMPG int)
+
+ (#static I2L int)
+ (#static L2I int)
+ (#static L2D int)
+ (#static D2L int)
+ (#static I2C int)
+
+ (#static AALOAD int)
(#static AASTORE int)
+ (#static ARRAYLENGTH int)
+
+ (#static GETSTATIC int)
(#static PUTSTATIC int)
(#static GETFIELD int)
+ (#static PUTFIELD int)
+
(#static INVOKESTATIC int)
- (#static INVOKEVIRTUAL int)
(#static INVOKESPECIAL int)
- (#static CHECKCAST int))
+ (#static INVOKEVIRTUAL int)
+
+ (#static ATHROW int)
+
+ (#static RETURN int)
+ (#static ARETURN int)
+ )
(jvm-import org.objectweb.asm.FieldVisitor
(visitEnd [] void))
+(jvm-import org.objectweb.asm.Label
+ (new []))
+
(jvm-import org.objectweb.asm.MethodVisitor
(visitCode [] void)
(visitMaxs [int int] void)
@@ -47,9 +102,15 @@
(visitTypeInsn [int String] void)
(visitVarInsn [int int] void)
(visitIntInsn [int int] void)
- (visitMethodInsn [int String String String boolean] void))
+ (visitMethodInsn [int String String String boolean] void)
+ (visitLabel [Label] void)
+ (visitJumpInsn [int Label] void))
## [Insts]
+(def: #export (with-label action)
+ (-> (-> Label $;Inst) $;Inst)
+ (action (Label.new [])))
+
(do-template [<name> <type> <prepare>]
[(def: #export (<name> value)
(-> <type> $;Inst)
@@ -72,11 +133,50 @@
(do-to visitor
(MethodVisitor.visitInsn [<inst>]))))]
- [RETURN Opcodes.RETURN]
- [ARETURN Opcodes.ARETURN]
- [NULL Opcodes.ACONST_NULL]
- [DUP Opcodes.DUP]
- [AASTORE Opcodes.AASTORE]
+ [DUP Opcodes.DUP]
+ [DUP2_X1 Opcodes.DUP2_X1]
+ [POP Opcodes.POP]
+ [POP2 Opcodes.POP2]
+
+ [NULL Opcodes.ACONST_NULL]
+
+ [IADD Opcodes.IADD]
+
+ [LAND Opcodes.LAND]
+ [LOR Opcodes.LOR]
+ [LXOR Opcodes.LXOR]
+ [LSHL Opcodes.LSHL]
+ [LSHR Opcodes.LSHR]
+ [LUSHR Opcodes.LUSHR]
+
+ [LADD Opcodes.LADD]
+ [LSUB Opcodes.LSUB]
+ [LMUL Opcodes.LMUL]
+ [LDIV Opcodes.LDIV]
+ [LREM Opcodes.LREM]
+ [LCMP Opcodes.LCMP]
+
+ [DADD Opcodes.DADD]
+ [DSUB Opcodes.DSUB]
+ [DMUL Opcodes.DMUL]
+ [DDIV Opcodes.DDIV]
+ [DREM Opcodes.DREM]
+ [DCMPG Opcodes.DCMPG]
+
+ [I2L Opcodes.I2L]
+ [L2I Opcodes.L2I]
+ [L2D Opcodes.L2D]
+ [D2L Opcodes.D2L]
+ [I2C Opcodes.I2C]
+
+ [AALOAD Opcodes.AALOAD]
+ [AASTORE Opcodes.AASTORE]
+ [ARRAYLENGTH Opcodes.ARRAYLENGTH]
+
+ [ATHROW Opcodes.ATHROW]
+
+ [RETURN Opcodes.RETURN]
+ [ARETURN Opcodes.ARETURN]
)
(do-template [<name> <inst>]
@@ -97,7 +197,11 @@
(do-to visitor
(MethodVisitor.visitFieldInsn [<inst> ($t;binary-name class) field ($t;descriptor type)]))))]
+ [GETSTATIC Opcodes.GETSTATIC]
[PUTSTATIC Opcodes.PUTSTATIC]
+
+ [PUTFIELD Opcodes.PUTFIELD]
+ [GETFIELD Opcodes.GETFIELD]
)
(do-template [<name> <inst>]
@@ -107,8 +211,9 @@
(do-to visitor
(MethodVisitor.visitTypeInsn [<inst> ($t;binary-name class)]))))]
- [ANEWARRAY Opcodes.ANEWARRAY]
[CHECKCAST Opcodes.CHECKCAST]
+ [NEW Opcodes.NEW]
+ [ANEWARRAY Opcodes.ANEWARRAY]
)
(def: #export (NEWARRAY type)
@@ -134,8 +239,28 @@
[INVOKESTATIC Opcodes.INVOKESTATIC]
[INVOKEVIRTUAL Opcodes.INVOKEVIRTUAL]
+ [INVOKESPECIAL Opcodes.INVOKESPECIAL]
)
+(do-template [<name> <inst>]
+ [(def: #export (<name> @where)
+ (-> $;Label $;Inst)
+ (function [visitor]
+ (do-to visitor
+ (MethodVisitor.visitJumpInsn [<inst> @where]))))]
+
+ [IF_ICMPEQ Opcodes.IF_ICMPEQ]
+ [IF_ACMPEQ Opcodes.IF_ACMPEQ]
+ [IFNULL Opcodes.IFNULL]
+ [GOTO Opcodes.GOTO]
+ )
+
+(def: #export (label @label)
+ (-> $;Label $;Inst)
+ (function [visitor]
+ (do-to visitor
+ (MethodVisitor.visitLabel [@label]))))
+
(def: #export (array type size)
(-> $;Type Nat $;Inst)
(case type