@Override public void initSimpleCopy() { first = stats.get(0); default_edge = first.getSuccessorEdges(Statement.STATEDGE_DIRECT_ALL).get(0); sortEdgesAndNodes(); }
private SequenceStatement(Statement head, Statement tail) { this(Arrays.asList(head, tail)); List<StatEdge> lstSuccs = tail.getSuccessorEdges(STATEDGE_DIRECT_ALL); if (!lstSuccs.isEmpty()) { StatEdge edge = lstSuccs.get(0); if (edge.getType() == StatEdge.TYPE_REGULAR && edge.getDestination() != head) { post = edge.getDestination(); } } }
private static boolean checkSynchronizedCompleteness(Set<Statement> setNodes) { // check exit nodes for (Statement stat : setNodes) { if (stat.isMonitorEnter()) { List<StatEdge> lstSuccs = stat.getSuccessorEdges(Statement.STATEDGE_DIRECT_ALL); if (lstSuccs.size() != 1 || lstSuccs.get(0).getType() != StatEdge.TYPE_REGULAR) { return false; } if (!setNodes.contains(lstSuccs.get(0).getDestination())) { return false; } } } return true; }
private SwitchStatement(Statement head, Statement poststat) { this(); first = head; stats.addWithKey(head, head.id); // find post node Set<Statement> lstNodes = new HashSet<>(head.getNeighbours(StatEdge.TYPE_REGULAR, DIRECTION_FORWARD)); // cluster nodes if (poststat != null) { post = poststat; lstNodes.remove(post); } default_edge = head.getSuccessorEdges(Statement.STATEDGE_DIRECT_ALL).get(0); for (Statement st : lstNodes) { stats.addWithKey(st, st.id); } }
@Override public void replaceStatement(Statement oldstat, Statement newstat) { super.replaceStatement(oldstat, newstat); if (ifstat == oldstat) { ifstat = newstat; } if (elsestat == oldstat) { elsestat = newstat; } List<StatEdge> lstSuccs = first.getSuccessorEdges(STATEDGE_DIRECT_ALL); if (iftype == IFTYPE_IF) { ifedge = lstSuccs.get(0); elseedge = null; } else { StatEdge edge0 = lstSuccs.get(0); StatEdge edge1 = lstSuccs.get(1); if (edge0.getDestination() == ifstat) { ifedge = edge0; elseedge = edge1; } else { ifedge = edge1; elseedge = edge0; } } }
@Override public void initSimpleCopy() { first = stats.get(0); List<StatEdge> lstSuccs = first.getSuccessorEdges(STATEDGE_DIRECT_ALL); ifedge = lstSuccs.get((iftype == IFTYPE_IF || negated) ? 0 : 1); if (stats.size() > 1) { ifstat = stats.get(1); } if (iftype == IFTYPE_IFELSE) { elseedge = lstSuccs.get(negated ? 1 : 0); elsestat = stats.get(2); } }
public SynchronizedStatement(Statement head, Statement body, Statement exc) { this(); first = head; stats.addWithKey(head, head.id); this.body = body; stats.addWithKey(body, body.id); stats.addWithKey(exc, exc.id); List<StatEdge> lstSuccs = body.getSuccessorEdges(STATEDGE_DIRECT_ALL); if (!lstSuccs.isEmpty()) { StatEdge edge = lstSuccs.get(0); if (edge.getType() == StatEdge.TYPE_REGULAR) { post = edge.getDestination(); } } }
for (StatEdge edge : stat.getSuccessorEdges(StatEdge.TYPE_REGULAR)) {
public static Statement isHead(Statement head) { if (head.type == TYPE_BASICBLOCK && head.getLastBasicType() == LASTBASICTYPE_IF) { int regsize = head.getSuccessorEdges(StatEdge.TYPE_REGULAR).size(); Statement p = null; boolean ok = (regsize < 2); if (!ok) { List<Statement> lst = new ArrayList<>(); if (DecHelper.isChoiceStatement(head, lst)) { p = lst.remove(0); for (Statement st : lst) { if (st.isMonitorEnter()) { return null; } } ok = DecHelper.checkStatementExceptions(lst); } } if (ok) { return new IfStatement(head, regsize, p); } } return null; }
public static Statement isHead(Statement head) { if (head.getLastBasicType() != Statement.LASTBASICTYPE_GENERAL) { return null; } Set<Statement> setHandlers = DecHelper.getUniquePredExceptions(head); if (setHandlers.size() != 1) { return null; } for (StatEdge edge : head.getSuccessorEdges(StatEdge.TYPE_EXCEPTION)) { Statement exc = edge.getDestination(); if (edge.getExceptions() == null && exc.getLastBasicType() == LASTBASICTYPE_GENERAL && setHandlers.contains(exc)) { List<StatEdge> lstSuccs = exc.getSuccessorEdges(STATEDGE_DIRECT_ALL); if (lstSuccs.isEmpty() || lstSuccs.get(0).getType() != StatEdge.TYPE_REGULAR) { if (head.isMonitorEnter() || exc.isMonitorEnter()) { return null; } if (DecHelper.checkStatementExceptions(Arrays.asList(head, exc))) { return new CatchAllStatement(head, exc); } } } } return null; }
private static void removeNonImmediateEdges(Statement stat) { for (Statement st : stat.getStats()) { removeNonImmediateEdges(st); } if (!stat.hasBasicSuccEdge()) { for (StatEdge edge : stat.getSuccessorEdges(StatEdge.TYPE_CONTINUE | StatEdge.TYPE_BREAK)) { stat.removeSuccessor(edge); } } }
public static Statement isHead2Block(Statement head) { if (head.getLastBasicType() != Statement.LASTBASICTYPE_GENERAL) { return null; } // at most one outgoing edge StatEdge edge = null; List<StatEdge> lstSuccs = head.getSuccessorEdges(STATEDGE_DIRECT_ALL); if (!lstSuccs.isEmpty()) { edge = lstSuccs.get(0); } if (edge != null && edge.getType() == StatEdge.TYPE_REGULAR) { Statement stat = edge.getDestination(); if (stat != head && stat.getPredecessorEdges(StatEdge.TYPE_REGULAR).size() == 1 && !stat.isMonitorEnter()) { if (stat.getLastBasicType() == Statement.LASTBASICTYPE_GENERAL) { if (DecHelper.checkStatementExceptions(Arrays.asList(head, stat))) { return new SequenceStatement(head, stat); } } } } return null; }
private CatchStatement(Statement head, Statement next, Set<Statement> setHandlers) { this(); first = head; stats.addWithKey(first, first.id); for (StatEdge edge : head.getSuccessorEdges(StatEdge.TYPE_EXCEPTION)) { Statement stat = edge.getDestination(); if (setHandlers.contains(stat)) { stats.addWithKey(stat, stat.id); exctstrings.add(new ArrayList<>(edge.getExceptions())); vars.add(new VarExprent(DecompilerContext.getCounterContainer().getCounterAndIncrement(CounterContainer.VAR_COUNTER), new VarType(CodeConstants.TYPE_OBJECT, 0, edge.getExceptions().get(0)), // FIXME: for now simply the first type. Should get the first common superclass when possible. DecompilerContext.getVarProcessor())); } } if (next != null) { post = next; } }
public static Statement isHead(Statement head) { if (head.getLastBasicType() == LASTBASICTYPE_GENERAL && !head.isMonitorEnter()) { // at most one outgoing edge StatEdge edge = null; List<StatEdge> lstSuccs = head.getSuccessorEdges(STATEDGE_DIRECT_ALL); if (!lstSuccs.isEmpty()) { edge = lstSuccs.get(0); } // regular loop if (edge != null && edge.getType() == StatEdge.TYPE_REGULAR && edge.getDestination() == head) { return new DoStatement(head); } // continues if (head.type != TYPE_DO && (edge == null || edge.getType() != StatEdge.TYPE_REGULAR) && head.getContinueSet().contains(head.getBasichead())) { return new DoStatement(head); } } return null; }
private CatchAllStatement(Statement head, Statement handler) { this(); first = head; stats.addWithKey(head, head.id); this.handler = handler; stats.addWithKey(handler, handler.id); List<StatEdge> lstSuccs = head.getSuccessorEdges(STATEDGE_DIRECT_ALL); if (!lstSuccs.isEmpty()) { StatEdge edge = lstSuccs.get(0); if (edge.getType() == StatEdge.TYPE_REGULAR) { post = edge.getDestination(); } } vars.add(new VarExprent(DecompilerContext.getCounterContainer().getCounterAndIncrement(CounterContainer.VAR_COUNTER), new VarType(CodeConstants.TYPE_OBJECT, 0, "java/lang/Throwable"), DecompilerContext.getVarProcessor())); }
Statement stnew = to.getStats().get(i); for (StatEdge edgeold : stold.getSuccessorEdges(Statement.STATEDGE_DIRECT_ALL)) {
public static boolean splitIrreducibleNode(Statement statement) { Statement splitnode = getCandidateForSplitting(statement); if (splitnode == null) { return false; } StatEdge enteredge = splitnode.getPredecessorEdges(StatEdge.TYPE_REGULAR).iterator().next(); // copy the smallest statement Statement splitcopy = copyStatement(splitnode, null, new HashMap<>()); initCopiedStatement(splitcopy); // insert the copy splitcopy.setParent(statement); statement.getStats().addWithKey(splitcopy, splitcopy.id); // switch input edges for (StatEdge prededge : splitnode.getPredecessorEdges(Statement.STATEDGE_DIRECT_ALL)) { if (prededge.getSource() == enteredge.getSource() || prededge.closure == enteredge.getSource()) { splitnode.removePredecessor(prededge); prededge.getSource().changeEdgeNode(Statement.DIRECTION_FORWARD, prededge, splitcopy); splitcopy.addPredecessor(prededge); } } // connect successors for (StatEdge succ : splitnode.getSuccessorEdges(Statement.STATEDGE_DIRECT_ALL)) { splitcopy.addSuccessor(new StatEdge(succ.getType(), splitcopy, succ.getDestination(), succ.closure)); } return true; }
public static TextBuffer jmpWrapper(Statement stat, int indent, boolean semicolon, BytecodeMappingTracer tracer) { TextBuffer buf = stat.toJava(indent, tracer); List<StatEdge> lstSuccs = stat.getSuccessorEdges(Statement.STATEDGE_DIRECT_ALL); if (lstSuccs.size() == 1) { StatEdge edge = lstSuccs.get(0); if (edge.getType() != StatEdge.TYPE_REGULAR && edge.explicit && edge.getDestination().type != Statement.TYPE_DUMMYEXIT) { buf.appendIndent(indent); switch (edge.getType()) { case StatEdge.TYPE_BREAK: addDeletedGotoInstructionMapping(stat, tracer); buf.append("break"); break; case StatEdge.TYPE_CONTINUE: addDeletedGotoInstructionMapping(stat, tracer); buf.append("continue"); } if (edge.labeled) { buf.append(" label").append(edge.closure.id.toString()); } buf.append(";").appendLineSeparator(); tracer.incrementCurrentSourceLine(); } } if (buf.length() == 0 && semicolon) { buf.appendIndent(indent).append(";").appendLineSeparator(); tracer.incrementCurrentSourceLine(); } return buf; }
current.removeSuccessor(current.getSuccessorEdges(Statement.STATEDGE_DIRECT_ALL).get(0));
List<StatEdge> lstSuccs = first.getSuccessorEdges(STATEDGE_DIRECT_ALL); if (first.type == TYPE_TRYCATCH && first.varDefinitions.isEmpty() && isFinally && !labeled && !first.isLabeled() && (lstSuccs.isEmpty() || !lstSuccs.get(0).explicit)) {