public static <T> T last(final Iterable<T> collection) { VerifyArgument.notNull(collection, "collection"); if (collection instanceof List<?>) { return last((List<T>) collection); } final Iterator<T> iterator = collection.iterator(); final boolean hasAny = iterator.hasNext(); if (!hasAny) { throw Error.sequenceHasNoElements(); } T last; do { last = iterator.next(); } while (iterator.hasNext()); return last; }
public static <T> T last(final Iterable<T> collection) { VerifyArgument.notNull(collection, "collection"); if (collection instanceof List<?>) { return last((List<T>) collection); } final Iterator<T> iterator = collection.iterator(); final boolean hasAny = iterator.hasNext(); if (!hasAny) { throw Error.sequenceHasNoElements(); } T last; do { last = iterator.next(); } while (iterator.hasNext()); return last; }
public static <T> T last(final Iterable<T> collection) { VerifyArgument.notNull(collection, "collection"); if (collection instanceof List<?>) { return last((List<T>) collection); } final Iterator<T> iterator = collection.iterator(); final boolean hasAny = iterator.hasNext(); if (!hasAny) { throw Error.sequenceHasNoElements(); } T last; do { last = iterator.next(); } while (iterator.hasNext()); return last; }
private boolean isSingleStoreBoolean(final Variable variable) { if (_singleStoreVariables.contains(variable)) { final List<ExpressionToInfer> assignments = _assignmentExpressions.get(variable); final ExpressionToInfer e = single(assignments); return matchBooleanConstant(last(e.expression.getArguments())) != null; } return false; }
private boolean isSingleStoreBoolean(final Variable variable) { if (_singleStoreVariables.contains(variable)) { final List<ExpressionToInfer> assignments = _assignmentExpressions.get(variable); final ExpressionToInfer e = single(assignments); return matchBooleanConstant(last(e.expression.getArguments())) != null; } return false; }
private boolean isSingleStoreBoolean(final Variable variable) { if (_singleStoreVariables.contains(variable)) { final List<ExpressionToInfer> assignments = _assignmentExpressions.get(variable); final ExpressionToInfer e = single(assignments); return matchBooleanConstant(last(e.expression.getArguments())) != null; } return false; }
public SubroutineInfo(final ControlFlowNode entryNode, final List<ControlFlowNode> contents, final ControlFlowGraph cfg) { this.start = entryNode.getStart(); this.end = last(contents).getEnd(); this.entryNode = entryNode; this.contents = contents; this.cfg = cfg; for (final ControlFlowNode node : contents) { if (node.getNodeType() == ControlFlowNodeType.Normal && node.getEnd().getOpCode().isReturnFromSubroutine()) { this.exitNodes.add(node); } } } }
public SubroutineInfo(final ControlFlowNode entryNode, final List<ControlFlowNode> contents, final ControlFlowGraph cfg) { this.start = entryNode.getStart(); this.end = last(contents).getEnd(); this.entryNode = entryNode; this.contents = contents; this.cfg = cfg; for (final ControlFlowNode node : contents) { if (node.getNodeType() == ControlFlowNodeType.Normal && node.getEnd().getOpCode().isReturnFromSubroutine()) { this.exitNodes.add(node); } } } }
public SubroutineInfo(final ControlFlowNode entryNode, final List<ControlFlowNode> contents, final ControlFlowGraph cfg) { this.start = entryNode.getStart(); this.end = last(contents).getEnd(); this.entryNode = entryNode; this.contents = contents; this.cfg = cfg; for (final ControlFlowNode node : contents) { if (node.getNodeType() == ControlFlowNodeType.Normal && node.getEnd().getOpCode().isReturnFromSubroutine()) { this.exitNodes.add(node); } } } }
@SuppressWarnings("ConstantConditions") private void transformLeaveStatements(final Block method) { final StrongBox<Label> target = new StrongBox<>(); final Set<Node> visitedNodes = new LinkedHashSet<>(); outer: for (final Expression e : method.getSelfAndChildrenRecursive(Expression.class)) { if (matchGetOperand(e, AstCode.Goto, target)) { visitedNodes.clear(); final Node exit = exit(e, new HashSet<Node>()); if (exit != null && matchLeaveHandler(exit)) { final Node parent = parentLookup.get(e); final Node grandParent = parent != null ? parentLookup.get(parent) : null; if (parent instanceof Block && (grandParent instanceof CatchBlock || grandParent instanceof TryCatchBlock) && e == last(((Block) parent).getBody())) { if (grandParent instanceof TryCatchBlock && parent == ((TryCatchBlock) grandParent).getFinallyBlock()) { e.setCode(AstCode.EndFinally); } else { e.setCode(AstCode.Leave); } e.setOperand(null); } } } } }
@SuppressWarnings("ConstantConditions") private void transformLeaveStatements(final Block method) { final StrongBox<Label> target = new StrongBox<>(); final Set<Node> visitedNodes = new LinkedHashSet<>(); outer: for (final Expression e : method.getSelfAndChildrenRecursive(Expression.class)) { if (matchGetOperand(e, AstCode.Goto, target)) { visitedNodes.clear(); final Node exit = exit(e, new HashSet<Node>()); if (exit != null && matchLeaveHandler(exit)) { final Node parent = parentLookup.get(e); final Node grandParent = parent != null ? parentLookup.get(parent) : null; if (parent instanceof Block && (grandParent instanceof CatchBlock || grandParent instanceof TryCatchBlock) && e == last(((Block) parent).getBody())) { if (grandParent instanceof TryCatchBlock && parent == ((TryCatchBlock) grandParent).getFinallyBlock()) { e.setCode(AstCode.EndFinally); } else { e.setCode(AstCode.Leave); } e.setOperand(null); } } } } }
final Node lastInFinally = last(finallyBlock.getBody());
@SuppressWarnings("ConstantConditions") private void transformLeaveStatements(final Block method) { final StrongBox<Label> target = new StrongBox<>(); final Set<Node> visitedNodes = new LinkedHashSet<>(); outer: for (final Expression e : method.getSelfAndChildrenRecursive(Expression.class)) { if (matchGetOperand(e, AstCode.Goto, target)) { visitedNodes.clear(); final Node exit = exit(e, new HashSet<Node>()); if (exit != null && matchLeaveHandler(exit)) { final Node parent = parentLookup.get(e); final Node grandParent = parent != null ? parentLookup.get(parent) : null; if (parent instanceof Block && (grandParent instanceof CatchBlock || grandParent instanceof TryCatchBlock) && e == last(((Block) parent).getBody())) { if (grandParent instanceof TryCatchBlock && parent == ((TryCatchBlock) grandParent).getFinallyBlock()) { e.setCode(AstCode.EndFinally); } else { e.setCode(AstCode.Leave); } e.setOperand(null); } } } } }
remapHandlersForInlinedSubroutine(reference, first(contents), last(contents)); duplicateHandlersForInlinedSubroutine(subroutine, remappedJumps);
Instruction last = last(finallyNodes).getEnd(); Instruction nextToLast = last.getPrevious();
Instruction last = last(finallyNodes).getEnd(); Instruction nextToLast = last.getPrevious();
new InstructionBlock( _instructions.atOffset(entry.getStartOffset()), afterTry != null ? afterTry.getPrevious() : last(_instructions) ), new InstructionBlock( new InstructionBlock( _instructions.atOffset(entry.getStartOffset()), afterTry != null ? afterTry.getPrevious() : last(_instructions) ), new InstructionBlock(
new InstructionBlock( _instructions.atOffset(entry.getStartOffset()), afterTry != null ? afterTry.getPrevious() : last(_instructions) ), new InstructionBlock( new InstructionBlock( _instructions.atOffset(entry.getStartOffset()), afterTry != null ? afterTry.getPrevious() : last(_instructions) ), new InstructionBlock(
Instruction last = last(finallyNodes).getEnd(); Instruction nextToLast = last.getPrevious();
new InstructionBlock( _instructions.atOffset(entry.getStartOffset()), afterTry != null ? afterTry.getPrevious() : last(_instructions) ), new InstructionBlock( new InstructionBlock( _instructions.atOffset(entry.getStartOffset()), afterTry != null ? afterTry.getPrevious() : last(_instructions) ), new InstructionBlock(