diff options
-rw-r--r-- | lopcodes.c | 88 | ||||
-rw-r--r-- | lopcodes.h | 5 | ||||
-rw-r--r-- | lopnames.h | 94 | ||||
-rw-r--r-- | ltests.c | 7 |
4 files changed, 100 insertions, 94 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lopcodes.c,v 1.81 2018/04/04 14:23:41 roberto Exp roberto $ | 2 | ** $Id: lopcodes.c,v 1.83 2018/06/26 18:00:55 roberto Exp $ |
3 | ** Opcodes for Lua virtual machine | 3 | ** Opcodes for Lua virtual machine |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -17,92 +17,6 @@ | |||
17 | 17 | ||
18 | /* ORDER OP */ | 18 | /* ORDER OP */ |
19 | 19 | ||
20 | #if defined(LUAI_DEFOPNAMES) | ||
21 | |||
22 | LUAI_DDEF const char *const luaP_opnames[NUM_OPCODES+1] = { | ||
23 | "MOVE", | ||
24 | "LOADI", | ||
25 | "LOADF", | ||
26 | "LOADK", | ||
27 | "LOADKX", | ||
28 | "LOADBOOL", | ||
29 | "LOADNIL", | ||
30 | "GETUPVAL", | ||
31 | "SETUPVAL", | ||
32 | "GETTABUP", | ||
33 | "GETTABLE", | ||
34 | "GETI", | ||
35 | "GETFIELD", | ||
36 | "SETTABUP", | ||
37 | "SETTABLE", | ||
38 | "SETI", | ||
39 | "SETFIELD", | ||
40 | "NEWTABLE", | ||
41 | "SELF", | ||
42 | "ADDI", | ||
43 | "SUBI", | ||
44 | "MULI", | ||
45 | "MODI", | ||
46 | "POWI", | ||
47 | "DIVI", | ||
48 | "IDIVI", | ||
49 | "BANDK", | ||
50 | "BORK", | ||
51 | "BXORK", | ||
52 | "SHRI", | ||
53 | "SHLI", | ||
54 | "ADD", | ||
55 | "SUB", | ||
56 | "MUL", | ||
57 | "MOD", | ||
58 | "POW", | ||
59 | "DIV", | ||
60 | "IDIV", | ||
61 | "BAND", | ||
62 | "BOR", | ||
63 | "BXOR", | ||
64 | "SHL", | ||
65 | "SHR", | ||
66 | "UNM", | ||
67 | "BNOT", | ||
68 | "NOT", | ||
69 | "LEN", | ||
70 | "CONCAT", | ||
71 | "CLOSE", | ||
72 | "JMP", | ||
73 | "EQ", | ||
74 | "LT", | ||
75 | "LE", | ||
76 | "EQK", | ||
77 | "EQI", | ||
78 | "LTI", | ||
79 | "LEI", | ||
80 | "GTI", | ||
81 | "GEI", | ||
82 | "TEST", | ||
83 | "TESTSET", | ||
84 | "CALL", | ||
85 | "TAILCALL", | ||
86 | "RETURN", | ||
87 | "RETURN0", | ||
88 | "RETURN1", | ||
89 | "FORLOOP1", | ||
90 | "FORPREP1", | ||
91 | "FORLOOP", | ||
92 | "FORPREP", | ||
93 | "TFORCALL", | ||
94 | "TFORLOOP", | ||
95 | "SETLIST", | ||
96 | "CLOSURE", | ||
97 | "VARARG", | ||
98 | "PREPVARARG", | ||
99 | "EXTRAARG", | ||
100 | NULL | ||
101 | }; | ||
102 | |||
103 | #endif | ||
104 | |||
105 | |||
106 | LUAI_DDEF const lu_byte luaP_opmodes[NUM_OPCODES] = { | 20 | LUAI_DDEF const lu_byte luaP_opmodes[NUM_OPCODES] = { |
107 | /* OT IT T A mode opcode */ | 21 | /* OT IT T A mode opcode */ |
108 | opmode(0, 0, 0, 1, iABC) /* OP_MOVE */ | 22 | opmode(0, 0, 0, 1, iABC) /* OP_MOVE */ |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lopcodes.h,v 1.192 2018/06/08 19:07:27 roberto Exp roberto $ | 2 | ** $Id: lopcodes.h,v 1.194 2018/06/26 18:00:55 roberto Exp $ |
3 | ** Opcodes for Lua virtual machine | 3 | ** Opcodes for Lua virtual machine |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -358,9 +358,6 @@ LUAI_DDEC(const lu_byte luaP_opmodes[NUM_OPCODES];) | |||
358 | #define opmode(ot,it,t,a,m) (((ot)<<6) | ((it)<<5) | ((t)<<4) | ((a)<<3) | (m)) | 358 | #define opmode(ot,it,t,a,m) (((ot)<<6) | ((it)<<5) | ((t)<<4) | ((a)<<3) | (m)) |
359 | 359 | ||
360 | 360 | ||
361 | LUAI_DDEC(const char *const luaP_opnames[NUM_OPCODES+1];) /* opcode names */ | ||
362 | |||
363 | |||
364 | /* number of list items to accumulate before a SETLIST instruction */ | 361 | /* number of list items to accumulate before a SETLIST instruction */ |
365 | #define LFIELDS_PER_FLUSH 50 | 362 | #define LFIELDS_PER_FLUSH 50 |
366 | 363 | ||
diff --git a/lopnames.h b/lopnames.h new file mode 100644 index 00000000..ab434b59 --- /dev/null +++ b/lopnames.h | |||
@@ -0,0 +1,94 @@ | |||
1 | /* | ||
2 | ** $Id: lopnames.h,v 1.1 2018/06/26 18:00:55 roberto Exp $ | ||
3 | ** Opcode names | ||
4 | ** See Copyright Notice in lua.h | ||
5 | */ | ||
6 | |||
7 | #if !defined(lopnames_h) | ||
8 | #define lopnames_h | ||
9 | |||
10 | /* ORDER OP */ | ||
11 | |||
12 | static const char *const opnames[] = { | ||
13 | "MOVE", | ||
14 | "LOADI", | ||
15 | "LOADF", | ||
16 | "LOADK", | ||
17 | "LOADKX", | ||
18 | "LOADBOOL", | ||
19 | "LOADNIL", | ||
20 | "GETUPVAL", | ||
21 | "SETUPVAL", | ||
22 | "GETTABUP", | ||
23 | "GETTABLE", | ||
24 | "GETI", | ||
25 | "GETFIELD", | ||
26 | "SETTABUP", | ||
27 | "SETTABLE", | ||
28 | "SETI", | ||
29 | "SETFIELD", | ||
30 | "NEWTABLE", | ||
31 | "SELF", | ||
32 | "ADDI", | ||
33 | "SUBI", | ||
34 | "MULI", | ||
35 | "MODI", | ||
36 | "POWI", | ||
37 | "DIVI", | ||
38 | "IDIVI", | ||
39 | "BANDK", | ||
40 | "BORK", | ||
41 | "BXORK", | ||
42 | "SHRI", | ||
43 | "SHLI", | ||
44 | "ADD", | ||
45 | "SUB", | ||
46 | "MUL", | ||
47 | "MOD", | ||
48 | "POW", | ||
49 | "DIV", | ||
50 | "IDIV", | ||
51 | "BAND", | ||
52 | "BOR", | ||
53 | "BXOR", | ||
54 | "SHL", | ||
55 | "SHR", | ||
56 | "UNM", | ||
57 | "BNOT", | ||
58 | "NOT", | ||
59 | "LEN", | ||
60 | "CONCAT", | ||
61 | "CLOSE", | ||
62 | "JMP", | ||
63 | "EQ", | ||
64 | "LT", | ||
65 | "LE", | ||
66 | "EQK", | ||
67 | "EQI", | ||
68 | "LTI", | ||
69 | "LEI", | ||
70 | "GTI", | ||
71 | "GEI", | ||
72 | "TEST", | ||
73 | "TESTSET", | ||
74 | "CALL", | ||
75 | "TAILCALL", | ||
76 | "RETURN", | ||
77 | "RETURN0", | ||
78 | "RETURN1", | ||
79 | "FORLOOP1", | ||
80 | "FORPREP1", | ||
81 | "FORLOOP", | ||
82 | "FORPREP", | ||
83 | "TFORCALL", | ||
84 | "TFORLOOP", | ||
85 | "SETLIST", | ||
86 | "CLOSURE", | ||
87 | "VARARG", | ||
88 | "PREPVARARG", | ||
89 | "EXTRAARG", | ||
90 | NULL | ||
91 | }; | ||
92 | |||
93 | #endif | ||
94 | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltests.c,v 2.244 2018/06/11 14:19:50 roberto Exp roberto $ | 2 | ** $Id: ltests.c,v 2.246 2018/06/26 18:00:55 roberto Exp roberto $ |
3 | ** Internal Module for Debugging of the Lua Implementation | 3 | ** Internal Module for Debugging of the Lua Implementation |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -27,6 +27,7 @@ | |||
27 | #include "lfunc.h" | 27 | #include "lfunc.h" |
28 | #include "lmem.h" | 28 | #include "lmem.h" |
29 | #include "lopcodes.h" | 29 | #include "lopcodes.h" |
30 | #include "lopnames.h" | ||
30 | #include "lstate.h" | 31 | #include "lstate.h" |
31 | #include "lstring.h" | 32 | #include "lstring.h" |
32 | #include "ltable.h" | 33 | #include "ltable.h" |
@@ -523,7 +524,7 @@ int lua_checkmemory (lua_State *L) { | |||
523 | static char *buildop (Proto *p, int pc, char *buff) { | 524 | static char *buildop (Proto *p, int pc, char *buff) { |
524 | Instruction i = p->code[pc]; | 525 | Instruction i = p->code[pc]; |
525 | OpCode o = GET_OPCODE(i); | 526 | OpCode o = GET_OPCODE(i); |
526 | const char *name = luaP_opnames[o]; | 527 | const char *name = opnames[o]; |
527 | int line = luaG_getfuncline(p, pc); | 528 | int line = luaG_getfuncline(p, pc); |
528 | sprintf(buff, "(%4d) %4d - ", line, pc); | 529 | sprintf(buff, "(%4d) %4d - ", line, pc); |
529 | switch (getOpMode(o)) { | 530 | switch (getOpMode(o)) { |
@@ -599,7 +600,7 @@ static int printcode (lua_State *L) { | |||
599 | printf("numparams: %d\n", p->numparams); | 600 | printf("numparams: %d\n", p->numparams); |
600 | for (pc=0; pc<p->sizecode; pc++) { | 601 | for (pc=0; pc<p->sizecode; pc++) { |
601 | char buff[100]; | 602 | char buff[100]; |
602 | printf("%d\t%s\n", pc + 1, buildop(p, pc, buff)); | 603 | printf("%s\n", buildop(p, pc, buff)); |
603 | } | 604 | } |
604 | return 0; | 605 | return 0; |
605 | } | 606 | } |