aboutsummaryrefslogtreecommitdiff
path: root/lvm.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-02-12 11:04:19 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-02-12 11:04:19 -0200
commit1bdc156b52f51c7c353a5cd50447c827de853005 (patch)
tree1baeba130ef96f411d92406992fad7ded1827ed7 /lvm.c
parent03d8a9bf0d8d9c149c0c2c0ae63732a8bfa512fd (diff)
downloadlua-1bdc156b52f51c7c353a5cd50447c827de853005.tar.gz
lua-1bdc156b52f51c7c353a5cd50447c827de853005.tar.bz2
lua-1bdc156b52f51c7c353a5cd50447c827de853005.zip
details
Diffstat (limited to 'lvm.c')
-rw-r--r--lvm.c55
1 files changed, 30 insertions, 25 deletions
diff --git a/lvm.c b/lvm.c
index 39c5f6d3..5e7fd09b 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 1.167 2001/02/09 18:07:47 roberto Exp roberto $ 2** $Id: lvm.c,v 1.168 2001/02/09 20:22:29 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*/
@@ -134,24 +134,26 @@ static void callTM (lua_State *L, const char *fmt, ...) {
134*/ 134*/
135void luaV_gettable (lua_State *L, StkId t, TObject *key, StkId res) { 135void luaV_gettable (lua_State *L, StkId t, TObject *key, StkId res) {
136 Closure *tm; 136 Closure *tm;
137 int tg; 137 if (ttype(t) == LUA_TTABLE) { /* `t' is a table? */
138 if (ttype(t) == LUA_TTABLE && /* `t' is a table? */ 138 int tg = hvalue(t)->htag;
139 ((tg = hvalue(t)->htag) == LUA_TTABLE || /* with default tag? */ 139 if (tg == LUA_TTABLE || /* with default tag? */
140 luaT_gettm(G(L), tg, TM_GETTABLE) == NULL)) { /* or no TM? */ 140 (tm = luaT_gettm(G(L), tg, TM_GETTABLE)) == NULL) { /* or no TM? */
141 const TObject *h = luaH_get(hvalue(t), key); /* do a primitive get */ 141 const TObject *h = luaH_get(hvalue(t), key); /* do a primitive get */
142 /* result is no nil or there is no `index' tag method? */ 142 /* result is no nil or there is no `index' tag method? */
143 if (ttype(h) != LUA_TNIL || ((tm=luaT_gettm(G(L), tg, TM_INDEX)) == NULL)) { 143 if (ttype(h) != LUA_TNIL || /* no nil? */
144 setobj(res, h); 144 ((tm=luaT_gettm(G(L), tg, TM_INDEX)) == NULL)) { /* or no index TM? */
145 return; 145 setobj(res, h); /* default get */
146 return;
147 }
146 } 148 }
147 /* else will call `index' tag method */ 149 /* else will call the tag method */
148 } 150 }
149 else /* try a `gettable' tag method */ 151 else { /* not a table; try a `gettable' tag method */
150 tm = luaT_gettmbyObj(G(L), t, TM_GETTABLE); 152 tm = luaT_gettmbyObj(G(L), t, TM_GETTABLE);
151 if (tm == NULL) /* no tag method? */ 153 if (tm == NULL) /* no tag method? */
152 luaG_typeerror(L, t, "index"); 154 luaG_typeerror(L, t, "index");
153 else 155 }
154 callTM(L, "coor", tm, t, key, res); 156 callTM(L, "coor", tm, t, key, res);
155} 157}
156 158
157 159
@@ -160,19 +162,22 @@ void luaV_gettable (lua_State *L, StkId t, TObject *key, StkId res) {
160** Receives table at `t', key at `key' and value at `val'. 162** Receives table at `t', key at `key' and value at `val'.
161*/ 163*/
162void luaV_settable (lua_State *L, StkId t, StkId key, StkId val) { 164void luaV_settable (lua_State *L, StkId t, StkId key, StkId val) {
163 int tg; 165 Closure *tm;
164 if (ttype(t) == LUA_TTABLE && /* `t' is a table? */ 166 if (ttype(t) == LUA_TTABLE) { /* `t' is a table? */
165 ((tg = hvalue(t)->htag) == LUA_TTABLE || /* with default tag? */ 167 int tg = hvalue(t)->htag;
166 luaT_gettm(G(L), tg, TM_SETTABLE) == NULL)) { /* or no TM? */ 168 if (hvalue(t)->htag == LUA_TTABLE || /* with default tag? */
167 setobj(luaH_set(L, hvalue(t), key), val); /* do a primitive set */ 169 (tm = luaT_gettm(G(L), tg, TM_SETTABLE)) == NULL) { /* or no TM? */
170 setobj(luaH_set(L, hvalue(t), key), val); /* do a primitive set */
171 return;
172 }
173 /* else will call the tag method */
168 } 174 }
169 else { /* try a `settable' tag method */ 175 else { /* not a table; try a `settable' tag method */
170 Closure *tm = luaT_gettmbyObj(G(L), t, TM_SETTABLE); 176 tm = luaT_gettmbyObj(G(L), t, TM_SETTABLE);
171 if (tm == NULL) /* no tag method? */ 177 if (tm == NULL) /* no tag method? */
172 luaG_typeerror(L, t, "index"); 178 luaG_typeerror(L, t, "index");
173 else
174 callTM(L, "cooo", tm, t, key, val);
175 } 179 }
180 callTM(L, "cooo", tm, t, key, val);
176} 181}
177 182
178 183