Package org.candle.decompiler.intermediate.code

Examples of org.candle.decompiler.intermediate.code.AbstractIntermediate


  }

  @Override
  public void visitCaseIntermediate(CaseIntermediate line) {
    //find successor of Case...
    AbstractIntermediate ai = igc.getSingleSuccessor(line);
   
    //find the previous node...
    Set<AbstractIntermediate> predecessors = new HashSet<AbstractIntermediate>(Graphs.predecessorListOf(igc.getGraph(), ai));
    predecessors.remove(line);
   
View Full Code Here


      //check to see that 1 predecessor is a GOTO.
     
      TreeSet<GoToIntermediate> incomingGotoNonNested = new TreeSet<GoToIntermediate>(new IntermediateComparator());
      TreeSet<GoToIntermediate> incomingGotoNested = new TreeSet<GoToIntermediate>(new IntermediateComparator());
      GoToIntermediate nestedLine = null;
      AbstractIntermediate otherLine = null;
     
      //classify.
      for(AbstractIntermediate predecessor : predecessors) {
        //check to see if 1 is GOTO.
        if(predecessor instanceof GoToIntermediate) {
View Full Code Here

              //check to see if the declaration is the same as the iterator's name.
              if(StringUtils.equals(iteratorName, v.getName())) {
                LOG.debug("Identified Likely Iterator: "+v.getName());
               
                //get the ".next()" statement, which should be the first child.
                AbstractIntermediate firstChild = igc.getTrueTarget(line);
               
                //see if this is a statement, if the statement is an assignment...
                //then check the right side to see if it is an invocation.. and the invocation has the method name "next"...
                if(firstChild instanceof StatementIntermediate) {
                  StatementIntermediate nextStatement = (StatementIntermediate)firstChild;
View Full Code Here

    super(igc, false);
  }

  @Override
  public void visitWhileIntermediate(WhileIntermediate line) {
    AbstractIntermediate falseTarget = igc.getFalseTarget(line);
    AbstractIntermediate trueTarget = igc.getTrueTarget(line);
   
    line.getBlockRange().setStart(trueTarget.getInstruction());
    line.getBlockRange().setEnd(falseTarget.getInstruction().getPrev());
    super.visitWhileIntermediate(line);
  }
View Full Code Here

    }
   
    //find the element directly after this one...
    SortedSet<AbstractIntermediate> elseBranchElements = igc.getOrderedIntermediate().subSet(maxGotoForBranch, false, line, false);
   
    AbstractIntermediate ai = igc.getSinglePredecessor(elseBranchElements.first());
    if(!(ai instanceof IfIntermediate || ai instanceof ElseIfIntermediate)) {
      return;
    }
   
   
   
    //get the first element...
    if(elseBranchElements.size() > 0) {
      AbstractIntermediate firstElseBlockElement = elseBranchElements.first();
      if(firstElseBlockElement instanceof StatementIntermediate) {
        //we should add the ELSE right away...
       
        addElseBlock(firstElseBlockElement, maxGotoForBranch);
        return;
      }
     
      if(firstElseBlockElement instanceof BooleanBranchIntermediate) {
        //only add ELSE if the child of conditional doesn't go to the target.
        BooleanBranchIntermediate ci = (BooleanBranchIntermediate)firstElseBlockElement;
        if(igc.getFalseTarget(ci) == line || igc.getTrueTarget(ci) == line) {
          //do nothing.
          return;
        }
       
        //else if this is an ElseIf, probably should be an IF.
        if(firstElseBlockElement instanceof ElseIfIntermediate) {
          IfIntermediate ifIntermediate = new IfIntermediate(firstElseBlockElement.getInstruction(), ((BooleanBranchIntermediate) firstElseBlockElement).getExpression());
          igc.getGraph().addVertex(ifIntermediate);
          igc.redirectPredecessors(firstElseBlockElement, ifIntermediate);
          igc.redirectSuccessors(firstElseBlockElement, ifIntermediate);
          igc.getGraph().removeVertex(firstElseBlockElement);
         
View Full Code Here

  @Override
  public void visitFinallyIntermediate(FinallyIntermediate line) {
    NonGotoIterator iter = new NonGotoIterator(igc.getGraph(), line);
    //walk until we find a THROW.
   
    AbstractIntermediate throwsStatement = null;
    while(iter.hasNext()) {
      AbstractIntermediate i = iter.next();
      if(i instanceof StatementIntermediate) {
        StatementIntermediate s = (StatementIntermediate)i;
       
        if(s.getExpression() instanceof Throw) {
          throwsStatement = s;
View Full Code Here

 
  @Override
  public void visitSwitchIntermediate(SwitchIntermediate line) {
    boolean foundUpper = false;
   
    AbstractIntermediate lastNode = igc.findNextNode(findMaxCase(line).getTarget());
    TreeSet<AbstractIntermediate> elements = (TreeSet<AbstractIntermediate>)igc.getOrderedIntermediate().subSet(line, true, lastNode, false);
   
    int position = lastNode.getInstruction().getPosition();
   
    //look for goto statements...
    for(AbstractIntermediate element : elements) {
      if(element instanceof GoToIntermediate) {
        GoToIntermediate gti = (GoToIntermediate)element;
       
        if(igc.getTarget(gti).getInstruction().getPosition() > position) {
          line.getBlockRange().setEnd(igc.getTarget(gti).getInstruction().getPrev());
          foundUpper = true;
          break;
        }
      }
    }
   
    if(!foundUpper) {
      //find the last node... and then get the next.
      line.getBlockRange().setEnd(lastNode.getInstruction());
    }
   
  }
View Full Code Here

    Collections.sort(switchCases, new CaseIntermediateComparator());
    return switchCases;
  }
 
  public Set<AbstractIntermediate> getNodesWithinRange(BlockRange blockRange) {
    AbstractIntermediate start = findNextNode(blockRange.getStart());
    AbstractIntermediate end = findPreviousNode(blockRange.getEnd());
   
    return orderedIntermediate.subSet(start, false, end, false);
  }
View Full Code Here

    }
    //processLastCatch(line);
   
    BreadthFirstIterator<AbstractIntermediate, IntermediateEdge> bfi = new BreadthFirstIterator<AbstractIntermediate, IntermediateEdge>(igc.getGraph(), line);
   
    AbstractIntermediate lastStatement = null;
    while(bfi.hasNext()) {
      AbstractIntermediate next = bfi.next();
      if(next instanceof GoToIntermediate) {
        //this would be a possible GOTO... find previous.
        LOG.debug("Catch GOGO: "+next+" goto:"+next.getInstruction().getPosition());
        lastStatement = igc.getSinglePredecessor(next);
        break;
      }
      if(next instanceof StatementIntermediate) {
        //determine what type of statement...
View Full Code Here

    GoToIntermediate gotoHandle = (GoToIntermediate)igc.findNextNode(ih.getNext());
    TreeSet<AbstractIntermediate> ordered = new TreeSet<AbstractIntermediate>(new IntermediateComparator());
    //no finally clause...
    ordered.addAll(igc.getCatchClauses(tryBlock));
   
    AbstractIntermediate target = igc.getTarget(gotoHandle);
    //now, look backwards and find the non-GOTO statement.
   
    List<AbstractIntermediate> candidates = Graphs.predecessorListOf(igc.getGraph(), target);
    Set<AbstractIntermediate> elements = new HashSet<AbstractIntermediate>();
   
View Full Code Here

TOP

Related Classes of org.candle.decompiler.intermediate.code.AbstractIntermediate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.