eris: refactoring table API so that table methods can see value being inserted
This commit is contained in:
@@ -123,17 +123,17 @@ l_noret luaX_syntaxerror (LexState *ls, const char *msg) {
|
||||
*/
|
||||
TString *luaX_newstring (LexState *ls, const char *str, size_t l) {
|
||||
lua_State *L = ls->L;
|
||||
TValue *o; /* entry for `str' */
|
||||
TString *ts = luaS_newlstr(L, str, l); /* create new string */
|
||||
setsvalue2s(L, L->top++, ts); /* temporarily anchor it in stack */
|
||||
o = luaH_set(L, ls->fs->h, L->top - 1);
|
||||
const TValue *o = luaH_get(ls->fs->h, L->top - 1);
|
||||
if (ttisnil(o)) { /* not in use yet? (see 'addK') */
|
||||
/* boolean value does not need GC barrier;
|
||||
table has no metatable, so it does not need to invalidate cache */
|
||||
setbvalue(o, 1); /* t[string] = true */
|
||||
TValue truev;
|
||||
setbvalue(&truev, 1);
|
||||
luaH_setupdate(L, ls->fs->h, L->top - 1, &truev, o);
|
||||
luaC_checkGC(L);
|
||||
}
|
||||
else { /* string already present */
|
||||
} else { /* string already present */
|
||||
ts = rawtsvalue(keyfromval(o)); /* re-use value previously stored */
|
||||
}
|
||||
L->top--; /* remove string from stack */
|
||||
|
||||
Reference in New Issue
Block a user