aboutsummaryrefslogtreecommitdiff
path: root/lvm.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2023-05-16 14:55:49 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2023-05-16 14:55:49 -0300
commitf8d30826dda6ee8e99200de57a1997734b853db2 (patch)
treed3a24665802f41fe3216714252ed189006f302cd /lvm.h
parent351ccd733298e08c41937c1baf22a68e62bfeca9 (diff)
downloadlua-f8d30826dda6ee8e99200de57a1997734b853db2.tar.gz
lua-f8d30826dda6ee8e99200de57a1997734b853db2.tar.bz2
lua-f8d30826dda6ee8e99200de57a1997734b853db2.zip
New table API for 'set' functions
Diffstat (limited to 'lvm.h')
-rw-r--r--lvm.h25
1 files changed, 20 insertions, 5 deletions
diff --git a/lvm.h b/lvm.h
index 704446c2..750a22b2 100644
--- a/lvm.h
+++ b/lvm.h
@@ -104,14 +104,27 @@ typedef enum {
104 ? &hvalue(t)->array[k - 1] : luaH_getint(hvalue(t), k), \ 104 ? &hvalue(t)->array[k - 1] : luaH_getint(hvalue(t), k), \
105 !isempty(slot))) /* result not empty? */ 105 !isempty(slot))) /* result not empty? */
106 106
107#define luaV_fastgeti1(t,k,val,aux) \ 107#define luaV_fastgeti1(t,k,res,aux) \
108 if (!ttistable(t)) aux = HNOTATABLE; \ 108 if (!ttistable(t)) aux = HNOTATABLE; \
109 else { Table *h = hvalue(t); lua_Unsigned u = l_castS2U(k); \ 109 else { Table *h = hvalue(t); lua_Unsigned u = l_castS2U(k); \
110 if ((u - 1u < h->alimit)) { \ 110 if ((u - 1u < h->alimit)) { \
111 int tag = *getArrTag(h,u); \ 111 int tag = *getArrTag(h,u); \
112 if (tagisempty(tag)) aux = HNOTFOUND; \ 112 if (tagisempty(tag)) aux = HNOTFOUND; \
113 else { arr2val(h, u, tag, val); aux = HOK; }} \ 113 else { arr2val(h, u, tag, res); aux = HOK; }} \
114 else { aux = luaH_getint1(h, u, val); }} 114 else { aux = luaH_getint1(h, u, res); }}
115
116
117#define luaV_fastset1(t,k,val,aux,f) \
118 (aux = (!ttistable(t) ? HNOTATABLE : f(hvalue(t), k, val)))
119
120#define luaV_fastseti1(t,k,val,aux) \
121 if (!ttistable(t)) aux = HNOTATABLE; \
122 else { Table *h = hvalue(t); lua_Unsigned u = l_castS2U(k); \
123 if ((u - 1u < h->alimit)) { \
124 lu_byte *tag = getArrTag(h,u); \
125 if (tagisempty(*tag)) aux = ~cast_int(u); \
126 else { val2arr(h, u, tag, val); aux = HOK; }} \
127 else { aux = luaH_setint1(h, u, val); }}
115 128
116 129
117/* 130/*
@@ -122,6 +135,8 @@ typedef enum {
122 { setobj2t(L, cast(TValue *,slot), v); \ 135 { setobj2t(L, cast(TValue *,slot), v); \
123 luaC_barrierback(L, gcvalue(t), v); } 136 luaC_barrierback(L, gcvalue(t), v); }
124 137
138#define luaV_finishfastset1(L,t,v) luaC_barrierback(L, gcvalue(t), v)
139
125 140
126/* 141/*
127** Shift right is the same as shift left with a negative 'y' 142** Shift right is the same as shift left with a negative 'y'
@@ -140,8 +155,8 @@ LUAI_FUNC int luaV_tointegerns (const TValue *obj, lua_Integer *p,
140LUAI_FUNC int luaV_flttointeger (lua_Number n, lua_Integer *p, F2Imod mode); 155LUAI_FUNC int luaV_flttointeger (lua_Number n, lua_Integer *p, F2Imod mode);
141LUAI_FUNC void luaV_finishget1 (lua_State *L, const TValue *t, TValue *key, 156LUAI_FUNC void luaV_finishget1 (lua_State *L, const TValue *t, TValue *key,
142 StkId val, int aux); 157 StkId val, int aux);
143LUAI_FUNC void luaV_finishset (lua_State *L, const TValue *t, TValue *key, 158LUAI_FUNC void luaV_finishset1 (lua_State *L, const TValue *t, TValue *key,
144 TValue *val, const TValue *slot); 159 TValue *val, int aux);
145LUAI_FUNC void luaV_finishOp (lua_State *L); 160LUAI_FUNC void luaV_finishOp (lua_State *L);
146LUAI_FUNC void luaV_execute (lua_State *L, CallInfo *ci); 161LUAI_FUNC void luaV_execute (lua_State *L, CallInfo *ci);
147LUAI_FUNC void luaV_concat (lua_State *L, int total); 162LUAI_FUNC void luaV_concat (lua_State *L, int total);