diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1998-12-30 11:16:50 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1998-12-30 11:16:50 -0200 |
commit | fe5c41fb8a0e1d4f130437b22667bf699851b17a (patch) | |
tree | 61671399e70d42e12ace5fa06e3c66d77532693f /lvm.c | |
parent | 9a455438417b45be12b763ca56005b32bf0bb017 (diff) | |
download | lua-fe5c41fb8a0e1d4f130437b22667bf699851b17a.tar.gz lua-fe5c41fb8a0e1d4f130437b22667bf699851b17a.tar.bz2 lua-fe5c41fb8a0e1d4f130437b22667bf699851b17a.zip |
new functions "tinsert" and "tremove"
Diffstat (limited to 'lvm.c')
-rw-r--r-- | lvm.c | 24 |
1 files changed, 13 insertions, 11 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lvm.c,v 1.33 1998/12/24 14:57:23 roberto Exp $ | 2 | ** $Id: lvm.c,v 1.34 1998/12/27 20:25:20 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 | */ |
@@ -93,6 +93,16 @@ int luaV_tostring (TObject *obj) { | |||
93 | } | 93 | } |
94 | 94 | ||
95 | 95 | ||
96 | void luaV_setn (Hash *t, int val) { | ||
97 | TObject index, value; | ||
98 | ttype(&index) = LUA_T_STRING; | ||
99 | tsvalue(&index) = luaS_new("n"); | ||
100 | ttype(&value) = LUA_T_NUMBER; | ||
101 | nvalue(&value) = val; | ||
102 | *(luaH_set(t, &index)) = value; | ||
103 | } | ||
104 | |||
105 | |||
96 | void luaV_closure (int nelems) | 106 | void luaV_closure (int nelems) |
97 | { | 107 | { |
98 | if (nelems > 0) { | 108 | if (nelems > 0) { |
@@ -275,8 +285,7 @@ void luaV_comparison (lua_Type ttype_less, lua_Type ttype_equal, | |||
275 | } | 285 | } |
276 | 286 | ||
277 | 287 | ||
278 | void luaV_pack (StkId firstel, int nvararg, TObject *tab) | 288 | void luaV_pack (StkId firstel, int nvararg, TObject *tab) { |
279 | { | ||
280 | TObject *firstelem = L->stack.stack+firstel; | 289 | TObject *firstelem = L->stack.stack+firstel; |
281 | int i; | 290 | int i; |
282 | Hash *htab; | 291 | Hash *htab; |
@@ -285,14 +294,7 @@ void luaV_pack (StkId firstel, int nvararg, TObject *tab) | |||
285 | ttype(tab) = LUA_T_ARRAY; | 294 | ttype(tab) = LUA_T_ARRAY; |
286 | for (i=0; i<nvararg; i++) | 295 | for (i=0; i<nvararg; i++) |
287 | luaH_setint(htab, i+1, firstelem+i); | 296 | luaH_setint(htab, i+1, firstelem+i); |
288 | /* store counter in field "n" */ { | 297 | luaV_setn(htab, nvararg); /* store counter in field "n" */ |
289 | TObject index, extra; | ||
290 | ttype(&index) = LUA_T_STRING; | ||
291 | tsvalue(&index) = luaS_new("n"); | ||
292 | ttype(&extra) = LUA_T_NUMBER; | ||
293 | nvalue(&extra) = nvararg; | ||
294 | *(luaH_set(htab, &index)) = extra; | ||
295 | } | ||
296 | } | 298 | } |
297 | 299 | ||
298 | 300 | ||