ScopeBlock catchSB = findScopeBlock(rootScopeBlock, pc + 1); if ((catchSB != null) && (catchSB.getStart() < pc)) { ScopeBlock sb = new ScopeBlock(pc, catchSB.getFinish()); catchSB.setFinish(getPC() - 1); rootScopeBlock.addChild(sb);
/** * returns the scope block in which this register was assigned, by traversing the scope block tree * * @param sb * the scope block to start searching in * @param pc * the current program counter * @return the scope block or null if not found */ @Nullable private ScopeBlock findScopeBlock(ScopeBlock sb, int pc) { if ((pc <= sb.getStart()) || (pc >= sb.getFinish())) { return null; } if (sb.children != null) { for (ScopeBlock child : sb.children) { ScopeBlock foundSb = findScopeBlock(child, pc); if (foundSb != null) { return foundSb; } } } return sb; }
ScopeBlock catchSB = findScopeBlock(rootScopeBlock, pc + 1); if ((catchSB != null) && (catchSB.getStart() < pc)) { ScopeBlock sb = new ScopeBlock(pc, catchSB.getFinish()); catchSB.setFinish(getPC() - 1); rootScopeBlock.addChild(sb);
/** * returns the scope block in which this register was assigned, by traversing the scope block tree * * @param sb * the scope block to start searching in * @param pc * the current program counter * @return the scope block or null if not found */ @Nullable private ScopeBlock findScopeBlock(ScopeBlock sb, int pc) { if ((pc <= sb.getStart()) || (pc >= sb.getFinish())) { return null; } List<ScopeBlock> children = sb.getChildren(); if (children != null) { for (ScopeBlock child : children) { ScopeBlock foundSb = findScopeBlock(child, pc); if (foundSb != null) { return foundSb; } } } return sb; }
/** * returns an existing scope block that has the same target as the one looked for * * @param sb * the scope block to start with * @param start * the current pc * @param target * the target to look for * * @return the scope block found or null */ private ScopeBlock findScopeBlockWithTarget(ScopeBlock sb, int start, int target) { ScopeBlock parentBlock = null; int finishLocation = sb.getFinish(); if ((sb.getStart() < start) && (finishLocation >= start) && ((finishLocation <= target) || (sb.isGoto() && !sb.isLoop()))) { parentBlock = sb; } List<ScopeBlock> children = sb.getChildren(); if (children != null) { for (ScopeBlock child : children) { ScopeBlock targetBlock = findScopeBlockWithTarget(child, start, target); if (targetBlock != null) { return targetBlock; } } } return parentBlock; }