diff --git a/lapi.c b/lapi.c index b2035931..29f639a6 100644 --- a/lapi.c +++ b/lapi.c @@ -1,5 +1,5 @@ /* -** $Id: lapi.c,v 2.148 2011/06/02 19:31:40 roberto Exp roberto $ +** $Id: lapi.c,v 2.149 2011/06/13 14:13:06 roberto Exp roberto $ ** Lua API ** See Copyright Notice in lua.h */ @@ -744,7 +744,7 @@ LUA_API void lua_rawseti (lua_State *L, int idx, int n) { api_checknelems(L, 1); o = index2addr(L, idx); api_check(L, ttistable(o), "table expected"); - setobj2t(L, luaH_setint(L, hvalue(o), n), L->top-1); + luaH_setint(L, hvalue(o), n, L->top - 1); luaC_barrierback(L, gcvalue(o), L->top-1); L->top--; lua_unlock(L); diff --git a/ldebug.c b/ldebug.c index 9a0242b6..e57beff6 100644 --- a/ldebug.c +++ b/ldebug.c @@ -1,5 +1,5 @@ /* -** $Id: ldebug.c,v 2.81 2011/04/28 14:00:11 roberto Exp roberto $ +** $Id: ldebug.c,v 2.82 2011/06/02 19:31:40 roberto Exp roberto $ ** Debug Interface ** See Copyright Notice in lua.h */ @@ -190,12 +190,14 @@ static void collectvalidlines (lua_State *L, Closure *f) { } else { int i; + TValue v; int *lineinfo = f->l.p->lineinfo; - Table *t = luaH_new(L); - sethvalue(L, L->top, t); + Table *t = luaH_new(L); /* new table to store active lines */ + sethvalue(L, L->top, t); /* push it on stack */ incr_top(L); - for (i=0; il.p->sizelineinfo; i++) - setbvalue(luaH_setint(L, t, lineinfo[i]), 1); + setbvalue(&v, 1); /* boolean 'true' to be the value of all indices */ + for (i = 0; i < f->l.p->sizelineinfo; i++) /* for all lines with code */ + luaH_setint(L, t, lineinfo[i], &v); /* table[line] = true */ } } diff --git a/llex.c b/llex.c index 5b07da4b..cc56ce8c 100644 --- a/llex.c +++ b/llex.c @@ -1,5 +1,5 @@ /* -** $Id: llex.c,v 2.54 2011/07/15 12:30:41 roberto Exp roberto $ +** $Id: llex.c,v 2.55 2011/07/15 12:48:03 roberto Exp roberto $ ** Lexical Analyzer ** See Copyright Notice in lua.h */ @@ -126,7 +126,7 @@ TString *luaX_newstring (LexState *ls, const char *str, size_t 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_setstr(L, ls->fs->h, ts); + o = luaH_set(L, ls->fs->h, L->top - 1); if (ttisnil(o)) { setbvalue(o, 1); /* t[string] = true */ luaC_checkGC(L); diff --git a/lstate.c b/lstate.c index fa67e855..506af472 100644 --- a/lstate.c +++ b/lstate.c @@ -1,5 +1,5 @@ /* -** $Id: lstate.c,v 2.88 2010/12/20 18:17:46 roberto Exp roberto $ +** $Id: lstate.c,v 2.89 2010/12/20 19:40:07 roberto Exp roberto $ ** Global State ** See Copyright Notice in lua.h */ @@ -136,10 +136,10 @@ static void init_registry (lua_State *L, global_State *g) { luaH_resize(L, registry, LUA_RIDX_LAST, 0); /* registry[LUA_RIDX_MAINTHREAD] = L */ setthvalue(L, &mt, L); - setobj2t(L, luaH_setint(L, registry, LUA_RIDX_MAINTHREAD), &mt); + luaH_setint(L, registry, LUA_RIDX_MAINTHREAD, &mt); /* registry[LUA_RIDX_GLOBALS] = table of globals */ sethvalue(L, &mt, luaH_new(L)); - setobj2t(L, luaH_setint(L, registry, LUA_RIDX_GLOBALS), &mt); + luaH_setint(L, registry, LUA_RIDX_GLOBALS, &mt); } diff --git a/ltable.c b/ltable.c index 9abf47eb..b2f40083 100644 --- a/ltable.c +++ b/ltable.c @@ -1,5 +1,5 @@ /* -** $Id: ltable.c,v 2.59 2011/06/09 18:23:27 roberto Exp roberto $ +** $Id: ltable.c,v 2.60 2011/06/16 14:14:31 roberto Exp roberto $ ** Lua tables (hash) ** See Copyright Notice in lua.h */ @@ -314,7 +314,7 @@ void luaH_resize (lua_State *L, Table *t, int nasize, int nhsize) { /* re-insert elements from vanishing slice */ for (i=nasize; iarray[i])) - setobjt2t(L, luaH_setint(L, t, i+1), &t->array[i]); + luaH_setint(L, t, i + 1, &t->array[i]); } /* shrink array */ luaM_reallocvector(L, t->array, oldasize, nasize, TValue); @@ -507,27 +507,17 @@ TValue *luaH_set (lua_State *L, Table *t, const TValue *key) { } -TValue *luaH_setint (lua_State *L, Table *t, int key) { +void luaH_setint (lua_State *L, Table *t, int key, TValue *value) { const TValue *p = luaH_getint(t, key); + TValue *cell; if (p != luaO_nilobject) - return cast(TValue *, p); + cell = cast(TValue *, p); else { TValue k; setnvalue(&k, cast_num(key)); - return newkey(L, t, &k); - } -} - - -TValue *luaH_setstr (lua_State *L, Table *t, TString *key) { - const TValue *p = luaH_getstr(t, key); - if (p != luaO_nilobject) - return cast(TValue *, p); - else { - TValue k; - setsvalue(L, &k, key); - return newkey(L, t, &k); + cell = newkey(L, t, &k); } + setobj2t(L, cell, value); } diff --git a/ltable.h b/ltable.h index 823940b4..ad13c969 100644 --- a/ltable.h +++ b/ltable.h @@ -1,5 +1,5 @@ /* -** $Id: ltable.h,v 2.13 2009/11/06 17:07:48 roberto Exp roberto $ +** $Id: ltable.h,v 2.14 2010/06/25 12:18:10 roberto Exp roberto $ ** Lua tables (hash) ** See Copyright Notice in lua.h */ @@ -17,9 +17,8 @@ LUAI_FUNC const TValue *luaH_getint (Table *t, int key); -LUAI_FUNC TValue *luaH_setint (lua_State *L, Table *t, int key); +LUAI_FUNC void luaH_setint (lua_State *L, Table *t, int key, TValue *value); LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key); -LUAI_FUNC TValue *luaH_setstr (lua_State *L, Table *t, TString *key); LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key); LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key); LUAI_FUNC Table *luaH_new (lua_State *L); diff --git a/lvm.c b/lvm.c index 5afb26d2..680b1055 100644 --- a/lvm.c +++ b/lvm.c @@ -1,5 +1,5 @@ /* -** $Id: lvm.c,v 2.140 2011/06/02 19:31:40 roberto Exp roberto $ +** $Id: lvm.c,v 2.141 2011/06/09 18:24:22 roberto Exp roberto $ ** Lua virtual machine ** See Copyright Notice in lua.h */ @@ -808,7 +808,7 @@ void luaV_execute (lua_State *L) { luaH_resizearray(L, h, last); /* pre-allocate it at once */ for (; n > 0; n--) { TValue *val = ra+n; - setobj2t(L, luaH_setint(L, h, last--), val); + luaH_setint(L, h, last--, val); luaC_barrierback(L, obj2gco(h), val); } L->top = ci->top; /* correct top (in case of previous open call) */