Examples of Jump


Examples of org.eclipse.jdt.internal.debug.eval.ast.instructions.Jump

    fCounter++;

    if (hasElseStatement) {
      // Insert the jump
      int jumpAddress = ifTrueAddress + 2;
      Jump jump = new Jump();
      fInstructions.insert(jump, jumpAddress);
      // Set the jump offset
      jump.setOffset(ifFalse.getSize() + 1);
      fCounter++;
    }

    storeInstruction();
View Full Code Here

Examples of org.eclipse.jdt.internal.debug.eval.ast.instructions.Jump

    // this statement, set the offset of the corresponding jump.
    for (Iterator<CompleteInstruction> iter = fCompleteInstructions.iterator(); iter.hasNext();) {
      CompleteInstruction instruction = iter.next();
      if (instruction.fLabel != null && instruction.fLabel.equals(label)) {
        iter.remove();
        Jump jumpInstruction = instruction.fInstruction;
        int instructionAddress = fInstructions.indexOf(jumpInstruction);
        if (instruction.fIsBreak) {
          // jump to the instruction after the statement
          jumpInstruction.setOffset(fInstructions.getEnd()
              - instructionAddress);
        }
      }
    }
  }
View Full Code Here

Examples of org.eclipse.jdt.internal.debug.eval.ast.instructions.Jump

    // add the conditionnalJump
    ConditionalJump conditionalJump = new ConditionalJump(false);
    fInstructions.insert(conditionalJump, conditionAddress + 1);

    // add the jump
    Jump jump = new Jump();
    fInstructions.add(jump);

    // set jump offsets
    conditionalJump.setOffset(body.getSize() + 1);
    jump.setOffset(-(condition.getSize() + body.getSize() + 2));

    // for each pending break or continue instruction which are related to
    // this loop, set the offset of the corresponding jump.
    for (Iterator<CompleteInstruction> iter = fCompleteInstructions.iterator(); iter.hasNext();) {
      CompleteInstruction instruction = iter.next();
      Jump jumpInstruction = instruction.fInstruction;
      int instructionAddress = fInstructions.indexOf(jumpInstruction);
      if (instructionAddress > conditionAddress
          && (instruction.fLabel == null || instruction.fLabel
              .equals(label))) {
        iter.remove();
        if (instruction.fIsBreak) {
          // jump to the instruction after the last jump
          jumpInstruction
              .setOffset((bodyAddress - instructionAddress) + 2);
        } else {
          // jump to the first instruction of the condition
          jumpInstruction.setOffset((conditionAddress - condition
              .getSize()) - instructionAddress);
        }
      }
    }
View Full Code Here

Examples of org.eclipse.jdt.internal.debug.eval.ast.instructions.Jump

      return false;
    }
    // create the equivalent jump instruction in the instruction
    // and add an element in the list of pending break and continue
    // instructions
    Jump instruction = new Jump();
    SimpleName labelName = node.getLabel();
    String label = null;
    if (labelName != null) {
      label = labelName.getIdentifier();
    }
View Full Code Here

Examples of org.eclipse.jdt.internal.debug.eval.ast.instructions.Jump

      return false;
    }
    // create the equivalent jump instruction in the instruction
    // and add an element in the list of pending break and continue
    // instructions
    Jump instruction = new Jump();
    SimpleName labelName = node.getLabel();
    String label = null;
    if (labelName != null) {
      label = labelName.getIdentifier();
    }
View Full Code Here

