Пример #1
0
  public void PushStacks() {
    _floatFrameStack.push(new floatStack());
    _intFrameStack.push(new intStack());
    _boolFrameStack.push(new booleanStack());
    _codeFrameStack.push(new ObjectStack());
    _nameFrameStack.push(new ObjectStack());

    AssignStacksFromFrame();
  }
Пример #2
0
  public int ExecuteInstruction(Object inObject) {

    if (inObject instanceof Program) {
      Program p = (Program) inObject;

      if (_useFrames) {
        _execStack.push("frame.pop");
      }

      p.PushAllReverse(_execStack);

      if (_useFrames) {
        _execStack.push("frame.push");
      }

      return 0;
    }

    if (inObject instanceof Integer) {
      _intStack.push((Integer) inObject);
      return 0;
    }

    if (inObject instanceof Number) {
      _floatStack.push(((Number) inObject).floatValue());
      return 0;
    }

    if (inObject instanceof Instruction) {
      ((Instruction) inObject).Execute(this);
      return 0;
    }

    if (inObject instanceof String) {
      Instruction i = _instructions.get(inObject);

      if (i != null) {
        i.Execute(this);
      } else {
        _nameStack.push(inObject);
      }

      return 0;
    }

    return -1;
  }
Пример #3
0
  public void PopFrame() {
    if (_useFrames) {
      boolean boolTop = _boolStack.top();
      int intTop = _intStack.top();
      float floatTop = _floatStack.top();
      Object nameTop = _nameStack.top();
      Object codeTop = _codeStack.top();

      PopStacks();

      _floatStack.push(floatTop);
      _intStack.push(intTop);
      _boolStack.push(boolTop);

      if (nameTop != null) _nameStack.push(nameTop);
      if (codeTop != null) _codeStack.push(codeTop);
    }
  }
Пример #4
0
 public void PushAllReverse(ObjectStack inOther) {
   for (int n = _size - 1; n >= 0; n--) inOther.push(_stack[n]);
 }
Пример #5
0
 /**
  * Loads a Push program into the interpreter's exec and code stacks.
  *
  * @param inProgram The program to load.
  */
 public void LoadProgram(Program inProgram) {
   _codeStack.push(inProgram);
   _execStack.push(inProgram);
 }