List of usage examples for org.objectweb.asm Opcodes FLOAT
Integer FLOAT
To view the source code for org.objectweb.asm Opcodes FLOAT.
Click Source Link
From source file:ch.eiafr.cojac.FloatVariablesSorter.java
License:Apache License
@Override public void visitFrame(int type, int nLocal, final Object[] local, int nStack, final Object[] stack) { ArrayList<Object> newLocal = new ArrayList<>(); int nDummySlotsToAdd = 0; for (Object object : local) { if (object == Opcodes.DOUBLE) { newLocal.add(COJAC_DOUBLE_WRAPPER_INTERNAL_NAME); } else if (object == Opcodes.FLOAT) { newLocal.add(COJAC_FLOAT_WRAPPER_INTERNAL_NAME); } else if (object instanceof String && ((String) object).endsWith("[D")) { String tab = (String) object; tab = tab.replaceAll("D", COJAC_DOUBLE_WRAPPER_TYPE_DESCR); newLocal.add(tab);//from w w w.j a v a 2 s.co m } else if (object instanceof String && ((String) object).endsWith("[F")) { String tab = (String) object; tab = tab.replaceAll("F", COJAC_FLOAT_WRAPPER_TYPE_DESCR); newLocal.add(tab); } else { newLocal.add(object); } } while (nDummySlotsToAdd > 0) { newLocal.add(Opcodes.TOP); // or maybe Opcodes.NULL marker? nLocal++; } ArrayList<Object> newStack = new ArrayList<>(); for (Object object : stack) { if (object == Opcodes.DOUBLE) { newStack.add(COJAC_DOUBLE_WRAPPER_INTERNAL_NAME); } else if (object == Opcodes.FLOAT) { newStack.add(COJAC_FLOAT_WRAPPER_INTERNAL_NAME); } else if (object instanceof String && ((String) object).endsWith("[D")) { String tab = (String) object; tab = tab.replaceAll("D", COJAC_DOUBLE_WRAPPER_TYPE_DESCR); newStack.add(tab); } else if (object instanceof String && ((String) object).endsWith("[F")) { String tab = (String) object; tab = tab.replaceAll("F", COJAC_FLOAT_WRAPPER_TYPE_DESCR); newStack.add(tab); } else { newStack.add(object); } } mv.visitFrame(type, nLocal, newLocal.toArray(), nStack, newStack.toArray()); }
From source file:com.google.code.jconts.instrument.util.Frames.java
License:Apache License
public static Object toFrameType(Type type) { switch (type.getSort()) { case Type.BOOLEAN: case Type.CHAR: case Type.BYTE: case Type.SHORT: case Type.INT: return Opcodes.INTEGER; case Type.FLOAT: return Opcodes.FLOAT; case Type.LONG: return Opcodes.LONG; case Type.DOUBLE: return Opcodes.DOUBLE; case Type.ARRAY: return type.getDescriptor(); // case Type.OBJECT: default:/*from w w w. j a v a 2 s .co m*/ return type.getInternalName(); } }
From source file:com.google.code.jconts.instrument.util.Frames.java
License:Apache License
public static Type fromFrameType(final Object type) { if (type instanceof String) { return Type.getObjectType((String) type); } else if (type == Opcodes.INTEGER) { return Type.INT_TYPE; } else if (type == Opcodes.FLOAT) { return Type.FLOAT_TYPE; } else if (type == Opcodes.LONG) { return Type.LONG_TYPE; } else if (type == Opcodes.DOUBLE) { return Type.DOUBLE_TYPE; }/* w w w . j av a2 s. c o m*/ throw new IllegalArgumentException("Unexpected local type: " + type); }
From source file:com.google.devtools.build.android.desugar.BytecodeTypeInference.java
License:Open Source License
/** Convert the type in stack map frame to inference type. */ private InferredType convertTypeInStackMapFrame(Object typeInStackMapFrame) { if (typeInStackMapFrame == Opcodes.TOP) { return InferredType.TOP; } else if (typeInStackMapFrame == Opcodes.INTEGER) { return InferredType.INT; } else if (typeInStackMapFrame == Opcodes.FLOAT) { return InferredType.FLOAT; } else if (typeInStackMapFrame == Opcodes.DOUBLE) { return InferredType.DOUBLE; } else if (typeInStackMapFrame == Opcodes.LONG) { return InferredType.LONG; } else if (typeInStackMapFrame == Opcodes.NULL) { return InferredType.NULL; } else if (typeInStackMapFrame == Opcodes.UNINITIALIZED_THIS) { return InferredType.UNINITIALIZED_THIS; } else if (typeInStackMapFrame instanceof String) { String referenceTypeName = (String) typeInStackMapFrame; if (referenceTypeName.charAt(0) == '[') { return InferredType.createNonUninitializedType(referenceTypeName); } else {/*from ww w.jav a 2 s.c om*/ return InferredType.createNonUninitializedType('L' + referenceTypeName + ';'); } } else if (typeInStackMapFrame instanceof Label) { Label label = (Label) typeInStackMapFrame; return InferredType.createUninitializedType(label); } else { throw new RuntimeException("Cannot reach here. Unhandled element: value=" + typeInStackMapFrame + ", class=" + typeInStackMapFrame.getClass() + ". The current method being desugared is " + methodSignature); } }
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: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); }// w w w .j a va 2s . com 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(); }/*from w w w . j a v a2 s .c o m*/ } 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;//from w ww.j a v a 2s .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().//from w w w . j av 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); }