diff options
Diffstat (limited to 'lvm.h')
-rw-r--r-- | lvm.h | 31 |
1 files changed, 15 insertions, 16 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lvm.h,v 2.38 2015/08/03 20:40:26 roberto Exp roberto $ | 2 | ** $Id: lvm.h,v 2.39 2015/09/09 13:44:07 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 | */ |
@@ -49,25 +49,24 @@ | |||
49 | 49 | ||
50 | 50 | ||
51 | /* | 51 | /* |
52 | ** fast track for 'gettable': 1 means 'aux' points to resulted value; | 52 | ** fast track for 'gettable': if 't' is a table and 't[k]' is not nil, |
53 | ** 0 means 'aux' is metamethod (if 't' is a table) or NULL. 'f' is | 53 | ** return 1 with 'slot' pointing to 't[k]' (final result). Otherwise, |
54 | ** the raw get function to use. | 54 | ** return 0 (meaning it will have to check metamethod) with 'slot' |
55 | ** pointing to a nil 't[k]' (if 't' is a table) or NULL (otherwise). | ||
56 | ** 'f' is the raw get function to use. | ||
55 | */ | 57 | */ |
56 | #define luaV_fastget(L,t,k,aux,f) \ | 58 | #define luaV_fastget(L,t,k,slot,f) \ |
57 | (!ttistable(t) \ | 59 | (!ttistable(t) \ |
58 | ? (aux = NULL, 0) /* not a table; 'aux' is NULL and result is 0 */ \ | 60 | ? (slot = NULL, 0) /* not a table; 'slot' is NULL and result is 0 */ \ |
59 | : (aux = f(hvalue(t), k), /* else, do raw access */ \ | 61 | : (slot = f(hvalue(t), k), /* else, do raw access */ \ |
60 | !ttisnil(aux) ? 1 /* result not nil? 'aux' has it */ \ | 62 | !ttisnil(slot))) /* result not nil? */ |
61 | : (aux = fasttm(L, hvalue(t)->metatable, TM_INDEX), /* get metamethod */\ | ||
62 | aux != NULL ? 0 /* has metamethod? must call it */ \ | ||
63 | : (aux = luaO_nilobject, 1)))) /* else, final result is nil */ | ||
64 | 63 | ||
65 | /* | 64 | /* |
66 | ** standard implementation for 'gettable' | 65 | ** standard implementation for 'gettable' |
67 | */ | 66 | */ |
68 | #define luaV_gettable(L,t,k,v) { const TValue *aux; \ | 67 | #define luaV_gettable(L,t,k,v) { const TValue *slot; \ |
69 | if (luaV_fastget(L,t,k,aux,luaH_get)) { setobj2s(L, v, aux); } \ | 68 | if (luaV_fastget(L,t,k,slot,luaH_get)) { setobj2s(L, v, slot); } \ |
70 | else luaV_finishget(L,t,k,v,aux); } | 69 | else luaV_finishget(L,t,k,v,slot); } |
71 | 70 | ||
72 | 71 | ||
73 | /* | 72 | /* |
@@ -100,9 +99,9 @@ LUAI_FUNC int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r); | |||
100 | LUAI_FUNC int luaV_tonumber_ (const TValue *obj, lua_Number *n); | 99 | LUAI_FUNC int luaV_tonumber_ (const TValue *obj, lua_Number *n); |
101 | LUAI_FUNC int luaV_tointeger (const TValue *obj, lua_Integer *p, int mode); | 100 | LUAI_FUNC int luaV_tointeger (const TValue *obj, lua_Integer *p, int mode); |
102 | LUAI_FUNC void luaV_finishget (lua_State *L, const TValue *t, TValue *key, | 101 | LUAI_FUNC void luaV_finishget (lua_State *L, const TValue *t, TValue *key, |
103 | StkId val, const TValue *tm); | 102 | StkId val, const TValue *slot); |
104 | LUAI_FUNC void luaV_finishset (lua_State *L, const TValue *t, TValue *key, | 103 | LUAI_FUNC void luaV_finishset (lua_State *L, const TValue *t, TValue *key, |
105 | StkId val, const TValue *oldval); | 104 | StkId val, const TValue *slot); |
106 | LUAI_FUNC void luaV_finishOp (lua_State *L); | 105 | LUAI_FUNC void luaV_finishOp (lua_State *L); |
107 | LUAI_FUNC void luaV_execute (lua_State *L); | 106 | LUAI_FUNC void luaV_execute (lua_State *L); |
108 | LUAI_FUNC void luaV_concat (lua_State *L, int total); | 107 | LUAI_FUNC void luaV_concat (lua_State *L, int total); |