Package org.apache.bcel.generic

Examples of org.apache.bcel.generic.InstructionHandle


    _falseList.append(exp._falseList);
      }
  }

  // Backpatch true list and restore current iterator/node
  InstructionHandle restore;
  restore = il.append(methodGen.storeCurrentNode());
  backPatchTrueList(restore);
  BranchHandle skipFalse = il.append(new GOTO(null));

  // Backpatch false list and restore current iterator/node
View Full Code Here


      // Translate left hand side - must be true
      _left.translateDesynthesized(classGen, methodGen);

      // Need this for chaining any OR-expression children
      InstructionHandle middle = il.append(NOP);

      // Translate left right side - must be true
      _right.translateDesynthesized(classGen, methodGen);

      // Need this for chaining any OR-expression children
      InstructionHandle after = il.append(NOP);

      // Append child expression false-lists to our false-list
      _falseList.append(_right._falseList.append(_left._falseList));

      // Special case for OR-expression as a left child of AND.
      // The true-list of OR must point to second clause of AND.
      if ((_left instanceof LogicalExpr) &&
    (((LogicalExpr)_left).getOp() == OR)) {
    _left.backPatchTrueList(middle);
      }
      else if (_left instanceof NotCall) {
    _left.backPatchTrueList(middle);
      }
      else {
    _trueList.append(_left._trueList);
      }

      // Special case for OR-expression as a right child of AND
      // The true-list of OR must point to true-list of AND.
      if ((_right instanceof LogicalExpr) &&
    (((LogicalExpr)_right).getOp() == OR)) {
    _right.backPatchTrueList(after);
      }
      else if (_right instanceof NotCall) {
    _right.backPatchTrueList(after);
      }
      else {
    _trueList.append(_right._trueList);
      }
  }
  // Compile OR-expression
  else {
      // Translate left-hand side expression and produce true/false list
      _left.translateDesynthesized(classGen, methodGen);

      // This GOTO is used to skip over the code for the last test
      // in the case where the the first test succeeds
      InstructionHandle ih = il.append(new GOTO(null));

      // Translate right-hand side expression and produce true/false list
      _right.translateDesynthesized(classGen, methodGen);

      _left._trueList.backPatch(ih);
      _left._falseList.backPatch(ih.getNext());
     
      _falseList.append(_right._falseList);
      _trueList.add(ih).append(_right._trueList);
  }
    }
View Full Code Here

    if(igc.getFinallyClause(tryBlock) != null) {
      return;
    }
   
    //now, we are going to look for the block jump.
    InstructionHandle ih = tryBlock.getBlockRange().getEnd();
    //see about a goto.
    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);
View Full Code Here

  }
 
  @Override
  public void visitIfIntermediate(IfIntermediate line) {
    AbstractIntermediate l = igc.getTrueTarget(line);
    InstructionHandle lower = l.getInstruction();
    line.getBlockRange().setStart(lower);
   
    //upper range...
    AbstractIntermediate u = igc.getFalseTarget(line);
    NullIntermediate nullIntermediate = new NullIntermediate(u.getInstruction().getPrev());
View Full Code Here

   
    Map<InstructionRange, List<CodeExceptionGen>> tryRangeGen = new HashMap<InstructionRange, List<CodeExceptionGen>>();
   
    //create try statements...
    for(CodeExceptionGen ceg : exceptions) {
      InstructionHandle min = (ceg.getStartPC());
      InstructionHandle max = (ceg.getEndPC());
     
      InstructionRange tryRange = new InstructionRange();
      tryRange.setStart(min);
      tryRange.setEnd(max);
     
View Full Code Here

   
    ListenableDirectedGraph<InstructionHandle, IntermediateEdge> instructionHandleGraph = new ListenableDirectedGraph<InstructionHandle, IntermediateEdge>(IntermediateEdge.class);
    InstructionGraphContext igc = new InstructionGraphContext(instructionHandleGraph);

    for(InstructionHandle instructionHandle : instructionList.getInstructionHandles()) {
      InstructionHandle iv = instructionHandle;
      instructionHandleGraph.addVertex(iv);
    }
   
    Iterator<InstructionHandle> iter = instructionList.iterator();
    while(iter.hasNext()) {
      InstructionHandle ih = iter.next();
      InstructionHandle sourceVertex = igc.getPositionMap().get(ih.getPosition());
     
      if(ih.getInstruction() instanceof Select) {
        for(InstructionHandle targetVertex : ((Select)ih.getInstruction()).getTargets()) {
          instructionHandleGraph.addEdge(sourceVertex, targetVertex);
        }
        InstructionHandle targetVertex = ((Select)ih.getInstruction()).getTarget();
        if(targetVertex != null) {
          instructionHandleGraph.addEdge(sourceVertex, targetVertex);
        }
      }
      else if(ih instanceof BranchHandle) {
        //if this is an unconditional branch, only add the branch between the instruction and it's target.
        InstructionHandle targetVertex = igc.getPositionMap().get(((BranchHandle) ih).getTarget().getPosition());
        instructionHandleGraph.addEdge(sourceVertex, targetVertex);
      }
      if(!(ih.getInstruction() instanceof UnconditionalBranch)) {
        if(ih.getNext() != null) {
          InstructionHandle targetVertex = igc.getPositionMap().get((ih).getNext().getPosition());
          instructionHandleGraph.addEdge(sourceVertex, targetVertex);
        }
      }
    }
   
View Full Code Here

    //now, we will map the CEG.
    for(CodeExceptionGen ceg : exceptions) {
      int t1 = ceg.getStartPC().getPosition();
      int t2 = ceg.getHandlerPC().getPosition();
     
      InstructionHandle source = ivc.get(t1);
      InstructionHandle target = ivc.get(t2);

      IntermediateEdge ie = new IntermediateEdge();
      addExceptionHandle(ie, ceg);
      ie.setType(EdgeType.EXCEPTION);
      igc.getGraph().addEdge(source, target, ie);
View Full Code Here

    if(ivs.size() > 1) {
      //check to see if the predecessors pushed.
     
      int count = 0;
      for(InstructionHandle iv : ivs) {
        InstructionHandle jvmiv = (InstructionHandle)iv;
        jvmiv = findSource(jvmiv);
       
        if(jvmiv.getInstruction() instanceof PushInstruction) {
          count++;
        }
      }
     
      if(count > 1) {
View Full Code Here

    for(InstructionHandle source : preds) {
      this.igc.getGraph().removeEdge(source, iv);
    }
   
    int i=0;
    InstructionHandle target = iv;
    for(InstructionHandle source : preds) {
      //source = findSource(source);
      if(i>0) {
        //clone.
        try {
View Full Code Here

   
    List<InstructionHandle> successors = igc.getSuccessors(ih);
   
    if(successors.size() == 1) {
      //now check to see whether there is an intermediate on the objects...
      InstructionHandle target = successors.get(0);
     
      if(LOG.isDebugEnabled()) {
        LOG.debug("Remove vertex:" + ih);
      }
     
View Full Code Here

TOP

Related Classes of org.apache.bcel.generic.InstructionHandle

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.