diff --git a/lcode.c b/lcode.c index bd73dc57..cc06ec47 100644 --- a/lcode.c +++ b/lcode.c @@ -1,5 +1,5 @@ /* -** $Id: lcode.c,v 1.54 2000/12/26 18:46:09 roberto Exp roberto $ +** $Id: lcode.c,v 1.55 2000/12/28 12:55:41 roberto Exp roberto $ ** Code generator for Lua ** See Copyright Notice in lua.h */ @@ -32,7 +32,7 @@ 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' */ + return CREATE_0(-1); /* no optimizations after an invalid instruction */ } @@ -206,7 +206,7 @@ static OpCode invertjump (OpCode op) { case OP_JMPF: case OP_JMPONF: return OP_JMPT; default: LUA_INTERNALERROR("invalid jump instruction"); - return OP_END; /* to avoid warnings */ + return OP_JMP; /* to avoid warnings */ } } @@ -236,7 +236,7 @@ void luaK_patchlist (FuncState *fs, int list, int target) { 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); + luaK_patchlistaux(fs, list, target, OP_ADD, 0); } @@ -653,7 +653,6 @@ int luaK_code2 (FuncState *fs, OpCode o, int arg1, int arg2) { const OpProperties luaK_opproperties[NUM_OPCODES] = { - {iO, 0, 0}, /* OP_END */ {iU, 0, 0}, /* OP_RETURN */ {iAB, 0, 0}, /* OP_CALL */ {iAB, 0, 0}, /* OP_TAILCALL */ diff --git a/lopcodes.h b/lopcodes.h index 5c9ffe59..a30de1be 100644 --- a/lopcodes.h +++ b/lopcodes.h @@ -1,5 +1,5 @@ /* -** $Id: lopcodes.h,v 1.68 2000/10/24 16:05:59 roberto Exp roberto $ +** $Id: lopcodes.h,v 1.69 2000/12/04 18:33:40 roberto Exp roberto $ ** Opcodes for Lua virtual machine ** See Copyright Notice in lua.h */ @@ -82,7 +82,6 @@ typedef enum { /*---------------------------------------------------------------------- name args stack before stack after side effects ------------------------------------------------------------------------*/ -OP_END,/* - - (return) no results */ OP_RETURN,/* U v_n-v_x(at u) (return) returns v_x-v_n */ OP_CALL,/* A B v_n-v_1 f(at a) r_b-r_1 f(v1,...,v_n) */ diff --git a/lparser.c b/lparser.c index bc1bf0c3..96395b38 100644 --- a/lparser.c +++ b/lparser.c @@ -1,5 +1,5 @@ /* -** $Id: lparser.c,v 1.122 2001/01/10 16:40:56 roberto Exp roberto $ +** $Id: lparser.c,v 1.123 2001/01/10 17:41:50 roberto Exp roberto $ ** LL(1) Parser and code generator for Lua ** See Copyright Notice in lua.h */ @@ -335,7 +335,7 @@ static void close_func (LexState *ls) { lua_State *L = ls->L; FuncState *fs = ls->fs; Proto *f = fs->f; - luaK_code0(fs, OP_END); + luaK_code1(fs, OP_RETURN, ls->fs->nactloc); /* final return */ luaK_getlabel(fs); /* close eventual list of pending jumps */ removelocalvars(ls, fs->nactloc); luaM_reallocvector(L, f->code, f->sizecode, fs->pc, Instruction); diff --git a/ltests.c b/ltests.c index ae0c71fc..97c63dfb 100644 --- a/ltests.c +++ b/ltests.c @@ -1,5 +1,5 @@ /* -** $Id: ltests.c,v 1.54 2000/10/31 13:10:24 roberto Exp roberto $ +** $Id: ltests.c,v 1.55 2000/12/28 12:55:41 roberto Exp roberto $ ** Internal Module for Debugging of the Lua Implementation ** See Copyright Notice in lua.h */ @@ -53,7 +53,7 @@ static void setnameval (lua_State *L, const char *name, int val) { static const char *const instrname[NUM_OPCODES] = { - "END", "RETURN", "CALL", "TAILCALL", "PUSHNIL", "POP", "PUSHINT", + "RETURN", "CALL", "TAILCALL", "PUSHNIL", "POP", "PUSHINT", "PUSHSTRING", "PUSHNUM", "PUSHNEGNUM", "PUSHUPVALUE", "GETLOCAL", "GETGLOBAL", "GETTABLE", "GETDOTTED", "GETINDEXED", "PUSHSELF", "CREATETABLE", "SETLOCAL", "SETGLOBAL", "SETTABLE", "SETLIST", "SETMAP", @@ -64,7 +64,7 @@ static const char *const instrname[NUM_OPCODES] = { }; -static int pushop (lua_State *L, Proto *p, int pc) { +static void pushop (lua_State *L, Proto *p, int pc) { char buff[100]; Instruction i = p->code[pc]; OpCode o = GET_OPCODE(i); @@ -85,26 +85,23 @@ static int pushop (lua_State *L, Proto *p, int pc) { break; } lua_pushstring(L, buff); - return (o != OP_END); } static int listcode (lua_State *L) { int pc; Proto *p; - int res; luaL_arg_check(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), 1, "Lua function expected"); p = clvalue(luaA_index(L, 1))->f.l; lua_newtable(L); setnameval(L, "maxstack", p->maxstacksize); setnameval(L, "numparams", p->numparams); - pc = 0; - do { + for (pc=0; pcsizecode; pc++) { lua_pushnumber(L, pc+1); - res = pushop(L, p, pc++); + pushop(L, p, pc); lua_settable(L, -3); - } while (res); + } return 1; } diff --git a/lundump.c b/lundump.c index 0a856747..1711e4f0 100644 --- a/lundump.c +++ b/lundump.c @@ -1,5 +1,5 @@ /* -** $Id: lundump.c,v 1.36 2000/12/28 12:55:41 roberto Exp roberto $ +** $Id: lundump.c,v 1.37 2000/12/28 12:59:41 roberto Exp roberto $ ** load bytecodes from files ** See Copyright Notice in lua.h */ @@ -108,7 +108,6 @@ static void LoadCode (lua_State* L, Proto* tf, ZIO* Z, int swap) tf->code=luaM_newvector(L,size,Instruction); tf->sizecode=size; LoadVector(L,tf->code,size,sizeof(*tf->code),Z,swap); - if (tf->code[size-1]!=OP_END) luaO_verror(L,"bad code in `%.99s'",ZNAME(Z)); } static void LoadLocals (lua_State* L, Proto* tf, ZIO* Z, int swap) diff --git a/lvm.c b/lvm.c index fd5481bc..a589dd2c 100644 --- a/lvm.c +++ b/lvm.c @@ -1,5 +1,5 @@ /* -** $Id: lvm.c,v 1.151 2001/01/10 18:56:11 roberto Exp roberto $ +** $Id: lvm.c,v 1.152 2001/01/11 18:59:32 roberto Exp roberto $ ** Lua virtual machine ** See Copyright Notice in lua.h */ @@ -360,10 +360,6 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) { if (linehook) traceexec(L, base, top, linehook); switch (GET_OPCODE(i)) { - case OP_END: { - L->top = top; - return top; - } case OP_RETURN: { L->top = top; return base+GETARG_U(i);