-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVM.java
More file actions
92 lines (91 loc) · 3.15 KB
/
VM.java
File metadata and controls
92 lines (91 loc) · 3.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import java.math.BigDecimal;
public class VM {
static {
System.loadLibrary("VM");
}
public VM() {
init();
}
private native void runWithString(byte opcode, String data);
private native void runWithDouble(byte opcode, String data);
private native void runWithBoolean(byte opcode, boolean data);
private native String disassembleWithString(byte opcode, String data);
private native String disassembleWithDouble(byte opcode, String data);
private native String disassembleWithBoolean(byte opcode, boolean data);
public native String pop();
private native void init();
public native void run(byte opcode);
public void run(byte opcode, BigDecimal data) {
runWithDouble(opcode, data + "");
}
public void run(byte opcode, String data) {
runWithString(opcode, data);
}
public void run(byte opcode, boolean data) {
runWithBoolean(opcode, data);
}
public String disassemble(byte opcode, BigDecimal data) {
return disassembleWithDouble(opcode, data + "");
}
public String disassemble(byte opcode) {
return disassembleWithString(opcode, null);
}
public String disassemble(byte opcode, String data) {
return disassembleWithString(opcode, data);
}
public String disassemble(byte opcode, boolean data) {
return disassembleWithBoolean(opcode, data);
}
public static final byte EXIT = 0;
public static final byte PUT = 1;
public static final byte POP = 2;
public static final byte ADD = 15;
public static final byte SUB = 16;
public static final byte MUL = 17;
public static final byte DIV = 18;
public static final byte MOD = 19;
public static final byte EQ = 20;
public static final byte FEQ = 21;
public static final byte GT = 22;
public static final byte GE = 23;
public static final byte LT = 24;
public static final byte LE = 25;
public static final byte LAND = 26;
public static final byte LOR = 27;
public static final byte AND = 28;
public static final byte OR = 29;
public static final byte NOT = 30;
public static final byte LNOT = 31;
public static final byte LSHIFT = 32;
public static final byte RSHIFT = 33;
public static final byte XOR = 34;
public static final byte NEG = 35;
public static final byte MEMSET = 50;
public static final byte MEMGET = 51;
public static final byte MEMSIZE = 52;
public static final byte MEMPUT = 53;
public static final byte MEMINS = 54;
public static final byte MEMDEL = 55;
public static final byte TONUM = 65;
public static final byte TOTXT = 66;
public static final byte ISNUM = 67;
public static final byte CANNUM = 68;
public static final byte TOBOOL = 69;
public static final byte REC = 75;
public static final byte END = 76;
public static final byte RUN = 77;
public static final byte REPEAT = 78;
public static final byte BREAK = 79;
public static final byte IFTRUN = 80;
public static final byte IFFRUN = 81;
public static final byte WTRUN = 82;
public static final byte WFRUN = 83;
public static final byte THREAD = 84;
public static final byte SKIP = 85;
public static final byte IFSKIP = 86;
public static final byte MKFN = 87;
public static final byte CALLFN = 88;
public static final byte EXITFN = 89;
public static final byte DLCALL = 100;
public static final byte PRINT = 101;
}