Beispiel #1
0
 private void insertCopy(Incoming incoming, Map<BasicBlock, BasicBlock> blockMap) {
   final Phi phi = incoming.getPhi();
   Program program = phi.getBasicBlock().getProgram();
   AssignInstruction copyInstruction = new AssignInstruction();
   Variable firstCopy = program.createVariable();
   copyInstruction.setReceiver(firstCopy);
   copyInstruction.setAssignee(incoming.getValue());
   BasicBlock source = blockMap.get(incoming.getSource());
   if (source == null) {
     source = incoming.getSource();
   } else {
     incoming.setSource(source);
   }
   if (!(incoming.getSource().getLastInstruction() instanceof JumpInstruction)) {
     final BasicBlock copyBlock = program.createBasicBlock();
     JumpInstruction jumpInstruction = new JumpInstruction();
     jumpInstruction.setTarget(phi.getBasicBlock());
     copyBlock.getInstructions().add(jumpInstruction);
     incoming
         .getSource()
         .getLastInstruction()
         .acceptVisitor(
             new BasicBlockMapper(
                 block -> block == phi.getBasicBlock().getIndex() ? copyBlock.getIndex() : block));
     blockMap.put(source, copyBlock);
     incoming.setSource(copyBlock);
     source = copyBlock;
   }
   source.getInstructions().add(source.getInstructions().size() - 1, copyInstruction);
   incoming.setValue(copyInstruction.getReceiver());
 }
Beispiel #2
0
 Statement generateJumpStatement(BasicBlock target) {
   if (nextBlock == target && blockMap[target.getIndex()] == null) {
     return null;
   }
   Decompiler.Block block = blockMap[target.getIndex()];
   if (block == null) {
     throw new IllegalStateException("Could not find block for basic block $" + target.getIndex());
   }
   if (target.getIndex() == indexer.nodeAt(block.end)) {
     BreakStatement breakStmt = new BreakStatement();
     breakStmt.setLocation(currentLocation);
     breakStmt.setTarget(block.statement);
     return breakStmt;
   } else {
     ContinueStatement contStmt = new ContinueStatement();
     contStmt.setLocation(currentLocation);
     contStmt.setTarget(block.statement);
     return contStmt;
   }
 }