renaming of some opcodes and fields

This commit is contained in:
Roberto Ierusalimschy
2000-01-28 14:53:00 -02:00
parent d6b9f49aaf
commit 1f691a4fcd
7 changed files with 79 additions and 79 deletions

View File

@@ -1,5 +1,5 @@
/* /*
** $Id: ldebug.c,v 1.5 2000/01/19 12:00:45 roberto Exp roberto $ ** $Id: ldebug.c,v 1.6 2000/01/25 13:57:18 roberto Exp roberto $
** Debug Interface ** Debug Interface
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -94,7 +94,7 @@ static const char *luaG_getname (lua_State *L, const char **name, StkId top) {
if (ttype(f) == LUA_T_LCLMARK) if (ttype(f) == LUA_T_LCLMARK)
f = protovalue(f); f = protovalue(f);
LUA_ASSERT(L, ttype(f) == LUA_T_LMARK, "must be a Lua function"); LUA_ASSERT(L, ttype(f) == LUA_T_LMARK, "must be a Lua function");
*name = tfvalue(f)->strcnst[i]->str; *name = tfvalue(f)->kstr[i]->str;
return luaO_typename(f+2); return luaO_typename(f+2);
} }
} }

20
lfunc.c
View File

@@ -1,5 +1,5 @@
/* /*
** $Id: lfunc.c,v 1.16 1999/12/27 17:33:22 roberto Exp roberto $ ** $Id: lfunc.c,v 1.17 2000/01/25 13:57:18 roberto Exp roberto $
** Auxiliary functions to manipulate prototypes and closures ** Auxiliary functions to manipulate prototypes and closures
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -34,12 +34,12 @@ TProtoFunc *luaF_newproto (lua_State *L) {
f->code = NULL; f->code = NULL;
f->lineDefined = 0; f->lineDefined = 0;
f->source = NULL; f->source = NULL;
f->strcnst = NULL; f->kstr = NULL;
f->nstrcnst = 0; f->nkstr = 0;
f->numcnst = NULL; f->knum = NULL;
f->nnumcnst = 0; f->nknum = 0;
f->protocnst = NULL; f->kproto = NULL;
f->nprotocnst = 0; f->nkproto = 0;
f->locvars = NULL; f->locvars = NULL;
f->next = L->rootproto; f->next = L->rootproto;
L->rootproto = f; L->rootproto = f;
@@ -53,9 +53,9 @@ void luaF_freeproto (lua_State *L, TProtoFunc *f) {
L->nblocks -= gcsizeproto(L, f); L->nblocks -= gcsizeproto(L, f);
luaM_free(L, f->code); luaM_free(L, f->code);
luaM_free(L, f->locvars); luaM_free(L, f->locvars);
luaM_free(L, f->strcnst); luaM_free(L, f->kstr);
luaM_free(L, f->numcnst); luaM_free(L, f->knum);
luaM_free(L, f->protocnst); luaM_free(L, f->kproto);
luaM_free(L, f); luaM_free(L, f);
} }

10
lgc.c
View File

@@ -1,5 +1,5 @@
/* /*
** $Id: lgc.c,v 1.39 1999/12/27 17:33:22 roberto Exp roberto $ ** $Id: lgc.c,v 1.40 2000/01/25 13:57:18 roberto Exp roberto $
** Garbage Collector ** Garbage Collector
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -33,10 +33,10 @@ static void protomark (lua_State *L, TProtoFunc *f) {
int i; int i;
f->marked = 1; f->marked = 1;
strmark(L, f->source); strmark(L, f->source);
for (i=f->nstrcnst-1; i>=0; i--) for (i=f->nkstr-1; i>=0; i--)
strmark(L, f->strcnst[i]); strmark(L, f->kstr[i]);
for (i=f->nprotocnst-1; i>=0; i--) for (i=f->nkproto-1; i>=0; i--)
protomark(L, f->protocnst[i]); protomark(L, f->kproto[i]);
} }
} }

View File

@@ -1,5 +1,5 @@
/* /*
** $Id: lobject.h,v 1.43 1999/12/29 16:31:15 roberto Exp roberto $ ** $Id: lobject.h,v 1.44 2000/01/25 13:57:18 roberto Exp roberto $
** Type definitions for Lua objects ** Type definitions for Lua objects
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -154,12 +154,12 @@ typedef struct TaggedString {
typedef struct TProtoFunc { typedef struct TProtoFunc {
struct TProtoFunc *next; struct TProtoFunc *next;
int marked; int marked;
struct TaggedString **strcnst; struct TaggedString **kstr; /* strings used by the function */
int nstrcnst; int nkstr; /* size of `kstr' */
real *numcnst; real *knum; /* real numbers used by the function */
int nnumcnst; int nknum; /* size of `knum' */
struct TProtoFunc **protocnst; struct TProtoFunc **kproto; /* functions defined inside the function */
int nprotocnst; int nkproto; /* size of `kproto' */
Byte *code; /* ends with opcode ENDCODE */ Byte *code; /* ends with opcode ENDCODE */
int lineDefined; int lineDefined;
TaggedString *source; TaggedString *source;