Examples of org.eclipse.jdt.internal.debug.eval.ast.instructions.Jump

        if (storeRequired) {
          storeInstruction();
        }
      }

      Jump jump = new Jump();
      jump.setOffset(1);
      push(jump);
      storeInstruction();

      for (int i = 0; i < operatorNumber; i++) {
        conditionalJumps[i].setOffset(fCounter
View Full Code Here

Examples of org.eclipse.jdt.internal.debug.eval.ast.instructions.Jump

    push(new NoOp(fCounter));
    int switchStart = fCounter;
    node.getExpression().accept(this);

    ArrayList<Statement> statementsDefault = null;
    Jump jumpDefault = null;
    ArrayList<slot> jumpsStatements = new ArrayList<slot>();
    slot currentslot = new slot();
    jumpsStatements.add(currentslot);

    for (Iterator<Statement> iter = node.statements().iterator(); iter.hasNext();) {
      Statement statement = iter.next();
      if (statement instanceof SwitchCase) {
        SwitchCase switchCase = (SwitchCase) statement;
        if (switchCase.isDefault()) {
          jumpDefault = new Jump();
          push(jumpDefault);
          storeInstruction(); // jump
          statementsDefault = new ArrayList<Statement>();
        } else {
          if (switchCase.getExpression() instanceof StringLiteral) {
            push(new SendMessage(
                "equals", "(Ljava/lang/Object;)Z", 1, null, fCounter)); //$NON-NLS-1$ //$NON-NLS-2$
          } else {
            push(new EqualEqualOperator(Instruction.T_int,
                Instruction.T_int, true, fCounter));
          }
          push(new Dup());
          storeInstruction(); // dupe
          switchCase.getExpression().accept(this);
          storeInstruction(); // equal-equal
          ConditionalJump condJump = new ConditionalJump(true);
          push(condJump);
          storeInstruction(); // conditional jump
          if (currentslot.stmts != null) {
            currentslot = new slot();
            jumpsStatements.add(currentslot);
          }
          currentslot.jumps.add(condJump);
        }
      } else {
        if (statementsDefault != null) {
          statementsDefault.add(statement);
        } else {
          if (currentslot.stmts == null) {
            currentslot.stmts = new ArrayList<Statement>();
          }
          currentslot.stmts.add(statement);
        }
      }
    }

    Jump jumpEnd = null;
    if (jumpDefault == null) {
      push(new Pop(0));
      storeInstruction(); // pop
      jumpEnd = new Jump();
      push(jumpEnd);
      storeInstruction(); // jump
    }

    for (Iterator<slot> iter = jumpsStatements.iterator(); iter.hasNext();) {
      currentslot = iter.next();
      for (Iterator<ConditionalJump> iterator = currentslot.jumps.iterator(); iterator.hasNext();) {
        ConditionalJump condJump = iterator.next();
        condJump.setOffset((fCounter - fInstructions.indexOf(condJump)) - 1);
      }
      if (currentslot.stmts != null) {
        push(new Pop(0));
        storeInstruction(); // pop
        for (Iterator<Statement> iterator = currentslot.stmts.iterator(); iterator.hasNext();) {
          iterator.next().accept(this);
        }
      }
    }

    // default case
    if (jumpDefault != null) {
      jumpDefault.setOffset((fCounter - fInstructions.indexOf(jumpDefault)) - 1);
      push(new Pop(0));
      storeInstruction(); // pop
      for (Iterator<Statement> iterator = statementsDefault.iterator(); iterator.hasNext();) {
        iterator.next().accept(this);
      }
    } else if(jumpEnd != null){
      jumpEnd.setOffset((fCounter - fInstructions.indexOf(jumpEnd)) - 1);
    }

    // for each pending break or continue instruction which are related to
    // this loop, set the offset of the corresponding jump.
    String label = getLabel(node);
    for (Iterator<CompleteInstruction> iter = fCompleteInstructions.iterator(); iter.hasNext();) {
      CompleteInstruction instruction = iter.next();
      Jump jumpInstruction = instruction.fInstruction;
      int instructionAddress = fInstructions.indexOf(jumpInstruction);
      if (instructionAddress > switchStart && (instruction.fLabel == null || instruction.fLabel.equals(label))) {
        iter.remove();
        if (instruction.fIsBreak) {
          // jump to the instruction after the last instruction of the
          // switch
          jumpInstruction.setOffset((fCounter - instructionAddress) - 1);
        }
      }
    }
    return false;
  }
View Full Code Here

Examples of org.mozilla.javascript.ast.Jump

                        sb.append(" ");
                    }
                    sb.append("]");
                }
            } else if (this instanceof Jump) {
                Jump jump = (Jump)this;
                if (type == Token.BREAK || type == Token.CONTINUE) {
                    sb.append(" [label: ");
                    appendPrintId(jump.getJumpStatement(), printIds, sb);
                    sb.append(']');
                } else if (type == Token.TRY) {
                    Node catchNode = jump.target;
                    Node finallyTarget = jump.getFinally();
                    if (catchNode != null) {
                        sb.append(" [catch: ");
                        appendPrintId(catchNode, printIds, sb);
                        sb.append(']');
                    }
                    if (finallyTarget != null) {
                        sb.append(" [finally: ");
                        appendPrintId(finallyTarget, printIds, sb);
                        sb.append(']');
                    }
                } else if (type == Token.LABEL || type == Token.LOOP
                           || type == Token.SWITCH)
                {
                    sb.append(" [break: ");
                    appendPrintId(jump.target, printIds, sb);
                    sb.append(']');
                    if (type == Token.LOOP) {
                        sb.append(" [continue: ");
                        appendPrintId(jump.getContinue(), printIds, sb);
                        sb.append(']');
                    }
                } else {
                    sb.append(" [target: ");
                    appendPrintId(jump.target, printIds, sb);
View Full Code Here

Examples of org.mozilla.javascript.ast.Jump

                break;
              }

              case Token.TRY:
              {
                Jump jump = (Jump)node;
                Node finallytarget = jump.getFinally();
                if (finallytarget != null) {
                    hasFinally = true;
                    loops.push(node);
                    loopEnds.push(finallytarget);
                }
                break;
              }

              case Token.TARGET:
              case Token.LEAVEWITH:
                if (!loopEnds.isEmpty() && loopEnds.peek() == node) {
                    loopEnds.pop();
                    loops.pop();
                }
                break;

              case Token.YIELD:
                ((FunctionNode)tree).addResumptionPoint(node);
                break;

              case Token.RETURN:
              {
                boolean isGenerator = tree.getType() == Token.FUNCTION
                    && ((FunctionNode)tree).isGenerator();
                if (isGenerator) {
                    node.putIntProp(Node.GENERATOR_END_PROP, 1);
                }
                /* If we didn't support try/finally, it wouldn't be
                 * necessary to put LEAVEWITH nodes here... but as
                 * we do need a series of JSR FINALLY nodes before
                 * each RETURN, we need to ensure that each finally
                 * block gets the correct scope... which could mean
                 * that some LEAVEWITH nodes are necessary.
                 */
                if (!hasFinally)
                    break;     // skip the whole mess.
                Node unwindBlock = null;
                for (int i=loops.size()-1; i >= 0; i--) {
                    Node n = (Node) loops.get(i);
                    int elemtype = n.getType();
                    if (elemtype == Token.TRY || elemtype == Token.WITH) {
                        Node unwind;
                        if (elemtype == Token.TRY) {
                            Jump jsrnode = new Jump(Token.JSR);
                            Node jsrtarget = ((Jump)n).getFinally();
                            jsrnode.target = jsrtarget;
                            unwind = jsrnode;
                        } else {
                            unwind = new Node(Token.LEAVEWITH);
                        }
                        if (unwindBlock == null) {
                            unwindBlock = new Node(Token.BLOCK,
                                                   node.getLineno());
                        }
                        unwindBlock.addChildToBack(unwind);
                    }
                }
                if (unwindBlock != null) {
                    Node returnNode = node;
                    Node returnExpr = returnNode.getFirstChild();
                    node = replaceCurrent(parent, previous, node, unwindBlock);
                    if (returnExpr == null || isGenerator) {
                        unwindBlock.addChildToBack(returnNode);
                    } else {
                        Node store = new Node(Token.EXPR_RESULT, returnExpr);
                        unwindBlock.addChildToFront(store);
                        returnNode = new Node(Token.RETURN_RESULT);
                        unwindBlock.addChildToBack(returnNode);
                        // transform return expression
                        transformCompilationUnit_r(tree, store, scope,
                                                   createScopeObjects,
                                                   inStrictMode);
                    }
                    // skip transformCompilationUnit_r to avoid infinite loop
                    continue siblingLoop;
                }
                break;
              }

              case Token.BREAK:
              case Token.CONTINUE:
              {
                Jump jump = (Jump)node;
                Jump jumpStatement = jump.getJumpStatement();
                if (jumpStatement == null) Kit.codeBug();

                for (int i = loops.size(); ;) {
                    if (i == 0) {
                        // Parser/IRFactory ensure that break/continue
                        // always has a jump statement associated with it
                        // which should be found
                        throw Kit.codeBug();
                    }
                    --i;
                    Node n = (Node) loops.get(i);
                    if (n == jumpStatement) {
                        break;
                    }

                    int elemtype = n.getType();
                    if (elemtype == Token.WITH) {
                        Node leave = new Node(Token.LEAVEWITH);
                        previous = addBeforeCurrent(parent, previous, node,
                                                    leave);
                    } else if (elemtype == Token.TRY) {
                        Jump tryNode = (Jump)n;
                        Jump jsrFinally = new Jump(Token.JSR);
                        jsrFinally.target = tryNode.getFinally();
                        previous = addBeforeCurrent(parent, previous, node,
                                                    jsrFinally);
                    }
                }
View Full Code Here

Examples of org.mozilla.javascript.ast.Jump

                        sb.append(" ");
                    }
                    sb.append("]");
                }
            } else if (this instanceof Jump) {
                Jump jump = (Jump)this;
                if (type == Token.BREAK || type == Token.CONTINUE) {
                    sb.append(" [label: ");
                    appendPrintId(jump.getJumpStatement(), printIds, sb);
                    sb.append(']');
                } else if (type == Token.TRY) {
                    Node catchNode = jump.target;
                    Node finallyTarget = jump.getFinally();
                    if (catchNode != null) {
                        sb.append(" [catch: ");
                        appendPrintId(catchNode, printIds, sb);
                        sb.append(']');
                    }
                    if (finallyTarget != null) {
                        sb.append(" [finally: ");
                        appendPrintId(finallyTarget, printIds, sb);
                        sb.append(']');
                    }
                } else if (type == Token.LABEL || type == Token.LOOP
                           || type == Token.SWITCH)
                {
                    sb.append(" [break: ");
                    appendPrintId(jump.target, printIds, sb);
                    sb.append(']');
                    if (type == Token.LOOP) {
                        sb.append(" [continue: ");
                        appendPrintId(jump.getContinue(), printIds, sb);
                        sb.append(']');
                    }
                } else {
                    sb.append(" [target: ");
                    appendPrintId(jump.target, printIds, sb);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.