diff options
| -rw-r--r-- | lapi.c | 8 | ||||
| -rw-r--r-- | lobject.c | 6 | ||||
| -rw-r--r-- | lobject.h | 8 | ||||
| -rw-r--r-- | lstate.c | 5 | ||||
| -rw-r--r-- | ltm.c | 5 |
5 files changed, 12 insertions, 20 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lapi.c,v 2.290 2018/02/27 20:01:55 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 2.291 2018/04/04 14:23:41 roberto Exp roberto $ |
| 3 | ** Lua API | 3 | ** Lua API |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -38,10 +38,12 @@ const char lua_ident[] = | |||
| 38 | 38 | ||
| 39 | 39 | ||
| 40 | /* value at a non-valid index */ | 40 | /* value at a non-valid index */ |
| 41 | #define NONVALIDVALUE cast(TValue *, luaO_nilobject) | 41 | |
| 42 | static const TValue nonvalidvaluep = {NILCONSTANT}; | ||
| 43 | #define NONVALIDVALUE cast(TValue *, &nonvalidvaluep) | ||
| 42 | 44 | ||
| 43 | /* corresponding test */ | 45 | /* corresponding test */ |
| 44 | #define isvalid(o) ((o) != luaO_nilobject) | 46 | #define isvalid(o) ((o) != &nonvalidvaluep) |
| 45 | 47 | ||
| 46 | /* test for pseudo index */ | 48 | /* test for pseudo index */ |
| 47 | #define ispseudo(i) ((i) <= LUA_REGISTRYINDEX) | 49 | #define ispseudo(i) ((i) <= LUA_REGISTRYINDEX) |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lobject.c,v 2.124 2018/02/27 18:47:32 roberto Exp roberto $ | 2 | ** $Id: lobject.c,v 2.125 2018/04/25 16:26:20 roberto Exp roberto $ |
| 3 | ** Some generic functions over Lua objects | 3 | ** Some generic functions over Lua objects |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -29,10 +29,6 @@ | |||
| 29 | #include "lvm.h" | 29 | #include "lvm.h" |
| 30 | 30 | ||
| 31 | 31 | ||
| 32 | |||
| 33 | LUAI_DDEF const TValue luaO_nilobject_ = {NILCONSTANT}; | ||
| 34 | |||
| 35 | |||
| 36 | /* | 32 | /* |
| 37 | ** converts an integer to a "floating point byte", represented as | 33 | ** converts an integer to a "floating point byte", represented as |
| 38 | ** (eeeeexxx), where the real value is (1xxx) * 2^(eeeee - 1) if | 34 | ** (eeeeexxx), where the real value is (1xxx) * 2^(eeeee - 1) if |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lobject.h,v 2.142 2018/04/04 14:23:41 roberto Exp roberto $ | 2 | ** $Id: lobject.h,v 2.143 2018/06/01 16:51:34 roberto Exp roberto $ |
| 3 | ** Type definitions for Lua objects | 3 | ** Type definitions for Lua objects |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -150,10 +150,6 @@ typedef StackValue *StkId; /* index to stack elements */ | |||
| 150 | #define setnilvalue(obj) settt_(obj, LUA_TNIL) | 150 | #define setnilvalue(obj) settt_(obj, LUA_TNIL) |
| 151 | 151 | ||
| 152 | 152 | ||
| 153 | /* (address of) a fixed nil value */ | ||
| 154 | #define luaO_nilobject (&luaO_nilobject_) | ||
| 155 | |||
| 156 | |||
| 157 | /* | 153 | /* |
| 158 | ** Variant tag, used only in tables to signal an empty slot | 154 | ** Variant tag, used only in tables to signal an empty slot |
| 159 | ** (which might be different from a slot containing nil) | 155 | ** (which might be different from a slot containing nil) |
| @@ -730,8 +726,6 @@ typedef struct Table { | |||
| 730 | #define sizenode(t) (twoto((t)->lsizenode)) | 726 | #define sizenode(t) (twoto((t)->lsizenode)) |
| 731 | 727 | ||
| 732 | 728 | ||
| 733 | LUAI_DDEC const TValue luaO_nilobject_; | ||
| 734 | |||
| 735 | /* size of buffer for 'luaO_utf8esc' function */ | 729 | /* size of buffer for 'luaO_utf8esc' function */ |
| 736 | #define UTF8BUFFSZ 8 | 730 | #define UTF8BUFFSZ 8 |
| 737 | 731 | ||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lstate.c,v 2.151 2018/02/05 17:11:37 roberto Exp roberto $ | 2 | ** $Id: lstate.c,v 2.152 2018/05/29 18:02:51 roberto Exp roberto $ |
| 3 | ** Global State | 3 | ** Global State |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -69,12 +69,11 @@ typedef struct LG { | |||
| 69 | memcpy(b + p, &t, sizeof(t)); p += sizeof(t); } | 69 | memcpy(b + p, &t, sizeof(t)); p += sizeof(t); } |
| 70 | 70 | ||
| 71 | static unsigned int luai_makeseed (lua_State *L) { | 71 | static unsigned int luai_makeseed (lua_State *L) { |
| 72 | char buff[4 * sizeof(size_t)]; | 72 | char buff[3 * sizeof(size_t)]; |
| 73 | unsigned int h = cast_uint(time(NULL)); | 73 | unsigned int h = cast_uint(time(NULL)); |
| 74 | int p = 0; | 74 | int p = 0; |
| 75 | addbuff(buff, p, L); /* heap variable */ | 75 | addbuff(buff, p, L); /* heap variable */ |
| 76 | addbuff(buff, p, &h); /* local variable */ | 76 | addbuff(buff, p, &h); /* local variable */ |
| 77 | addbuff(buff, p, luaO_nilobject); /* global variable */ | ||
| 78 | addbuff(buff, p, &lua_newstate); /* public function */ | 77 | addbuff(buff, p, &lua_newstate); /* public function */ |
| 79 | lua_assert(p == sizeof(buff)); | 78 | lua_assert(p == sizeof(buff)); |
| 80 | return luaS_hash(buff, p, h); | 79 | return luaS_hash(buff, p, h); |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ltm.c,v 2.66 2018/02/27 17:48:28 roberto Exp roberto $ | 2 | ** $Id: ltm.c,v 2.67 2018/04/04 14:23:41 roberto Exp roberto $ |
| 3 | ** Tag methods | 3 | ** Tag methods |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -69,6 +69,7 @@ const TValue *luaT_gettm (Table *events, TMS event, TString *ename) { | |||
| 69 | 69 | ||
| 70 | 70 | ||
| 71 | const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, TMS event) { | 71 | const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, TMS event) { |
| 72 | static const TValue nilobject = {NILCONSTANT}; | ||
| 72 | Table *mt; | 73 | Table *mt; |
| 73 | switch (ttype(o)) { | 74 | switch (ttype(o)) { |
| 74 | case LUA_TTABLE: | 75 | case LUA_TTABLE: |
| @@ -80,7 +81,7 @@ const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, TMS event) { | |||
| 80 | default: | 81 | default: |
| 81 | mt = G(L)->mt[ttype(o)]; | 82 | mt = G(L)->mt[ttype(o)]; |
| 82 | } | 83 | } |
| 83 | return (mt ? luaH_getshortstr(mt, G(L)->tmname[event]) : luaO_nilobject); | 84 | return (mt ? luaH_getshortstr(mt, G(L)->tmname[event]) : &nilobject); |
| 84 | } | 85 | } |
| 85 | 86 | ||
| 86 | 87 | ||
