/** * Constructs an instance. * * @param method non-null; the method being represented by this instance */ public LocalVariableInfo(RopMethod method) { if (method == null) { throw new NullPointerException("method == null"); } BasicBlockList blocks = method.getBlocks(); int maxLabel = blocks.getMaxLabel(); this.regCount = blocks.getRegCount(); this.emptySet = new RegisterSpecSet(regCount); this.blockStarts = new RegisterSpecSet[maxLabel]; this.insnAssignments = new HashMap<Insn, RegisterSpec>(blocks.getInstructionCount()); emptySet.setImmutable(); }
/** * Merges the given register set into the set for the block with the given label. If there was not * already an associated set, then this is the same as calling {@link #setStarts}. Otherwise, this * will merge the two sets and call {@link #setStarts} on the result of the merge. * * @param label >= 0; the block label * @param specs non-null; the register set to merge into the start set for the block * @return <code>true</code> if the merge resulted in an actual change to the associated set * (including storing one for the first time) or <code>false</code> if there was no change */ public boolean mergeStarts(int label, RegisterSpecSet specs) { RegisterSpecSet start = getStarts0(label); boolean changed = false; if (start == null) { setStarts(label, specs); return true; } RegisterSpecSet newStart = start.mutableCopy(); newStart.intersect(specs, true); if (start.equals(newStart)) { return false; } newStart.setImmutable(); setStarts(label, newStart); return true; }
/** * Gets a mutable copy of the register set associated with the start of the block with the given * label. This returns a newly-allocated empty {@link RegisterSpecSet} of appropriate max size if * there is not yet any set associated with the block. * * @param label >= 0; the block label * @return non-null; the associated register set */ public RegisterSpecSet mutableCopyOfStarts(int label) { RegisterSpecSet result = getStarts0(label); return (result != null) ? result.mutableCopy() : new RegisterSpecSet(regCount); }