diff options
Diffstat (limited to 'lvm.h')
-rw-r--r-- | lvm.h | 49 |
1 files changed, 13 insertions, 36 deletions
@@ -76,20 +76,9 @@ typedef enum { | |||
76 | 76 | ||
77 | 77 | ||
78 | /* | 78 | /* |
79 | ** fast track for 'gettable': if 't' is a table and 't[k]' is present, | 79 | ** fast track for 'gettable' |
80 | ** return 1 with 'slot' pointing to 't[k]' (position of final result). | ||
81 | ** Otherwise, return 0 (meaning it will have to check metamethod) | ||
82 | ** with 'slot' pointing to an empty 't[k]' (if 't' is a table) or NULL | ||
83 | ** (otherwise). 'f' is the raw get function to use. | ||
84 | */ | 80 | */ |
85 | #define luaV_fastget(L,t,k,slot,f) \ | 81 | #define luaV_fastget(t,k,res,f, aux) \ |
86 | (!ttistable(t) \ | ||
87 | ? (slot = NULL, 0) /* not a table; 'slot' is NULL and result is 0 */ \ | ||
88 | : (slot = f(hvalue(t), k), /* else, do raw access */ \ | ||
89 | !isempty(slot))) /* result not empty? */ | ||
90 | |||
91 | |||
92 | #define luaV_fastget1(t,k,res,f, aux) \ | ||
93 | (aux = (!ttistable(t) ? HNOTATABLE : f(hvalue(t), k, res))) | 82 | (aux = (!ttistable(t) ? HNOTATABLE : f(hvalue(t), k, res))) |
94 | 83 | ||
95 | 84 | ||
@@ -97,45 +86,33 @@ typedef enum { | |||
97 | ** Special case of 'luaV_fastget' for integers, inlining the fast case | 86 | ** Special case of 'luaV_fastget' for integers, inlining the fast case |
98 | ** of 'luaH_getint'. | 87 | ** of 'luaH_getint'. |
99 | */ | 88 | */ |
100 | #define luaV_fastgeti(L,t,k,slot) \ | 89 | #define luaV_fastgeti(t,k,res,aux) \ |
101 | (!ttistable(t) \ | ||
102 | ? (slot = NULL, 0) /* not a table; 'slot' is NULL and result is 0 */ \ | ||
103 | : (slot = (l_castS2U(k) - 1u < hvalue(t)->alimit) \ | ||
104 | ? &hvalue(t)->array[k - 1] : luaH_getint(hvalue(t), k), \ | ||
105 | !isempty(slot))) /* result not empty? */ | ||
106 | |||
107 | #define luaV_fastgeti1(t,k,res,aux) \ | ||
108 | if (!ttistable(t)) aux = HNOTATABLE; \ | 90 | if (!ttistable(t)) aux = HNOTATABLE; \ |
109 | else { Table *h = hvalue(t); lua_Unsigned u = l_castS2U(k); \ | 91 | else { Table *h = hvalue(t); lua_Unsigned u = l_castS2U(k); \ |
110 | if ((u - 1u < h->alimit)) { \ | 92 | if ((u - 1u < h->alimit)) { \ |
111 | int tag = *getArrTag(h,u); \ | 93 | int tag = *getArrTag(h,u); \ |
112 | if (tagisempty(tag)) aux = HNOTFOUND; \ | 94 | if (tagisempty(tag)) aux = HNOTFOUND; \ |
113 | else { arr2val(h, u, tag, res); aux = HOK; }} \ | 95 | else { arr2val(h, u, tag, res); aux = HOK; }} \ |
114 | else { aux = luaH_getint1(h, u, res); }} | 96 | else { aux = luaH_getint(h, u, res); }} |
115 | 97 | ||
116 | 98 | ||
117 | #define luaV_fastset1(t,k,val,aux,f) \ | 99 | #define luaV_fastset(t,k,val,aux,f) \ |
118 | (aux = (!ttistable(t) ? HNOTATABLE : f(hvalue(t), k, val))) | 100 | (aux = (!ttistable(t) ? HNOTATABLE : f(hvalue(t), k, val))) |
119 | 101 | ||
120 | #define luaV_fastseti1(t,k,val,aux) \ | 102 | #define luaV_fastseti(t,k,val,aux) \ |
121 | if (!ttistable(t)) aux = HNOTATABLE; \ | 103 | if (!ttistable(t)) aux = HNOTATABLE; \ |
122 | else { Table *h = hvalue(t); lua_Unsigned u = l_castS2U(k); \ | 104 | else { Table *h = hvalue(t); lua_Unsigned u = l_castS2U(k); \ |
123 | if ((u - 1u < h->alimit)) { \ | 105 | if ((u - 1u < h->alimit)) { \ |
124 | lu_byte *tag = getArrTag(h,u); \ | 106 | lu_byte *tag = getArrTag(h,u); \ |
125 | if (tagisempty(*tag)) aux = ~cast_int(u); \ | 107 | if (tagisempty(*tag)) aux = ~cast_int(u); \ |
126 | else { val2arr(h, u, tag, val); aux = HOK; }} \ | 108 | else { val2arr(h, u, tag, val); aux = HOK; }} \ |
127 | else { aux = luaH_setint1(h, u, val); }} | 109 | else { aux = luaH_psetint(h, u, val); }} |
128 | 110 | ||
129 | 111 | ||
130 | /* | 112 | /* |
131 | ** Finish a fast set operation (when fast get succeeds). In that case, | 113 | ** Finish a fast set operation (when fast set succeeds). |
132 | ** 'slot' points to the place to put the value. | ||
133 | */ | 114 | */ |
134 | #define luaV_finishfastset(L,t,slot,v) \ | 115 | #define luaV_finishfastset(L,t,v) luaC_barrierback(L, gcvalue(t), v) |
135 | { setobj2t(L, cast(TValue *,slot), v); \ | ||
136 | luaC_barrierback(L, gcvalue(t), v); } | ||
137 | |||
138 | #define luaV_finishfastset1(L,t,v) luaC_barrierback(L, gcvalue(t), v) | ||
139 | 116 | ||
140 | 117 | ||
141 | /* | 118 | /* |
@@ -153,10 +130,10 @@ LUAI_FUNC int luaV_tointeger (const TValue *obj, lua_Integer *p, F2Imod mode); | |||
153 | LUAI_FUNC int luaV_tointegerns (const TValue *obj, lua_Integer *p, | 130 | LUAI_FUNC int luaV_tointegerns (const TValue *obj, lua_Integer *p, |
154 | F2Imod mode); | 131 | F2Imod mode); |
155 | LUAI_FUNC int luaV_flttointeger (lua_Number n, lua_Integer *p, F2Imod mode); | 132 | LUAI_FUNC int luaV_flttointeger (lua_Number n, lua_Integer *p, F2Imod mode); |
156 | LUAI_FUNC void luaV_finishget1 (lua_State *L, const TValue *t, TValue *key, | 133 | LUAI_FUNC void luaV_finishget (lua_State *L, const TValue *t, TValue *key, |
157 | StkId val, int aux); | 134 | StkId val, int aux); |
158 | LUAI_FUNC void luaV_finishset1 (lua_State *L, const TValue *t, TValue *key, | 135 | LUAI_FUNC void luaV_finishset (lua_State *L, const TValue *t, TValue *key, |
159 | TValue *val, int aux); | 136 | TValue *val, int aux); |
160 | LUAI_FUNC void luaV_finishOp (lua_State *L); | 137 | LUAI_FUNC void luaV_finishOp (lua_State *L); |
161 | LUAI_FUNC void luaV_execute (lua_State *L, CallInfo *ci); | 138 | LUAI_FUNC void luaV_execute (lua_State *L, CallInfo *ci); |
162 | LUAI_FUNC void luaV_concat (lua_State *L, int total); | 139 | LUAI_FUNC void luaV_concat (lua_State *L, int total); |