lcode.c 17 KB

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