diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-06-01 13:51:34 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-06-01 13:51:34 -0300 |
commit | fb8fa661366e15e98c60d8929feaab9e551a02f9 (patch) | |
tree | b3eb16fcfe3eab8f4b07ccaa71c55011016ad005 /lvm.c | |
parent | b3970649550fe8471c55bfae57aa3752ddfa97a9 (diff) | |
download | lua-fb8fa661366e15e98c60d8929feaab9e551a02f9.tar.gz lua-fb8fa661366e15e98c60d8929feaab9e551a02f9.tar.bz2 lua-fb8fa661366e15e98c60d8929feaab9e551a02f9.zip |
no more 'luaH_emptyobject' and comparisons of addresses of global variables
(instead, use a different kind of nil to signal the fake entry returned
when a key is not found in a table)
Diffstat (limited to 'lvm.c')
-rw-r--r-- | lvm.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lvm.c,v 2.355 2018/05/22 12:02:36 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 2.356 2018/05/30 14:25:52 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 | */ |
@@ -227,9 +227,9 @@ void luaV_finishget (lua_State *L, const TValue *t, TValue *key, StkId val, | |||
227 | /* | 227 | /* |
228 | ** Finish a table assignment 't[key] = val'. | 228 | ** Finish a table assignment 't[key] = val'. |
229 | ** If 'slot' is NULL, 't' is not a table. Otherwise, 'slot' points | 229 | ** If 'slot' is NULL, 't' is not a table. Otherwise, 'slot' points |
230 | ** to the entry 't[key]', or to 'luaH_emptyobject' if there is no such | 230 | ** to the entry 't[key]', or to a value with an absent key if there |
231 | ** entry. (The value at 'slot' must be empty, otherwise 'luaV_fastget' | 231 | ** is no such entry. (The value at 'slot' must be empty, otherwise |
232 | ** would have done the job.) | 232 | ** 'luaV_fastget' would have done the job.) |
233 | */ | 233 | */ |
234 | void luaV_finishset (lua_State *L, const TValue *t, TValue *key, | 234 | void luaV_finishset (lua_State *L, const TValue *t, TValue *key, |
235 | TValue *val, const TValue *slot) { | 235 | TValue *val, const TValue *slot) { |
@@ -241,7 +241,7 @@ void luaV_finishset (lua_State *L, const TValue *t, TValue *key, | |||
241 | lua_assert(isempty(slot)); /* slot must be empty */ | 241 | lua_assert(isempty(slot)); /* slot must be empty */ |
242 | tm = fasttm(L, h->metatable, TM_NEWINDEX); /* get metamethod */ | 242 | tm = fasttm(L, h->metatable, TM_NEWINDEX); /* get metamethod */ |
243 | if (tm == NULL) { /* no metamethod? */ | 243 | if (tm == NULL) { /* no metamethod? */ |
244 | if (slot == luaH_emptyobject) /* no previous entry? */ | 244 | if (isabstkey(slot)) /* no previous entry? */ |
245 | slot = luaH_newkey(L, h, key); /* create one */ | 245 | slot = luaH_newkey(L, h, key); /* create one */ |
246 | /* no metamethod and (now) there is an entry with given key */ | 246 | /* no metamethod and (now) there is an entry with given key */ |
247 | setobj2t(L, cast(TValue *, slot), val); /* set its new value */ | 247 | setobj2t(L, cast(TValue *, slot), val); /* set its new value */ |