static int count(final Map<Variable, MutableInteger> map, final Variable variable) { final MutableInteger count = map.get(variable); return count != null ? count.getValue() : 0; }
static int count(final Map<Variable, MutableInteger> map, final Variable variable) { final MutableInteger count = map.get(variable); return count != null ? count.getValue() : 0; }
static int count(final Map<Variable, MutableInteger> map, final Variable variable) { final MutableInteger count = map.get(variable); return count != null ? count.getValue() : 0; }
private static void parseTypeParameters( final String s, final MutableInteger position, final Type<?> resolvedType, final Type<?>[] typeArguments) { int i = position.getValue(); assert s.charAt(i) == '<'; position.increment(); for (int j = 0; j < typeArguments.length; j++) { typeArguments[j] = parseTypeArgument(s, position, resolvedType, j); } i = position.getValue(); if (s.charAt(i) != '>') { throw Error.invalidSignatureExpectedEndOfTypeArguments(s, i); } position.increment(); }
private static void parseTypeParameters( final String s, final MutableInteger position, final Type<?> resolvedType, final Type<?>[] typeArguments) { int i = position.getValue(); assert s.charAt(i) == '<'; position.increment(); for (int j = 0; j < typeArguments.length; j++) { typeArguments[j] = parseTypeArgument(s, position, resolvedType, j); } i = position.getValue(); if (s.charAt(i) != '>') { throw Error.invalidSignatureExpectedEndOfTypeArguments(s, i); } position.increment(); }
private static void parseTypeParameters( final String s, final MutableInteger position, final Type<?> resolvedType, final Type<?>[] typeArguments) { int i = position.getValue(); assert s.charAt(i) == '<'; position.increment(); for (int j = 0; j < typeArguments.length; j++) { typeArguments[j] = parseTypeArgument(s, position, resolvedType, j); } i = position.getValue(); if (s.charAt(i) != '>') { throw Error.invalidSignatureExpectedEndOfTypeArguments(s, i); } position.increment(); }
final boolean inlineIfPossible(final List<Node> body, final MutableInteger position) { final int currentPosition = position.getValue(); if (inlineOneIfPossible(body, currentPosition, true)) { position.setValue(currentPosition - inlineInto(body, currentPosition, _aggressive)); return true; } return false; }
final boolean inlineIfPossible(final List<Node> body, final MutableInteger position) { final int currentPosition = position.getValue(); if (inlineOneIfPossible(body, currentPosition, true)) { position.setValue(currentPosition - inlineInto(body, currentPosition, _aggressive)); return true; } return false; }
final boolean inlineIfPossible(final List<Node> body, final MutableInteger position) { final int currentPosition = position.getValue(); if (inlineOneIfPossible(body, currentPosition, true)) { position.setValue(currentPosition - inlineInto(body, currentPosition, _aggressive)); return true; } return false; }
@Override protected boolean run( final List<Node> body, final BasicBlock branchBlock, final Expression branchCondition, final Label thenLabel, final Label elseLabel, final boolean negate) { if (labelGlobalRefCount.get(elseLabel).getValue() != 1) { return false; } final BasicBlock elseBlock = labelToBasicBlock.get(elseLabel); if (matchSingleAndBreak(elseBlock, AstCode.IfTrue, label1, expression, label2)) { final Label elseThenLabel = label1.get(); final Label elseElseLabel = label2.get(); final Expression elseCondition = expression.get(); return runCore(body, branchBlock, branchCondition, thenLabel, elseLabel, elseCondition, negate, elseThenLabel, elseElseLabel, false) || runCore(body, branchBlock, branchCondition, thenLabel, elseLabel, elseCondition, negate, elseElseLabel, elseThenLabel, true); } return false; }
@Override protected boolean run( final List<Node> body, final BasicBlock branchBlock, final Expression branchCondition, final Label thenLabel, final Label elseLabel, final boolean negate) { if (labelGlobalRefCount.get(elseLabel).getValue() != 1) { return false; } final BasicBlock elseBlock = labelToBasicBlock.get(elseLabel); if (matchSingleAndBreak(elseBlock, AstCode.IfTrue, label1, expression, label2)) { final Label elseThenLabel = label1.get(); final Label elseElseLabel = label2.get(); final Expression elseCondition = expression.get(); return runCore(body, branchBlock, branchCondition, thenLabel, elseLabel, elseCondition, negate, elseThenLabel, elseElseLabel, false) || runCore(body, branchBlock, branchCondition, thenLabel, elseLabel, elseCondition, negate, elseElseLabel, elseThenLabel, true); } return false; }
@Override protected boolean run( final List<Node> body, final BasicBlock branchBlock, final Expression branchCondition, final Label thenLabel, final Label elseLabel, final boolean negate) { if (labelGlobalRefCount.get(elseLabel).getValue() != 1) { return false; } final BasicBlock elseBlock = labelToBasicBlock.get(elseLabel); if (matchSingleAndBreak(elseBlock, AstCode.IfTrue, label1, expression, label2)) { final Label elseThenLabel = label1.get(); final Label elseElseLabel = label2.get(); final Expression elseCondition = expression.get(); return runCore(body, branchBlock, branchCondition, thenLabel, elseLabel, elseCondition, negate, elseThenLabel, elseElseLabel, false) || runCore(body, branchBlock, branchCondition, thenLabel, elseLabel, elseCondition, negate, elseElseLabel, elseThenLabel, true); } return false; }
private static boolean introducePreIncrementForVariables(final List<Node> body, final MutableInteger position) { final int i = position.getValue(); if (i >= body.size() - 1) { return false; } final Node node = body.get(i); final Node next = body.get(i + 1); final StrongBox<Variable> v = new StrongBox<>(); final StrongBox<Expression> t = new StrongBox<>(); final StrongBox<Integer> d = new StrongBox<>(); if (!(node instanceof Expression && next instanceof Expression)) { return false; } final Expression e = (Expression) node; final Expression n = (Expression) next; if (matchGetArgument(e, AstCode.Inc, v, t) && matchGetOperand(t.get(), AstCode.LdC, Integer.class, d) && Math.abs(d.get()) == 1 && match(n, AstCode.Store) && matchLoad(n.getArguments().get(0), v.get())) { n.getArguments().set( 0, new Expression(AstCode.PreIncrement, d.get(), n.getArguments().get(0).getOffset(), n.getArguments().get(0)) ); body.remove(i); position.decrement(); return true; } return false; }
private static boolean introducePreIncrementForVariables(final List<Node> body, final MutableInteger position) { final int i = position.getValue(); if (i >= body.size() - 1) { return false; } final Node node = body.get(i); final Node next = body.get(i + 1); final StrongBox<Variable> v = new StrongBox<>(); final StrongBox<Expression> t = new StrongBox<>(); final StrongBox<Integer> d = new StrongBox<>(); if (!(node instanceof Expression && next instanceof Expression)) { return false; } final Expression e = (Expression) node; final Expression n = (Expression) next; if (matchGetArgument(e, AstCode.Inc, v, t) && matchGetOperand(t.get(), AstCode.LdC, Integer.class, d) && Math.abs(d.get()) == 1 && match(n, AstCode.Store) && matchLoad(n.getArguments().get(0), v.get())) { n.getArguments().set( 0, new Expression(AstCode.PreIncrement, d.get(), n.getArguments().get(0).getOffset(), n.getArguments().get(0)) ); body.remove(i); position.decrement(); return true; } return false; }
private static boolean introducePreIncrementForVariables(final List<Node> body, final MutableInteger position) { final int i = position.getValue(); if (i >= body.size() - 1) { return false; } final Node node = body.get(i); final Node next = body.get(i + 1); final StrongBox<Variable> v = new StrongBox<>(); final StrongBox<Expression> t = new StrongBox<>(); final StrongBox<Integer> d = new StrongBox<>(); if (!(node instanceof Expression && next instanceof Expression)) { return false; } final Expression e = (Expression) node; final Expression n = (Expression) next; if (matchGetArgument(e, AstCode.Inc, v, t) && matchGetOperand(t.get(), AstCode.LdC, Integer.class, d) && Math.abs(d.get()) == 1 && match(n, AstCode.Store) && matchLoad(n.getArguments().get(0), v.get())) { n.getArguments().set( 0, new Expression(AstCode.PreIncrement, d.get(), n.getArguments().get(0).getOffset(), n.getArguments().get(0)) ); body.remove(i); position.decrement(); return true; } return false; }
!secondToLast.isConditionalControlFlow() && matchGetOperand(headBody.get(headBody.size() - 1), AstCode.Goto, nextLabel) && labelGlobalRefCount.get(nextLabel.get()).getValue() == 1 & (nextBlock = labelToBasicBlock.get(nextLabel.get())) != null && nextBlock != EMPTY_BLOCK && labelGlobalRefCount.get(firstInTryBody).getValue() > 1) {
private static void introducePreIncrementOptimization(final DecompilerContext context, final Block method) { final Inlining inlining = new Inlining(context, method); inlining.analyzeMethod(); for (final Block block : method.getSelfAndChildrenRecursive(Block.class)) { final List<Node> body = block.getBody(); final MutableInteger position = new MutableInteger(); for (; position.getValue() < body.size() - 1; position.increment()) { if (!introducePreIncrementForVariables(body, position) && !introducePreIncrementForStaticFields(body, position, inlining)) { introducePreIncrementForInstanceFields(body, position, inlining); } } } }
private static void introducePreIncrementOptimization(final DecompilerContext context, final Block method) { final Inlining inlining = new Inlining(context, method); inlining.analyzeMethod(); for (final Block block : method.getSelfAndChildrenRecursive(Block.class)) { final List<Node> body = block.getBody(); final MutableInteger position = new MutableInteger(); for (; position.getValue() < body.size() - 1; position.increment()) { if (!introducePreIncrementForVariables(body, position) && !introducePreIncrementForStaticFields(body, position, inlining)) { introducePreIncrementForInstanceFields(body, position, inlining); } } } }
private static void introducePreIncrementOptimization(final DecompilerContext context, final Block method) { final Inlining inlining = new Inlining(context, method); inlining.analyzeMethod(); for (final Block block : method.getSelfAndChildrenRecursive(Block.class)) { final List<Node> body = block.getBody(); final MutableInteger position = new MutableInteger(); for (; position.getValue() < body.size() - 1; position.increment()) { if (!introducePreIncrementForVariables(body, position) && !introducePreIncrementForStaticFields(body, position, inlining)) { introducePreIncrementForInstanceFields(body, position, inlining); } } } }