TObject' renamed to TValue' + other name changes and better assertions
for incremental garbage collection
This commit is contained in:
24
lcode.c
24
lcode.c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lcode.c,v 1.120 2003/11/19 19:59:18 roberto Exp roberto $
|
||||
** $Id: lcode.c,v 1.121 2003/12/09 16:56:11 roberto Exp roberto $
|
||||
** Code generator for Lua
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@@ -207,8 +207,9 @@ static void freeexp (FuncState *fs, expdesc *e) {
|
||||
}
|
||||
|
||||
|
||||
static int addk (FuncState *fs, TObject *k, TObject *v) {
|
||||
TObject *idx = luaH_set(fs->L, fs->h, k);
|
||||
static int addk (FuncState *fs, TValue *k, TValue *v) {
|
||||
lua_State *L = fs->L;
|
||||
TValue *idx = luaH_set(L, fs->h, k);
|
||||
Proto *f = fs->f;
|
||||
int oldsize = f->sizek;
|
||||
if (ttisnumber(idx)) {
|
||||
@@ -217,34 +218,35 @@ static int addk (FuncState *fs, TObject *k, TObject *v) {
|
||||
}
|
||||
else { /* constant not found; create a new entry */
|
||||
setnvalue(idx, cast(lua_Number, fs->nk));
|
||||
luaM_growvector(fs->L, f->k, fs->nk, f->sizek, TObject,
|
||||
luaM_growvector(L, f->k, fs->nk, f->sizek, TValue,
|
||||
MAXARG_Bx, "constant table overflow");
|
||||
while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]);
|
||||
setobj(&f->k[fs->nk], v);
|
||||
luaC_barrier(fs->L, f, v);
|
||||
setobj(L, &f->k[fs->nk], v);
|
||||
luaC_barrier(L, f, v);
|
||||
return fs->nk++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int luaK_stringK (FuncState *fs, TString *s) {
|
||||
TObject o;
|
||||
setsvalue(&o, s);
|
||||
TValue o;
|
||||
setsvalue(fs->L, &o, s);
|
||||
return addk(fs, &o, &o);
|
||||
}
|
||||
|
||||
|
||||
int luaK_numberK (FuncState *fs, lua_Number r) {
|
||||
TObject o;
|
||||
TValue o;
|
||||
setnvalue(&o, r);
|
||||
return addk(fs, &o, &o);
|
||||
}
|
||||
|
||||
|
||||
static int nil_constant (FuncState *fs) {
|
||||
TObject k, v;
|
||||
TValue k, v;
|
||||
setnilvalue(&v);
|
||||
sethvalue(&k, fs->h); /* cannot use nil as key; instead use table itself */
|
||||
/* cannot use nil as key; instead use table itself to represent nil */
|
||||
sethvalue(fs->L, &k, fs->h);
|
||||
return addk(fs, &k, &v);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user