aboutsummaryrefslogtreecommitdiff
path: root/lvm.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-01-19 11:20:30 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-01-19 11:20:30 -0200
commit4ac58853dc820127a11a14ed8bde1fae9458369e (patch)
treee8179692c97e935ba921c8ebd17abf9c8510d89e /lvm.c
parentf2c451d7455aad3496f32dfa2bfca7f7e8b5376d (diff)
downloadlua-4ac58853dc820127a11a14ed8bde1fae9458369e.tar.gz
lua-4ac58853dc820127a11a14ed8bde1fae9458369e.tar.bz2
lua-4ac58853dc820127a11a14ed8bde1fae9458369e.zip
thead-specific state separated from "global" state
Diffstat (limited to 'lvm.c')
-rw-r--r--lvm.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/lvm.c b/lvm.c
index fe2e8be2..1dcfa5fd 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 1.153 2001/01/15 16:13:24 roberto Exp roberto $ 2** $Id: lvm.c,v 1.154 2001/01/18 15:59:09 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*/
@@ -118,16 +118,16 @@ const TObject *luaV_gettable (lua_State *L, StkId t) {
118 int tg; 118 int tg;
119 if (ttype(t) == LUA_TTABLE && /* `t' is a table? */ 119 if (ttype(t) == LUA_TTABLE && /* `t' is a table? */
120 ((tg = hvalue(t)->htag) == LUA_TTABLE || /* with default tag? */ 120 ((tg = hvalue(t)->htag) == LUA_TTABLE || /* with default tag? */
121 luaT_gettm(L, tg, TM_GETTABLE) == NULL)) { /* or no TM? */ 121 luaT_gettm(G(L), tg, TM_GETTABLE) == NULL)) { /* or no TM? */
122 /* do a primitive get */ 122 /* do a primitive get */
123 const TObject *h = luaH_get(hvalue(t), L->top-1); 123 const TObject *h = luaH_get(hvalue(t), L->top-1);
124 /* result is no nil or there is no `index' tag method? */ 124 /* result is no nil or there is no `index' tag method? */
125 if (ttype(h) != LUA_TNIL || ((tm=luaT_gettm(L, tg, TM_INDEX)) == NULL)) 125 if (ttype(h) != LUA_TNIL || ((tm=luaT_gettm(G(L), tg, TM_INDEX)) == NULL))
126 return h; /* return result */ 126 return h; /* return result */
127 /* else call `index' tag method */ 127 /* else call `index' tag method */
128 } 128 }
129 else { /* try a `gettable' tag method */ 129 else { /* try a `gettable' tag method */
130 tm = luaT_gettmbyObj(L, t, TM_GETTABLE); 130 tm = luaT_gettmbyObj(G(L), t, TM_GETTABLE);
131 } 131 }
132 if (tm != NULL) { /* is there a tag method? */ 132 if (tm != NULL) { /* is there a tag method? */
133 luaD_checkstack(L, 2); 133 luaD_checkstack(L, 2);
@@ -152,11 +152,11 @@ void luaV_settable (lua_State *L, StkId t, StkId key) {
152 int tg; 152 int tg;
153 if (ttype(t) == LUA_TTABLE && /* `t' is a table? */ 153 if (ttype(t) == LUA_TTABLE && /* `t' is a table? */
154 ((tg = hvalue(t)->htag) == LUA_TTABLE || /* with default tag? */ 154 ((tg = hvalue(t)->htag) == LUA_TTABLE || /* with default tag? */
155 luaT_gettm(L, tg, TM_SETTABLE) == NULL)) { /* or no TM? */ 155 luaT_gettm(G(L), tg, TM_SETTABLE) == NULL)) { /* or no TM? */
156 setobj(luaH_set(L, hvalue(t), key), L->top-1); /* do a primitive set */ 156 setobj(luaH_set(L, hvalue(t), key), L->top-1); /* do a primitive set */
157 } 157 }
158 else { /* try a `settable' tag method */ 158 else { /* try a `settable' tag method */
159 Closure *tm = luaT_gettmbyObj(L, t, TM_SETTABLE); 159 Closure *tm = luaT_gettmbyObj(G(L), t, TM_SETTABLE);
160 if (tm != NULL) { 160 if (tm != NULL) {
161 luaD_checkstack(L, 3); 161 luaD_checkstack(L, 3);
162 setobj(L->top+2, L->top-1); 162 setobj(L->top+2, L->top-1);
@@ -174,7 +174,7 @@ void luaV_settable (lua_State *L, StkId t, StkId key) {
174 174
175const TObject *luaV_getglobal (lua_State *L, TString *s) { 175const TObject *luaV_getglobal (lua_State *L, TString *s) {
176 const TObject *value = luaH_getstr(L->gt, s); 176 const TObject *value = luaH_getstr(L->gt, s);
177 Closure *tm = luaT_gettmbyObj(L, value, TM_GETGLOBAL); 177 Closure *tm = luaT_gettmbyObj(G(L), value, TM_GETGLOBAL);
178 if (tm == NULL) /* is there a tag method? */ 178 if (tm == NULL) /* is there a tag method? */
179 return value; /* default behavior */ 179 return value; /* default behavior */
180 else { /* tag method */ 180 else { /* tag method */
@@ -191,7 +191,7 @@ const TObject *luaV_getglobal (lua_State *L, TString *s) {
191 191
192void luaV_setglobal (lua_State *L, TString *s) { 192void luaV_setglobal (lua_State *L, TString *s) {
193 TObject *oldvalue = luaH_setstr(L, L->gt, s); 193 TObject *oldvalue = luaH_setstr(L, L->gt, s);
194 Closure *tm = luaT_gettmbyObj(L, oldvalue, TM_SETGLOBAL); 194 Closure *tm = luaT_gettmbyObj(G(L), oldvalue, TM_SETGLOBAL);
195 if (tm == NULL) { /* no tag methods? */ 195 if (tm == NULL) { /* no tag methods? */
196 setobj(oldvalue, L->top - 1); /* raw set */ 196 setobj(oldvalue, L->top - 1); /* raw set */
197 } 197 }
@@ -209,12 +209,12 @@ void luaV_setglobal (lua_State *L, TString *s) {
209 209
210static int call_binTM (lua_State *L, StkId top, TMS event) { 210static int call_binTM (lua_State *L, StkId top, TMS event) {
211 /* try first operand */ 211 /* try first operand */
212 Closure *tm = luaT_gettmbyObj(L, top-2, event); 212 Closure *tm = luaT_gettmbyObj(G(L), top-2, event);
213 L->top = top; 213 L->top = top;
214 if (tm == NULL) { 214 if (tm == NULL) {
215 tm = luaT_gettmbyObj(L, top-1, event); /* try second operand */ 215 tm = luaT_gettmbyObj(G(L), top-1, event); /* try second operand */
216 if (tm == NULL) { 216 if (tm == NULL) {
217 tm = luaT_gettm(L, 0, event); /* try a `global' method */ 217 tm = luaT_gettm(G(L), 0, event); /* try a `global' method */
218 if (tm == NULL) 218 if (tm == NULL)
219 return 0; /* error */ 219 return 0; /* error */
220 } 220 }
@@ -369,7 +369,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) {
369 } 369 }
370 case OP_PUSHNIL: { 370 case OP_PUSHNIL: {
371 int n = GETARG_U(i); 371 int n = GETARG_U(i);
372 LUA_ASSERT(n>0, "invalid argument"); 372 lua_assert(n>0);
373 do { 373 do {
374 setnilvalue(top++); 374 setnilvalue(top++);
375 } while (--n > 0); 375 } while (--n > 0);
@@ -620,8 +620,8 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) {
620 break; 620 break;
621 } 621 }
622 case OP_FORLOOP: { 622 case OP_FORLOOP: {
623 LUA_ASSERT(ttype(top-1) == LUA_TNUMBER, "invalid step"); 623 lua_assert(ttype(top-1) == LUA_TNUMBER);
624 LUA_ASSERT(ttype(top-2) == LUA_TNUMBER, "invalid limit"); 624 lua_assert(ttype(top-2) == LUA_TNUMBER);
625 if (ttype(top-3) != LUA_TNUMBER) 625 if (ttype(top-3) != LUA_TNUMBER)
626 lua_error(L, "`for' index must be a number"); 626 lua_error(L, "`for' index must be a number");
627 nvalue(top-3) += nvalue(top-1); /* increment index */ 627 nvalue(top-3) += nvalue(top-1); /* increment index */
@@ -651,7 +651,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) {
651 } 651 }
652 case OP_LFORLOOP: { 652 case OP_LFORLOOP: {
653 Node *node; 653 Node *node;
654 LUA_ASSERT(ttype(top-3) == LUA_TTABLE, "invalid table"); 654 lua_assert(ttype(top-3) == LUA_TTABLE);
655 node = luaH_next(L, hvalue(top-3), top-2); 655 node = luaH_next(L, hvalue(top-3), top-2);
656 if (node == NULL) /* end loop? */ 656 if (node == NULL) /* end loop? */
657 top -= 3; /* remove table, key, and value */ 657 top -= 3; /* remove table, key, and value */