View File

@@ -1,5 +1,5 @@
/* /*
** $Id: lopcodes.h,v 1.36 1999/12/29 16:31:15 roberto Exp roberto $ ** $Id: lopcodes.h,v 1.37 2000/01/25 13:57:18 roberto Exp roberto $
** Opcodes for Lua virtual machine ** Opcodes for Lua virtual machine
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -27,16 +27,16 @@ TAILCALL,/* b c v_c-v_1 f (return) f(v1,...,v_c) */
PUSHNIL,/* b - nil_0-nil_b */ PUSHNIL,/* b - nil_0-nil_b */
POP,/* b a_b-a_1 - */ POP,/* b a_b-a_1 - */
PUSHNUMBERW,/* w - (float)w */ PUSHINTW,/* w - (float)w */
PUSHNUMBER,/* b - (float)b */ PUSHINT,/* b - (float)b */
PUSHNUMBERNEGW,/* w - (float)-w */ PUSHINTNEGW,/* w - (float)-w */
PUSHNUMBERNEG,/* b - (float)-b */ PUSHINTNEG,/* b - (float)-b */
PUSHSTRCNSTW,/* w - STRCNST[w] */ PUSHSTRINGW,/* w - KSTR[w] */
PUSHSTRCNST,/* b - STRCNST[b] */ PUSHSTRING,/* b - KSTR[b] */
PUSHNUMCNSTW,/* w - NUMCNST[w] */ PUSHNUMBERW,/* w - KNUM[w] */
PUSHNUMCNST,/* b - NUMCNST[b] */ PUSHNUMBER,/* b - KNUM[b] */
PUSHUPVALUE,/* b - Closure[b] */ PUSHUPVALUE,/* b - Closure[b] */

View File

