new.java~9~

来自「Java源码」· JAVA~9~ 代码 · 共 56 行

JAVA~9~
56
字号
package AM.vm_impl.instruction;

import AM.am_data_structure.Instruction;
import AM.am_data_structure.AbstractMachineState;
import AM.vm_impl.util.Tracer;
import AM.vm_impl.vm_data_structure.VM_DataArea;
import AM.vm_impl.vm_data_structure.VM_Method;


/**
 * Created by IntelliJ IDEA. User: yellowicq Date: 2004-4-27 Time: 14:48:58
 * To change this template use File | Settings | File Templates.
 */
public class NEW
    implements Instruction {
  private String className;

  private NEW(){}

  public NEW(String className) {
    this.className=className;
  }

  public String Name() {
    return "new";
  }

  public int NumArguments() {
    return 1;
  }

  public String ToString() {
    return Name();
  }

  public void SI(AbstractMachineState state) {
    Tracer.debug("SI new");
    VM_DataArea VM_da = (VM_DataArea) state.getDataArea();
    VM_Method VM_prog = (VM_Method) state.getProgram();
    // Implementation of allocate semantics
    int value2 = ( (Integer) VM_da.stackFrame.pop()).intValue();
    int value1 = ( (Integer) VM_da.stackFrame.pop()).intValue();
    int result = value1 + value2;
    VM_da.stackFrame.push(new Integer(result));
    //move the cp pointer to next
    synchronized (this) {
      VM_prog.Next();
      VM_da.regs.setCP_GLOBAL(VM_prog.Consult_CP());
    }
  }

  public void Process(String args[]) {
    // Proces the text representation of the instruction
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?