Package org.eclipse.jdt.internal.debug.eval.ast.instructions

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


  private Instruction pop() {
    return fStack.pop();
  }

  private void storeInstruction() {
    Instruction instruction = pop();
    fCounter++;
    if (instruction instanceof CompoundInstruction) {
      ((CompoundInstruction) instruction).setEnd(fCounter);
    }
    fInstructions.add(instruction);
    verbose("Add " + instruction.toString()); //$NON-NLS-1$
  }
View Full Code Here


  /**
   *
   */
  private void addPopInstruction() {
    Instruction lastInstruction = fInstructions
        .getInstruction(fInstructions.getEnd());
    push(new Pop(lastInstruction.getSize() + 1));
    storeInstruction();
  }
View Full Code Here

    if (!isActive() || hasErrors())
      return;

    // Get the instructions
    int ifFalseAddress = fInstructions.getEnd();
    Instruction ifFalse = fInstructions.get(ifFalseAddress);
    int ifTrueAddress = ifFalseAddress - ifFalse.getSize();
    Instruction ifTrue = fInstructions.get(ifTrueAddress);
    int conditionalAddress = ifTrueAddress - ifTrue.getSize();

    // Insert the conditional jump
    ConditionalJump conditionalJump = new ConditionalJump(false);
    fInstructions.insert(conditionalJump, conditionalAddress + 1);

    // Insert the jump
    int jumpAddress = ifTrueAddress + 2;
    Jump jump = new Jump();
    fInstructions.insert(jump, jumpAddress);

    // Set the jump offsets
    conditionalJump.setOffset(ifTrue.getSize() + 1);
    jump.setOffset(ifFalse.getSize() + 1);

    fCounter += 2;
    storeInstruction();
View Full Code Here

    String label = getLabel(node);

    // get address of each part
    int conditionAddress = fInstructions.getEnd();
    Instruction condition = fInstructions.getInstruction(conditionAddress);
    int bodyAddress = conditionAddress - condition.getSize();
    Instruction body = fInstructions.getInstruction(bodyAddress);
    int bodyStartAddress = bodyAddress - body.getSize();

    // add the conditionnalJump
    ConditionalJump conditionalJump = new ConditionalJump(true);
    fInstructions.add(conditionalJump);
    fCounter++;

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

    // 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();
View Full Code Here

     * i.next() | Body -- -- - jump to the first instruction of the
     * condition.
     */

    int bodyAddress = fInstructions.getEnd();
    Instruction body = fInstructions.getInstruction(bodyAddress);
    int conditionAddress = bodyAddress - body.getSize();
    Instruction condition = fInstructions.getInstruction(conditionAddress);
    int initAddress = conditionAddress - condition.getSize();

    // add conditional jump
    ConditionalJump condJump = new ConditionalJump(false);
    fInstructions.insert(condJump, conditionAddress + 1);
    bodyAddress++;
View Full Code Here

    String label = getLabel(node);
    boolean hasCondition = node.getExpression() != null;

    // get address of each part
    int updatersAddress = fInstructions.getEnd();
    Instruction updaters = fInstructions.getInstruction(updatersAddress);
    int bodyAddress = updatersAddress - updaters.getSize();
    Instruction body = fInstructions.getInstruction(bodyAddress);
    int bodyStartAddress = bodyAddress - body.getSize();

    int conditionAddress;
    Instruction condition;

    if (hasCondition) {
      conditionAddress = bodyStartAddress;
      condition = fInstructions.getInstruction(conditionAddress);
    } else {
      conditionAddress = 0;
      condition = null;
    }

    // add jump
    Jump jump = new Jump();
    fInstructions.add(jump);
    fCounter++;

    if (hasCondition) {
      // add conditional jump
      ConditionalJump condJump = new ConditionalJump(false);
      fInstructions.insert(condJump, conditionAddress + 1);
      bodyAddress++;
      bodyStartAddress++;
      updatersAddress++;
      fCounter++;
      // set conditional jump offset
      condJump.setOffset(body.getSize() + updaters.getSize() + 1);
    }

    // set jump offset
    jump.setOffset(-((hasCondition && (condition != null) ? condition
        .getSize() : 0) + body.getSize() + updaters.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();) {
View Full Code Here

    boolean hasElseStatement = node.getElseStatement() != null;

    // Get the instructions

    int ifFalseAddress = 0;
    Instruction ifFalse = null;
    int ifTrueAddress = 0;
    Instruction ifTrue = null;

    if (hasElseStatement) {
      ifFalseAddress = fInstructions.getEnd();
      ifFalse = fInstructions.get(ifFalseAddress);
      ifTrueAddress = ifFalseAddress - ifFalse.getSize();
      ifTrue = fInstructions.get(ifTrueAddress);
    } else {
      ifTrueAddress = fInstructions.getEnd();
      ifTrue = fInstructions.get(ifTrueAddress);
    }

    int conditionalAddress = ifTrueAddress - ifTrue.getSize();

    // Insert the conditional jump
    ConditionalJump conditionalJump = new ConditionalJump(false);
    fInstructions.insert(conditionalJump, conditionalAddress + 1);
    // Set the jump offset
    conditionalJump.setOffset(ifTrue.getSize()
        + ((hasElseStatement) ? 1 : 0));
    fCounter++;

    if (hasElseStatement) {
      // Insert the jump
View Full Code Here

    String label = getLabel(node);

    // get address of each part
    int bodyAddress = fInstructions.getEnd();
    Instruction body = fInstructions.getInstruction(bodyAddress);
    int conditionAddress = bodyAddress - body.getSize();
    Instruction condition = fInstructions.getInstruction(conditionAddress);

    // 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

  public void execute() throws CoreException {
    try {
      reset();
      while (fInstructionCounter < fInstructions.length && !fStopped) {
        Instruction instruction = fInstructions[fInstructionCounter++];
        instruction.setInterpreter(this);
        instruction.execute();
        instruction.setInterpreter(null);
      }
    } catch (VMDisconnectedException e) {
      throw new CoreException(new Status(IStatus.ERROR,
          JDIDebugModel.getPluginIdentifier(), e.getMessage(), e));
    } finally {
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.internal.debug.eval.ast.instructions.Instruction

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.