diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-01-25 15:39:28 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-01-25 15:39:28 -0200 |
commit | 4a13f513f8070003019eec0afc566608e436212b (patch) | |
tree | 484624343f0afdb8e2ab737751c0a96b4f1d5ac4 /lvm.c | |
parent | 13ad46b67d8b5d4402215e07b412b8b786eb27ea (diff) | |
download | lua-4a13f513f8070003019eec0afc566608e436212b.tar.gz lua-4a13f513f8070003019eec0afc566608e436212b.tar.bz2 lua-4a13f513f8070003019eec0afc566608e436212b.zip |
luaH_set does the set!
Diffstat (limited to 'lvm.c')
-rw-r--r-- | lvm.c | 21 |
1 files changed, 8 insertions, 13 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lvm.c,v 1.39 1999/01/15 13:14:24 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 1.40 1999/01/20 20:22:06 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 | */ |
@@ -90,12 +90,11 @@ void luaV_setn (Hash *t, int val) { | |||
90 | TObject index, value; | 90 | TObject index, value; |
91 | ttype(&index) = LUA_T_STRING; tsvalue(&index) = luaS_new("n"); | 91 | ttype(&index) = LUA_T_STRING; tsvalue(&index) = luaS_new("n"); |
92 | ttype(&value) = LUA_T_NUMBER; nvalue(&value) = val; | 92 | ttype(&value) = LUA_T_NUMBER; nvalue(&value) = val; |
93 | *(luaH_set(t, &index)) = value; | 93 | luaH_set(t, &index, &value); |
94 | } | 94 | } |
95 | 95 | ||
96 | 96 | ||
97 | void luaV_closure (int nelems) | 97 | void luaV_closure (int nelems) { |
98 | { | ||
99 | if (nelems > 0) { | 98 | if (nelems > 0) { |
100 | struct Stack *S = &L->stack; | 99 | struct Stack *S = &L->stack; |
101 | Closure *c = luaF_newclosure(nelems); | 100 | Closure *c = luaF_newclosure(nelems); |
@@ -155,7 +154,7 @@ void luaV_settable (TObject *t, int deep) { | |||
155 | else { /* object is a table... */ | 154 | else { /* object is a table... */ |
156 | im = luaT_getim(avalue(t)->htag, IM_SETTABLE); | 155 | im = luaT_getim(avalue(t)->htag, IM_SETTABLE); |
157 | if (ttype(im) == LUA_T_NIL) { /* and does not have a "settable" method */ | 156 | if (ttype(im) == LUA_T_NIL) { /* and does not have a "settable" method */ |
158 | *(luaH_set(avalue(t), t+1)) = *(S->top-1); | 157 | luaH_set(avalue(t), t+1, S->top-1); |
159 | /* if deep, pop only value; otherwise, pop table, index and value */ | 158 | /* if deep, pop only value; otherwise, pop table, index and value */ |
160 | S->top -= (deep) ? 1 : 3; | 159 | S->top -= (deep) ? 1 : 3; |
161 | return; | 160 | return; |
@@ -180,7 +179,7 @@ void luaV_rawsettable (TObject *t) { | |||
180 | lua_error("indexed expression not a table"); | 179 | lua_error("indexed expression not a table"); |
181 | else { | 180 | else { |
182 | struct Stack *S = &L->stack; | 181 | struct Stack *S = &L->stack; |
183 | *(luaH_set(avalue(t), t+1)) = *(S->top-1); | 182 | luaH_set(avalue(t), t+1, S->top-1); |
184 | S->top -= 3; | 183 | S->top -= 3; |
185 | } | 184 | } |
186 | } | 185 | } |
@@ -482,12 +481,8 @@ StkId luaV_execute (Closure *cl, TProtoFunc *tf, StkId base) | |||
482 | setlist: { | 481 | setlist: { |
483 | int n = *(pc++); | 482 | int n = *(pc++); |
484 | TObject *arr = S->top-n-1; | 483 | TObject *arr = S->top-n-1; |
485 | for (; n; n--) { | 484 | for (; n; n--) |
486 | ttype(S->top) = LUA_T_NUMBER; | 485 | luaH_setint(avalue(arr), n+aux, --S->top); |
487 | nvalue(S->top) = n+aux; | ||
488 | *(luaH_set(avalue(arr), S->top)) = *(S->top-1); | ||
489 | S->top--; | ||
490 | } | ||
491 | break; | 486 | break; |
492 | } | 487 | } |
493 | 488 | ||
@@ -499,7 +494,7 @@ StkId luaV_execute (Closure *cl, TProtoFunc *tf, StkId base) | |||
499 | setmap: { | 494 | setmap: { |
500 | TObject *arr = S->top-(2*aux)-3; | 495 | TObject *arr = S->top-(2*aux)-3; |
501 | do { | 496 | do { |
502 | *(luaH_set(avalue(arr), S->top-2)) = *(S->top-1); | 497 | luaH_set(avalue(arr), S->top-2, S->top-1); |
503 | S->top-=2; | 498 | S->top-=2; |
504 | } while (aux--); | 499 | } while (aux--); |
505 | break; | 500 | break; |