Mercurial > hg > Members > nobuyasu > myCompiler
comparison Bison-Flex/Compiler-StackBase/UTF8/vm_code.h @ 4:805d39d28230
add Compiler-stackbase
author | nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 17 May 2011 08:00:38 +0900 |
parents | |
children | caede627f691 |
comparison
equal
deleted
inserted
replaced
3:3cea2e8a0e4b | 4:805d39d28230 |
---|---|
1 // | |
2 // 仮想CPUの命令コード割り当て | |
3 // | |
4 // (c)2008 Chihiro.SAKAMOTO HyperWorks | |
5 // | |
6 #ifdef VM_ENUMDEF | |
7 #define VMCODE0(code_, name_) code_, | |
8 #define VMCODE1(code_, name_) code_, | |
9 #endif | |
10 #ifdef VM_CREATE | |
11 #define VMCODE0(code_, name_) void name_() { statement.push_back(CVMCode(code_)); } | |
12 #define VMCODE1(code_, name_) void name_(int arg1) { statement.push_back(CVMCode(code_, arg1)); } | |
13 #endif | |
14 #ifdef VM_SWITCHTABLE | |
15 #define VMCODE0(code_, name_) case code_: name_(); break; | |
16 #define VMCODE1(code_, name_) case code_: name_(value()); break; | |
17 #endif | |
18 #ifdef VM_NAMETABLE | |
19 #define VMCODE0(code_, name_) #name_, | |
20 #define VMCODE1(code_, name_) #name_, | |
21 #endif | |
22 | |
23 VMCODE1(VM_PUSHCONST, PushConst) | |
24 VMCODE1(VM_PUSHSTRING, PushString) | |
25 VMCODE1(VM_PUSHVALUE, PushValue) | |
26 VMCODE1(VM_PUSHLOCAL, PushLocal) | |
27 VMCODE1(VM_PUSHARRAY, PushArray) | |
28 VMCODE1(VM_PUSHLOCALARRAY, PushLocalArray) | |
29 VMCODE1(VM_PUSHLOCALREF, PushLocalRef) | |
30 VMCODE1(VM_PUSHLOCALARRAYREF, PushLocalArrayRef) | |
31 VMCODE1(VM_PUSHADDR, PushAddr) | |
32 VMCODE1(VM_PUSHARRAYADDR, PushArrayAddr) | |
33 VMCODE1(VM_POPVALUE, PopValue) | |
34 VMCODE1(VM_POPLOCAL, PopLocal) | |
35 VMCODE1(VM_POPARRAY, PopArray) | |
36 VMCODE1(VM_POPLOCALARRAY, PopLocalArray) | |
37 VMCODE1(VM_POPLOCALREF, PopLocalRef) | |
38 VMCODE1(VM_POPLOCALARRAYREF, PopLocalArrayRef) | |
39 VMCODE1(VM_ALLOCSTACK, OpAllocStack) | |
40 VMCODE0(VM_POP, OpPop) | |
41 VMCODE0(VM_NEG, OpNeg) | |
42 VMCODE0(VM_EQ, OpEq) | |
43 VMCODE0(VM_NE, OpNe) | |
44 VMCODE0(VM_GT, OpGt) | |
45 VMCODE0(VM_GE, OpGe) | |
46 VMCODE0(VM_LT, OpLt) | |
47 VMCODE0(VM_LE, OpLe) | |
48 VMCODE0(VM_LOGAND, OpLogAnd) | |
49 VMCODE0(VM_LOGOR, OpLogOr) | |
50 VMCODE0(VM_AND, OpAnd) | |
51 VMCODE0(VM_OR, OpOr) | |
52 VMCODE0(VM_LSHIFT, OpLeftShift) | |
53 VMCODE0(VM_RSHIFT, OpRightShift) | |
54 VMCODE0(VM_ADD, OpAdd) | |
55 VMCODE0(VM_SUB, OpSub) | |
56 VMCODE0(VM_MUL, OpMul) | |
57 VMCODE0(VM_DIV, OpDiv) | |
58 VMCODE0(VM_MOD, OpMod) | |
59 VMCODE0(VM_STREQ, OpStrEq) | |
60 VMCODE0(VM_STRNE, OpStrNe) | |
61 VMCODE0(VM_STRGT, OpStrGt) | |
62 VMCODE0(VM_STRGE, OpStrGe) | |
63 VMCODE0(VM_STRLT, OpStrLt) | |
64 VMCODE0(VM_STRLE, OpStrLe) | |
65 VMCODE0(VM_STRADD, OpStrAdd) | |
66 VMCODE1(VM_JMP, OpJmp) | |
67 VMCODE1(VM_JMPC, OpJmpC) | |
68 VMCODE1(VM_JMPNC, OpJmpNC) | |
69 VMCODE1(VM_TEST, OpTest) | |
70 VMCODE1(VM_CALL, OpCall) | |
71 VMCODE1(VM_SYSCALL, OpSysCall) | |
72 VMCODE0(VM_RETURN, OpReturn) | |
73 VMCODE0(VM_RETURNV, OpReturnV) | |
74 VMCODE0(VM_HALT, OpHalt) | |
75 | |
76 #undef VMCODE0 | |
77 #undef VMCODE1 |