-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInstructions.cs
115 lines (103 loc) · 2.25 KB
/
Instructions.cs
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
namespace vm;
public enum Instructions : byte
{
PUSH, // int
POP,
ADD,
SUB,
MUL,
DIV,
NEG,
EXP,
MOD,
LT,
GT,
EQ,
AND,
OR,
NOT,
XOR,
LS,
RS,
LOAD, // load local val or fct arg
GLOAD,
STORE,
GSTORE,
JUMP,
CJUMP,
CALL,
RET,
HALT,
PUSH_STR,
PUSH_CHAR,
CONCAT
}
class Instruction
{
public static Dictionary<string, int> vInstruction = new()
{
{"PUSH", 0},
{"POP", 1},
{"ADD", 2},
{"SUB", 3},
{"MUL", 4},
{"DIV", 5},
{"NEG", 6},
{"EXP", 7},
{"MOD", 8},
{"LT", 9},
{"GT", 10},
{"EQ", 11},
{"AND", 12},
{"OR", 13},
{"NOT", 14},
{"XOR", 15},
{"LS", 16},
{"RS", 17},
{"LOAD", 18},
{"GLOAD", 19},
{"STORE", 20},
{"GSTORE", 21},
{"JUMP", 22},
{"CJUMP", 23},
{"CALL", 24},
{"RET", 25},
{"HALT", 26},
{"PUSH_STR", 27},
{"PUSH_CHAR", 28},
{"CONCAT", 29},
};
// public static Dictionary<TokenType, string> cOperation = new()
// {
// {TokenType.PLUS, "ADD"},
// {TokenType.MINUS, "SUB"},
// {TokenType.MOD, "MOD"},
// {TokenType.STAR, "MUL"},
// {TokenType.SLASH, "DIV"},
// {TokenType.LESS, "LT"},
// {TokenType.GREATER, "GT"},
// {TokenType.EQUAL_EQUAL, "EQ"},
// {TokenType.AND, "AND"},
// {TokenType.OR, "OR"},
// {TokenType.BANG, "NEG"},
// };
public static Dictionary<Instructions, string> cInstruction = new()
{
{Instructions.PUSH, "PUSH"},
{Instructions.PUSH_STR, "PUSH_STR"},
{Instructions.PUSH_CHAR, "PUSH_CHAR"},
{Instructions.POP, "POP"},
{Instructions.LOAD, "LOAD"},
{Instructions.GLOAD, "GLOAD"},
{Instructions.STORE, "STORE"},
{Instructions.GSTORE, "GSTORE"},
{Instructions.RET, "RET"},
{Instructions.CJUMP, "CJUMP"},
{Instructions.JUMP, "JUMP"},
{Instructions.EQ, "EQ"},
{Instructions.GT, "GT"},
{Instructions.LT, "LT"},
{Instructions.NEG, "LT"},
{Instructions.NOT, "NOT"},
};
}