@@ -1,5 +1,5 @@
/* /*
** $Id: lparser.c,v 1.55 2000/01/25 13:57:18 roberto Exp roberto $ ** $Id: lparser.c,v 1.56 2000/01/25 18:44:21 roberto Exp roberto $
** LL(1) Parser and code generator for Lua ** LL(1) Parser and code generator for Lua
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -150,7 +150,7 @@ static void deltastack (LexState *ls, int delta) {
fs->stacksize += delta; fs->stacksize += delta;
if (fs->stacksize > fs->maxstacksize) { if (fs->stacksize > fs->maxstacksize) {
if (fs->stacksize > MAX_BYTE) if (fs->stacksize > MAX_BYTE)
luaY_error(ls, "function/expression too complex"); luaY_error(ls, "function or expression too complex");
fs->maxstacksize = fs->stacksize; fs->maxstacksize = fs->stacksize;
} }
} }
@@ -214,24 +214,24 @@ static void code_opcode (LexState *ls, OpCode op, int delta) {
} }
static void code_strcnst (LexState *ls, int c) { static void code_kstr (LexState *ls, int c) {
code_oparg(ls, PUSHSTRCNST, c, 1); code_oparg(ls, PUSHSTRING, c, 1);
} }
static void assertglobal (LexState *ls, int index) { static void assertglobal (LexState *ls, int index) {
luaS_assertglobal(ls->L, ls->fs->f->strcnst[index]); luaS_assertglobal(ls->L, ls->fs->f->kstr[index]);
} }
static int string_constant (LexState *ls, FuncState *fs, TaggedString *s) { static int string_constant (LexState *ls, FuncState *fs, TaggedString *s) {
TProtoFunc *f = fs->f; TProtoFunc *f = fs->f;
int c = s->constindex; int c = s->constindex;
if (c >= f->nstrcnst || f->strcnst[c] != s) { if (c >= f->nkstr || f->kstr[c] != s) {
luaM_growvector(ls->L, f->strcnst, f->nstrcnst, 1, luaM_growvector(ls->L, f->kstr, f->nkstr, 1,
TaggedString *, constantEM, MAX_ARG); TaggedString *, constantEM, MAX_ARG);
c = f->nstrcnst++; c = f->nkstr++;
f->strcnst[c] = s; f->kstr[c] = s;
s->constindex = c; /* hint for next time */ s->constindex = c; /* hint for next time */
} }
return c; return c;
@@ -239,7 +239,7 @@ static int string_constant (LexState *ls, FuncState *fs, TaggedString *s) {
static void code_string (LexState *ls, TaggedString *s) { static void code_string (LexState *ls, TaggedString *s) {
code_strcnst(ls, string_constant(ls, ls->fs, s)); code_kstr(ls, string_constant(ls, ls->fs, s));
} }
@@ -247,15 +247,15 @@ static void code_string (LexState *ls, TaggedString *s) {
static int real_constant (LexState *ls, real r) { static int real_constant (LexState *ls, real r) {
/* check whether `r' has appeared within the last LIM entries */ /* check whether `r' has appeared within the last LIM entries */
TProtoFunc *f = ls->fs->f; TProtoFunc *f = ls->fs->f;
int c = f->nnumcnst; int c = f->nknum;
int lim = c < LIM ? 0 : c-LIM; int lim = c < LIM ? 0 : c-LIM;
while (--c >= lim) while (--c >= lim)
if (f->numcnst[c] == r) return c; if (f->knum[c] == r) return c;
/* not found; create a new entry */ /* not found; create a new entry */
luaM_growvector(ls->L, f->numcnst, f->nnumcnst, 1, luaM_growvector(ls->L, f->knum, f->nknum, 1,
real, constantEM, MAX_ARG); real, constantEM, MAX_ARG);
c = f->nnumcnst++; c = f->nknum++;
f->numcnst[c] = r; f->knum[c] = r;
return c; return c;
} }
@@ -264,10 +264,10 @@ static void code_number (LexState *ls, real f) {
real af = (f<0) ? -f : f; real af = (f<0) ? -f : f;
if (0 <= af && af <= (real)MAX_WORD && (int)af == af) { if (0 <= af && af <= (real)MAX_WORD && (int)af == af) {
/* abs(f) has a short integer value */ /* abs(f) has a short integer value */
code_oparg(ls, (f<0) ? PUSHNUMBERNEG : PUSHNUMBER, (int)af, 1); code_oparg(ls, (f<0) ? PUSHINTNEG : PUSHINT, (int)af, 1);
} }
else else
code_oparg(ls, PUSHNUMCNST, real_constant(ls, f), 1); code_oparg(ls, PUSHNUMBER, real_constant(ls, f), 1);
} }
@@ -469,7 +469,7 @@ static void code_args (LexState *ls, int nparams, int dots) {
static void unloaddot (LexState *ls, vardesc *v) { static void unloaddot (LexState *ls, vardesc *v) {
/* dotted variables <a.x> must be stored as regular indexed vars <a["x"]> */ /* dotted variables <a.x> must be stored as regular indexed vars <a["x"]> */
if (v->k == VDOT) { if (v->k == VDOT) {
code_strcnst(ls, v->info); code_kstr(ls, v->info);
v->k = VINDEXED; v->k = VINDEXED;
} }
} }
@@ -551,13 +551,13 @@ static void func_onstack (LexState *ls, FuncState *func) {
FuncState *fs = ls->fs; FuncState *fs = ls->fs;
TProtoFunc *f = fs->f; TProtoFunc *f = fs->f;
int i; int i;
luaM_growvector(ls->L, f->protocnst, f->nprotocnst, 1, luaM_growvector(ls->L, f->kproto, f->nkproto, 1,
TProtoFunc *, constantEM, MAX_ARG); TProtoFunc *, constantEM, MAX_ARG);
f->protocnst[f->nprotocnst] = func->f; f->kproto[f->nkproto] = func->f;
for (i=0; i<func->nupvalues; i++) for (i=0; i<func->nupvalues; i++)
lua_pushvar(ls, &func->upvalues[i]); lua_pushvar(ls, &func->upvalues[i]);
deltastack(ls, 1); /* CLOSURE puts one extra element (before poping) */ deltastack(ls, 1); /* CLOSURE puts one extra element (before popping) */
code_oparg(ls, CLOSURE, f->nprotocnst++, -func->nupvalues); code_oparg(ls, CLOSURE, f->nkproto++, -func->nupvalues);
code_byte(ls, (Byte)func->nupvalues); code_byte(ls, (Byte)func->nupvalues);
} }
@@ -592,9 +592,9 @@ static void close_func (LexState *ls) {
code_opcode(ls, ENDCODE, 0); code_opcode(ls, ENDCODE, 0);
f->code[0] = (Byte)fs->maxstacksize; f->code[0] = (Byte)fs->maxstacksize;
luaM_reallocvector(ls->L, f->code, fs->pc, Byte); luaM_reallocvector(ls->L, f->code, fs->pc, Byte);
luaM_reallocvector(ls->L, f->strcnst, f->nstrcnst, TaggedString *); luaM_reallocvector(ls->L, f->kstr, f->nkstr, TaggedString *);
luaM_reallocvector(ls->L, f->numcnst, f->nnumcnst, real); luaM_reallocvector(ls->L, f->knum, f->nknum, real);
luaM_reallocvector(ls->L, f->protocnst, f->nprotocnst, TProtoFunc *); luaM_reallocvector(ls->L, f->kproto, f->nkproto, TProtoFunc *);
if (fs->nvars != -1) { /* debug information? */ if (fs->nvars != -1) { /* debug information? */
luaI_registerlocalvar(ls, NULL, -1); /* flag end of vector */ luaI_registerlocalvar(ls, NULL, -1); /* flag end of vector */
luaM_reallocvector(ls->L, f->locvars, fs->nvars, LocVar); luaM_reallocvector(ls->L, f->locvars, fs->nvars, LocVar);
@@ -661,7 +661,7 @@ static int checkname (LexState *ls) {
static TaggedString *str_checkname (LexState *ls) { static TaggedString *str_checkname (LexState *ls) {
int i = checkname(ls); /* this call may realloc `f->consts' */ int i = checkname(ls); /* this call may realloc `f->consts' */
return ls->fs->f->strcnst[i]; return ls->fs->f->kstr[i];
} }
@@ -853,7 +853,7 @@ static void recfield (LexState *ls) {
/* recfield -> (NAME | '['exp1']') = exp1 */ /* recfield -> (NAME | '['exp1']') = exp1 */
switch (ls->token) { switch (ls->token) {
case NAME: case NAME:
code_strcnst(ls, checkname(ls)); code_kstr(ls, checkname(ls));
break; break;
case '[': case '[':
@@ -917,7 +917,7 @@ static void constructor_part (LexState *ls, constdesc *cd) {
if (ls->token == '=') { if (ls->token == '=') {
switch (v.k) { switch (v.k) {
case VGLOBAL: case VGLOBAL:
code_strcnst(ls, v.info); code_kstr(ls, v.info);
break; break;
case VLOCAL: case VLOCAL:
code_string(ls, ls->fs->localvar[v.info]); code_string(ls, ls->fs->localvar[v.info]);
@@ -1291,7 +1291,7 @@ static int funcname (LexState *ls, vardesc *v) {
needself = (ls->token == ':'); needself = (ls->token == ':');
next(ls); next(ls);
lua_pushvar(ls, v); lua_pushvar(ls, v);
code_strcnst(ls, checkname(ls)); code_kstr(ls, checkname(ls));
v->k = VINDEXED; v->k = VINDEXED;
} }
return needself; return needself;

34
lvm.c
View File

@@ -1,5 +1,5 @@
/* /*
** $Id: lvm.c,v 1.82 2000/01/24 20:14:07 roberto Exp roberto $ ** $Id: lvm.c,v 1.83 2000/01/25 13:57:18 roberto Exp roberto $
** Lua virtual machine ** Lua virtual machine
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -314,7 +314,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, const TProtoFunc *tf,
StkId base) { StkId base) {
register StkId top; /* keep top local, for performance */ register StkId top; /* keep top local, for performance */
register const Byte *pc = tf->code; register const Byte *pc = tf->code;
TaggedString **strcnst = tf->strcnst; TaggedString **kstr = tf->kstr;
if (L->callhook) if (L->callhook)
luaD_callHook(L, base-1, L->callhook, "call"); luaD_callHook(L, base-1, L->callhook, "call");
luaD_checkstack(L, (*pc++)+EXTRA_STACK); luaD_checkstack(L, (*pc++)+EXTRA_STACK);
@@ -358,31 +358,31 @@ StkId luaV_execute (lua_State *L, const Closure *cl, const TProtoFunc *tf,
top -= aux; top -= aux;
break; break;
case PUSHNUMBERW: aux += highbyte(L, *pc++); case PUSHINTW: aux += highbyte(L, *pc++);
case PUSHNUMBER: aux += *pc++; case PUSHINT: aux += *pc++;
ttype(top) = LUA_T_NUMBER; ttype(top) = LUA_T_NUMBER;
nvalue(top) = aux; nvalue(top) = aux;
top++; top++;
break; break;
case PUSHNUMBERNEGW: aux += highbyte(L, *pc++); case PUSHINTNEGW: aux += highbyte(L, *pc++);
case PUSHNUMBERNEG: aux += *pc++; case PUSHINTNEG: aux += *pc++;
ttype(top) = LUA_T_NUMBER; ttype(top) = LUA_T_NUMBER;
nvalue(top) = -aux; nvalue(top) = -aux;
top++; top++;
break; break;
case PUSHSTRCNSTW: aux += highbyte(L, *pc++); case PUSHSTRINGW: aux += highbyte(L, *pc++);
case PUSHSTRCNST: aux += *pc++; case PUSHSTRING: aux += *pc++;
ttype(top) = LUA_T_STRING; ttype(top) = LUA_T_STRING;
tsvalue(top) = strcnst[aux]; tsvalue(top) = kstr[aux];
top++; top++;
break; break;
case PUSHNUMCNSTW: aux += highbyte(L, *pc++); case PUSHNUMBERW: aux += highbyte(L, *pc++);
case PUSHNUMCNST: aux += *pc++; case PUSHNUMBER: aux += *pc++;
ttype(top) = LUA_T_NUMBER; ttype(top) = LUA_T_NUMBER;
nvalue(top) = tf->numcnst[aux]; nvalue(top) = tf->knum[aux];
top++; top++;
break; break;
@@ -396,7 +396,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, const TProtoFunc *tf,
case GETGLOBALW: aux += highbyte(L, *pc++); case GETGLOBALW: aux += highbyte(L, *pc++);
case GETGLOBAL: aux += *pc++; case GETGLOBAL: aux += *pc++;
luaV_getglobal(L, strcnst[aux]->u.s.gv, top); luaV_getglobal(L, kstr[aux]->u.s.gv, top);
top++; top++;
break; break;
@@ -408,7 +408,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, const TProtoFunc *tf,
case GETDOTTEDW: aux += highbyte(L, *pc++); case GETDOTTEDW: aux += highbyte(L, *pc++);
case GETDOTTED: aux += *pc++; case GETDOTTED: aux += *pc++;
ttype(top) = LUA_T_STRING; ttype(top) = LUA_T_STRING;
tsvalue(top++) = strcnst[aux]; tsvalue(top++) = kstr[aux];
luaV_gettable(L, top); luaV_gettable(L, top);
top--; top--;
break; break;
@@ -418,7 +418,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, const TProtoFunc *tf,
TObject receiver; TObject receiver;
receiver = *(top-1); receiver = *(top-1);
ttype(top) = LUA_T_STRING; ttype(top) = LUA_T_STRING;
tsvalue(top++) = strcnst[aux]; tsvalue(top++) = kstr[aux];
luaV_gettable(L, top); luaV_gettable(L, top);
*(top-1) = receiver; *(top-1) = receiver;
break; break;
@@ -439,7 +439,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, const TProtoFunc *tf,
case SETGLOBALW: aux += highbyte(L, *pc++); case SETGLOBALW: aux += highbyte(L, *pc++);
case SETGLOBAL: aux += *pc++; case SETGLOBAL: aux += *pc++;
luaV_setglobal(L, strcnst[aux]->u.s.gv, top); luaV_setglobal(L, kstr[aux]->u.s.gv, top);
top--; top--;
break; break;
@@ -632,7 +632,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, const TProtoFunc *tf,
case CLOSUREW: aux += highbyte(L, *pc++); case CLOSUREW: aux += highbyte(L, *pc++);
case CLOSURE: aux += *pc++; case CLOSURE: aux += *pc++;
ttype(top) = LUA_T_LPROTO; ttype(top) = LUA_T_LPROTO;
tfvalue(top) = tf->protocnst[aux]; tfvalue(top) = tf->kproto[aux];
L->top = ++top; L->top = ++top;
aux = *pc++; /* number of upvalues */ aux = *pc++; /* number of upvalues */
luaV_closure(L, aux); luaV_closure(L, aux);