2000-02-22 16:31:19 +03:00
|
|
|
/*
|
2000-08-09 00:42:07 +04:00
|
|
|
** $Id: lcode.c,v 1.43 2000/08/08 18:26:05 roberto Exp roberto $
|
2000-02-22 16:31:19 +03:00
|
|
|
** Code generator for Lua
|
|
|
|
** See Copyright Notice in lua.h
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2000-04-05 00:48:44 +04:00
|
|
|
#include "stdlib.h"
|
|
|
|
|
2000-03-09 16:57:37 +03:00
|
|
|
#define LUA_REENTRANT
|
|
|
|
|
2000-06-12 17:52:05 +04:00
|
|
|
#include "lua.h"
|
|
|
|
|
2000-02-22 16:31:19 +03:00
|
|
|
#include "lcode.h"
|
2000-03-03 15:33:59 +03:00
|
|
|
#include "ldo.h"
|
2000-02-22 16:31:19 +03:00
|
|
|
#include "llex.h"
|
|
|
|
#include "lmem.h"
|
|
|
|
#include "lobject.h"
|
|
|
|
#include "lopcodes.h"
|
|
|
|
#include "lparser.h"
|
2000-03-03 15:33:59 +03:00
|
|
|
|
|
|
|
|
|
|
|
void luaK_error (LexState *ls, const char *msg) {
|
2000-05-24 22:04:17 +04:00
|
|
|
luaX_error(ls, msg, ls->t.token);
|
2000-03-03 15:33:59 +03:00
|
|
|
}
|
2000-02-22 16:31:19 +03:00
|
|
|
|
2000-04-07 23:35:20 +04:00
|
|
|
|
2000-04-05 21:51:58 +04:00
|
|
|
/*
|
2000-04-07 23:35:20 +04:00
|
|
|
** Returns the the previous instruction, for optimizations.
|
2000-04-05 21:51:58 +04:00
|
|
|
** If there is a jump target between this and the current instruction,
|
|
|
|
** returns a dummy instruction to avoid wrong optimizations.
|
|
|
|
*/
|
|
|
|
static Instruction previous_instruction (FuncState *fs) {
|
|
|
|
if (fs->pc > fs->lasttarget) /* no jumps to current position? */
|
|
|
|
return fs->f->code[fs->pc-1]; /* returns previous instruction */
|
|
|
|
else
|
|
|
|
return CREATE_0(OP_END); /* no optimizations after an `END' */
|
|
|
|
}
|
|
|
|
|
2000-02-22 16:31:19 +03:00
|
|
|
|
2000-04-05 21:51:58 +04:00
|
|
|
int luaK_jump (FuncState *fs) {
|
2000-05-22 22:44:46 +04:00
|
|
|
int j = luaK_code1(fs, OP_JMP, NO_JUMP);
|
2000-04-06 21:36:52 +04:00
|
|
|
if (j == fs->lasttarget) { /* possible jumps to this jump? */
|
|
|
|
luaK_concat(fs, &j, fs->jlt); /* keep them on hold */
|
|
|
|
fs->jlt = NO_JUMP;
|
|
|
|
}
|
|
|
|
return j;
|
2000-04-05 21:51:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void luaK_fixjump (FuncState *fs, int pc, int dest) {
|
2000-02-22 16:31:19 +03:00
|
|
|
Instruction *jmp = &fs->f->code[pc];
|
2000-03-16 21:03:09 +03:00
|
|
|
if (dest == NO_JUMP)
|
2000-04-05 21:51:58 +04:00
|
|
|
SETARG_S(*jmp, NO_JUMP); /* point to itself to represent end of list */
|
2000-03-16 21:03:09 +03:00
|
|
|
else { /* jump is relative to position following jump instruction */
|
|
|
|
int offset = dest-(pc+1);
|
2000-04-05 00:48:44 +04:00
|
|
|
if (abs(offset) > MAXARG_S)
|
2000-03-16 21:03:09 +03:00
|
|
|
luaK_error(fs->ls, "control structure too long");
|
|
|
|
SETARG_S(*jmp, offset);
|
|
|
|
}
|
2000-03-13 23:37:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int luaK_getjump (FuncState *fs, int pc) {
|
|
|
|
int offset = GETARG_S(fs->f->code[pc]);
|
2000-04-05 21:51:58 +04:00
|
|
|
if (offset == NO_JUMP) /* point to itself represents end of list */
|
2000-03-13 23:37:16 +03:00
|
|
|
return NO_JUMP; /* end of list */
|
|
|
|
else
|
2000-03-16 21:03:09 +03:00
|
|
|
return (pc+1)+offset; /* turn offset into absolute position */
|
2000-02-22 16:31:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-03-04 23:18:15 +03:00
|
|
|
/*
|
|
|
|
** returns current `pc' and marks it as a jump target (to avoid wrong
|
|
|
|
** optimizations with consecutive instructions not in the same basic block).
|
2000-06-05 18:56:18 +04:00
|
|
|
** discharge list of jumps to last target.
|
2000-03-04 23:18:15 +03:00
|
|
|
*/
|
2000-03-13 23:37:16 +03:00
|
|
|
int luaK_getlabel (FuncState *fs) {
|
2000-04-06 21:36:52 +04:00
|
|
|
if (fs->pc != fs->lasttarget) {
|
|
|
|
int lasttarget = fs->lasttarget;
|
|
|
|
fs->lasttarget = fs->pc;
|
|
|
|
luaK_patchlist(fs, fs->jlt, lasttarget); /* discharge old list `jlt' */
|
2000-06-05 18:56:18 +04:00
|
|
|
fs->jlt = NO_JUMP; /* nobody jumps to this new label (yet) */
|
2000-04-06 21:36:52 +04:00
|
|
|
}
|
2000-03-04 23:18:15 +03:00
|
|
|
return fs->pc;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-03-13 23:37:16 +03:00
|
|
|
void luaK_deltastack (FuncState *fs, int delta) {
|
2000-04-05 21:51:58 +04:00
|
|
|
fs->stacklevel += delta;
|
2000-06-05 18:56:18 +04:00
|
|
|
if (fs->stacklevel > fs->f->maxstacksize) {
|
2000-04-05 21:51:58 +04:00
|
|
|
if (fs->stacklevel > MAXSTACK)
|
2000-03-13 23:37:16 +03:00
|
|
|
luaK_error(fs->ls, "function or expression too complex");
|
2000-04-05 21:51:58 +04:00
|
|
|
fs->f->maxstacksize = fs->stacklevel;
|
2000-03-03 15:33:59 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-03-03 21:53:17 +03:00
|
|
|
void luaK_kstr (LexState *ls, int c) {
|
2000-04-07 23:35:20 +04:00
|
|
|
luaK_code1(ls->fs, OP_PUSHSTRING, c);
|
2000-03-03 15:33:59 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-06-05 18:56:18 +04:00
|
|
|
static int number_constant (FuncState *fs, Number r) {
|
2000-03-03 17:58:26 +03:00
|
|
|
/* check whether `r' has appeared within the last LOOKBACKNUMS entries */
|
2000-03-13 23:37:16 +03:00
|
|
|
Proto *f = fs->f;
|
2000-03-03 15:33:59 +03:00
|
|
|
int c = f->nknum;
|
|
|
|
int lim = c < LOOKBACKNUMS ? 0 : c-LOOKBACKNUMS;
|
|
|
|
while (--c >= lim)
|
|
|
|
if (f->knum[c] == r) return c;
|
|
|
|
/* not found; create a new entry */
|
2000-05-24 17:54:49 +04:00
|
|
|
luaM_growvector(fs->L, f->knum, f->nknum, 1, Number,
|
|
|
|
"constant table overflow", MAXARG_U);
|
2000-03-03 15:33:59 +03:00
|
|
|
c = f->nknum++;
|
|
|
|
f->knum[c] = r;
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-03-13 23:37:16 +03:00
|
|
|
void luaK_number (FuncState *fs, Number f) {
|
2000-06-05 18:56:18 +04:00
|
|
|
if (f <= (Number)MAXARG_S && (Number)(int)f == f)
|
2000-04-07 23:35:20 +04:00
|
|
|
luaK_code1(fs, OP_PUSHINT, (int)f); /* f has a short integer value */
|
2000-03-03 15:33:59 +03:00
|
|
|
else
|
2000-06-05 18:56:18 +04:00
|
|
|
luaK_code1(fs, OP_PUSHNUM, number_constant(fs, f));
|
2000-03-03 15:33:59 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-03-13 23:37:16 +03:00
|
|
|
void luaK_adjuststack (FuncState *fs, int n) {
|
2000-03-03 15:33:59 +03:00
|
|
|
if (n > 0)
|
2000-04-07 23:35:20 +04:00
|
|
|
luaK_code1(fs, OP_POP, n);
|
2000-06-05 18:56:18 +04:00
|
|
|
else
|
2000-04-07 23:35:20 +04:00
|
|
|
luaK_code1(fs, OP_PUSHNIL, -n);
|
2000-03-03 15:33:59 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-03-13 23:37:16 +03:00
|
|
|
int luaK_lastisopen (FuncState *fs) {
|
2000-03-17 16:09:46 +03:00
|
|
|
/* check whether last instruction is an open function call */
|
|
|
|
Instruction i = previous_instruction(fs);
|
|
|
|
if (GET_OPCODE(i) == OP_CALL && GETARG_B(i) == MULT_RET)
|
2000-03-04 23:18:15 +03:00
|
|
|
return 1;
|
|
|
|
else return 0;
|
2000-03-03 15:33:59 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-03-13 23:37:16 +03:00
|
|
|
void luaK_setcallreturns (FuncState *fs, int nresults) {
|
2000-03-17 16:09:46 +03:00
|
|
|
if (luaK_lastisopen(fs)) { /* expression is an open function call? */
|
|
|
|
SETARG_B(fs->f->code[fs->pc-1], nresults); /* set number of results */
|
2000-03-13 23:37:16 +03:00
|
|
|
luaK_deltastack(fs, nresults); /* push results */
|
2000-03-03 15:33:59 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-03-13 23:37:16 +03:00
|
|
|
static int discharge (FuncState *fs, expdesc *var) {
|
2000-03-03 15:33:59 +03:00
|
|
|
switch (var->k) {
|
|
|
|
case VLOCAL:
|
2000-04-07 23:35:20 +04:00
|
|
|
luaK_code1(fs, OP_GETLOCAL, var->u.index);
|
2000-03-03 15:33:59 +03:00
|
|
|
break;
|
|
|
|
case VGLOBAL:
|
2000-04-07 23:35:20 +04:00
|
|
|
luaK_code1(fs, OP_GETGLOBAL, var->u.index);
|
2000-03-03 15:33:59 +03:00
|
|
|
break;
|
|
|
|
case VINDEXED:
|
2000-04-07 23:35:20 +04:00
|
|
|
luaK_code0(fs, OP_GETTABLE);
|
2000-03-03 15:33:59 +03:00
|
|
|
break;
|
|
|
|
case VEXP:
|
2000-03-09 16:57:37 +03:00
|
|
|
return 0; /* nothing to do */
|
2000-03-03 15:33:59 +03:00
|
|
|
}
|
|
|
|
var->k = VEXP;
|
2000-03-13 23:37:16 +03:00
|
|
|
var->u.l.t = var->u.l.f = NO_JUMP;
|
2000-03-09 16:57:37 +03:00
|
|
|
return 1;
|
2000-03-04 23:18:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-03-13 23:37:16 +03:00
|
|
|
static void discharge1 (FuncState *fs, expdesc *var) {
|
|
|
|
discharge(fs, var);
|
2000-06-05 18:56:18 +04:00
|
|
|
/* if it has jumps then it is already discharged */
|
2000-03-13 23:37:16 +03:00
|
|
|
if (var->u.l.t == NO_JUMP && var->u.l.f == NO_JUMP)
|
|
|
|
luaK_setcallreturns(fs, 1); /* call must return 1 value */
|
2000-03-03 15:33:59 +03:00
|
|
|
}
|
2000-04-07 23:35:20 +04:00
|
|
|
|
2000-03-03 15:33:59 +03:00
|
|
|
|
|
|
|
void luaK_storevar (LexState *ls, const expdesc *var) {
|
2000-03-13 23:37:16 +03:00
|
|
|
FuncState *fs = ls->fs;
|
2000-03-03 15:33:59 +03:00
|
|
|
switch (var->k) {
|
|
|
|
case VLOCAL:
|
2000-04-07 23:35:20 +04:00
|
|
|
luaK_code1(fs, OP_SETLOCAL, var->u.index);
|
2000-03-03 15:33:59 +03:00
|
|
|
break;
|
|
|
|
case VGLOBAL:
|
2000-04-07 23:35:20 +04:00
|
|
|
luaK_code1(fs, OP_SETGLOBAL, var->u.index);
|
2000-03-03 15:33:59 +03:00
|
|
|
break;
|
2000-04-07 17:13:11 +04:00
|
|
|
case VINDEXED: /* table is at top-3; pop 3 elements after operation */
|
2000-04-07 23:35:20 +04:00
|
|
|
luaK_code2(fs, OP_SETTABLE, 3, 3);
|
2000-03-03 15:33:59 +03:00
|
|
|
break;
|
|
|
|
default:
|
2000-06-30 18:35:17 +04:00
|
|
|
LUA_INTERNALERROR("invalid var kind to store");
|
2000-03-03 15:33:59 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-03-09 16:57:37 +03:00
|
|
|
static OpCode invertjump (OpCode op) {
|
|
|
|
switch (op) {
|
2000-04-07 17:13:11 +04:00
|
|
|
case OP_JMPNE: return OP_JMPEQ;
|
|
|
|
case OP_JMPEQ: return OP_JMPNE;
|
2000-04-05 00:48:44 +04:00
|
|
|
case OP_JMPLT: return OP_JMPGE;
|
|
|
|
case OP_JMPLE: return OP_JMPGT;
|
|
|
|
case OP_JMPGT: return OP_JMPLE;
|
|
|
|
case OP_JMPGE: return OP_JMPLT;
|
|
|
|
case OP_JMPT: case OP_JMPONT: return OP_JMPF;
|
|
|
|
case OP_JMPF: case OP_JMPONF: return OP_JMPT;
|
2000-03-09 16:57:37 +03:00
|
|
|
default:
|
2000-06-30 18:35:17 +04:00
|
|
|
LUA_INTERNALERROR("invalid jump instruction");
|
2000-03-10 21:37:44 +03:00
|
|
|
return OP_END; /* to avoid warnings */
|
2000-03-09 16:57:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-03-13 23:37:16 +03:00
|
|
|
static void luaK_patchlistaux (FuncState *fs, int list, int target,
|
2000-03-09 16:57:37 +03:00
|
|
|
OpCode special, int special_target) {
|
2000-03-13 23:37:16 +03:00
|
|
|
Instruction *code = fs->f->code;
|
|
|
|
while (list != NO_JUMP) {
|
|
|
|
int next = luaK_getjump(fs, list);
|
|
|
|
Instruction *i = &code[list];
|
|
|
|
OpCode op = GET_OPCODE(*i);
|
|
|
|
if (op == special) /* this `op' already has a value */
|
2000-03-16 21:03:09 +03:00
|
|
|
luaK_fixjump(fs, list, special_target);
|
2000-03-13 23:37:16 +03:00
|
|
|
else {
|
2000-03-16 21:03:09 +03:00
|
|
|
luaK_fixjump(fs, list, target); /* do the patch */
|
2000-04-05 00:48:44 +04:00
|
|
|
if (op == OP_JMPONT) /* remove eventual values */
|
|
|
|
SET_OPCODE(*i, OP_JMPT);
|
|
|
|
else if (op == OP_JMPONF)
|
|
|
|
SET_OPCODE(*i, OP_JMPF);
|
2000-03-09 16:57:37 +03:00
|
|
|
}
|
2000-03-13 23:37:16 +03:00
|
|
|
list = next;
|
2000-03-09 16:57:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-03-13 23:37:16 +03:00
|
|
|
void luaK_patchlist (FuncState *fs, int list, int target) {
|
2000-04-06 21:36:52 +04:00
|
|
|
if (target == fs->lasttarget) /* same target that list `jlt'? */
|
|
|
|
luaK_concat(fs, &fs->jlt, list); /* delay fixing */
|
|
|
|
else
|
|
|
|
luaK_patchlistaux(fs, list, target, OP_END, 0);
|
2000-03-09 16:57:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-03-10 17:38:10 +03:00
|
|
|
static int need_value (FuncState *fs, int list, OpCode hasvalue) {
|
2000-03-13 23:37:16 +03:00
|
|
|
/* check whether list has a jump without a value */
|
|
|
|
for (; list != NO_JUMP; list = luaK_getjump(fs, list))
|
|
|
|
if (GET_OPCODE(fs->f->code[list]) != hasvalue) return 1;
|
|
|
|
return 0; /* not found */
|
2000-03-09 16:57:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-04-05 21:51:58 +04:00
|
|
|
void luaK_concat (FuncState *fs, int *l1, int l2) {
|
2000-03-13 23:37:16 +03:00
|
|
|
if (*l1 == NO_JUMP)
|
2000-03-09 16:57:37 +03:00
|
|
|
*l1 = l2;
|
2000-03-13 23:37:16 +03:00
|
|
|
else {
|
2000-03-09 16:57:37 +03:00
|
|
|
int list = *l1;
|
|
|
|
for (;;) { /* traverse `l1' */
|
2000-03-13 23:37:16 +03:00
|
|
|
int next = luaK_getjump(fs, list);
|
|
|
|
if (next == NO_JUMP) { /* end of list? */
|
|
|
|
luaK_fixjump(fs, list, l2);
|
2000-03-09 16:57:37 +03:00
|
|
|
return;
|
|
|
|
}
|
2000-03-13 23:37:16 +03:00
|
|
|
list = next;
|
2000-03-09 16:57:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-03-24 15:18:30 +03:00
|
|
|
static void luaK_testgo (FuncState *fs, expdesc *v, int invert, OpCode jump) {
|
2000-06-16 21:51:40 +04:00
|
|
|
int prevpos; /* position of last instruction */
|
2000-03-09 16:57:37 +03:00
|
|
|
Instruction *previous;
|
2000-06-16 21:51:40 +04:00
|
|
|
int *golist, *exitlist;
|
|
|
|
if (!invert) {
|
|
|
|
golist = &v->u.l.f; /* go if false */
|
|
|
|
exitlist = &v->u.l.t; /* exit if true */
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
golist = &v->u.l.t; /* go if true */
|
|
|
|
exitlist = &v->u.l.f; /* exit if false */
|
2000-03-24 15:18:30 +03:00
|
|
|
}
|
2000-03-13 23:37:16 +03:00
|
|
|
discharge1(fs, v);
|
2000-06-16 21:51:40 +04:00
|
|
|
prevpos = fs->pc-1;
|
|
|
|
previous = &fs->f->code[prevpos];
|
2000-06-30 18:35:17 +04:00
|
|
|
LUA_ASSERT(*previous==previous_instruction(fs), "no jump allowed here");
|
2000-06-05 18:56:18 +04:00
|
|
|
if (!ISJUMP(GET_OPCODE(*previous)))
|
2000-06-16 21:51:40 +04:00
|
|
|
prevpos = luaK_code1(fs, jump, NO_JUMP);
|
|
|
|
else { /* last instruction is already a jump */
|
|
|
|
if (invert)
|
|
|
|
SET_OPCODE(*previous, invertjump(GET_OPCODE(*previous)));
|
|
|
|
}
|
|
|
|
luaK_concat(fs, exitlist, prevpos); /* insert last jump in `exitlist' */
|
2000-03-24 15:18:30 +03:00
|
|
|
luaK_patchlist(fs, *golist, luaK_getlabel(fs));
|
|
|
|
*golist = NO_JUMP;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void luaK_goiftrue (FuncState *fs, expdesc *v, int keepvalue) {
|
2000-04-05 00:48:44 +04:00
|
|
|
luaK_testgo(fs, v, 1, keepvalue ? OP_JMPONF : OP_JMPF);
|
2000-03-09 16:57:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-06-16 21:51:40 +04:00
|
|
|
static void luaK_goiffalse (FuncState *fs, expdesc *v, int keepvalue) {
|
2000-04-05 00:48:44 +04:00
|
|
|
luaK_testgo(fs, v, 0, keepvalue ? OP_JMPONT : OP_JMPT);
|
2000-03-09 16:57:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-04-14 21:47:24 +04:00
|
|
|
static int code_label (FuncState *fs, OpCode op, int arg) {
|
2000-06-21 22:13:56 +04:00
|
|
|
luaK_getlabel(fs); /* those instructions may be jump targets */
|
|
|
|
return luaK_code1(fs, op, arg);
|
2000-04-14 21:47:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-03-09 16:57:37 +03:00
|
|
|
void luaK_tostack (LexState *ls, expdesc *v, int onlyone) {
|
2000-03-13 23:37:16 +03:00
|
|
|
FuncState *fs = ls->fs;
|
2000-03-24 15:18:30 +03:00
|
|
|
if (!discharge(fs, v)) { /* `v' is an expression? */
|
2000-03-10 17:38:10 +03:00
|
|
|
OpCode previous = GET_OPCODE(fs->f->code[fs->pc-1]);
|
2000-03-13 23:37:16 +03:00
|
|
|
if (!ISJUMP(previous) && v->u.l.f == NO_JUMP && v->u.l.t == NO_JUMP) {
|
2000-04-17 18:05:34 +04:00
|
|
|
/* expression has no jumps */
|
2000-03-24 15:18:30 +03:00
|
|
|
if (onlyone)
|
2000-03-13 23:37:16 +03:00
|
|
|
luaK_setcallreturns(fs, 1); /* call must return 1 value */
|
2000-03-09 16:57:37 +03:00
|
|
|
}
|
2000-04-17 18:05:34 +04:00
|
|
|
else { /* expression has jumps */
|
|
|
|
int final; /* position after whole expression */
|
|
|
|
int j = NO_JUMP; /* eventual jump over values */
|
|
|
|
int p_nil = NO_JUMP; /* position of an eventual PUSHNIL */
|
|
|
|
int p_1 = NO_JUMP; /* position of an eventual PUSHINT */
|
2000-06-16 21:51:40 +04:00
|
|
|
if (ISJUMP(previous) || need_value(fs, v->u.l.f, OP_JMPONF)
|
|
|
|
|| need_value(fs, v->u.l.t, OP_JMPONT)) {
|
2000-04-19 17:41:37 +04:00
|
|
|
/* expression needs values */
|
2000-04-17 18:05:34 +04:00
|
|
|
if (ISJUMP(previous))
|
|
|
|
luaK_concat(fs, &v->u.l.t, fs->pc-1); /* put `previous' in t. list */
|
|
|
|
else {
|
2000-05-22 22:44:46 +04:00
|
|
|
j = code_label(fs, OP_JMP, NO_JUMP); /* to jump over both pushes */
|
2000-04-17 18:05:34 +04:00
|
|
|
luaK_deltastack(fs, -1); /* next PUSHes may be skipped */
|
|
|
|
}
|
|
|
|
p_nil = code_label(fs, OP_PUSHNILJMP, 0);
|
2000-05-22 22:44:46 +04:00
|
|
|
luaK_deltastack(fs, -1); /* next PUSH is skipped */
|
2000-04-17 18:05:34 +04:00
|
|
|
p_1 = code_label(fs, OP_PUSHINT, 1);
|
|
|
|
luaK_patchlist(fs, j, luaK_getlabel(fs));
|
|
|
|
}
|
|
|
|
final = luaK_getlabel(fs);
|
|
|
|
luaK_patchlistaux(fs, v->u.l.f, p_nil, OP_JMPONF, final);
|
|
|
|
luaK_patchlistaux(fs, v->u.l.t, p_1, OP_JMPONT, final);
|
|
|
|
v->u.l.f = v->u.l.t = NO_JUMP;
|
|
|
|
}
|
2000-03-09 16:57:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-03-03 15:33:59 +03:00
|
|
|
void luaK_prefix (LexState *ls, int op, expdesc *v) {
|
2000-03-13 23:37:16 +03:00
|
|
|
FuncState *fs = ls->fs;
|
2000-03-09 16:57:37 +03:00
|
|
|
if (op == '-') {
|
|
|
|
luaK_tostack(ls, v, 1);
|
2000-04-07 23:35:20 +04:00
|
|
|
luaK_code0(fs, OP_MINUS);
|
2000-03-09 16:57:37 +03:00
|
|
|
}
|
|
|
|
else { /* op == NOT */
|
|
|
|
Instruction *previous;
|
2000-03-13 23:37:16 +03:00
|
|
|
discharge1(fs, v);
|
2000-03-09 16:57:37 +03:00
|
|
|
previous = &fs->f->code[fs->pc-1];
|
|
|
|
if (ISJUMP(GET_OPCODE(*previous)))
|
|
|
|
SET_OPCODE(*previous, invertjump(GET_OPCODE(*previous)));
|
|
|
|
else
|
2000-04-07 23:35:20 +04:00
|
|
|
luaK_code0(fs, OP_NOT);
|
2000-03-09 16:57:37 +03:00
|
|
|
/* interchange true and false lists */
|
|
|
|
{ int temp = v->u.l.f; v->u.l.f = v->u.l.t; v->u.l.t = temp; }
|
|
|
|
}
|
2000-03-03 15:33:59 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-03-04 23:18:15 +03:00
|
|
|
void luaK_infix (LexState *ls, int op, expdesc *v) {
|
2000-03-13 23:37:16 +03:00
|
|
|
FuncState *fs = ls->fs;
|
2000-03-10 21:37:44 +03:00
|
|
|
if (op == TK_AND)
|
2000-03-13 23:37:16 +03:00
|
|
|
luaK_goiftrue(fs, v, 1);
|
2000-03-10 21:37:44 +03:00
|
|
|
else if (op == TK_OR)
|
2000-03-13 23:37:16 +03:00
|
|
|
luaK_goiffalse(fs, v, 1);
|
2000-03-09 16:57:37 +03:00
|
|
|
else
|
2000-03-10 17:38:10 +03:00
|
|
|
luaK_tostack(ls, v, 1); /* all other binary operators need a value */
|
2000-04-07 23:35:20 +04:00
|
|
|
}
|
2000-03-03 15:33:59 +03:00
|
|
|
|
|
|
|
|
|
|
|
void luaK_posfix (LexState *ls, int op, expdesc *v1, expdesc *v2) {
|
2000-03-13 23:37:16 +03:00
|
|
|
FuncState *fs = ls->fs;
|
2000-03-10 21:37:44 +03:00
|
|
|
if (op == TK_AND) {
|
2000-06-30 18:35:17 +04:00
|
|
|
LUA_ASSERT(v1->u.l.t == NO_JUMP, "list must be closed");
|
2000-03-13 23:37:16 +03:00
|
|
|
discharge1(fs, v2);
|
2000-03-09 16:57:37 +03:00
|
|
|
v1->u.l.t = v2->u.l.t;
|
2000-04-05 21:51:58 +04:00
|
|
|
luaK_concat(fs, &v1->u.l.f, v2->u.l.f);
|
2000-03-09 16:57:37 +03:00
|
|
|
}
|
2000-03-10 21:37:44 +03:00
|
|
|
else if (op == TK_OR) {
|
2000-06-30 18:35:17 +04:00
|
|
|
LUA_ASSERT(v1->u.l.f == NO_JUMP, "list must be closed");
|
2000-03-13 23:37:16 +03:00
|
|
|
discharge1(fs, v2);
|
2000-03-09 16:57:37 +03:00
|
|
|
v1->u.l.f = v2->u.l.f;
|
2000-04-05 21:51:58 +04:00
|
|
|
luaK_concat(fs, &v1->u.l.t, v2->u.l.t);
|
2000-03-09 16:57:37 +03:00
|
|
|
}
|
|
|
|
else {
|
2000-03-10 17:38:10 +03:00
|
|
|
luaK_tostack(ls, v2, 1); /* `v2' must be a value */
|
2000-03-09 16:57:37 +03:00
|
|
|
switch (op) {
|
2000-04-07 23:35:20 +04:00
|
|
|
case '+': luaK_code0(fs, OP_ADD); break;
|
|
|
|
case '-': luaK_code0(fs, OP_SUB); break;
|
|
|
|
case '*': luaK_code0(fs, OP_MULT); break;
|
|
|
|
case '/': luaK_code0(fs, OP_DIV); break;
|
|
|
|
case '^': luaK_code0(fs, OP_POW); break;
|
|
|
|
case TK_CONCAT: luaK_code1(fs, OP_CONCAT, 2); break;
|
2000-05-22 22:44:46 +04:00
|
|
|
case TK_EQ: luaK_code1(fs, OP_JMPEQ, NO_JUMP); break;
|
|
|
|
case TK_NE: luaK_code1(fs, OP_JMPNE, NO_JUMP); break;
|
|
|
|
case '>': luaK_code1(fs, OP_JMPGT, NO_JUMP); break;
|
|
|
|
case '<': luaK_code1(fs, OP_JMPLT, NO_JUMP); break;
|
|
|
|
case TK_GE: luaK_code1(fs, OP_JMPGE, NO_JUMP); break;
|
|
|
|
case TK_LE: luaK_code1(fs, OP_JMPLE, NO_JUMP); break;
|
2000-03-09 16:57:37 +03:00
|
|
|
}
|
2000-03-03 15:33:59 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-04-07 23:35:20 +04:00
|
|
|
|
2000-08-08 22:26:05 +04:00
|
|
|
static void codelineinfo (FuncState *fs) {
|
|
|
|
LexState *ls = fs->ls;
|
|
|
|
if (ls->lastline > fs->lastline) {
|
|
|
|
luaM_growvector(fs->L, fs->f->lineinfo, fs->nlineinfo, 2, int,
|
|
|
|
"line info overflow", MAX_INT);
|
|
|
|
if (ls->lastline > fs->lastline+1)
|
|
|
|
fs->f->lineinfo[fs->nlineinfo++] = -(ls->lastline - (fs->lastline+1));
|
|
|
|
fs->f->lineinfo[fs->nlineinfo++] = fs->pc;
|
|
|
|
fs->lastline = ls->lastline;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-04-07 23:35:20 +04:00
|
|
|
int luaK_code0 (FuncState *fs, OpCode o) {
|
|
|
|
return luaK_code2(fs, o, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int luaK_code1 (FuncState *fs, OpCode o, int arg1) {
|
|
|
|
return luaK_code2(fs, o, arg1, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int luaK_code2 (FuncState *fs, OpCode o, int arg1, int arg2) {
|
|
|
|
Instruction i = previous_instruction(fs);
|
2000-06-29 00:21:06 +04:00
|
|
|
int delta = luaK_opproperties[o].push - luaK_opproperties[o].pop;
|
2000-05-22 22:44:46 +04:00
|
|
|
int optm = 0; /* 1 when there is an optimization */
|
2000-04-07 23:35:20 +04:00
|
|
|
switch (o) {
|
2000-06-16 21:51:40 +04:00
|
|
|
case OP_CLOSURE: {
|
2000-04-14 21:47:24 +04:00
|
|
|
delta = -arg2+1;
|
|
|
|
break;
|
2000-06-16 21:51:40 +04:00
|
|
|
}
|
|
|
|
case OP_SETTABLE: {
|
2000-06-05 18:56:18 +04:00
|
|
|
delta = -arg2;
|
|
|
|
break;
|
2000-06-16 21:51:40 +04:00
|
|
|
}
|
|
|
|
case OP_SETLIST: {
|
2000-06-05 18:56:18 +04:00
|
|
|
if (arg2 == 0) return NO_JUMP; /* nothing to do */
|
2000-05-22 22:44:46 +04:00
|
|
|
delta = -arg2;
|
2000-04-14 21:47:24 +04:00
|
|
|
break;
|
2000-06-16 21:51:40 +04:00
|
|
|
}
|
|
|
|
case OP_SETMAP: {
|
2000-06-05 18:56:18 +04:00
|
|
|
if (arg1 == 0) return NO_JUMP; /* nothing to do */
|
|
|
|
delta = -2*arg1;
|
2000-04-14 21:47:24 +04:00
|
|
|
break;
|
2000-06-16 21:51:40 +04:00
|
|
|
}
|
|
|
|
case OP_RETURN: {
|
2000-04-07 23:35:20 +04:00
|
|
|
if (GET_OPCODE(i) == OP_CALL && GETARG_B(i) == MULT_RET) {
|
|
|
|
SET_OPCODE(i, OP_TAILCALL);
|
|
|
|
SETARG_B(i, arg1);
|
2000-05-22 22:44:46 +04:00
|
|
|
optm = 1;
|
2000-04-07 23:35:20 +04:00
|
|
|
}
|
|
|
|
break;
|
2000-06-16 21:51:40 +04:00
|
|
|
}
|
|
|
|
case OP_PUSHNIL: {
|
2000-06-05 18:56:18 +04:00
|
|
|
if (arg1 == 0) return NO_JUMP; /* nothing to do */
|
2000-04-07 23:35:20 +04:00
|
|
|
delta = arg1;
|
|
|
|
switch(GET_OPCODE(i)) {
|
2000-05-22 22:44:46 +04:00
|
|
|
case OP_PUSHNIL: SETARG_U(i, GETARG_U(i)+arg1); optm = 1; break;
|
|
|
|
default: break;
|
2000-04-07 23:35:20 +04:00
|
|
|
}
|
|
|
|
break;
|
2000-06-16 21:51:40 +04:00
|
|
|
}
|
|
|
|
case OP_POP: {
|
2000-06-05 18:56:18 +04:00
|
|
|
if (arg1 == 0) return NO_JUMP; /* nothing to do */
|
2000-04-07 23:35:20 +04:00
|
|
|
delta = -arg1;
|
|
|
|
switch(GET_OPCODE(i)) {
|
2000-05-22 22:44:46 +04:00
|
|
|
case OP_SETTABLE: SETARG_B(i, GETARG_B(i)+arg1); optm = 1; break;
|
|
|
|
default: break;
|
2000-04-07 23:35:20 +04:00
|
|
|
}
|
|
|
|
break;
|
2000-06-16 21:51:40 +04:00
|
|
|
}
|
|
|
|
case OP_GETTABLE: {
|
2000-04-07 23:35:20 +04:00
|
|
|
switch(GET_OPCODE(i)) {
|
2000-05-22 22:44:46 +04:00
|
|
|
case OP_PUSHSTRING: /* `t.x' */
|
|
|
|
SET_OPCODE(i, OP_GETDOTTED);
|
|
|
|
optm = 1;
|
|
|
|
break;
|
|
|
|
case OP_GETLOCAL: /* `t[i]' */
|
|
|
|
SET_OPCODE(i, OP_GETINDEXED);
|
|
|
|
optm = 1;
|
|
|
|
break;
|
|
|
|
default: break;
|
2000-04-07 23:35:20 +04:00
|
|
|
}
|
|
|
|
break;
|
2000-06-16 21:51:40 +04:00
|
|
|
}
|
|
|
|
case OP_ADD: {
|
2000-04-07 23:35:20 +04:00
|
|
|
switch(GET_OPCODE(i)) {
|
2000-05-22 22:44:46 +04:00
|
|
|
case OP_PUSHINT: SET_OPCODE(i, OP_ADDI); optm = 1; break; /* `a+k' */
|
|
|
|
default: break;
|
2000-04-07 23:35:20 +04:00
|
|
|
}
|
|
|
|
break;
|
2000-06-16 21:51:40 +04:00
|
|
|
}
|
|
|
|
case OP_SUB: {
|
2000-04-07 23:35:20 +04:00
|
|
|
switch(GET_OPCODE(i)) {
|
2000-05-22 22:44:46 +04:00
|
|
|
case OP_PUSHINT: /* `a-k' */
|
|
|
|
i = CREATE_S(OP_ADDI, -GETARG_S(i));
|
|
|
|
optm = 1;
|
|
|
|
break;
|
|
|
|
default: break;
|
2000-04-07 23:35:20 +04:00
|
|
|
}
|
|
|
|
break;
|
2000-06-16 21:51:40 +04:00
|
|
|
}
|
|
|
|
case OP_CONCAT: {
|
2000-04-07 23:35:20 +04:00
|
|
|
delta = -arg1+1;
|
|
|
|
switch(GET_OPCODE(i)) {
|
2000-05-22 22:44:46 +04:00
|
|
|
case OP_CONCAT: /* `a..b..c' */
|
|
|
|
SETARG_U(i, GETARG_U(i)+1);
|
|
|
|
optm = 1;
|
|
|
|
break;
|
|
|
|
default: break;
|
2000-04-07 23:35:20 +04:00
|
|
|
}
|
|
|
|
break;
|
2000-06-16 21:51:40 +04:00
|
|
|
}
|
|
|
|
case OP_MINUS: {
|
2000-04-07 23:35:20 +04:00
|
|
|
switch(GET_OPCODE(i)) {
|
2000-05-22 22:44:46 +04:00
|
|
|
case OP_PUSHINT: /* `-k' */
|
|
|
|
SETARG_S(i, -GETARG_S(i));
|
|
|
|
optm = 1;
|
|
|
|
break;
|
|
|
|
case OP_PUSHNUM: /* `-k' */
|
|
|
|
SET_OPCODE(i, OP_PUSHNEGNUM);
|
|
|
|
optm = 1;
|
|
|
|
break;
|
|
|
|
default: break;
|
2000-04-07 23:35:20 +04:00
|
|
|
}
|
|
|
|
break;
|
2000-06-16 21:51:40 +04:00
|
|
|
}
|
|
|
|
case OP_JMPNE: {
|
2000-05-22 22:44:46 +04:00
|
|
|
if (i == CREATE_U(OP_PUSHNIL, 1)) { /* `a~=nil' */
|
2000-04-07 23:35:20 +04:00
|
|
|
i = CREATE_S(OP_JMPT, NO_JUMP);
|
2000-05-22 22:44:46 +04:00
|
|
|
optm = 1;
|
2000-04-07 23:35:20 +04:00
|
|
|
}
|
|
|
|
break;
|
2000-06-16 21:51:40 +04:00
|
|
|
}
|
|
|
|
case OP_JMPEQ: {
|
2000-04-07 23:35:20 +04:00
|
|
|
if (i == CREATE_U(OP_PUSHNIL, 1)) { /* `a==nil' */
|
|
|
|
i = CREATE_0(OP_NOT);
|
|
|
|
delta = -1; /* just undo effect of previous PUSHNIL */
|
2000-05-22 22:44:46 +04:00
|
|
|
optm = 1;
|
2000-04-07 23:35:20 +04:00
|
|
|
}
|
|
|
|
break;
|
2000-06-16 21:51:40 +04:00
|
|
|
}
|
2000-04-14 21:47:24 +04:00
|
|
|
case OP_JMPT:
|
2000-06-16 21:51:40 +04:00
|
|
|
case OP_JMPONT: {
|
|
|
|
switch (GET_OPCODE(i)) {
|
|
|
|
case OP_NOT: {
|
|
|
|
i = CREATE_S(OP_JMPF, NO_JUMP);
|
|
|
|
optm = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case OP_PUSHINT: {
|
|
|
|
if (o == OP_JMPT) { /* JMPONT must keep original integer value */
|
|
|
|
i = CREATE_S(OP_JMP, NO_JUMP);
|
|
|
|
optm = 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case OP_PUSHNIL: {
|
|
|
|
if (GETARG_U(i) == 1) {
|
|
|
|
fs->pc--; /* erase previous instruction */
|
|
|
|
luaK_deltastack(fs, -1); /* correct stack */
|
|
|
|
return NO_JUMP;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2000-04-14 21:47:24 +04:00
|
|
|
case OP_JMPF:
|
2000-06-16 21:51:40 +04:00
|
|
|
case OP_JMPONF: {
|
2000-04-07 23:35:20 +04:00
|
|
|
switch (GET_OPCODE(i)) {
|
2000-06-16 21:51:40 +04:00
|
|
|
case OP_NOT: {
|
|
|
|
i = CREATE_S(OP_JMPT, NO_JUMP);
|
|
|
|
optm = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case OP_PUSHINT: { /* `while 1 do ...' */
|
|
|
|
fs->pc--; /* erase previous instruction */
|
|
|
|
luaK_deltastack(fs, -1); /* correct stack */
|
|
|
|
return NO_JUMP;
|
|
|
|
}
|
|
|
|
case OP_PUSHNIL: { /* `repeat ... until nil' */
|
|
|
|
if (GETARG_U(i) == 1) {
|
|
|
|
i = CREATE_S(OP_JMP, NO_JUMP);
|
|
|
|
optm = 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2000-05-22 22:44:46 +04:00
|
|
|
default: break;
|
2000-04-07 23:35:20 +04:00
|
|
|
}
|
|
|
|
break;
|
2000-06-16 21:51:40 +04:00
|
|
|
}
|
2000-04-14 21:47:24 +04:00
|
|
|
case OP_GETDOTTED:
|
|
|
|
case OP_GETINDEXED:
|
|
|
|
case OP_TAILCALL:
|
2000-06-16 21:51:40 +04:00
|
|
|
case OP_ADDI: {
|
2000-06-30 18:35:17 +04:00
|
|
|
LUA_INTERNALERROR("instruction used only for optimizations");
|
2000-05-22 22:44:46 +04:00
|
|
|
break;
|
2000-06-16 21:51:40 +04:00
|
|
|
}
|
|
|
|
default: {
|
2000-06-30 18:35:17 +04:00
|
|
|
LUA_ASSERT(delta != VD, "invalid delta");
|
2000-05-22 22:44:46 +04:00
|
|
|
break;
|
2000-06-16 21:51:40 +04:00
|
|
|
}
|
2000-04-07 23:35:20 +04:00
|
|
|
}
|
|
|
|
luaK_deltastack(fs, delta);
|
2000-05-22 22:44:46 +04:00
|
|
|
if (optm) { /* optimize: put instruction in place of last one */
|
|
|
|
fs->f->code[fs->pc-1] = i; /* change previous instruction */
|
|
|
|
return fs->pc-1; /* do not generate new instruction */
|
|
|
|
}
|
2000-06-16 21:51:40 +04:00
|
|
|
/* else build new instruction */
|
2000-05-22 22:44:46 +04:00
|
|
|
switch ((enum Mode)luaK_opproperties[o].mode) {
|
2000-04-07 23:35:20 +04:00
|
|
|
case iO: i = CREATE_0(o); break;
|
|
|
|
case iU: i = CREATE_U(o, arg1); break;
|
|
|
|
case iS: i = CREATE_S(o, arg1); break;
|
|
|
|
case iAB: i = CREATE_AB(o, arg1, arg2); break;
|
|
|
|
}
|
2000-08-09 00:42:07 +04:00
|
|
|
codelineinfo(fs);
|
2000-06-21 22:13:56 +04:00
|
|
|
/* put new instruction in code array */
|
2000-06-26 23:28:31 +04:00
|
|
|
luaM_growvector(fs->L, fs->f->code, fs->pc, 1, Instruction,
|
|
|
|
"code size overflow", MAX_INT);
|
2000-04-07 23:35:20 +04:00
|
|
|
fs->f->code[fs->pc] = i;
|
|
|
|
return fs->pc++;
|
|
|
|
}
|
|
|
|
|
2000-05-22 22:44:46 +04:00
|
|
|
|
2000-06-21 21:05:49 +04:00
|
|
|
const struct OpProperties luaK_opproperties[NUM_OPCODES] = {
|
2000-06-29 00:21:06 +04:00
|
|
|
{iO, 0, 0}, /* OP_END */
|
|
|
|
{iU, 0, 0}, /* OP_RETURN */
|
|
|
|
{iAB, 0, 0}, /* OP_CALL */
|
|
|
|
{iAB, 0, 0}, /* OP_TAILCALL */
|
|
|
|
{iU, VD, 0}, /* OP_PUSHNIL */
|
|
|
|
{iU, VD, 0}, /* OP_POP */
|
|
|
|
{iS, 1, 0}, /* OP_PUSHINT */
|
|
|
|
{iU, 1, 0}, /* OP_PUSHSTRING */
|
|
|
|
{iU, 1, 0}, /* OP_PUSHNUM */
|
|
|
|
{iU, 1, 0}, /* OP_PUSHNEGNUM */
|
|
|
|
{iU, 1, 0}, /* OP_PUSHUPVALUE */
|
|
|
|
{iU, 1, 0}, /* OP_GETLOCAL */
|
|
|
|
{iU, 1, 0}, /* OP_GETGLOBAL */
|
|
|
|
{iO, 1, 2}, /* OP_GETTABLE */
|
|
|
|
{iU, 1, 1}, /* OP_GETDOTTED */
|
|
|
|
{iU, 1, 1}, /* OP_GETINDEXED */
|
|
|
|
{iU, 2, 1}, /* OP_PUSHSELF */
|
|
|
|
{iU, 1, 0}, /* OP_CREATETABLE */
|
|
|
|
{iU, 0, 1}, /* OP_SETLOCAL */
|
|
|
|
{iU, 0, 1}, /* OP_SETGLOBAL */
|
|
|
|
{iAB, VD, 0}, /* OP_SETTABLE */
|
|
|
|
{iAB, VD, 0}, /* OP_SETLIST */
|
|
|
|
{iU, VD, 0}, /* OP_SETMAP */
|
|
|
|
{iO, 1, 2}, /* OP_ADD */
|
|
|
|
{iS, 1, 1}, /* OP_ADDI */
|
|
|
|
{iO, 1, 2}, /* OP_SUB */
|
|
|
|
{iO, 1, 2}, /* OP_MULT */
|
|
|
|
{iO, 1, 2}, /* OP_DIV */
|
|
|
|
{iO, 1, 2}, /* OP_POW */
|
|
|
|
{iU, VD, 0}, /* OP_CONCAT */
|
|
|
|
{iO, 1, 1}, /* OP_MINUS */
|
|
|
|
{iO, 1, 1}, /* OP_NOT */
|
|
|
|
{iS, 0, 2}, /* OP_JMPNE */
|
|
|
|
{iS, 0, 2}, /* OP_JMPEQ */
|
|
|
|
{iS, 0, 2}, /* OP_JMPLT */
|
|
|
|
{iS, 0, 2}, /* OP_JMPLE */
|
|
|
|
{iS, 0, 2}, /* OP_JMPGT */
|
|
|
|
{iS, 0, 2}, /* OP_JMPGE */
|
|
|
|
{iS, 0, 1}, /* OP_JMPT */
|
|
|
|
{iS, 0, 1}, /* OP_JMPF */
|
|
|
|
{iS, 0, 1}, /* OP_JMPONT */
|
|
|
|
{iS, 0, 1}, /* OP_JMPONF */
|
|
|
|
{iS, 0, 0}, /* OP_JMP */
|
|
|
|
{iO, 1, 0}, /* OP_PUSHNILJMP */
|
|
|
|
{iS, 0, 0}, /* OP_FORPREP */
|
|
|
|
{iS, 0, 3}, /* OP_FORLOOP */
|
|
|
|
{iS, 3, 0}, /* OP_LFORPREP */
|
|
|
|
{iS, 0, 4}, /* OP_LFORLOOP */
|
|
|
|
{iAB, VD, 0} /* OP_CLOSURE */
|
2000-05-22 22:44:46 +04:00
|
|
|
};
|
2000-06-29 00:21:06 +04:00
|
|
|
|