private Map mergeMultiAndSingle(MultiType multi, Type single) { Map map1 = getAllMultiInterfaces(multi); Map map2 = getAllInterfaces(single.getCtClass(), null); return findCommonInterfaces(map1, map2); }
private void mergeExceptionHandlers(IntQueue queue, MethodInfo method, int pos, Frame frame) { for (int i = 0; i < exceptions.length; i++) { ExceptionInfo exception = exceptions[i]; // Start is inclusive, while end is exclusive! if (pos >= exception.start && pos < exception.end) { Frame newFrame = frame.copy(); newFrame.clearStack(); newFrame.push(exception.type); merge(queue, newFrame, exception.handler); } } }
private void evalLoad(Type expected, int index, Frame frame, Subroutine subroutine) throws BadBytecode { Type type = frame.getLocal(index); verifyAssignable(expected, type); simplePush(type, frame); access(index, type, subroutine); }
private void evalStore(Type expected, int index, Frame frame, Subroutine subroutine) throws BadBytecode { Type type = simplePop(frame); // RETURN_ADDRESS is allowed by ASTORE if (! (expected == Type.OBJECT && type == Type.RETURN_ADDRESS)) verifyAssignable(expected, type); simpleSetLocal(index, type, frame); access(index, type, subroutine); }
private void evalBinaryMath(Type expected, Frame frame) throws BadBytecode { Type value2 = simplePop(frame); Type value1 = simplePop(frame); verifyAssignable(expected, value2); verifyAssignable(expected, value1); simplePush(value1, frame); }
private void printLocals(Frame frame) { stream.print("locals ["); int length = frame.localsLength(); for (int i = 0; i < length; i++) { if (i > 0) stream.print(", "); Type type = frame.getLocal(i); stream.print(type == null ? "empty" : type.toString()); } stream.println("]"); }
private Map findCommonInterfaces(Type type) { Map typeMap = getAllInterfaces(type.clazz, null); Map thisMap = getAllInterfaces(this.clazz, null); return findCommonInterfaces(typeMap, thisMap); }
private Map mergeMultiInterfaces(MultiType type1, MultiType type2) { Map map1 = getAllMultiInterfaces(type1); Map map2 = getAllMultiInterfaces(type2); return findCommonInterfaces(map1, map2); }
Type getRootComponent(Type type) { while (type.isArray()) type = type.getComponent(); return type; }
/** * Prints all the methods declared in the given class. */ public static void print(CtClass clazz, PrintStream stream) { (new FramePrinter(stream)).print(clazz); }
/** * Gets the class that corresponds with this type. If this information * is not yet known, java.lang.Object will be returned. */ public CtClass getCtClass() { if (resolved != null) return resolved.getCtClass(); return Type.OBJECT.getCtClass(); }
public boolean equals(Object o) { if (! (o instanceof MultiArrayType)) return false; MultiArrayType multi = (MultiArrayType)o; return component.equals(multi.component) && dims == multi.dims; }
void add(int value) { IntQueue.Entry entry = new Entry(value); if (tail != null) tail.next = entry; tail = entry; if (head == null) head = entry; }
private void evalShift(Type expected, Frame frame) throws BadBytecode { Type value2 = simplePop(frame); Type value1 = simplePop(frame); verifyAssignable(Type.INTEGER, value2); verifyAssignable(expected, value1); simplePush(value1, frame); }