aboutsummaryrefslogtreecommitdiff
path: root/lvm.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-06-06 13:31:41 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-06-06 13:31:41 -0300
commit8bcf6228765e56be19feb90c8805cc2fb2223188 (patch)
treece13072efce7a8aadcdde8de747073f3d7bf0859 /lvm.c
parentdbbf6c073b4203169a0221a082f6d00ccb27754c (diff)
downloadlua-8bcf6228765e56be19feb90c8805cc2fb2223188.tar.gz
lua-8bcf6228765e56be19feb90c8805cc2fb2223188.tar.bz2
lua-8bcf6228765e56be19feb90c8805cc2fb2223188.zip
new signature for `luaH_set'
Diffstat (limited to 'lvm.c')
-rw-r--r--lvm.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/lvm.c b/lvm.c
index c264fd96..76661bfb 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 1.111 2000/06/05 14:56:18 roberto Exp roberto $ 2** $Id: lvm.c,v 1.112 2000/06/05 20:15:33 roberto Exp roberto $
3** Lua virtual machine 3** Lua virtual machine
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -65,13 +65,6 @@ int luaV_tostring (lua_State *L, TObject *obj) { /* LUA_NUMBER */
65} 65}
66 66
67 67
68void luaV_setn (lua_State *L, Hash *t, int val) {
69 TObject value;
70 ttype(&value) = TAG_NUMBER; nvalue(&value) = val;
71 luaH_setstr(L, t, luaS_new(L, "n"), &value);
72}
73
74
75static Closure *luaV_closure (lua_State *L, lua_Type t, int nelems) { 68static Closure *luaV_closure (lua_State *L, lua_Type t, int nelems) {
76 Closure *c = luaF_newclosure(L, nelems); 69 Closure *c = luaF_newclosure(L, nelems);
77 L->top -= nelems; 70 L->top -= nelems;
@@ -147,7 +140,7 @@ void luaV_settable (lua_State *L, StkId t, StkId top) {
147 else { /* object is a table... */ 140 else { /* object is a table... */
148 im = luaT_getim(L, avalue(t)->htag, IM_SETTABLE); 141 im = luaT_getim(L, avalue(t)->htag, IM_SETTABLE);
149 if (ttype(im) == TAG_NIL) { /* and does not have a `settable' method */ 142 if (ttype(im) == TAG_NIL) { /* and does not have a `settable' method */
150 luaH_set(L, avalue(t), t+1, top-1); 143 *luaH_set(L, avalue(t), t+1) = *(top-1);
151 return; 144 return;
152 } 145 }
153 /* else it has a `settable' method, go through to next command */ 146 /* else it has a `settable' method, go through to next command */
@@ -191,7 +184,7 @@ void luaV_setglobal (lua_State *L, TString *s, StkId top) {
191 TObject key; 184 TObject key;
192 ttype(&key) = TAG_STRING; 185 ttype(&key) = TAG_STRING;
193 tsvalue(&key) = s; 186 tsvalue(&key) = s;
194 luaH_set(L, L->gt, &key, top-1); 187 *luaH_set(L, L->gt, &key) = *(top-1);
195 } 188 }
196 } 189 }
197 else { 190 else {
@@ -311,8 +304,9 @@ void luaV_pack (lua_State *L, StkId firstelem, int nvararg, TObject *tab) {
311 htab = avalue(tab) = luaH_new(L, nvararg+1); /* +1 for field `n' */ 304 htab = avalue(tab) = luaH_new(L, nvararg+1); /* +1 for field `n' */
312 ttype(tab) = TAG_TABLE; 305 ttype(tab) = TAG_TABLE;
313 for (i=0; i<nvararg; i++) 306 for (i=0; i<nvararg; i++)
314 luaH_setint(L, htab, i+1, firstelem+i); 307 *luaH_setint(L, htab, i+1) = *(firstelem+i);
315 luaV_setn(L, htab, nvararg); /* store counter in field `n' */ 308 /* store counter in field `n' */
309 luaH_setstrnum(L, htab, luaS_new(L, "n"), nvararg);
316} 310}
317 311
318 312
@@ -476,7 +470,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) {
476 Hash *arr = avalue(top-n-1); 470 Hash *arr = avalue(top-n-1);
477 L->top = top-n; /* final value of `top' (in case of errors) */ 471 L->top = top-n; /* final value of `top' (in case of errors) */
478 for (; n; n--) 472 for (; n; n--)
479 luaH_setint(L, arr, n+aux, --top); 473 *luaH_setint(L, arr, n+aux) = *(--top);
480 break; 474 break;
481 } 475 }
482 476
@@ -486,8 +480,8 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) {
486 Hash *arr = avalue(finaltop-1); 480 Hash *arr = avalue(finaltop-1);
487 L->top = finaltop; /* final value of `top' (in case of errors) */ 481 L->top = finaltop; /* final value of `top' (in case of errors) */
488 for (; n; n--) { 482 for (; n; n--) {
489 luaH_set(L, arr, top-2, top-1);
490 top-=2; 483 top-=2;
484 *luaH_set(L, arr, top) = *(top+1);
491 } 485 }
492 break; 486 break;
493 } 487 }