List of usage examples for org.objectweb.asm.tree InsnList InsnList
InsnList
From source file:net.sandius.rembulan.compiler.gen.asm.BytecodeEmitVisitor.java
License:Apache License
private InsnList saveState(int state) { InsnList il = new InsnList(); il.add(ASMUtils.loadInt(state));/*from w ww . j a v a 2 s.co m*/ il.add(new VarInsnNode(ISTORE, runMethod.LV_RESUME)); return il; }
From source file:net.sandius.rembulan.compiler.gen.asm.BytecodeEmitVisitor.java
License:Apache License
private InsnList _return() { InsnList il = new InsnList(); if (!isSub()) { il.add(new InsnNode(RETURN)); } else {/*from w w w. j ava 2s. co m*/ il.add(new InsnNode(ACONST_NULL)); il.add(new InsnNode(ARETURN)); } return il; }
From source file:net.sandius.rembulan.compiler.gen.asm.BytecodeEmitVisitor.java
License:Apache License
private InsnList _nonLocalGoto(Label label) { InsnList il = new InsnList(); int st = resolver.labelStateIndex(label); il.add(saveState(st));/* w w w.jav a 2 s . c om*/ il.add(runMethod.createSnapshot()); il.add(new InsnNode(ARETURN)); return il; }
From source file:net.sandius.rembulan.compiler.gen.asm.BytecodeEmitVisitor.java
License:Apache License
private InsnList _goto(Label label) { InsnList il = new InsnList(); if (!isSub() || resolver.isLocalLabel(label)) { il.add(new JumpInsnNode(GOTO, l(label))); } else {//from ww w. j a v a2 s .co m il.add(_nonLocalGoto(label)); } return il; }
From source file:net.sandius.rembulan.compiler.gen.asm.BytecodeEmitVisitor.java
License:Apache License
private InsnList _next(Label label) { InsnList il = new InsnList(); if (!isSub() || resolver.isLocalLabel(label)) { // no-op//from w ww .j a va 2 s . c o m } else { il.add(_nonLocalGoto(label)); } return il; }
From source file:net.sandius.rembulan.compiler.gen.asm.helpers.BoxedPrimitivesMethods.java
License:Apache License
public static InsnList loadBoxedConstant(Object k, Class<?> castTo) { InsnList il = new InsnList(); if (k == null) { il.add(loadNull());// w w w. j a v a 2s .c o m } else if (k instanceof Boolean) { il.add(BoxedPrimitivesMethods.loadBoxedBoolean((Boolean) k)); } else if (k instanceof Double || k instanceof Float) { il.add(ASMUtils.loadDouble(((Number) k).doubleValue())); il.add(BoxedPrimitivesMethods.box(Type.DOUBLE_TYPE, Type.getType(Double.class))); } else if (k instanceof Number) { il.add(ASMUtils.loadLong(((Number) k).longValue())); il.add(BoxedPrimitivesMethods.box(Type.LONG_TYPE, Type.getType(Long.class))); } else if (k instanceof String) { il.add(new LdcInsnNode(k)); } else { throw new UnsupportedOperationException("Illegal constant type: " + k.getClass()); } if (castTo != null) { Objects.requireNonNull(k); if (!castTo.isAssignableFrom(k.getClass())) { il.add(new TypeInsnNode(CHECKCAST, Type.getInternalName(castTo))); } } return il; }
From source file:net.sandius.rembulan.compiler.gen.asm.helpers.ConversionMethods.java
License:Apache License
public static InsnList toNumericalValue(String what) { Objects.requireNonNull(what); InsnList il = new InsnList(); il.add(new LdcInsnNode(what)); il.add(new MethodInsnNode(INVOKESTATIC, Type.getInternalName(Conversions.class), "toNumericalValue", Type.getMethodDescriptor(Type.getType(Number.class), Type.getType(Object.class), Type.getType(String.class)), false));/* ww w.j a va 2s .com*/ return il; }
From source file:net.sandius.rembulan.compiler.gen.asm.helpers.ExecutionContextMethods.java
License:Apache License
public static InsnList newTable(int array, int hash) { InsnList il = new InsnList(); il.add(ASMUtils.loadInt(array));// w w w .j ava2 s. c o m il.add(ASMUtils.loadInt(hash)); il.add(new MethodInsnNode(INVOKEINTERFACE, selfTpe().getInternalName(), "newTable", Type.getMethodType(Type.getType(Table.class), Type.INT_TYPE, Type.INT_TYPE).getDescriptor(), true)); return il; }
From source file:net.sandius.rembulan.compiler.gen.asm.helpers.ReturnBufferMethods.java
License:Apache License
public static InsnList get(int index) { Check.nonNegative(index);//from ww w . j a v a 2 s . c om InsnList il = new InsnList(); if (index <= 4) { String methodName = "get" + index; il.add(new MethodInsnNode(INVOKEINTERFACE, selfTpe().getInternalName(), methodName, Type.getMethodType(Type.getType(Object.class)).getDescriptor(), true)); } else { il.add(ASMUtils.loadInt(index)); il.add(get()); } return il; }
From source file:net.sandius.rembulan.compiler.gen.asm.RunMethod.java
License:Apache License
private InsnList errorState(LabelNode label) { InsnList il = new InsnList(); il.add(label);//w ww . ja v a2 s .c om il.add(ASMUtils.frameSame()); il.add(new TypeInsnNode(NEW, Type.getInternalName(IllegalStateException.class))); il.add(new InsnNode(DUP)); il.add(ASMUtils.ctor(IllegalStateException.class)); il.add(new InsnNode(ATHROW)); return il; }