List of usage examples for org.objectweb.asm Opcodes T_DOUBLE
int T_DOUBLE
To view the source code for org.objectweb.asm Opcodes T_DOUBLE.
Click Source Link
From source file:edu.mit.streamjit.util.bytecode.MethodResolver.java
License:Open Source License
private void interpret(IntInsnNode insn, FrameState frame, BBInfo block) { int operand = insn.operand; switch (insn.getOpcode()) { case Opcodes.BIPUSH: case Opcodes.SIPUSH: frame.stack.push(module.constants().getSmallestIntConstant(insn.operand)); break;// ww w . ja v a 2 s. c om case Opcodes.NEWARRAY: ArrayType t; switch (operand) { case Opcodes.T_BOOLEAN: t = module.types().getArrayType(boolean[].class); break; case Opcodes.T_BYTE: t = module.types().getArrayType(byte[].class); break; case Opcodes.T_CHAR: t = module.types().getArrayType(char[].class); break; case Opcodes.T_SHORT: t = module.types().getArrayType(short[].class); break; case Opcodes.T_INT: t = module.types().getArrayType(int[].class); break; case Opcodes.T_LONG: t = module.types().getArrayType(long[].class); break; case Opcodes.T_FLOAT: t = module.types().getArrayType(float[].class); break; case Opcodes.T_DOUBLE: t = module.types().getArrayType(double[].class); break; default: throw new AssertionError(operand); } NewArrayInst i = new NewArrayInst(t, frame.stack.pop()); block.block.instructions().add(i); frame.stack.push(i); break; default: throw new UnsupportedOperationException("" + insn.getOpcode()); } }
From source file:edu.mit.streamjit.util.bytecode.MethodUnresolver.java
License:Open Source License
private void emit(NewArrayInst i, InsnList insns) { ArrayType t = i.getType();/*from w ww.j a va2s . com*/ if (t.getDimensions() == 1) { load(i.getOperand(0), insns); RegularType ct = t.getComponentType(); if (ct instanceof PrimitiveType) { if (ct.equals(booleanType)) insns.add(new IntInsnNode(Opcodes.NEWARRAY, Opcodes.T_BOOLEAN)); else if (ct.equals(byteType)) insns.add(new IntInsnNode(Opcodes.NEWARRAY, Opcodes.T_BYTE)); else if (ct.equals(charType)) insns.add(new IntInsnNode(Opcodes.NEWARRAY, Opcodes.T_CHAR)); else if (ct.equals(shortType)) insns.add(new IntInsnNode(Opcodes.NEWARRAY, Opcodes.T_SHORT)); else if (ct.equals(intType)) insns.add(new IntInsnNode(Opcodes.NEWARRAY, Opcodes.T_INT)); else if (ct.equals(longType)) insns.add(new IntInsnNode(Opcodes.NEWARRAY, Opcodes.T_LONG)); else if (ct.equals(floatType)) insns.add(new IntInsnNode(Opcodes.NEWARRAY, Opcodes.T_FLOAT)); else if (ct.equals(doubleType)) insns.add(new IntInsnNode(Opcodes.NEWARRAY, Opcodes.T_DOUBLE)); } else { insns.add(new TypeInsnNode(Opcodes.ANEWARRAY, internalName(ct.getKlass()))); } } else { for (Value v : i.operands()) load(v, insns); insns.add(new MultiANewArrayInsnNode(t.getDescriptor(), i.getNumOperands())); } store(i, insns); }
From source file:edu.ubc.mirrors.holograms.HologramMethodGenerator.java
License:Open Source License
@Override public void visitIntInsn(int opcode, int operand) { if (opcode == Opcodes.NEWARRAY) { // Wrap with an ArrayMirror Type elementType;/* w ww . j a va 2 s. com*/ switch (operand) { case Opcodes.T_BOOLEAN: elementType = Type.BOOLEAN_TYPE; break; case Opcodes.T_BYTE: elementType = Type.BYTE_TYPE; break; case Opcodes.T_CHAR: elementType = Type.CHAR_TYPE; break; case Opcodes.T_SHORT: elementType = Type.SHORT_TYPE; break; case Opcodes.T_INT: elementType = Type.INT_TYPE; break; case Opcodes.T_LONG: elementType = Type.LONG_TYPE; break; case Opcodes.T_FLOAT: elementType = Type.FLOAT_TYPE; break; case Opcodes.T_DOUBLE: elementType = Type.DOUBLE_TYPE; break; default: throw new IllegalArgumentException("Unknown type number: " + operand); } getClassMirror(elementType); swap(); invokeinterface(classMirrorType.getInternalName(), "newArray", Type.getMethodDescriptor(Type.getType(ArrayMirror.class), Type.INT_TYPE)); String arrayHologramType = "edu/ubc/mirrors/holograms/" + getSortName(elementType.getSort()) + "ArrayHologram"; invokestatic(objectHologramType.getInternalName(), "make", Type.getMethodDescriptor(hologramType, objectMirrorType)); checkcast(Type.getObjectType(arrayHologramType)); return; } super.visitIntInsn(opcode, operand); }
From source file:org.adjective.stout.operation.CreateArrayExpression.java
License:Apache License
public static int getTypeCode(Class<?> type) { if (type == Character.TYPE) { return Opcodes.T_CHAR; }/* ww w .j a va2s. c om*/ if (type == Byte.TYPE) { return Opcodes.T_BYTE; } if (type == Integer.TYPE) { return Opcodes.T_INT; } if (type == Boolean.TYPE) { return Opcodes.T_BOOLEAN; } if (type == Short.TYPE) { return Opcodes.T_SHORT; } if (type == Long.TYPE) { return Opcodes.T_LONG; } if (type == Float.TYPE) { return Opcodes.T_FLOAT; } if (type == Double.TYPE) { return Opcodes.T_DOUBLE; } throw new IllegalArgumentException("Not a primitive " + type); }
From source file:org.jacoco.core.internal.instr.FrameTracker.java
License:Open Source License
@Override public void visitIntInsn(final int opcode, final int operand) { switch (opcode) { case Opcodes.BIPUSH: case Opcodes.SIPUSH: push(Opcodes.INTEGER);//from ww w . ja v a2 s .c o m break; case Opcodes.NEWARRAY: pop(1); switch (operand) { case Opcodes.T_BOOLEAN: push("[Z"); break; case Opcodes.T_CHAR: push("[C"); break; case Opcodes.T_FLOAT: push("[F"); break; case Opcodes.T_DOUBLE: push("[D"); break; case Opcodes.T_BYTE: push("[B"); break; case Opcodes.T_SHORT: push("[S"); break; case Opcodes.T_INT: push("[I"); break; case Opcodes.T_LONG: push("[J"); break; default: throw new IllegalArgumentException(); } break; default: throw new IllegalArgumentException(); } mv.visitIntInsn(opcode, operand); }
From source file:org.jboss.byteman.agent.adapter.RuleGeneratorAdapter.java
License:Open Source License
/** * Generates the instruction to create a new array. * * @param type the type of the array elements. *///w w w . j a va2 s .c o m public void newArray(final Type type) { int typ; switch (type.getSort()) { case Type.BOOLEAN: typ = Opcodes.T_BOOLEAN; break; case Type.CHAR: typ = Opcodes.T_CHAR; break; case Type.BYTE: typ = Opcodes.T_BYTE; break; case Type.SHORT: typ = Opcodes.T_SHORT; break; case Type.INT: typ = Opcodes.T_INT; break; case Type.FLOAT: typ = Opcodes.T_FLOAT; break; case Type.LONG: typ = Opcodes.T_LONG; break; case Type.DOUBLE: typ = Opcodes.T_DOUBLE; break; default: typeInsn(Opcodes.ANEWARRAY, type); return; } visitIntInsn(Opcodes.NEWARRAY, typ); }
From source file:org.jboss.byteman.rule.expression.ArrayInitExpression.java
License:Open Source License
public void compile(MethodVisitor mv, CompileContext compileContext) throws CompileException { // make sure we are at the right source line compileContext.notifySourceLine(line); Type baseType = getType().getBaseType(); int currentStack = compileContext.getStackCount(); int expected = 1; int length = elements.size(); // stack array size and then create the array mv.visitLdcInsn(length);/*from w ww . j a v a2s. co m*/ compileContext.addStackCount(1); // new array pops count and pushes array so no change to stack size if (baseType.isArray()) { mv.visitMultiANewArrayInsn(getType().getInternalName(), 1); } else if (baseType.isObject()) { mv.visitTypeInsn(Opcodes.ANEWARRAY, baseType.getInternalName()); } else { int operand = 0; if (baseType.equals(Type.Z)) { operand = Opcodes.T_BOOLEAN; } else if (baseType.equals(Type.B)) { operand = Opcodes.T_BYTE; } else if (baseType.equals(Type.S)) { operand = Opcodes.T_SHORT; } else if (baseType.equals(Type.C)) { operand = Opcodes.T_CHAR; } else if (baseType.equals(Type.I)) { operand = Opcodes.T_INT; } else if (baseType.equals(Type.J)) { operand = Opcodes.T_LONG; } else if (baseType.equals(Type.F)) { operand = Opcodes.T_FLOAT; } else if (baseType.equals(Type.D)) { operand = Opcodes.T_DOUBLE; } mv.visitIntInsn(Opcodes.NEWARRAY, operand); } int idx = 0; boolean isTwoWords = (baseType.getNBytes() > 4); for (Expression element : elements) { int toPop = 0; // copy array so we can assign it -- adds one to height mv.visitInsn(Opcodes.DUP); // compile expression index -- adds 1 to height mv.visitLdcInsn(idx++); compileContext.addStackCount(2); // compile value -- adds one or two words to height element.compile(mv, compileContext); // ensure we have the correct value type compileContext.compileTypeConversion(element.type, baseType); // now we can do the array store if (baseType.isObject() || baseType.isArray()) { // compile load object - pops 3 mv.visitInsn(Opcodes.AASTORE); toPop = -3; } else if (baseType == Type.Z || baseType == Type.B) { // compile load byte - pops 3 mv.visitInsn(Opcodes.BASTORE); toPop = -3; } else if (baseType == Type.S) { // compile load short - pops 3 mv.visitInsn(Opcodes.SASTORE); toPop = -3; } else if (baseType == Type.C) { // compile load char - pops 3 mv.visitInsn(Opcodes.CASTORE); toPop = -3; } else if (baseType == Type.I) { // compile load int - pops 3 mv.visitInsn(Opcodes.IASTORE); toPop = -3; } else if (baseType == Type.J) { // compile load long - pops 4 mv.visitInsn(Opcodes.LASTORE); toPop = -4; } else if (baseType == Type.F) { // compile load float - pops 3 mv.visitInsn(Opcodes.FASTORE); toPop = -3; } else if (baseType == Type.D) { // compile load double - pops 4 mv.visitInsn(Opcodes.DASTORE); toPop = -4; } // pop the appropriate number of elements off the stack compileContext.addStackCount(toPop); } // check stack height if (compileContext.getStackCount() != currentStack + expected) { throw new CompileException("ArrayInitExpression.compile : invalid stack height " + compileContext.getStackCount() + " expecting " + (currentStack + expected)); } // no need to update stack max }
From source file:org.jboss.byteman.rule.expression.NewExpression.java
License:Open Source License
public void compile(MethodVisitor mv, CompileContext compileContext) throws CompileException { // make sure we are at the right source line compileContext.notifySourceLine(line); int currentStack = compileContext.getStackCount(); int expected = 1; int extraParams = 0; if (arrayDimCount == 0) { // ok, we need to create the new instance and then initialise it. // create the new instance -- adds 1 to stack String instantiatedClassName = type.getInternalName(); mv.visitTypeInsn(Opcodes.NEW, instantiatedClassName); compileContext.addStackCount(1); // copy the exception so we can init it mv.visitInsn(Opcodes.DUP);//ww w .j a va 2 s.c o m compileContext.addStackCount(1); int argCount = arguments.size(); // stack each of the arguments to the constructor for (int i = 0; i < argCount; i++) { Type argType = argumentTypes.get(i); Type paramType = paramTypes.get(i); int paramCount = (paramType.getNBytes() > 4 ? 2 : 1); // track extra storage used after type conversion extraParams += (paramCount); arguments.get(i).compile(mv, compileContext); compileTypeConversion(argType, paramType, mv, compileContext); } // construct the exception mv.visitMethodInsn(Opcodes.INVOKESPECIAL, instantiatedClassName, "<init>", getDescriptor()); // modify the stack height to account for the removed exception and params compileContext.addStackCount(-(extraParams + 1)); } else { // TODO !!! implement compilation for array types !!! if (arrayDimCount == 1) { // we can use a NEWARRAY or ANEWARRAY Type baseType = type.getBaseType(); // compile first array dimension adds 1 to stack arrayDims.get(0).compile(mv, compileContext); // compile new array op -- pops 1 and adds 1 to stack if (baseType.isObject()) { mv.visitTypeInsn(Opcodes.ANEWARRAY, baseType.getInternalName()); // } else if (baseType.isArray()) { // cannot happen!!! } else { int operand = 0; if (baseType.equals(Type.Z)) { operand = Opcodes.T_BOOLEAN; } else if (baseType.equals(Type.B)) { operand = Opcodes.T_BYTE; } else if (baseType.equals(Type.S)) { operand = Opcodes.T_SHORT; } else if (baseType.equals(Type.C)) { operand = Opcodes.T_CHAR; } else if (baseType.equals(Type.I)) { operand = Opcodes.T_INT; } else if (baseType.equals(Type.J)) { operand = Opcodes.T_LONG; } else if (baseType.equals(Type.F)) { operand = Opcodes.T_FLOAT; } else if (baseType.equals(Type.D)) { operand = Opcodes.T_DOUBLE; } mv.visitIntInsn(Opcodes.NEWARRAY, operand); } } else { // we need to use MULTIANEWARRAY for (int i = 0; i < arrayDimDefinedCount; i++) { // compile next array dimension adds 1 to stack arrayDims.get(i).compile(mv, compileContext); } // execute the MULTIANEWARRAY operation -- pops arrayDims operands and pushes 1 mv.visitMultiANewArrayInsn(type.getInternalName(), arrayDimDefinedCount); compileContext.addStackCount(1 - arrayDimDefinedCount); } } if (compileContext.getStackCount() != currentStack + expected) { throw new CompileException("NewExpression.compile : invalid stack height " + compileContext.getStackCount() + " expecting " + (currentStack + expected)); } }
From source file:org.openquark.cal.internal.javamodel.AsmJavaBytecodeGenerator.java
License:Open Source License
/** * @param elemType element type of the array. Must be a primitive type. * @return java op-code to use as the argument for the NEWARRAY op. *//*from w w w . j a va2s. com*/ private static int getNewArrayArgCode(JavaTypeName elemType) { switch (elemType.getTag()) { case JavaTypeName.VOID_TAG: throw new IllegalArgumentException(); case JavaTypeName.BOOLEAN_TAG: return Opcodes.T_BOOLEAN; case JavaTypeName.BYTE_TAG: return Opcodes.T_BYTE; case JavaTypeName.SHORT_TAG: return Opcodes.T_SHORT; case JavaTypeName.CHAR_TAG: return Opcodes.T_CHAR; case JavaTypeName.INT_TAG: return Opcodes.T_INT; case JavaTypeName.LONG_TAG: return Opcodes.T_LONG; case JavaTypeName.DOUBLE_TAG: return Opcodes.T_DOUBLE; case JavaTypeName.FLOAT_TAG: return Opcodes.T_FLOAT; case JavaTypeName.ARRAY_TAG: case JavaTypeName.OBJECT_TAG: default: { throw new IllegalArgumentException(); } } }
From source file:pxb.android.dex2jar.asm.PDescMethodVisitor.java
License:Apache License
public void visitIntInsn(int opcode, int operand) { super.visitIntInsn(opcode, operand); switch (opcode) { case BIPUSH:/*from w w w. ja v a 2 s . c o m*/ stack.push(Type.BYTE_TYPE); break; case SIPUSH: stack.push(Type.SHORT_TYPE); break; case NEWARRAY: stack.pop(); switch (operand) { case Opcodes.T_BOOLEAN: stack.push(Type.getType("[Z")); break; case Opcodes.T_BYTE: stack.push(Type.getType("[B")); break; case Opcodes.T_CHAR: stack.push(Type.getType("[C")); break; case Opcodes.T_DOUBLE: stack.push(Type.getType("[D")); break; case Opcodes.T_FLOAT: stack.push(Type.getType("[F")); break; case Opcodes.T_INT: stack.push(Type.getType("[I")); break; case Opcodes.T_LONG: stack.push(Type.getType("[J")); break; case Opcodes.T_SHORT: stack.push(Type.getType("[Z")); break; } break; } }