@Override public int compareTo(Location other) { int pos = handle.getPosition() - other.handle.getPosition(); return pos; }
/** * Is the given instruction part of this subroutine? */ public boolean containsInstruction(InstructionHandle handle) { return instructionSet.get(handle.getPosition()); }
/** * Return whether or not the given instruction is a load. * * @param handle * the instruction * @return true if the instruction is a load, false if not */ public boolean instructionIsLoad(InstructionHandle handle) { return loadHandleSet.get(handle.getPosition()); } }
@Override public int hashCode() { if (hash == 0) { return hash = System.identityHashCode(basicBlock) + handle.getPosition(); } return hash; }
@Override public String toString() { return valueNumber + " becomes null at " + location.getHandle().getPosition() + ":" + location; } }
/** * @return a compact string of the form "bb:xx", where "bb" is the basic * block number and "xx" is the bytecode offset */ public String toCompactString() { return basicBlock.getLabel() + ":" + handle.getPosition(); } }
public ValueType put(InstructionHandle handle, ValueType value) { ValueType old = get(handle); map[handle.getPosition()] = value; return old; } }
int minPC(Collection<Location> locs) { int result = 1000000; for (Location l : locs) { if (result > l.getHandle().getPosition()) { result = l.getHandle().getPosition(); } } return result; }
public int pos() { if (isEmpty()) { return getExceptionThrower().getPosition(); } return firstInstruction.getPosition(); }
@CheckForNull Location findLocation(CFG cfg, int pc) { for (Iterator<Location> i = cfg.locationIterator(); i.hasNext();) { Location loc = i.next(); if (loc.getHandle().getPosition() == pc) { return loc; } } return null; }
public boolean sourceIsTopOfLoop(@Nonnull Set<Integer> positions) { if (positions == null) { AnalysisContext.logError("Null positions", new NullPointerException("positions can't be null")); return false; } BasicBlock source = getSource(); InstructionHandle sourceInstruction = source.getLastInstruction(); if (sourceInstruction == null) { return false; } return positions.contains(sourceInstruction.getPosition()); }
/** * Create from MethodDescriptor and Location of visited instruction. * * @param methodDescriptor * MethodDescriptor identifying analyzed method * @param location * Location of instruction within analyed method * @return SourceLineAnnotation describing visited instruction */ public static SourceLineAnnotation fromVisitedInstruction(MethodDescriptor methodDescriptor, Location location) { return fromVisitedInstruction(methodDescriptor, location.getHandle().getPosition()); }
@Override public int hashCode() { int code = getBasicBlock().hashCode() * 227; if (next != null) { code += next.getPosition() + 1; } return code; }
public static boolean catchesNull(ConstantPool constantPool, Code code, Location location) { int position = location.getHandle().getPosition(); for (String t : catchTypesForNull) { int catchSize = Util.getSizeOfSurroundingTryBlock(constantPool, code, t, position); if (catchSize < Integer.MAX_VALUE) { return true; } } return false; }
public boolean isBackwardInBytecode() { BasicBlock source = getSource(); BasicBlock target = getTarget(); InstructionHandle sourceInstruction = source.getLastInstruction(); InstructionHandle targetInstruction = target.getFirstInstruction(); if (targetInstruction == null || sourceInstruction == null) { return false; } return targetInstruction.getPosition() < sourceInstruction.getPosition(); }
public static LocalVariableAnnotation getLocalVariableAnnotation(Method method, Location location, IndexedInstruction ins) { int local = ins.getIndex(); InstructionHandle handle = location.getHandle(); int position1 = handle.getNext().getPosition(); int position2 = handle.getPosition(); return getLocalVariableAnnotation(method, local, position1, position2); }
public void add(Location loc, ValueNumber vn, PointerUsageRequiringNonNullValue usage) { Pair p = new Pair(vn, usage); if (DerefFinder.DEBUG) { System.out.println("At " + loc + " adding dereference " + p); } map.add(loc.getHandle().getPosition(), p); }
private static int getLineNumber(Method method, InstructionHandle handle) { LineNumberTable table = method.getCode().getLineNumberTable(); if (table == null) { return -1; } return table.getSourceLine(handle.getPosition()); } }
private static String blockId(BasicBlock bb) { InstructionHandle handle = bb.getFirstInstruction(); if (handle == null) { return "" + bb.getLabel(); } return bb.getLabel() + ":" + handle.getPosition() + " " + handle.getInstruction(); }
boolean inExplictCatchNullBlock(Location loc) { int pc = loc.getHandle().getPosition(); int catchSize = Util.getSizeOfSurroundingTryBlock(classContext.getJavaClass().getConstantPool(), method.getCode(), "java/lang/NullPointerException", pc); if (catchSize < Integer.MAX_VALUE) { return true; } return false; }