mirror of
https://github.com/FranzHaidnor/haidnorJVM.git
synced 2026-03-14 06:03:50 +08:00
Initial commit
This commit is contained in:
40
src/main/java/haidnor/jvm/instruction/Instruction.java
Normal file
40
src/main/java/haidnor/jvm/instruction/Instruction.java
Normal file
@@ -0,0 +1,40 @@
|
||||
package haidnor.jvm.instruction;
|
||||
|
||||
import haidnor.jvm.runtime.Frame;
|
||||
import haidnor.jvm.util.CodeStream;
|
||||
|
||||
public abstract class Instruction {
|
||||
/**
|
||||
* 指令坐在 code 数组中的索引下标
|
||||
*/
|
||||
private final int index;
|
||||
|
||||
/**
|
||||
* 执行下一个执行的偏移量
|
||||
*/
|
||||
private int offSet = 1;
|
||||
|
||||
public Instruction(CodeStream codeStream) {
|
||||
this.index = codeStream.index();
|
||||
}
|
||||
|
||||
public abstract void execute(Frame frame);
|
||||
|
||||
public int index() {
|
||||
return index;
|
||||
}
|
||||
|
||||
public final int offSet() {
|
||||
return this.offSet;
|
||||
}
|
||||
|
||||
public void setOffSet(int offSet) {
|
||||
this.offSet = offSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return index + " " + this.getClass().getSimpleName();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user