lcode.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  1. /*
  2. ** $Id: lcode.c,v 1.34 2000/06/05 14:56:18 roberto Exp roberto $
  3. ** Code generator for Lua
  4. ** See Copyright Notice in lua.h
  5. */
  6. #include "stdlib.h"
  7. #define LUA_REENTRANT
  8. #include "lua.h"
  9. #include "lcode.h"
  10. #include "ldo.h"
  11. #include "llex.h"
  12. #include "lmem.h"
  13. #include "lobject.h"
  14. #include "lopcodes.h"
  15. #include "lparser.h"
  16. void luaK_error (LexState *ls, const char *msg) {
  17. luaX_error(ls, msg, ls->t.token);
  18. }
  19. /*
  20. ** Returns the the previous instruction, for optimizations.
  21. ** If there is a jump target between this and the current instruction,
  22. ** returns a dummy instruction to avoid wrong optimizations.
  23. */
  24. static Instruction previous_instruction (FuncState *fs) {
  25. if (fs->pc > fs->lasttarget) /* no jumps to current position? */
  26. return fs->f->code[fs->pc-1]; /* returns previous instruction */
  27. else
  28. return CREATE_0(OP_END); /* no optimizations after an `END' */
  29. }
  30. int luaK_jump (FuncState *fs) {
  31. int j = luaK_code1(fs, OP_JMP, NO_JUMP);
  32. if (j == fs->lasttarget) { /* possible jumps to this jump? */
  33. luaK_concat(fs, &j, fs->jlt); /* keep them on hold */
  34. fs->jlt = NO_JUMP;
  35. }
  36. return j;
  37. }
  38. static void luaK_fixjump (FuncState *fs, int pc, int dest) {
  39. Instruction *jmp = &fs->f->code[pc];
  40. if (dest == NO_JUMP)
  41. SETARG_S(*jmp, NO_JUMP); /* point to itself to represent end of list */
  42. else { /* jump is relative to position following jump instruction */
  43. int offset = dest-(pc+1);
  44. if (abs(offset) > MAXARG_S)
  45. luaK_error(fs->ls, "control structure too long");
  46. SETARG_S(*jmp, offset);
  47. }
  48. }
  49. static int luaK_getjump (FuncState *fs, int pc) {
  50. int offset = GETARG_S(fs->f->code[pc]);
  51. if (offset == NO_JUMP) /* point to itself represents end of list */
  52. return NO_JUMP; /* end of list */
  53. else
  54. return (pc+1)+offset; /* turn offset into absolute position */
  55. }
  56. /*
  57. ** returns current `pc' and marks it as a jump target (to avoid wrong
  58. ** optimizations with consecutive instructions not in the same basic block).
  59. ** discharge list of jumps to last target.
  60. */
  61. int luaK_getlabel (FuncState *fs) {
  62. if (fs->pc != fs->lasttarget) {
  63. int lasttarget = fs->lasttarget;
  64. fs->lasttarget = fs->pc;
  65. luaK_patchlist(fs, fs->jlt, lasttarget); /* discharge old list `jlt' */
  66. fs->jlt = NO_JUMP; /* nobody jumps to this new label (yet) */
  67. }
  68. return fs->pc;
  69. }
  70. void luaK_deltastack (FuncState *fs, int delta) {
  71. fs->stacklevel += delta;
  72. if (fs->stacklevel > fs->f->maxstacksize) {
  73. if (fs->stacklevel > MAXSTACK)
  74. luaK_error(fs->ls, "function or expression too complex");
  75. fs->f->maxstacksize = fs->stacklevel;
  76. }
  77. }
  78. void luaK_kstr (LexState *ls, int c) {
  79. luaK_code1(ls->fs, OP_PUSHSTRING, c);
  80. }
  81. static int number_constant (FuncState *fs, Number r) {
  82. /* check whether `r' has appeared within the last LOOKBACKNUMS entries */
  83. Proto *f = fs->f;
  84. int c = f->nknum;
  85. int lim = c < LOOKBACKNUMS ? 0 : c-LOOKBACKNUMS;
  86. while (--c >= lim)
  87. if (f->knum[c] == r) return c;
  88. /* not found; create a new entry */
  89. luaM_growvector(fs->L, f->knum, f->nknum, 1, Number,
  90. "constant table overflow", MAXARG_U);
  91. c = f->nknum++;
  92. f->knum[c] = r;
  93. return c;
  94. }
  95. void luaK_number (FuncState *fs, Number f) {
  96. if (f <= (Number)MAXARG_S && (Number)(int)f == f)
  97. luaK_code1(fs, OP_PUSHINT, (int)f); /* f has a short integer value */
  98. else
  99. luaK_code1(fs, OP_PUSHNUM, number_constant(fs, f));
  100. }
  101. void luaK_adjuststack (FuncState *fs, int n) {
  102. if (n > 0)
  103. luaK_code1(fs, OP_POP, n);
  104. else
  105. luaK_code1(fs, OP_PUSHNIL, -n);
  106. }
  107. int luaK_lastisopen (FuncState *fs) {
  108. /* check whether last instruction is an open function call */
  109. Instruction i = previous_instruction(fs);
  110. if (GET_OPCODE(i) == OP_CALL && GETARG_B(i) == MULT_RET)
  111. return 1;
  112. else return 0;
  113. }
  114. void luaK_setcallreturns (FuncState *fs, int nresults) {
  115. if (luaK_lastisopen(fs)) { /* expression is an open function call? */
  116. SETARG_B(fs->f->code[fs->pc-1], nresults); /* set number of results */
  117. luaK_deltastack(fs, nresults); /* push results */
  118. }
  119. }
  120. static int discharge (FuncState *fs, expdesc *var) {
  121. switch (var->k) {
  122. case VLOCAL:
  123. luaK_code1(fs, OP_GETLOCAL, var->u.index);
  124. break;
  125. case VGLOBAL:
  126. luaK_code1(fs, OP_GETGLOBAL, var->u.index);
  127. break;
  128. case VINDEXED:
  129. luaK_code0(fs, OP_GETTABLE);
  130. break;
  131. case VEXP:
  132. return 0; /* nothing to do */
  133. }
  134. var->k = VEXP;
  135. var->u.l.t = var->u.l.f = NO_JUMP;
  136. return 1;
  137. }
  138. static void discharge1 (FuncState *fs, expdesc *var) {
  139. discharge(fs, var);
  140. /* if it has jumps then it is already discharged */
  141. if (var->u.l.t == NO_JUMP && var->u.l.f == NO_JUMP)
  142. luaK_setcallreturns(fs, 1); /* call must return 1 value */
  143. }
  144. void luaK_storevar (LexState *ls, const expdesc *var) {
  145. FuncState *fs = ls->fs;
  146. switch (var->k) {
  147. case VLOCAL:
  148. luaK_code1(fs, OP_SETLOCAL, var->u.index);
  149. break;
  150. case VGLOBAL:
  151. luaK_code1(fs, OP_SETGLOBAL, var->u.index);
  152. break;
  153. case VINDEXED: /* table is at top-3; pop 3 elements after operation */
  154. luaK_code2(fs, OP_SETTABLE, 3, 3);
  155. break;
  156. default:
  157. LUA_INTERNALERROR(ls->L, "invalid var kind to store");
  158. }
  159. }
  160. static OpCode invertjump (OpCode op) {
  161. switch (op) {
  162. case OP_JMPNE: return OP_JMPEQ;
  163. case OP_JMPEQ: return OP_JMPNE;
  164. case OP_JMPLT: return OP_JMPGE;
  165. case OP_JMPLE: return OP_JMPGT;
  166. case OP_JMPGT: return OP_JMPLE;
  167. case OP_JMPGE: return OP_JMPLT;
  168. case OP_JMPT: case OP_JMPONT: return OP_JMPF;
  169. case OP_JMPF: case OP_JMPONF: return OP_JMPT;
  170. default:
  171. LUA_INTERNALERROR(NULL, "invalid jump instruction");
  172. return OP_END; /* to avoid warnings */
  173. }
  174. }
  175. static void luaK_patchlistaux (FuncState *fs, int list, int target,
  176. OpCode special, int special_target) {
  177. Instruction *code = fs->f->code;
  178. while (list != NO_JUMP) {
  179. int next = luaK_getjump(fs, list);
  180. Instruction *i = &code[list];
  181. OpCode op = GET_OPCODE(*i);
  182. if (op == special) /* this `op' already has a value */
  183. luaK_fixjump(fs, list, special_target);
  184. else {
  185. luaK_fixjump(fs, list, target); /* do the patch */
  186. if (op == OP_JMPONT) /* remove eventual values */
  187. SET_OPCODE(*i, OP_JMPT);
  188. else if (op == OP_JMPONF)
  189. SET_OPCODE(*i, OP_JMPF);
  190. }
  191. list = next;
  192. }
  193. }
  194. void luaK_patchlist (FuncState *fs, int list, int target) {
  195. if (target == fs->lasttarget) /* same target that list `jlt'? */
  196. luaK_concat(fs, &fs->jlt, list); /* delay fixing */
  197. else
  198. luaK_patchlistaux(fs, list, target, OP_END, 0);
  199. }
  200. static int need_value (FuncState *fs, int list, OpCode hasvalue) {
  201. /* check whether list has a jump without a value */
  202. for (; list != NO_JUMP; list = luaK_getjump(fs, list))
  203. if (GET_OPCODE(fs->f->code[list]) != hasvalue) return 1;
  204. return 0; /* not found */
  205. }
  206. void luaK_concat (FuncState *fs, int *l1, int l2) {
  207. if (*l1 == NO_JUMP)
  208. *l1 = l2;
  209. else {
  210. int list = *l1;
  211. for (;;) { /* traverse `l1' */
  212. int next = luaK_getjump(fs, list);
  213. if (next == NO_JUMP) { /* end of list? */
  214. luaK_fixjump(fs, list, l2);
  215. return;
  216. }
  217. list = next;
  218. }
  219. }
  220. }
  221. static void luaK_testgo (FuncState *fs, expdesc *v, int invert, OpCode jump) {
  222. Instruction *previous;
  223. int *golist = &v->u.l.f;
  224. int *exitlist = &v->u.l.t;
  225. if (invert) { /* interchange `golist' and `exitlist' */
  226. int *temp = golist; golist = exitlist; exitlist = temp;
  227. }
  228. discharge1(fs, v);
  229. previous = &fs->f->code[fs->pc-1];
  230. LUA_ASSERT(L, GET_OPCODE(*previous) != OP_SETLINE, "bad place to set line");
  231. if (!ISJUMP(GET_OPCODE(*previous)))
  232. luaK_code1(fs, jump, NO_JUMP);
  233. else if (invert)
  234. SET_OPCODE(*previous, invertjump(GET_OPCODE(*previous)));
  235. luaK_concat(fs, exitlist, fs->pc-1); /* insert last jump in `exitlist' */
  236. luaK_patchlist(fs, *golist, luaK_getlabel(fs));
  237. *golist = NO_JUMP;
  238. }
  239. void luaK_goiftrue (FuncState *fs, expdesc *v, int keepvalue) {
  240. luaK_testgo(fs, v, 1, keepvalue ? OP_JMPONF : OP_JMPF);
  241. }
  242. void luaK_goiffalse (FuncState *fs, expdesc *v, int keepvalue) {
  243. luaK_testgo(fs, v, 0, keepvalue ? OP_JMPONT : OP_JMPT);
  244. }
  245. static int code_label (FuncState *fs, OpCode op, int arg) {
  246. int j = luaK_getlabel(fs);
  247. luaK_code1(fs, op, arg);
  248. return j;
  249. }
  250. void luaK_tostack (LexState *ls, expdesc *v, int onlyone) {
  251. FuncState *fs = ls->fs;
  252. if (!discharge(fs, v)) { /* `v' is an expression? */
  253. OpCode previous = GET_OPCODE(fs->f->code[fs->pc-1]);
  254. LUA_ASSERT(L, previous != OP_SETLINE, "bad place to set line");
  255. if (!ISJUMP(previous) && v->u.l.f == NO_JUMP && v->u.l.t == NO_JUMP) {
  256. /* expression has no jumps */
  257. if (onlyone)
  258. luaK_setcallreturns(fs, 1); /* call must return 1 value */
  259. }
  260. else { /* expression has jumps */
  261. int final; /* position after whole expression */
  262. int j = NO_JUMP; /* eventual jump over values */
  263. int p_nil = NO_JUMP; /* position of an eventual PUSHNIL */
  264. int p_1 = NO_JUMP; /* position of an eventual PUSHINT */
  265. if (ISJUMP(previous) || need_value(fs, v->u.l.f, OP_JMPONF) ||
  266. need_value(fs, v->u.l.t, OP_JMPONT)) {
  267. /* expression needs values */
  268. if (ISJUMP(previous))
  269. luaK_concat(fs, &v->u.l.t, fs->pc-1); /* put `previous' in t. list */
  270. else {
  271. j = code_label(fs, OP_JMP, NO_JUMP); /* to jump over both pushes */
  272. luaK_deltastack(fs, -1); /* next PUSHes may be skipped */
  273. }
  274. p_nil = code_label(fs, OP_PUSHNILJMP, 0);
  275. luaK_deltastack(fs, -1); /* next PUSH is skipped */
  276. p_1 = code_label(fs, OP_PUSHINT, 1);
  277. luaK_patchlist(fs, j, luaK_getlabel(fs));
  278. }
  279. final = luaK_getlabel(fs);
  280. luaK_patchlistaux(fs, v->u.l.f, p_nil, OP_JMPONF, final);
  281. luaK_patchlistaux(fs, v->u.l.t, p_1, OP_JMPONT, final);
  282. v->u.l.f = v->u.l.t = NO_JUMP;
  283. }
  284. }
  285. }
  286. void luaK_prefix (LexState *ls, int op, expdesc *v) {
  287. FuncState *fs = ls->fs;
  288. if (op == '-') {
  289. luaK_tostack(ls, v, 1);
  290. luaK_code0(fs, OP_MINUS);
  291. }
  292. else { /* op == NOT */
  293. Instruction *previous;
  294. discharge1(fs, v);
  295. previous = &fs->f->code[fs->pc-1];
  296. if (ISJUMP(GET_OPCODE(*previous)))
  297. SET_OPCODE(*previous, invertjump(GET_OPCODE(*previous)));
  298. else
  299. luaK_code0(fs, OP_NOT);
  300. /* interchange true and false lists */
  301. { int temp = v->u.l.f; v->u.l.f = v->u.l.t; v->u.l.t = temp; }
  302. }
  303. }
  304. void luaK_infix (LexState *ls, int op, expdesc *v) {
  305. FuncState *fs = ls->fs;
  306. if (op == TK_AND)
  307. luaK_goiftrue(fs, v, 1);
  308. else if (op == TK_OR)
  309. luaK_goiffalse(fs, v, 1);
  310. else
  311. luaK_tostack(ls, v, 1); /* all other binary operators need a value */
  312. }
  313. void luaK_posfix (LexState *ls, int op, expdesc *v1, expdesc *v2) {
  314. FuncState *fs = ls->fs;
  315. if (op == TK_AND) {
  316. LUA_ASSERT(ls->L, v1->u.l.t == NO_JUMP, "list must be closed");
  317. discharge1(fs, v2);
  318. v1->u.l.t = v2->u.l.t;
  319. luaK_concat(fs, &v1->u.l.f, v2->u.l.f);
  320. }
  321. else if (op == TK_OR) {
  322. LUA_ASSERT(ls->L, v1->u.l.f == NO_JUMP, "list must be closed");
  323. discharge1(fs, v2);
  324. v1->u.l.f = v2->u.l.f;
  325. luaK_concat(fs, &v1->u.l.t, v2->u.l.t);
  326. }
  327. else {
  328. luaK_tostack(ls, v2, 1); /* `v2' must be a value */
  329. switch (op) {
  330. case '+': luaK_code0(fs, OP_ADD); break;
  331. case '-': luaK_code0(fs, OP_SUB); break;
  332. case '*': luaK_code0(fs, OP_MULT); break;
  333. case '/': luaK_code0(fs, OP_DIV); break;
  334. case '^': luaK_code0(fs, OP_POW); break;
  335. case TK_CONCAT: luaK_code1(fs, OP_CONCAT, 2); break;
  336. case TK_EQ: luaK_code1(fs, OP_JMPEQ, NO_JUMP); break;
  337. case TK_NE: luaK_code1(fs, OP_JMPNE, NO_JUMP); break;
  338. case '>': luaK_code1(fs, OP_JMPGT, NO_JUMP); break;
  339. case '<': luaK_code1(fs, OP_JMPLT, NO_JUMP); break;
  340. case TK_GE: luaK_code1(fs, OP_JMPGE, NO_JUMP); break;
  341. case TK_LE: luaK_code1(fs, OP_JMPLE, NO_JUMP); break;
  342. }
  343. }
  344. }
  345. int luaK_code0 (FuncState *fs, OpCode o) {
  346. return luaK_code2(fs, o, 0, 0);
  347. }
  348. int luaK_code1 (FuncState *fs, OpCode o, int arg1) {
  349. return luaK_code2(fs, o, arg1, 0);
  350. }
  351. #define VD 100 /* flag for variable delta */
  352. int luaK_code2 (FuncState *fs, OpCode o, int arg1, int arg2) {
  353. Instruction i = previous_instruction(fs);
  354. int delta = luaK_opproperties[o].delta;
  355. int optm = 0; /* 1 when there is an optimization */
  356. switch (o) {
  357. case OP_CLOSURE:
  358. delta = -arg2+1;
  359. break;
  360. case OP_SETTABLE:
  361. delta = -arg2;
  362. break;
  363. case OP_SETLIST:
  364. if (arg2 == 0) return NO_JUMP; /* nothing to do */
  365. delta = -arg2;
  366. break;
  367. case OP_SETMAP:
  368. if (arg1 == 0) return NO_JUMP; /* nothing to do */
  369. delta = -2*arg1;
  370. break;
  371. case OP_RETURN:
  372. if (GET_OPCODE(i) == OP_CALL && GETARG_B(i) == MULT_RET) {
  373. SET_OPCODE(i, OP_TAILCALL);
  374. SETARG_B(i, arg1);
  375. optm = 1;
  376. }
  377. break;
  378. case OP_PUSHNIL:
  379. if (arg1 == 0) return NO_JUMP; /* nothing to do */
  380. delta = arg1;
  381. switch(GET_OPCODE(i)) {
  382. case OP_PUSHNIL: SETARG_U(i, GETARG_U(i)+arg1); optm = 1; break;
  383. default: break;
  384. }
  385. break;
  386. case OP_POP:
  387. if (arg1 == 0) return NO_JUMP; /* nothing to do */
  388. delta = -arg1;
  389. switch(GET_OPCODE(i)) {
  390. case OP_SETTABLE: SETARG_B(i, GETARG_B(i)+arg1); optm = 1; break;
  391. default: break;
  392. }
  393. break;
  394. case OP_GETTABLE:
  395. switch(GET_OPCODE(i)) {
  396. case OP_PUSHSTRING: /* `t.x' */
  397. SET_OPCODE(i, OP_GETDOTTED);
  398. optm = 1;
  399. break;
  400. case OP_GETLOCAL: /* `t[i]' */
  401. SET_OPCODE(i, OP_GETINDEXED);
  402. optm = 1;
  403. break;
  404. default: break;
  405. }
  406. break;
  407. case OP_ADD:
  408. switch(GET_OPCODE(i)) {
  409. case OP_PUSHINT: SET_OPCODE(i, OP_ADDI); optm = 1; break; /* `a+k' */
  410. default: break;
  411. }
  412. break;
  413. case OP_SUB:
  414. switch(GET_OPCODE(i)) {
  415. case OP_PUSHINT: /* `a-k' */
  416. i = CREATE_S(OP_ADDI, -GETARG_S(i));
  417. optm = 1;
  418. break;
  419. default: break;
  420. }
  421. break;
  422. case OP_CONCAT:
  423. delta = -arg1+1;
  424. switch(GET_OPCODE(i)) {
  425. case OP_CONCAT: /* `a..b..c' */
  426. SETARG_U(i, GETARG_U(i)+1);
  427. optm = 1;
  428. break;
  429. default: break;
  430. }
  431. break;
  432. case OP_MINUS:
  433. switch(GET_OPCODE(i)) {
  434. case OP_PUSHINT: /* `-k' */
  435. SETARG_S(i, -GETARG_S(i));
  436. optm = 1;
  437. break;
  438. case OP_PUSHNUM: /* `-k' */
  439. SET_OPCODE(i, OP_PUSHNEGNUM);
  440. optm = 1;
  441. break;
  442. default: break;
  443. }
  444. break;
  445. case OP_JMPNE:
  446. if (i == CREATE_U(OP_PUSHNIL, 1)) { /* `a~=nil' */
  447. i = CREATE_S(OP_JMPT, NO_JUMP);
  448. optm = 1;
  449. }
  450. break;
  451. case OP_JMPEQ:
  452. if (i == CREATE_U(OP_PUSHNIL, 1)) { /* `a==nil' */
  453. i = CREATE_0(OP_NOT);
  454. delta = -1; /* just undo effect of previous PUSHNIL */
  455. optm = 1;
  456. }
  457. break;
  458. case OP_JMPT:
  459. case OP_JMPF:
  460. case OP_JMPONT:
  461. case OP_JMPONF:
  462. switch (GET_OPCODE(i)) {
  463. case OP_NOT: i = CREATE_S(invertjump(o), NO_JUMP); optm = 1; break;
  464. default: break;
  465. }
  466. break;
  467. case OP_GETDOTTED:
  468. case OP_GETINDEXED:
  469. case OP_TAILCALL:
  470. case OP_ADDI:
  471. LUA_INTERNALERROR(L, "instruction used only for optimizations");
  472. break;
  473. default:
  474. LUA_ASSERT(L, delta != VD, "invalid delta");
  475. break;
  476. }
  477. luaK_deltastack(fs, delta);
  478. if (optm) { /* optimize: put instruction in place of last one */
  479. fs->f->code[fs->pc-1] = i; /* change previous instruction */
  480. return fs->pc-1; /* do not generate new instruction */
  481. }
  482. /* build new instruction */
  483. switch ((enum Mode)luaK_opproperties[o].mode) {
  484. case iO: i = CREATE_0(o); break;
  485. case iU: i = CREATE_U(o, arg1); break;
  486. case iS: i = CREATE_S(o, arg1); break;
  487. case iAB: i = CREATE_AB(o, arg1, arg2); break;
  488. }
  489. /* put new instruction in code array */
  490. luaM_growvector(fs->L, fs->f->code, fs->pc, 1, Instruction,
  491. "code size overflow", MAX_INT);
  492. fs->f->code[fs->pc] = i;
  493. return fs->pc++;
  494. }
  495. const struct OpProperties luaK_opproperties[OP_SETLINE+1] = {
  496. {iO, 0}, /* OP_END */
  497. {iU, 0}, /* OP_RETURN */
  498. {iAB, 0}, /* OP_CALL */
  499. {iAB, 0}, /* OP_TAILCALL */
  500. {iU, VD}, /* OP_PUSHNIL */
  501. {iU, VD}, /* OP_POP */
  502. {iS, 1}, /* OP_PUSHINT */
  503. {iU, 1}, /* OP_PUSHSTRING */
  504. {iU, 1}, /* OP_PUSHNUM */
  505. {iU, 1}, /* OP_PUSHNEGNUM */
  506. {iU, 1}, /* OP_PUSHUPVALUE */
  507. {iU, 1}, /* OP_GETLOCAL */
  508. {iU, 1}, /* OP_GETGLOBAL */
  509. {iO, -1}, /* OP_GETTABLE */
  510. {iU, 0}, /* OP_GETDOTTED */
  511. {iU, 0}, /* OP_GETINDEXED */
  512. {iU, 1}, /* OP_PUSHSELF */
  513. {iU, 1}, /* OP_CREATETABLE */
  514. {iU, -1}, /* OP_SETLOCAL */
  515. {iU, -1}, /* OP_SETGLOBAL */
  516. {iAB, VD}, /* OP_SETTABLE */
  517. {iAB, VD}, /* OP_SETLIST */
  518. {iU, VD}, /* OP_SETMAP */
  519. {iO, -1}, /* OP_ADD */
  520. {iS, 0}, /* OP_ADDI */
  521. {iO, -1}, /* OP_SUB */
  522. {iO, -1}, /* OP_MULT */
  523. {iO, -1}, /* OP_DIV */
  524. {iO, -1}, /* OP_POW */
  525. {iU, VD}, /* OP_CONCAT */
  526. {iO, 0}, /* OP_MINUS */
  527. {iO, 0}, /* OP_NOT */
  528. {iS, -2}, /* OP_JMPNE */
  529. {iS, -2}, /* OP_JMPEQ */
  530. {iS, -2}, /* OP_JMPLT */
  531. {iS, -2}, /* OP_JMPLE */
  532. {iS, -2}, /* OP_JMPGT */
  533. {iS, -2}, /* OP_JMPGE */
  534. {iS, -1}, /* OP_JMPT */
  535. {iS, -1}, /* OP_JMPF */
  536. {iS, -1}, /* OP_JMPONT */
  537. {iS, -1}, /* OP_JMPONF */
  538. {iS, 0}, /* OP_JMP */
  539. {iO, 1}, /* OP_PUSHNILJMP */
  540. {iS, 0}, /* OP_FORPREP */
  541. {iS, -3}, /* OP_FORLOOP */
  542. {iS, 3}, /* OP_LFORPREP */
  543. {iS, -4}, /* OP_LFORLOOP */
  544. {iAB, VD}, /* OP_CLOSURE */
  545. {iU, 0} /* OP_SETLINE */
  546. };