List of usage examples for org.objectweb.asm Opcodes LONG
Integer LONG
To view the source code for org.objectweb.asm Opcodes LONG.
Click Source Link
From source file:de.scoopgmbh.copper.instrument.StackInfo.java
License:Apache License
static Type deferLocalDesc(Object object) { if (object instanceof String) return Type.getObjectType((String) object); //TODO: analyze opcode at pos label if (object instanceof Label) return Type.getType(Object.class); int intObject = (Integer) object; if (intObject == Opcodes.TOP) return null; if (intObject == Opcodes.INTEGER) return Type.INT_TYPE; if (intObject == Opcodes.FLOAT) return Type.FLOAT_TYPE; if (intObject == Opcodes.LONG) return Type.LONG_TYPE; if (intObject == Opcodes.DOUBLE) return Type.getType(double.class); if (intObject == Opcodes.LONG) return Type.getType(long.class); if (intObject == Opcodes.NULL) return Type.getType(Object.class); //TODO: defer from containing class if (intObject == Opcodes.UNINITIALIZED_THIS) return Type.getType(Object.class); throw new BuildStackFrameException("Couldnt defer desc for " + object); }
From source file:de.unisb.cs.st.javalanche.mutation.bytecodeMutations.unaryOperatorInsertion.UnaryOperatorMethodAdapter.java
License:Open Source License
@Override protected void handleMutation(Mutation mutation, final Integer type) { MutationCode unMutated = new MutationCode(null) { @Override//w w w .java 2s .com public void insertCodeBlock(MethodVisitor mv) { } }; List<MutationCode> mutated = new ArrayList<MutationCode>(); mutation.setOperatorAddInfo(MINUS); if (mutationManager.shouldApplyMutation(mutation)) { Mutation dbMutation = QueryManager.getMutation(mutation); final int negOpcode = getOpcode(Opcodes.INEG, type); MutationCode mutateMinus = new MutationCode(dbMutation) { @Override public void insertCodeBlock(MethodVisitor mv) { mv.visitInsn(negOpcode); } }; mutated.add(mutateMinus); } mutation.setOperatorAddInfo(BITWISE_NEGATE); if (mutationManager.shouldApplyMutation(mutation)) { Mutation dbMutation = QueryManager.getMutation(mutation); MutationCode mutateNegate = new MutationCode(dbMutation) { @Override public void insertCodeBlock(MethodVisitor mv) { if (type == Opcodes.INTEGER) { mv.visitInsn(Opcodes.ICONST_M1); mv.visitInsn(Opcodes.IXOR); } else if (type == Opcodes.LONG) { mv.visitLdcInsn(Long.valueOf(-1l)); mv.visitInsn(Opcodes.LXOR); } } }; mutated.add(mutateNegate); } if (mutated.size() > 0) { BytecodeTasks.insertIfElse(mv, unMutated, mutated.toArray(new MutationCode[0])); } else { logger.debug("Not applying mutation"); } }
From source file:edu.ubc.mirrors.holograms.FrameAnalyzer.java
License:Open Source License
public Object toFrameObject(FrameValue value) { if (value.isUninitializedThis()) { return Opcodes.UNINITIALIZED_THIS; } else if (value.isUninitialized()) { AbstractInsnNode newInsn = value.getNewInsn(); // TODO: Could also search up to the previous actual instruction... AbstractInsnNode labelNode = newInsn.getPrevious(); if (labelNode == null || !(labelNode instanceof LabelNode)) { labelNode = new LabelNode(); m.instructions.insertBefore(newInsn, labelNode); }//from w w w . java 2 s . c o m return ((LabelNode) labelNode).getLabel(); } else { Type type = value.getBasicValue().getType(); if (type == null) { return Opcodes.TOP; } else { switch (type.getSort()) { case Type.VOID: // TODO: Not sure what to do here. Used for BasicValue.RETURNADDRESS_VALUE, // but I can't figure out the correct verifier type for the return addresses // used by JSR/RET. return Opcodes.TOP; case Type.BOOLEAN: case Type.BYTE: case Type.CHAR: case Type.SHORT: case Type.INT: return Opcodes.INTEGER; case Type.LONG: return Opcodes.LONG; case Type.FLOAT: return Opcodes.FLOAT; case Type.DOUBLE: return Opcodes.DOUBLE; case Type.OBJECT: case Type.ARRAY: return type.getInternalName(); case Type.METHOD: // Shouldn't happen default: throw new RuntimeException("Bad sort: " + type.getSort()); } } } }
From source file:jaspex.speculation.newspec.FlowFrame.java
License:Open Source License
/** Converte lista de tipos no formato do visitFrame em BasicValues **/ private UtilList<BasicValue> convertFromFrame(List<Object> values, boolean locals) { UtilList<BasicValue> outList = new UtilArrayList<BasicValue>(); for (Object o : values) { if (o instanceof Integer) { Integer i = (Integer) o; if (i.equals(Opcodes.TOP)) { outList.add(BasicValue.UNINITIALIZED_VALUE); } else if (i.equals(Opcodes.INTEGER)) { outList.add(BasicValue.INT_VALUE); } else if (i.equals(Opcodes.FLOAT)) { outList.add(BasicValue.FLOAT_VALUE); } else if (i.equals(Opcodes.LONG)) { outList.add(BasicValue.LONG_VALUE); if (locals) outList.add(BasicValue.UNINITIALIZED_VALUE); } else if (i.equals(Opcodes.DOUBLE)) { outList.add(BasicValue.DOUBLE_VALUE); if (locals) outList.add(BasicValue.UNINITIALIZED_VALUE); } else if (i.equals(Opcodes.NULL)) { outList.add(BasicValue.REFERENCE_VALUE); } else if (i.equals(Opcodes.UNINITIALIZED_THIS)) { throw new AssertionError("FIXME"); } else { throw new AssertionError(); }// w w w . ja v a 2 s. com } else if (o instanceof String) { String s = (String) o; outList.add(_interpreter.newValue(Type.getObjectType(s))); } else if (o instanceof Label) { throw new AssertionError("FIXME"); } else { throw new AssertionError("FIXME"); } } return outList; }
From source file:jaspex.speculation.newspec.FlowFrame.java
License:Open Source License
/** Converte lista de BasicValues no formato usado no visitFrame **/ private static Object[] convertToFrame(UtilList<BasicValue> values, boolean locals) { UtilList<Object> outList = new UtilArrayList<Object>(); int top = 0;//w w w .j a v a2 s.c o m for (int i = 0; i < values.size(); i++) { BasicValue v = values.get(i); if (v.equals(BasicValue.UNINITIALIZED_VALUE) && locals) { // Os locals so criados logo com o tamanho do MAXLOCALS, mas com // UNINITIALIZED_VALUE at serem usados // Mesmo assim, podem existir outros locals usados, e temos // que introduzir algo na lista para as posies no mudarem // Por vezes um UninitializedValue est no lugar de um top if (i > 0 && (values.get(i - 1).equals(BasicValue.LONG_VALUE) || values.get(i - 1).equals(BasicValue.DOUBLE_VALUE))) { top++; continue; } outList.add("jaspex/HACK/UninitializedValue"); continue; } if (v instanceof MergedUninitializedValue) { // Normalmente no devia ser deixado um MergedUninitializedValue // na stack/locals, mas tal pode acontecer quando no faz diferena // nenhuma no bloco (por exemplo porque vai fazer return) outList.add("jaspex/HACK/MergedUninitializedValue"); continue; } if (v.getType() == null || v.equals(BasicValue.RETURNADDRESS_VALUE)) { throw new AssertionError("FIXME"); } Type type = v.getType(); Object convertedType; switch (type.getSort()) { case Type.BOOLEAN: case Type.BYTE: case Type.CHAR: case Type.SHORT: case Type.INT: convertedType = Opcodes.INTEGER; break; case Type.FLOAT: convertedType = Opcodes.FLOAT; break; case Type.LONG: convertedType = Opcodes.LONG; break; case Type.DOUBLE: convertedType = Opcodes.DOUBLE; break; case Type.ARRAY: case Type.OBJECT: convertedType = type.getInternalName(); break; default: throw new AssertionError(); } outList.add(convertedType); } assert ((outList.size() + top) == values.size()); return outList.toArray(); }
From source file:org.actorsguildframework.internal.codegenerator.GenerationUtils.java
License:Apache License
/** * Returns the descriptor type for the given class to put it into a frame descriptor * for MethodVisitor.visitFrame()./*www . j a v a 2 s . co m*/ * Does not support uninitialized types. * @param clazz the class of the type. May be null for the null descriptor. * @return the descriptor */ public static Object getFrameType(Class<?> clazz) { if (clazz == null) return Opcodes.NULL; if (!clazz.isPrimitive()) return Type.getInternalName(clazz); else if (clazz.equals(Integer.TYPE) || clazz.equals(Character.TYPE) || clazz.equals(Short.TYPE) || clazz.equals(Byte.TYPE) || clazz.equals(Boolean.TYPE)) return Opcodes.INTEGER; else if (clazz.equals(Long.TYPE)) return Opcodes.LONG; else if (clazz.equals(Double.TYPE)) return Opcodes.DOUBLE; else if (clazz.equals(Float.TYPE)) return Opcodes.FLOAT; else throw new RuntimeException("Oops, forgot the primitive " + clazz + "?"); }
From source file:org.copperengine.core.instrument.StackInfo.java
License:Apache License
static Type deferLocalDesc(Object object) { if (object instanceof String) return Type.getObjectType((String) object); // TODO: analyze opcode at pos label if (object instanceof Label) return Type.getType(Object.class); int intObject = (Integer) object; if (intObject == Opcodes.TOP) return null; if (intObject == Opcodes.INTEGER) return Type.INT_TYPE; if (intObject == Opcodes.FLOAT) return Type.FLOAT_TYPE; if (intObject == Opcodes.LONG) return Type.LONG_TYPE; if (intObject == Opcodes.DOUBLE) return Type.getType(double.class); if (intObject == Opcodes.LONG) return Type.getType(long.class); if (intObject == Opcodes.NULL) return Type.getType(Object.class); // TODO: defer from containing class if (intObject == Opcodes.UNINITIALIZED_THIS) return Type.getType(Object.class); throw new BuildStackFrameException("Couldnt defer desc for " + object); }
From source file:org.evosuite.instrumentation.testability.MethodNodeTransformer.java
License:Open Source License
/** * Creates a new local variable of the given type. * /*from w ww . j a v a 2 s . co m*/ * @param type * the type of the local variable to be created. * @return the identifier of the newly created local variable. */ public int newLocal(final Type type) { Object t; switch (type.getSort()) { case Type.BOOLEAN: case Type.CHAR: case Type.BYTE: case Type.SHORT: case Type.INT: t = Opcodes.INTEGER; break; case Type.FLOAT: t = Opcodes.FLOAT; break; case Type.LONG: t = Opcodes.LONG; break; case Type.DOUBLE: t = Opcodes.DOUBLE; break; case Type.ARRAY: t = type.getDescriptor(); break; // case Type.OBJECT: default: t = type.getInternalName(); break; } int local = newLocalMapping(type); setLocalType(local, type); setFrameLocal(local, t); return local; }
From source file:org.jacoco.core.internal.flow.FrameSnapshot.java
License:Open Source License
/** * Reduce double word types into a single slot as required * {@link MethodVisitor#visitFrame(int, int, Object[], int, Object[])} * method./* w ww . jav a 2 s. c om*/ */ private static Object[] reduce(final List<Object> source, final int popCount) { final List<Object> copy = new ArrayList<Object>(source); final int size = source.size() - popCount; copy.subList(size, source.size()).clear(); for (int i = size; --i >= 0;) { final Object type = source.get(i); if (type == Opcodes.LONG || type == Opcodes.DOUBLE) { copy.remove(i + 1); } } return copy.toArray(); }
From source file:org.jacoco.core.internal.flow.FrameSnapshotTest.java
License:Open Source License
@Test public void should_combine_slots_when_doube_or_long_types_are_given() { analyzer.visitInsn(Opcodes.DCONST_0); analyzer.visitVarInsn(Opcodes.DSTORE, 1); analyzer.visitInsn(Opcodes.FCONST_0); analyzer.visitVarInsn(Opcodes.FSTORE, 3); analyzer.visitInsn(Opcodes.ICONST_0); analyzer.visitInsn(Opcodes.LCONST_0); analyzer.visitInsn(Opcodes.ICONST_0); analyzer.visitInsn(Opcodes.DCONST_0); frame = FrameSnapshot.create(analyzer, 0); final Object[] vars = arr("Foo", Opcodes.DOUBLE, Opcodes.FLOAT); final Object[] stack = arr(Opcodes.INTEGER, Opcodes.LONG, Opcodes.INTEGER, Opcodes.DOUBLE); expectedVisitor.visitFrame(Opcodes.F_FULL, 3, vars, 4, stack); }