| 1 | /* |
| 2 | ** $Id: lopcodes.c,v 1.49 2012/05/14 13:34:18 roberto Exp $ |
| 3 | ** Opcodes for Lua virtual machine |
| 4 | ** See Copyright Notice in lua.h |
| 5 | */ |
| 6 | |
| 7 | |
| 8 | #define lopcodes_c |
| 9 | #define LUA_CORE |
| 10 | |
| 11 | |
| 12 | #include "lopcodes.h" |
| 13 | |
| 14 | |
| 15 | /* ORDER OP */ |
| 16 | |
| 17 | LUAI_DDEF const char *const luaP_opnames[NUM_OPCODES+1] = { |
| 18 | "MOVE", |
| 19 | "LOADK", |
| 20 | "LOADKX", |
| 21 | "LOADBOOL", |
| 22 | "LOADNIL", |
| 23 | "GETUPVAL", |
| 24 | "GETTABUP", |
| 25 | "GETTABLE", |
| 26 | "SETTABUP", |
| 27 | "SETUPVAL", |
| 28 | "SETTABLE", |
| 29 | "NEWTABLE", |
| 30 | "SELF", |
| 31 | "ADD", |
| 32 | "SUB", |
| 33 | "MUL", |
| 34 | "DIV", |
| 35 | "MOD", |
| 36 | "POW", |
| 37 | "UNM", |
| 38 | "NOT", |
| 39 | "LEN", |
| 40 | "CONCAT", |
| 41 | "JMP", |
| 42 | "EQ", |
| 43 | "LT", |
| 44 | "LE", |
| 45 | "TEST", |
| 46 | "TESTSET", |
| 47 | "CALL", |
| 48 | "TAILCALL", |
| 49 | "RETURN", |
| 50 | "FORLOOP", |
| 51 | "FORPREP", |
| 52 | "TFORCALL", |
| 53 | "TFORLOOP", |
| 54 | "SETLIST", |
| 55 | "CLOSURE", |
| 56 | "VARARG", |
| 57 | "EXTRAARG", |
| 58 | NULL |
| 59 | }; |
| 60 | |
| 61 | |
| 62 | #define opmode(t,a,b,c,m) (((t)<<7) | ((a)<<6) | ((b)<<4) | ((c)<<2) | (m)) |
| 63 | |
| 64 | LUAI_DDEF const lu_byte luaP_opmodes[NUM_OPCODES] = { |
| 65 | /* T A B C mode opcode */ |
| 66 | opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_MOVE */ |
| 67 | ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_LOADK */ |
| 68 | ,opmode(0, 1, OpArgN, OpArgN, iABx) /* OP_LOADKX */ |
| 69 | ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_LOADBOOL */ |
| 70 | ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_LOADNIL */ |
| 71 | ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_GETUPVAL */ |
| 72 | ,opmode(0, 1, OpArgU, OpArgK, iABC) /* OP_GETTABUP */ |
| 73 | ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_GETTABLE */ |
| 74 | ,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_SETTABUP */ |
| 75 | ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_SETUPVAL */ |
| 76 | ,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_SETTABLE */ |
| 77 | ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_NEWTABLE */ |
| 78 | ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_SELF */ |
| 79 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_ADD */ |
| 80 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SUB */ |
| 81 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MUL */ |
| 82 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_DIV */ |
| 83 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MOD */ |
| 84 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_POW */ |
| 85 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_UNM */ |
| 86 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_NOT */ |
| 87 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LEN */ |
| 88 | ,opmode(0, 1, OpArgR, OpArgR, iABC) /* OP_CONCAT */ |
| 89 | ,opmode(0, 0, OpArgR, OpArgN, iAsBx) /* OP_JMP */ |
| 90 | ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_EQ */ |
| 91 | ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LT */ |
| 92 | ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LE */ |
| 93 | ,opmode(1, 0, OpArgN, OpArgU, iABC) /* OP_TEST */ |
| 94 | ,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TESTSET */ |
| 95 | ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_CALL */ |
| 96 | ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_TAILCALL */ |
| 97 | ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_RETURN */ |
| 98 | ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORLOOP */ |
| 99 | ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORPREP */ |
| 100 | ,opmode(0, 0, OpArgN, OpArgU, iABC) /* OP_TFORCALL */ |
| 101 | ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_TFORLOOP */ |
| 102 | ,opmode(0, 0, OpArgU, OpArgU, iABC) /* OP_SETLIST */ |
| 103 | ,opmode(0, 1, OpArgU, OpArgN, iABx) /* OP_CLOSURE */ |
| 104 | ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_VARARG */ |
| 105 | ,opmode(0, 0, OpArgU, OpArgU, iAx) /* OP_EXTRAARG */ |
| 106 | }; |
| 107 | |