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: 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
** See Copyright Notice in lua.h
*/
@@ -150,7 +150,7 @@ static void deltastack (LexState *ls, int delta) {
fs->stacksize += delta;
if (fs->stacksize > fs->maxstacksize) {
if (fs->stacksize > MAX_BYTE)
luaY_error(ls, "function/expression too complex");
luaY_error(ls, "function or expression too complex");
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) {
code_oparg(ls, PUSHSTRCNST, c, 1);
static void code_kstr (LexState *ls, int c) {
code_oparg(ls, PUSHSTRING, c, 1);
}
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) {
TProtoFunc *f = fs->f;
int c = s->constindex;
if (c >= f->nstrcnst || f->strcnst[c] != s) {
luaM_growvector(ls->L, f->strcnst, f->nstrcnst, 1,
if (c >= f->nkstr || f->kstr[c] != s) {
luaM_growvector(ls->L, f->kstr, f->nkstr, 1,
TaggedString *, constantEM, MAX_ARG);
c = f->nstrcnst++;
f->strcnst[c] = s;
c = f->nkstr++;
f->kstr[c] = s;
s->constindex = c; /* hint for next time */
}
return c;
@@ -239,7 +239,7 @@ static int string_constant (LexState *ls, FuncState *fs, 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) {
/* check whether `r' has appeared within the last LIM entries */
TProtoFunc *f = ls->fs->f;
int c = f->nnumcnst;
int c = f->nknum;
int lim = c < LIM ? 0 : 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 */
luaM_growvector(ls->L, f->numcnst, f->nnumcnst, 1,
luaM_growvector(ls->L, f->knum, f->nknum, 1,
real, constantEM, MAX_ARG);
c = f->nnumcnst++;
f->numcnst[c] = r;
c = f->nknum++;
f->knum[c] = r;
return c;
}
@@ -264,10 +264,10 @@ static void code_number (LexState *ls, real f) {
real af = (f<0) ? -f : f;
if (0 <= af && af <= (real)MAX_WORD && (int)af == af) {
/* 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
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) {
/* dotted variables <a.x> must be stored as regular indexed vars <a["x"]> */
if (v->k == VDOT) {
code_strcnst(ls, v->info);
code_kstr(ls, v->info);
v->k = VINDEXED;
}
}
@@ -551,13 +551,13 @@ static void func_onstack (LexState *ls, FuncState *func) {
FuncState *fs = ls->fs;
TProtoFunc *f = fs->f;
int i;
luaM_growvector(ls->L, f->protocnst, f->nprotocnst, 1,
luaM_growvector(ls->L, f->kproto, f->nkproto, 1,
TProtoFunc *, constantEM, MAX_ARG);
f->protocnst[f->nprotocnst] = func->f;
f->kproto[f->nkproto] = func->f;
for (i=0; i<func->nupvalues; i++)
lua_pushvar(ls, &func->upvalues[i]);
deltastack(ls, 1); /* CLOSURE puts one extra element (before poping) */
code_oparg(ls, CLOSURE, f->nprotocnst++, -func->nupvalues);
deltastack(ls, 1); /* CLOSURE puts one extra element (before popping) */
code_oparg(ls, CLOSURE, f->nkproto++, -func->nupvalues);
code_byte(ls, (Byte)func->nupvalues);
}
@@ -592,9 +592,9 @@ static void close_func (LexState *ls) {
code_opcode(ls, ENDCODE, 0);
f->code[0] = (Byte)fs->maxstacksize;
luaM_reallocvector(ls->L, f->code, fs->pc, Byte);
luaM_reallocvector(ls->L, f->strcnst, f->nstrcnst, TaggedString *);
luaM_reallocvector(ls->L, f->numcnst, f->nnumcnst, real);
luaM_reallocvector(ls->L, f->protocnst, f->nprotocnst, TProtoFunc *);
luaM_reallocvector(ls->L, f->kstr, f->nkstr, TaggedString *);
luaM_reallocvector(ls->L, f->knum, f->nknum, real);
luaM_reallocvector(ls->L, f->kproto, f->nkproto, TProtoFunc *);
if (fs->nvars != -1) { /* debug information? */
luaI_registerlocalvar(ls, NULL, -1); /* flag end of vector */
luaM_reallocvector(ls->L, f->locvars, fs->nvars, LocVar);
@@ -661,7 +661,7 @@ static int checkname (LexState *ls) {
static TaggedString *str_checkname (LexState *ls) {
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 */
switch (ls->token) {
case NAME:
code_strcnst(ls, checkname(ls));
code_kstr(ls, checkname(ls));
break;
case '[':
@@ -917,7 +917,7 @@ static void constructor_part (LexState *ls, constdesc *cd) {
if (ls->token == '=') {
switch (v.k) {
case VGLOBAL:
code_strcnst(ls, v.info);
code_kstr(ls, v.info);
break;
case VLOCAL:
code_string(ls, ls->fs->localvar[v.info]);
@@ -1291,7 +1291,7 @@ static int funcname (LexState *ls, vardesc *v) {
needself = (ls->token == ':');
next(ls);
lua_pushvar(ls, v);
code_strcnst(ls, checkname(ls));
code_kstr(ls, checkname(ls));
v->k = VINDEXED;
}
return needself;