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:asmlib.Type.java
License:Open Source License
public static Type fromOpcode(int opcode) { char type;/* www. j a va2 s. c om*/ switch (opcode) { case Opcodes.T_BOOLEAN: type = 'Z'; break; case Opcodes.T_BYTE: type = 'B'; break; case Opcodes.T_CHAR: type = 'C'; break; case Opcodes.T_SHORT: type = 'S'; break; case Opcodes.T_INT: type = 'I'; break; case Opcodes.T_LONG: type = 'J'; break; case Opcodes.T_FLOAT: type = 'F'; break; case Opcodes.T_DOUBLE: type = 'D'; break; default: throw new InstrumentationException("Unknown or invalid bytecode type"); } return Type.fromBytecode(type); }
From source file:bytecode.InstructionExporter.java
License:Apache License
/** * Output instructions for allocating arrays, both for primitive and * reference types.// w ww . j a v a 2 s .c om * * @param instruction Array allocation instruction. * @return <code>null</code> */ @Override public Void visit(NewArray instruction) { if (instruction.getElementType().getSort() == Type.Sort.REF) { mv.visitTypeInsn(Opcodes.ANEWARRAY, instruction.getElementType().getInternalName()); } else { int type; switch (instruction.getElementType().getSort()) { case BOOL: type = Opcodes.T_BOOLEAN; break; case CHAR: type = Opcodes.T_CHAR; break; case FLOAT: type = Opcodes.T_FLOAT; break; case DOUBLE: type = Opcodes.T_DOUBLE; break; case BYTE: type = Opcodes.T_BYTE; break; case SHORT: type = Opcodes.T_SHORT; break; case INT: type = Opcodes.T_INT; break; case LONG: type = Opcodes.T_LONG; break; default: throw new RuntimeException("Unknown array element type"); } mv.visitIntInsn(Opcodes.NEWARRAY, type); } return null; }
From source file:bytecode.MethodImporter.java
License:Apache License
/** * Imports instructions with a single integer operand (byte push, short push * and allocation of primitive arrays)./*from w ww .j a v a 2s . co m*/ * * @param opcode Opcode. * @param operand Integer operand. */ @Override public void visitIntInsn(final int opcode, final int operand) { switch (opcode) { // Constants case Opcodes.BIPUSH: createConstant(new Byte((byte) operand)); break; case Opcodes.SIPUSH: createConstant(new Short((short) operand)); break; // New Array (Primitive) case Opcodes.NEWARRAY: Type type = null; switch (operand) { case Opcodes.T_BOOLEAN: type = Type.BOOL; break; case Opcodes.T_CHAR: type = Type.CHAR; break; case Opcodes.T_FLOAT: type = Type.FLOAT; break; case Opcodes.T_DOUBLE: type = Type.DOUBLE; break; case Opcodes.T_BYTE: type = Type.BYTE; break; case Opcodes.T_SHORT: type = Type.SHORT; break; case Opcodes.T_INT: type = Type.INT; break; case Opcodes.T_LONG: type = Type.LONG; break; } ordered.add(stack.push(new NewArray(type, stack.pop()))); break; } }
From source file:ch.eiafr.cojac.FloatReplacerMethodVisitor.java
License:Apache License
@Override public void visitIntInsn(int opcode, int operand) { if (opcode == NEWARRAY) { if (operand == Opcodes.T_FLOAT) { mv.visitMethodInsn(INVOKESTATIC, FN_NAME, "newarray", "(I)[" + Type.getType(Object.class).getDescriptor(), false); mv.visitTypeInsn(CHECKCAST, "[" + COJAC_FLOAT_WRAPPER_TYPE_DESCR); return; }/*w w w . j a v a2 s .c om*/ if (operand == Opcodes.T_DOUBLE) { mv.visitMethodInsn(INVOKESTATIC, DN_NAME, "newarray", "(I)[" + Type.getType(Object.class).getDescriptor(), false); mv.visitTypeInsn(CHECKCAST, "[" + COJAC_DOUBLE_WRAPPER_TYPE_DESCR); return; } } mv.visitIntInsn(opcode, operand); }
From source file:cl.inria.stiq.instrumenter.BCIUtils.java
License:Open Source License
/** * Returns the primitive type that corresponds to the given operand * /*from ww w. j a va2s .co m*/ * @param aOperand * {@link Opcodes#T_BOOLEAN} etc. */ public static PrimitiveTypeInfo getPrimitiveType(int aOperand) { switch (aOperand) { case Opcodes.T_BOOLEAN: return PrimitiveTypeInfo.BOOLEAN; case Opcodes.T_BYTE: return PrimitiveTypeInfo.BYTE; case Opcodes.T_CHAR: return PrimitiveTypeInfo.CHAR; case Opcodes.T_DOUBLE: return PrimitiveTypeInfo.DOUBLE; case Opcodes.T_FLOAT: return PrimitiveTypeInfo.FLOAT; case Opcodes.T_INT: return PrimitiveTypeInfo.INT; case Opcodes.T_LONG: return PrimitiveTypeInfo.LONG; case Opcodes.T_SHORT: return PrimitiveTypeInfo.SHORT; default: return null; } }
From source file:com.devexperts.aprof.transformer.AbstractMethodVisitor.java
License:Open Source License
@Override public void visitIntInsn(final int opcode, final int operand) { if (opcode == Opcodes.NEWARRAY && !context.isIntrinsicArraysCopyOf()) { String arrayDesc;// ww w. ja v a2s.co m switch (operand) { case Opcodes.T_BOOLEAN: arrayDesc = BOOLEAN_ARR_T_DESC; break; case Opcodes.T_CHAR: arrayDesc = CHAR_ARR_T_DESC; break; case Opcodes.T_FLOAT: arrayDesc = FLOAT_ARR_T_DESC; break; case Opcodes.T_DOUBLE: arrayDesc = DOUBLE_ARR_T_DESC; break; case Opcodes.T_BYTE: arrayDesc = BYTE_ARR_T_DESC; break; case Opcodes.T_SHORT: arrayDesc = SHORT_ARR_T_DESC; break; case Opcodes.T_INT: arrayDesc = INT_ARR_T_DESC; break; case Opcodes.T_LONG: arrayDesc = LONG_ARR_T_DESC; break; default: assert false; // should not happen return; } visitAllocateArrayBefore(arrayDesc); mv.visitIntInsn(opcode, operand); visitAllocateArrayAfter(arrayDesc); } else mv.visitIntInsn(opcode, operand); }
From source file:com.github.anba.es6draft.compiler.assembler.InstructionAssembler.java
License:Open Source License
private static final int arrayType(Type type) { switch (type.getSort()) { case Type.Sort.BOOLEAN: return Opcodes.T_BOOLEAN; case Type.Sort.CHAR: return Opcodes.T_CHAR; case Type.Sort.BYTE: return Opcodes.T_BYTE; case Type.Sort.SHORT: return Opcodes.T_SHORT; case Type.Sort.INT: return Opcodes.T_INT; case Type.Sort.FLOAT: return Opcodes.T_FLOAT; case Type.Sort.LONG: return Opcodes.T_LONG; case Type.Sort.DOUBLE: return Opcodes.T_DOUBLE; case Type.Sort.OBJECT: case Type.Sort.ARRAY: case Type.Sort.METHOD: case Type.Sort.VOID: default:/*from ww w . j av a2 s .c o m*/ throw new IllegalArgumentException(); } }
From source file:com.google.devtools.build.android.desugar.BytecodeTypeInference.java
License:Open Source License
@Override public void visitIntInsn(int opcode, int operand) { switch (opcode) { case Opcodes.BIPUSH: case Opcodes.SIPUSH: push(InferredType.INT);//from w w w . jav a 2s .co m break; case Opcodes.NEWARRAY: pop(); switch (operand) { case Opcodes.T_BOOLEAN: pushDescriptor("[Z"); break; case Opcodes.T_CHAR: pushDescriptor("[C"); break; case Opcodes.T_FLOAT: pushDescriptor("[F"); break; case Opcodes.T_DOUBLE: pushDescriptor("[D"); break; case Opcodes.T_BYTE: pushDescriptor("[B"); break; case Opcodes.T_SHORT: pushDescriptor("[S"); break; case Opcodes.T_INT: pushDescriptor("[I"); break; case Opcodes.T_LONG: pushDescriptor("[J"); break; default: throw new RuntimeException("Unhandled operand value: " + operand); } break; default: throw new RuntimeException("Unhandled opcode " + opcode); } super.visitIntInsn(opcode, operand); }
From source file:com.google.test.metric.asm.MethodVisitorBuilder.java
License:Apache License
private Type toType(int operand) { switch (operand) { case Opcodes.T_BOOLEAN: return JavaType.BOOLEAN; case Opcodes.T_BYTE: return JavaType.BYTE; case Opcodes.T_CHAR: return JavaType.CHAR; case Opcodes.T_DOUBLE: return JavaType.DOUBLE; case Opcodes.T_FLOAT: return JavaType.FLOAT; case Opcodes.T_INT: return JavaType.INT; case Opcodes.T_LONG: return JavaType.LONG; case Opcodes.T_SHORT: return JavaType.SHORT; default:// www . j a va2 s . com throw new IllegalArgumentException(); } }
From source file:com.offbynull.coroutines.instrumenter.LocalsStateGenerators.java
License:Open Source License
/** * Generates instructions to save the local variables table. * @param markerType debug marker type//from w w w . j av a2 s . com * @param storageVars variables to store locals in to * @param frame execution frame at the instruction where the local variables table is to be saved * @return instructions to save the local variables table in to an array * @throws NullPointerException if any argument is {@code null} */ public static InsnList saveLocals(MarkerType markerType, StorageVariables storageVars, Frame<BasicValue> frame) { Validate.notNull(markerType); Validate.notNull(storageVars); Validate.notNull(frame); Variable intsVar = storageVars.getIntStorageVar(); Variable floatsVar = storageVars.getFloatStorageVar(); Variable longsVar = storageVars.getLongStorageVar(); Variable doublesVar = storageVars.getDoubleStorageVar(); Variable objectsVar = storageVars.getObjectStorageVar(); int intsCounter = 0; int floatsCounter = 0; int longsCounter = 0; int doublesCounter = 0; int objectsCounter = 0; StorageSizes storageSizes = computeSizes(frame); InsnList ret = new InsnList(); // Create storage arrays and save them in respective storage vars ret.add(merge(debugMarker(markerType, "Saving locals"), mergeIf(intsVar != null, () -> new Object[] { debugMarker(markerType, "Generating ints container (" + storageSizes.getIntsSize() + ")"), new LdcInsnNode(storageSizes.getIntsSize()), new IntInsnNode(Opcodes.NEWARRAY, Opcodes.T_INT), new VarInsnNode(Opcodes.ASTORE, intsVar.getIndex()) }), mergeIf(floatsVar != null, () -> new Object[] { debugMarker(markerType, "Generating floats container (" + storageSizes.getFloatsSize() + ")"), new LdcInsnNode(storageSizes.getFloatsSize()), new IntInsnNode(Opcodes.NEWARRAY, Opcodes.T_FLOAT), new VarInsnNode(Opcodes.ASTORE, floatsVar.getIndex()) }), mergeIf(longsVar != null, () -> new Object[] { debugMarker(markerType, "Generating longs container (" + storageSizes.getLongsSize() + ")"), new LdcInsnNode(storageSizes.getLongsSize()), new IntInsnNode(Opcodes.NEWARRAY, Opcodes.T_LONG), new VarInsnNode(Opcodes.ASTORE, longsVar.getIndex()) }), mergeIf(doublesVar != null, () -> new Object[] { debugMarker(markerType, "Generating doubles container (" + storageSizes.getDoublesSize() + ")"), new LdcInsnNode(storageSizes.getDoublesSize()), new IntInsnNode(Opcodes.NEWARRAY, Opcodes.T_DOUBLE), new VarInsnNode(Opcodes.ASTORE, doublesVar.getIndex()) }), mergeIf(objectsVar != null, () -> new Object[] { debugMarker(markerType, "Generating objects container (" + storageSizes.getObjectsSize() + ")"), new LdcInsnNode(storageSizes.getObjectsSize()), new TypeInsnNode(Opcodes.ANEWARRAY, "java/lang/Object"), new VarInsnNode(Opcodes.ASTORE, objectsVar.getIndex()) }))); // Save the locals for (int i = 0; i < frame.getLocals(); i++) { BasicValue basicValue = frame.getLocal(i); Type type = basicValue.getType(); // If type == null, basicValue is pointing to uninitialized var -- basicValue.toString() will return '.'. This means that this // slot contains nothing to save. So, skip this slot if we encounter it. if (type == null) { ret.add(debugMarker(markerType, "Skipping uninitialized value at " + i)); continue; } // If type is 'Lnull;', this means that the slot has been assigned null and that "there has been no merge yet that would 'raise' // the type toward some class or interface type" (from ASM mailing list). We know this slot will always contain null at this // point in the code so we can avoid saving it. When we load it back up, we can simply push a null in to that slot, thereby // keeping the same 'Lnull;' type. if ("Lnull;".equals(type.getDescriptor())) { ret.add(debugMarker(markerType, "Skipping null value at " + i)); continue; } // Place item in to appropriate storage array switch (type.getSort()) { case Type.BOOLEAN: case Type.BYTE: case Type.SHORT: case Type.CHAR: case Type.INT: ret.add(debugMarker(markerType, "Inserting int at LVT index " + i + " to storage index " + intsCounter)); ret.add(new VarInsnNode(Opcodes.ALOAD, intsVar.getIndex())); // [int[]] ret.add(new LdcInsnNode(intsCounter)); // [int[], idx] ret.add(new VarInsnNode(Opcodes.ILOAD, i)); // [int[], idx, val] ret.add(new InsnNode(Opcodes.IASTORE)); // [] intsCounter++; break; case Type.FLOAT: ret.add(debugMarker(markerType, "Inserting float at LVT index " + i + " to storage index " + floatsCounter)); ret.add(new VarInsnNode(Opcodes.ALOAD, floatsVar.getIndex())); // [float[]] ret.add(new LdcInsnNode(floatsCounter)); // [float[], idx] ret.add(new VarInsnNode(Opcodes.FLOAD, i)); // [float[], idx, val] ret.add(new InsnNode(Opcodes.FASTORE)); // [] floatsCounter++; break; case Type.LONG: ret.add(debugMarker(markerType, "Inserting long at LVT index " + i + " to storage index " + longsCounter)); ret.add(new VarInsnNode(Opcodes.ALOAD, longsVar.getIndex())); // [long[]] ret.add(new LdcInsnNode(longsCounter)); // [long[], idx] ret.add(new VarInsnNode(Opcodes.LLOAD, i)); // [long[], idx, val] ret.add(new InsnNode(Opcodes.LASTORE)); // [] longsCounter++; break; case Type.DOUBLE: ret.add(debugMarker(markerType, "Inserting double at LVT index " + i + " to storage index " + doublesCounter)); ret.add(new VarInsnNode(Opcodes.ALOAD, doublesVar.getIndex())); // [double[]] ret.add(new LdcInsnNode(doublesCounter)); // [double[], idx] ret.add(new VarInsnNode(Opcodes.DLOAD, i)); // [double[], idx, val] ret.add(new InsnNode(Opcodes.DASTORE)); // [] doublesCounter++; break; case Type.ARRAY: case Type.OBJECT: ret.add(debugMarker(markerType, "Inserting object at LVT index " + i + " to storage index " + objectsCounter)); ret.add(new VarInsnNode(Opcodes.ALOAD, objectsVar.getIndex())); // [Object[]] ret.add(new LdcInsnNode(objectsCounter)); // [Object[], idx] ret.add(new VarInsnNode(Opcodes.ALOAD, i)); // [Object[], idx, val] ret.add(new InsnNode(Opcodes.AASTORE)); // [] objectsCounter++; break; case Type.METHOD: case Type.VOID: default: throw new IllegalStateException(); } } return ret; }