private DoStatement(Statement head) { this(); first = head; stats.addWithKey(first, first.id); // post is always null! }
public void addInstruction(Instruction inst, int offset) { collinstr.addWithKey(inst, offset); }
public GeneralStatement(Statement head, Collection<? extends Statement> statements, Statement post) { this(); first = head; stats.addWithKey(head, head.id); HashSet<Statement> set = new HashSet<>(statements); set.remove(head); for (Statement st : set) { stats.addWithKey(st, st.id); } this.post = post; }
public E putWithKey(E element, K key) { Integer index = map.get(key); if (index == null) { addWithKey(element, key); } else { return super.set(index, element); } return null; }
public RootStatement(Statement head, DummyExitStatement dummyExit) { type = Statement.TYPE_ROOT; first = head; this.dummyExit = dummyExit; stats.addWithKey(first, first.id); first.setParent(this); }
private void orderStatements() { for (Statement stat : statement.getReversePostOrderList()) { colOrderedIDoms.addWithKey(null, stat.id); } }
public VarVersionNode createNode(VarVersionPair ver) { VarVersionNode node; nodes.addWithKey(node = new VarVersionNode(ver.var, ver.version), ver); return node; }
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(); } } }
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); } }
public SequenceStatement(List<? extends Statement> lst) { this(); lastBasicType = lst.get(lst.size() - 1).getLastBasicType(); for (Statement st : lst) { stats.addWithKey(st, st.id); } first = stats.get(0); }
public void sortReversePostOrder() { LinkedList<DirectNode> res = new LinkedList<>(); addToReversePostOrderListIterative(first, res); nodes.clear(); for (DirectNode node : res) { nodes.addWithKey(node, node.id); } }
private void orderNodes() { setRoots = graph.getRoots(); for (IGraphNode node : graph.getReversePostOrderList()) { colOrderedIDoms.addWithKey(null, node); } }
public DirectGraph buildDirectGraph(RootStatement root) { this.root = root; graph = new DirectGraph(); flattenStatement(); // dummy exit node Statement dummyexit = root.getDummyExit(); DirectNode node = new DirectNode(DirectNode.NODE_DIRECT, dummyexit, dummyexit.id.toString()); node.exprents = new ArrayList<>(); graph.nodes.addWithKey(node, node.id); mapDestinationNodes.put(dummyexit.id, new String[]{node.id, null}); setEdges(); graph.first = graph.nodes.getWithKey(mapDestinationNodes.get(root.id)[0]); graph.sortReversePostOrder(); return graph; }
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())); }
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; } }
private VBStyleCollection<BasicBlock, Integer> createBasicBlocks(short[] startblock, InstructionSequence instrseq, Map<Integer, BasicBlock> mapInstrBlocks) { VBStyleCollection<BasicBlock, Integer> col = new VBStyleCollection<>(); InstructionSequence currseq = null; List<Integer> lstOffs = null; int len = startblock.length; short counter = 0; int blockoffset = 0; BasicBlock currentBlock = null; for (int i = 0; i < len; i++) { if (startblock[i] == 1) { currentBlock = new BasicBlock(++counter); currseq = currentBlock.getSeq(); lstOffs = currentBlock.getInstrOldOffsets(); col.addWithKey(currentBlock, currentBlock.id); blockoffset = instrseq.getOffset(i); } startblock[i] = counter; mapInstrBlocks.put(i, currentBlock); currseq.addInstruction(instrseq.getInstr(i), instrseq.getOffset(i) - blockoffset); lstOffs.add(instrseq.getOffset(i)); } last_id = counter; return col; }
graph.getBlocks().addWithKey(emptyblock, emptyblock.id);
private static void insertBlockBefore(ControlFlowGraph graph, BasicBlock oldblock, BasicBlock newblock) { List<BasicBlock> lstTemp = new ArrayList<>(); lstTemp.addAll(oldblock.getPreds()); lstTemp.addAll(oldblock.getPredExceptions()); // replace predecessors for (BasicBlock pred : lstTemp) { pred.replaceSuccessor(oldblock, newblock); } // copy exception edges and extend protected ranges for (BasicBlock hd : oldblock.getSuccExceptions()) { newblock.addSuccessorException(hd); ExceptionRangeCFG range = graph.getExceptionRange(hd, oldblock); range.getProtectedRange().add(newblock); } // replace handler for (ExceptionRangeCFG range : graph.getExceptions()) { if (range.getHandler() == oldblock) { range.setHandler(newblock); } } newblock.addSuccessor(oldblock); graph.getBlocks().addWithKey(newblock, newblock.id); if (graph.getFirst() == oldblock) { graph.setFirst(newblock); } }
Statement stcopy = st.getSimpleCopy(); to.getStats().addWithKey(stcopy, stcopy.id); mapAltToCopies.put(st, stcopy);
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; }