Package org.apache.bcel.generic

Examples of org.apache.bcel.generic.GOTO


      // The When object should be ignored completely in case it tests
      // for the support of a non-available element
      if (!when.ignore()) when.translateContents(classGen, methodGen);

      // goto exit after executing the body of when
      exitHandles.addElement(il.append(new GOTO(null)));
      if (whens.hasMoreElements() || otherwise != null) {
    nextElement = il.append(new GOTO(null));
    test.backPatchFalseList(nextElement);
      }
      else
    test.backPatchFalseList(exit = il.append(NOP));
      test.backPatchTrueList(truec.getNext());
View Full Code Here


  // 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
  restore = il.append(methodGen.storeCurrentNode());
  backPatchFalseList(restore);
  _falseList.add(il.append(new GOTO(null)));

  // True list falls through
  skipFalse.setTarget(il.append(NOP));
    }
View Full Code Here

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

  // Backpatch false list and restore current iterator/node
  restore = il.append(methodGen.storeIterator());
  il.append(methodGen.storeCurrentNode());
  exp.backPatchFalseList(restore);
  _falseList.add(il.append(new GOTO(null)));

  // True list falls through
  skipFalse.setTarget(il.append(NOP));
    }
View Full Code Here

  InstructionHandle begin, next;
  node2 = methodGen.addLocalVariable("step_pattern_tmp3",
             Util.getJCRefType(NODE_SIG),
             il.getEnd(), null);

  skipNext = il.append(new GOTO(null));
  next = il.append(new ALOAD(iter.getIndex()));
  begin = il.append(methodGen.nextNode());
  il.append(DUP);
  il.append(new ISTORE(node2.getIndex()));
  _falseList.add(il.append(new IFLT(null)))// NodeIterator.END
View Full Code Here

    public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
  final InstructionList il = methodGen.getInstructionList();

  _left.translate(classGen, methodGen);
  final InstructionHandle gotot = il.append(new GOTO(null));
  il.append(methodGen.loadContextNode());
  _right.translate(classGen, methodGen);

  _left._trueList.backPatch(gotot);
  _left._falseList.backPatch(gotot.getNext());
View Full Code Here

    public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
          BooleanType type) {
  final InstructionList il = methodGen.getInstructionList();
  FlowList falsel = translateToDesynthesized(classGen, methodGen, type);
  il.append(ICONST_1);
  final BranchHandle truec = il.append(new GOTO(null));
  falsel.backPatch(il.append(ICONST_0));
  truec.setTarget(il.append(NOP));
    }
View Full Code Here

      switch(kind) {
      case EQ: case LEQ: case GEQ: case NEQ: case LT: case GT:
  BranchHandle g;

  il.append(new PUSH(cp, 1));
  g = il.append(new GOTO(null));
  bh.setTarget(il.append(new PUSH(cp, 0)));
  g.setTarget(il.append(InstructionConstants.NOP)); // May be optimized away later
  ASTFunDecl.push();
  break;
View Full Code Here

                    if (target.equals(next3&& next2.getInstruction() instanceof GOTO
                            && next3.getInstruction() instanceof ICONST && next1.getTargeters().length == 0
                            && next2.getTargeters().length == 0 && next3.getTargeters().length == 1
                            && next4.getTargeters().length == 1) {
                        int c1 = ((ICONST) next1.getInstruction()).getValue().intValue();
                        GOTO g = (GOTO) next2.getInstruction();
                        int c2 = ((ICONST) next3.getInstruction()).getValue().intValue();
                        if (g.getTarget().equals(next4) && (c1 == 1 && c2 == 0 || c1 == 0 && c2 == 1)) {
                            boolean nullIsTrue = i instanceof IFNULL && c2 == 1 || i instanceof IFNONNULL && c2 == 0;

                            if (nullIsTrue) {
                                // System.out.println("Found NULL2Z instruction");
                                head.swapInstruction(new NULL2Z());
View Full Code Here

    il.append(new ASTORE(name));

    /* Upon normal execution we jump behind exception handler,
     * the target address is not known yet.
     */
    GOTO g = new GOTO(null);
    InstructionHandle try_end = il.append(g);

    /* } catch() { ... }
     * Add exception handler: print exception and return from method
     */
    InstructionHandle handler =
      il.append(factory.createFieldAccess("java.lang.System", "out", p_stream,
            Constants.GETSTATIC));
    // Little trick in order not to save exception object temporarily
    il.append(InstructionConstants.SWAP);

    il.append(factory.createInvoke("java.io.PrintStream", "println", Type.VOID,
     new Type[] { Type.OBJECT }, Constants.INVOKEVIRTUAL));
    il.append(InstructionConstants.RETURN);
    mg.addExceptionHandler(try_start, try_end, handler,
         new ObjectType("java.io.IOException"));

    /* Normal code continues, now we can set the branch target of the GOTO
     * that jumps over the handler code.
     */
    InstructionHandle ih =
      il.append(factory.createFieldAccess("java.lang.System", "out", p_stream,
            Constants.GETSTATIC));
    g.setTarget(ih);

    /* String concatenation compiles to StringBuffer operations.
     */
    il.append(factory.createNew(Type.STRINGBUFFER));
    il.append(InstructionConstants.DUP);
View Full Code Here

    BranchHandle i, g;

    i = il.append(new IFEQ(null)); // If POP() == FALSE(i.e. 0) then branch to ELSE
    ASTFunDecl.pop();
    il.append(then_code);
    g = il.append(new GOTO(null));
    i.setTarget(il.append(else_code));
    g.setTarget(il.append(InstructionConstants.NOP)); // May be optimized away later
  }
View Full Code Here

TOP

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

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.