aboutsummaryrefslogtreecommitdiff
path: root/lvm.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2003-12-10 10:13:36 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2003-12-10 10:13:36 -0200
commit47fc57a2529c83376883f36954082cfe80ae588f (patch)
treec2e57e2f9f7d78279144bfd9cbd04a3b1b131f12 /lvm.c
parent4d5fe1f54bc00850f77a7c42f9e95d0ff3f1ab5b (diff)
downloadlua-47fc57a2529c83376883f36954082cfe80ae588f.tar.gz
lua-47fc57a2529c83376883f36954082cfe80ae588f.tar.bz2
lua-47fc57a2529c83376883f36954082cfe80ae588f.zip
`TObject' renamed to `TValue' + other name changes and better assertions
for incremental garbage collection
Diffstat (limited to 'lvm.c')
-rw-r--r--lvm.c158
1 files changed, 79 insertions, 79 deletions
diff --git a/lvm.c b/lvm.c
index 29c27f0f..8ebf102a 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 1.290 2003/10/27 19:14:31 roberto Exp roberto $ 2** $Id: lvm.c,v 1.291 2003/12/09 16:56:11 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*/
@@ -40,7 +40,7 @@
40#define MAXTAGLOOP 100 40#define MAXTAGLOOP 100
41 41
42 42
43const TObject *luaV_tonumber (const TObject *obj, TObject *n) { 43const TValue *luaV_tonumber (const TValue *obj, TValue *n) {
44 lua_Number num; 44 lua_Number num;
45 if (ttisnumber(obj)) return obj; 45 if (ttisnumber(obj)) return obj;
46 if (ttisstring(obj) && luaO_str2d(svalue(obj), &num)) { 46 if (ttisstring(obj) && luaO_str2d(svalue(obj), &num)) {
@@ -58,7 +58,7 @@ int luaV_tostring (lua_State *L, StkId obj) {
58 else { 58 else {
59 char s[32]; /* 16 digits, sign, point and \0 (+ some extra...) */ 59 char s[32]; /* 16 digits, sign, point and \0 (+ some extra...) */
60 lua_number2str(s, nvalue(obj)); 60 lua_number2str(s, nvalue(obj));
61 setsvalue2s(obj, luaS_new(L, s)); 61 setsvalue2s(L, obj, luaS_new(L, s));
62 return 1; 62 return 1;
63 } 63 }
64} 64}
@@ -88,11 +88,11 @@ static void traceexec (lua_State *L, const Instruction *pc) {
88} 88}
89 89
90 90
91static void prepTMcall (lua_State *L, const TObject *f, 91static void prepTMcall (lua_State *L, const TValue *f,
92 const TObject *p1, const TObject *p2) { 92 const TValue *p1, const TValue *p2) {
93 setobj2s(L->top, f); /* push function */ 93 setobj2s(L, L->top, f); /* push function */
94 setobj2s(L->top+1, p1); /* 1st argument */ 94 setobj2s(L, L->top+1, p1); /* 1st argument */
95 setobj2s(L->top+2, p2); /* 2nd argument */ 95 setobj2s(L, L->top+2, p2); /* 2nd argument */
96} 96}
97 97
98 98
@@ -103,7 +103,7 @@ static void callTMres (lua_State *L, StkId res) {
103 luaD_call(L, L->top - 3, 1); 103 luaD_call(L, L->top - 3, 1);
104 res = restorestack(L, result); 104 res = restorestack(L, result);
105 L->top--; 105 L->top--;
106 setobjs2s(res, L->top); 106 setobjs2s(L, res, L->top);
107} 107}
108 108
109 109
@@ -115,16 +115,16 @@ static void callTM (lua_State *L) {
115} 115}
116 116
117 117
118void luaV_gettable (lua_State *L, const TObject *t, TObject *key, StkId val) { 118void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val) {
119 int loop; 119 int loop;
120 for (loop = 0; loop < MAXTAGLOOP; loop++) { 120 for (loop = 0; loop < MAXTAGLOOP; loop++) {
121 const TObject *tm; 121 const TValue *tm;
122 if (ttistable(t)) { /* `t' is a table? */ 122 if (ttistable(t)) { /* `t' is a table? */
123 Table *h = hvalue(t); 123 Table *h = hvalue(t);
124 const TObject *res = luaH_get(h, key); /* do a primitive set */ 124 const TValue *res = luaH_get(h, key); /* do a primitive set */
125 if (!ttisnil(res) || /* result is no nil? */ 125 if (!ttisnil(res) || /* result is no nil? */
126 (tm = fasttm(L, h->metatable, TM_INDEX)) == NULL) { /* or no TM? */ 126 (tm = fasttm(L, h->metatable, TM_INDEX)) == NULL) { /* or no TM? */
127 setobj2s(val, res); 127 setobj2s(L, val, res);
128 return; 128 return;
129 } 129 }
130 /* else will try the tag method */ 130 /* else will try the tag method */
@@ -142,16 +142,16 @@ void luaV_gettable (lua_State *L, const TObject *t, TObject *key, StkId val) {
142} 142}
143 143
144 144
145void luaV_settable (lua_State *L, const TObject *t, TObject *key, StkId val) { 145void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) {
146 int loop; 146 int loop;
147 for (loop = 0; loop < MAXTAGLOOP; loop++) { 147 for (loop = 0; loop < MAXTAGLOOP; loop++) {
148 const TObject *tm; 148 const TValue *tm;
149 if (ttistable(t)) { /* `t' is a table? */ 149 if (ttistable(t)) { /* `t' is a table? */
150 Table *h = hvalue(t); 150 Table *h = hvalue(t);
151 TObject *oldval = luaH_set(L, h, key); /* do a primitive set */ 151 TValue *oldval = luaH_set(L, h, key); /* do a primitive set */
152 if (!ttisnil(oldval) || /* result is no nil? */ 152 if (!ttisnil(oldval) || /* result is no nil? */
153 (tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL) { /* or no TM? */ 153 (tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL) { /* or no TM? */
154 setobj2t(oldval, val); 154 setobj2t(L, oldval, val);
155 luaC_barrier(L, h, val); 155 luaC_barrier(L, h, val);
156 return; 156 return;
157 } 157 }
@@ -161,7 +161,7 @@ void luaV_settable (lua_State *L, const TObject *t, TObject *key, StkId val) {
161 luaG_typeerror(L, t, "index"); 161 luaG_typeerror(L, t, "index");
162 if (ttisfunction(tm)) { 162 if (ttisfunction(tm)) {
163 prepTMcall(L, tm, t, key); 163 prepTMcall(L, tm, t, key);
164 setobj2s(L->top+3, val); /* 3th argument */ 164 setobj2s(L, L->top+3, val); /* 3th argument */
165 callTM(L); 165 callTM(L);
166 return; 166 return;
167 } 167 }
@@ -171,9 +171,9 @@ void luaV_settable (lua_State *L, const TObject *t, TObject *key, StkId val) {
171} 171}
172 172
173 173
174static int call_binTM (lua_State *L, const TObject *p1, const TObject *p2, 174static int call_binTM (lua_State *L, const TValue *p1, const TValue *p2,
175 StkId res, TMS event) { 175 StkId res, TMS event) {
176 const TObject *tm = luaT_gettmbyobj(L, p1, event); /* try first operand */ 176 const TValue *tm = luaT_gettmbyobj(L, p1, event); /* try first operand */
177 if (ttisnil(tm)) 177 if (ttisnil(tm))
178 tm = luaT_gettmbyobj(L, p2, event); /* try second operand */ 178 tm = luaT_gettmbyobj(L, p2, event); /* try second operand */
179 if (!ttisfunction(tm)) return 0; 179 if (!ttisfunction(tm)) return 0;
@@ -183,10 +183,10 @@ static int call_binTM (lua_State *L, const TObject *p1, const TObject *p2,
183} 183}
184 184
185 185
186static const TObject *get_compTM (lua_State *L, Table *mt1, Table *mt2, 186static const TValue *get_compTM (lua_State *L, Table *mt1, Table *mt2,
187 TMS event) { 187 TMS event) {
188 const TObject *tm1 = fasttm(L, mt1, event); 188 const TValue *tm1 = fasttm(L, mt1, event);
189 const TObject *tm2; 189 const TValue *tm2;
190 if (tm1 == NULL) return NULL; /* no metamethod */ 190 if (tm1 == NULL) return NULL; /* no metamethod */
191 if (mt1 == mt2) return tm1; /* same metatables => same metamethods */ 191 if (mt1 == mt2) return tm1; /* same metatables => same metamethods */
192 tm2 = fasttm(L, mt2, event); 192 tm2 = fasttm(L, mt2, event);
@@ -197,10 +197,10 @@ static const TObject *get_compTM (lua_State *L, Table *mt1, Table *mt2,
197} 197}
198 198
199 199
200static int call_orderTM (lua_State *L, const TObject *p1, const TObject *p2, 200static int call_orderTM (lua_State *L, const TValue *p1, const TValue *p2,
201 TMS event) { 201 TMS event) {
202 const TObject *tm1 = luaT_gettmbyobj(L, p1, event); 202 const TValue *tm1 = luaT_gettmbyobj(L, p1, event);
203 const TObject *tm2; 203 const TValue *tm2;
204 if (ttisnil(tm1)) return -1; /* no metamethod? */ 204 if (ttisnil(tm1)) return -1; /* no metamethod? */
205 tm2 = luaT_gettmbyobj(L, p2, event); 205 tm2 = luaT_gettmbyobj(L, p2, event);
206 if (!luaO_rawequalObj(tm1, tm2)) /* different metamethods? */ 206 if (!luaO_rawequalObj(tm1, tm2)) /* different metamethods? */
@@ -233,28 +233,28 @@ static int luaV_strcmp (const TString *ls, const TString *rs) {
233} 233}
234 234
235 235
236int luaV_lessthan (lua_State *L, const TObject *l, const TObject *r) { 236int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) {
237 int res; 237 int res;
238 if (ttype(l) != ttype(r)) 238 if (ttype(l) != ttype(r))
239 return luaG_ordererror(L, l, r); 239 return luaG_ordererror(L, l, r);
240 else if (ttisnumber(l)) 240 else if (ttisnumber(l))
241 return nvalue(l) < nvalue(r); 241 return nvalue(l) < nvalue(r);
242 else if (ttisstring(l)) 242 else if (ttisstring(l))
243 return luaV_strcmp(tsvalue(l), tsvalue(r)) < 0; 243 return luaV_strcmp(rawtsvalue(l), rawtsvalue(r)) < 0;
244 else if ((res = call_orderTM(L, l, r, TM_LT)) != -1) 244 else if ((res = call_orderTM(L, l, r, TM_LT)) != -1)
245 return res; 245 return res;
246 return luaG_ordererror(L, l, r); 246 return luaG_ordererror(L, l, r);
247} 247}
248 248
249 249
250static int luaV_lessequal (lua_State *L, const TObject *l, const TObject *r) { 250static int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r) {
251 int res; 251 int res;
252 if (ttype(l) != ttype(r)) 252 if (ttype(l) != ttype(r))
253 return luaG_ordererror(L, l, r); 253 return luaG_ordererror(L, l, r);
254 else if (ttisnumber(l)) 254 else if (ttisnumber(l))
255 return nvalue(l) <= nvalue(r); 255 return nvalue(l) <= nvalue(r);
256 else if (ttisstring(l)) 256 else if (ttisstring(l))
257 return luaV_strcmp(tsvalue(l), tsvalue(r)) <= 0; 257 return luaV_strcmp(rawtsvalue(l), rawtsvalue(r)) <= 0;
258 else if ((res = call_orderTM(L, l, r, TM_LE)) != -1) /* first try `le' */ 258 else if ((res = call_orderTM(L, l, r, TM_LE)) != -1) /* first try `le' */
259 return res; 259 return res;
260 else if ((res = call_orderTM(L, r, l, TM_LT)) != -1) /* else try `lt' */ 260 else if ((res = call_orderTM(L, r, l, TM_LT)) != -1) /* else try `lt' */
@@ -263,8 +263,8 @@ static int luaV_lessequal (lua_State *L, const TObject *l, const TObject *r) {
263} 263}
264 264
265 265
266int luaV_equalval (lua_State *L, const TObject *t1, const TObject *t2) { 266int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2) {
267 const TObject *tm; 267 const TValue *tm;
268 lua_assert(ttype(t1) == ttype(t2)); 268 lua_assert(ttype(t1) == ttype(t2));
269 switch (ttype(t1)) { 269 switch (ttype(t1)) {
270 case LUA_TNIL: return 1; 270 case LUA_TNIL: return 1;
@@ -273,7 +273,7 @@ int luaV_equalval (lua_State *L, const TObject *t1, const TObject *t2) {
273 case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2); 273 case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2);
274 case LUA_TUSERDATA: { 274 case LUA_TUSERDATA: {
275 if (uvalue(t1) == uvalue(t2)) return 1; 275 if (uvalue(t1) == uvalue(t2)) return 1;
276 tm = get_compTM(L, uvalue(t1)->uv.metatable, uvalue(t2)->uv.metatable, 276 tm = get_compTM(L, uvalue(t1)->metatable, uvalue(t2)->metatable,
277 TM_EQ); 277 TM_EQ);
278 break; /* will try TM */ 278 break; /* will try TM */
279 } 279 }
@@ -298,25 +298,25 @@ void luaV_concat (lua_State *L, int total, int last) {
298 if (!tostring(L, top-2) || !tostring(L, top-1)) { 298 if (!tostring(L, top-2) || !tostring(L, top-1)) {
299 if (!call_binTM(L, top-2, top-1, top-2, TM_CONCAT)) 299 if (!call_binTM(L, top-2, top-1, top-2, TM_CONCAT))
300 luaG_concaterror(L, top-2, top-1); 300 luaG_concaterror(L, top-2, top-1);
301 } else if (tsvalue(top-1)->tsv.len > 0) { /* if len=0, do nothing */ 301 } else if (tsvalue(top-1)->len > 0) { /* if len=0, do nothing */
302 /* at least two string values; get as many as possible */ 302 /* at least two string values; get as many as possible */
303 lu_mem tl = cast(lu_mem, tsvalue(top-1)->tsv.len) + 303 lu_mem tl = cast(lu_mem, tsvalue(top-1)->len) +
304 cast(lu_mem, tsvalue(top-2)->tsv.len); 304 cast(lu_mem, tsvalue(top-2)->len);
305 char *buffer; 305 char *buffer;
306 int i; 306 int i;
307 while (n < total && tostring(L, top-n-1)) { /* collect total length */ 307 while (n < total && tostring(L, top-n-1)) { /* collect total length */
308 tl += tsvalue(top-n-1)->tsv.len; 308 tl += tsvalue(top-n-1)->len;
309 n++; 309 n++;
310 } 310 }
311 if (tl > MAX_SIZET) luaG_runerror(L, "string size overflow"); 311 if (tl > MAX_SIZET) luaG_runerror(L, "string size overflow");
312 buffer = luaZ_openspace(L, &G(L)->buff, tl); 312 buffer = luaZ_openspace(L, &G(L)->buff, tl);
313 tl = 0; 313 tl = 0;
314 for (i=n; i>0; i--) { /* concat all strings */ 314 for (i=n; i>0; i--) { /* concat all strings */
315 size_t l = tsvalue(top-i)->tsv.len; 315 size_t l = tsvalue(top-i)->len;
316 memcpy(buffer+tl, svalue(top-i), l); 316 memcpy(buffer+tl, svalue(top-i), l);
317 tl += l; 317 tl += l;
318 } 318 }
319 setsvalue2s(top-n, luaS_newlstr(L, buffer, tl)); 319 setsvalue2s(L, top-n, luaS_newlstr(L, buffer, tl));
320 } 320 }
321 total -= n-1; /* got `n' strings to create 1 new */ 321 total -= n-1; /* got `n' strings to create 1 new */
322 last -= n-1; 322 last -= n-1;
@@ -324,10 +324,10 @@ void luaV_concat (lua_State *L, int total, int last) {
324} 324}
325 325
326 326
327static StkId Arith (lua_State *L, StkId ra, const TObject *rb, 327static StkId Arith (lua_State *L, StkId ra, const TValue *rb,
328 const TObject *rc, TMS op, const Instruction *pc) { 328 const TValue *rc, TMS op, const Instruction *pc) {
329 TObject tempb, tempc; 329 TValue tempb, tempc;
330 const TObject *b, *c; 330 const TValue *b, *c;
331 L->ci->u.l.savedpc = pc; 331 L->ci->u.l.savedpc = pc;
332 if ((b = luaV_tonumber(rb, &tempb)) != NULL && 332 if ((b = luaV_tonumber(rb, &tempb)) != NULL &&
333 (c = luaV_tonumber(rc, &tempc)) != NULL) { 333 (c = luaV_tonumber(rc, &tempc)) != NULL) {
@@ -337,7 +337,7 @@ static StkId Arith (lua_State *L, StkId ra, const TObject *rb,
337 case TM_MUL: setnvalue(ra, nvalue(b) * nvalue(c)); break; 337 case TM_MUL: setnvalue(ra, nvalue(b) * nvalue(c)); break;
338 case TM_DIV: setnvalue(ra, nvalue(b) / nvalue(c)); break; 338 case TM_DIV: setnvalue(ra, nvalue(b) / nvalue(c)); break;
339 case TM_POW: { 339 case TM_POW: {
340 const TObject *f = luaH_getstr(hvalue(gt(L)), G(L)->tmname[TM_POW]); 340 const TValue *f = luaH_getstr(hvalue(gt(L)), G(L)->tmname[TM_POW]);
341 if (!ttisfunction(f)) 341 if (!ttisfunction(f))
342 luaG_runerror(L, "`__pow' (`^' operator) is not a function"); 342 luaG_runerror(L, "`__pow' (`^' operator) is not a function");
343 prepTMcall(L, f, b, c); 343 prepTMcall(L, f, b, c);
@@ -376,7 +376,7 @@ static StkId Arith (lua_State *L, StkId ra, const TObject *rb,
376 376
377StkId luaV_execute (lua_State *L, int nexeccalls) { 377StkId luaV_execute (lua_State *L, int nexeccalls) {
378 LClosure *cl; 378 LClosure *cl;
379 TObject *k; 379 TValue *k;
380 StkId base; 380 StkId base;
381 const Instruction *pc; 381 const Instruction *pc;
382 callentry: /* entry point when calling new functions */ 382 callentry: /* entry point when calling new functions */
@@ -409,11 +409,11 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
409 GET_OPCODE(i) == OP_RETURN || GET_OPCODE(i) == OP_SETLISTO); 409 GET_OPCODE(i) == OP_RETURN || GET_OPCODE(i) == OP_SETLISTO);
410 switch (GET_OPCODE(i)) { 410 switch (GET_OPCODE(i)) {
411 case OP_MOVE: { 411 case OP_MOVE: {
412 setobjs2s(ra, RB(i)); 412 setobjs2s(L, ra, RB(i));
413 break; 413 break;
414 } 414 }
415 case OP_LOADK: { 415 case OP_LOADK: {
416 setobj2s(ra, KBx(i)); 416 setobj2s(L, ra, KBx(i));
417 break; 417 break;
418 } 418 }
419 case OP_LOADBOOL: { 419 case OP_LOADBOOL: {
@@ -422,7 +422,7 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
422 break; 422 break;
423 } 423 }
424 case OP_LOADNIL: { 424 case OP_LOADNIL: {
425 TObject *rb = RB(i); 425 TValue *rb = RB(i);
426 do { 426 do {
427 setnilvalue(rb--); 427 setnilvalue(rb--);
428 } while (rb >= ra); 428 } while (rb >= ra);
@@ -430,11 +430,11 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
430 } 430 }
431 case OP_GETUPVAL: { 431 case OP_GETUPVAL: {
432 int b = GETARG_B(i); 432 int b = GETARG_B(i);
433 setobj2s(ra, cl->upvals[b]->v); 433 setobj2s(L, ra, cl->upvals[b]->v);
434 break; 434 break;
435 } 435 }
436 case OP_GETGLOBAL: { 436 case OP_GETGLOBAL: {
437 TObject *rb = KBx(i); 437 TValue *rb = KBx(i);
438 lua_assert(ttisstring(rb) && ttistable(&cl->g)); 438 lua_assert(ttisstring(rb) && ttistable(&cl->g));
439 L->ci->u.l.savedpc = pc; 439 L->ci->u.l.savedpc = pc;
440 luaV_gettable(L, &cl->g, rb, ra); /***/ 440 luaV_gettable(L, &cl->g, rb, ra); /***/
@@ -456,7 +456,7 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
456 } 456 }
457 case OP_SETUPVAL: { 457 case OP_SETUPVAL: {
458 UpVal *uv = cl->upvals[GETARG_B(i)]; 458 UpVal *uv = cl->upvals[GETARG_B(i)];
459 setobj(uv->v, ra); 459 setobj(L, uv->v, ra);
460 luaC_barrier(L, uv, ra); 460 luaC_barrier(L, uv, ra);
461 break; 461 break;
462 } 462 }
@@ -469,7 +469,7 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
469 case OP_NEWTABLE: { 469 case OP_NEWTABLE: {
470 int b = GETARG_B(i); 470 int b = GETARG_B(i);
471 b = fb2int(b); 471 b = fb2int(b);
472 sethvalue(ra, luaH_new(L, b, GETARG_C(i))); 472 sethvalue(L, ra, luaH_new(L, b, GETARG_C(i)));
473 L->ci->u.l.savedpc = pc; 473 L->ci->u.l.savedpc = pc;
474 luaC_checkGC(L); /***/ 474 luaC_checkGC(L); /***/
475 base = L->base; 475 base = L->base;
@@ -477,15 +477,15 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
477 } 477 }
478 case OP_SELF: { 478 case OP_SELF: {
479 StkId rb = RB(i); 479 StkId rb = RB(i);
480 setobjs2s(ra+1, rb); 480 setobjs2s(L, ra+1, rb);
481 L->ci->u.l.savedpc = pc; 481 L->ci->u.l.savedpc = pc;
482 luaV_gettable(L, rb, RKC(i), ra); /***/ 482 luaV_gettable(L, rb, RKC(i), ra); /***/
483 base = L->base; 483 base = L->base;
484 break; 484 break;
485 } 485 }
486 case OP_ADD: { 486 case OP_ADD: {
487 TObject *rb = RKB(i); 487 TValue *rb = RKB(i);
488 TObject *rc = RKC(i); 488 TValue *rc = RKC(i);
489 if (ttisnumber(rb) && ttisnumber(rc)) { 489 if (ttisnumber(rb) && ttisnumber(rc)) {
490 setnvalue(ra, nvalue(rb) + nvalue(rc)); 490 setnvalue(ra, nvalue(rb) + nvalue(rc));
491 } 491 }
@@ -494,8 +494,8 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
494 break; 494 break;
495 } 495 }
496 case OP_SUB: { 496 case OP_SUB: {
497 TObject *rb = RKB(i); 497 TValue *rb = RKB(i);
498 TObject *rc = RKC(i); 498 TValue *rc = RKC(i);
499 if (ttisnumber(rb) && ttisnumber(rc)) { 499 if (ttisnumber(rb) && ttisnumber(rc)) {
500 setnvalue(ra, nvalue(rb) - nvalue(rc)); 500 setnvalue(ra, nvalue(rb) - nvalue(rc));
501 } 501 }
@@ -504,8 +504,8 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
504 break; 504 break;
505 } 505 }
506 case OP_MUL: { 506 case OP_MUL: {
507 TObject *rb = RKB(i); 507 TValue *rb = RKB(i);
508 TObject *rc = RKC(i); 508 TValue *rc = RKC(i);
509 if (ttisnumber(rb) && ttisnumber(rc)) { 509 if (ttisnumber(rb) && ttisnumber(rc)) {
510 setnvalue(ra, nvalue(rb) * nvalue(rc)); 510 setnvalue(ra, nvalue(rb) * nvalue(rc));
511 } 511 }
@@ -514,8 +514,8 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
514 break; 514 break;
515 } 515 }
516 case OP_DIV: { 516 case OP_DIV: {
517 TObject *rb = RKB(i); 517 TValue *rb = RKB(i);
518 TObject *rc = RKC(i); 518 TValue *rc = RKC(i);
519 if (ttisnumber(rb) && ttisnumber(rc)) { 519 if (ttisnumber(rb) && ttisnumber(rc)) {
520 setnvalue(ra, nvalue(rb) / nvalue(rc)); 520 setnvalue(ra, nvalue(rb) / nvalue(rc));
521 } 521 }
@@ -528,8 +528,8 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
528 break; 528 break;
529 } 529 }
530 case OP_UNM: { 530 case OP_UNM: {
531 const TObject *rb = RB(i); 531 const TValue *rb = RB(i);
532 TObject temp; 532 TValue temp;
533 if (tonumber(rb, &temp)) { 533 if (tonumber(rb, &temp)) {
534 setnvalue(ra, -nvalue(rb)); 534 setnvalue(ra, -nvalue(rb));
535 } 535 }
@@ -554,7 +554,7 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
554 luaV_concat(L, c-b+1, c); /* may change `base' (and `ra') */ /***/ 554 luaV_concat(L, c-b+1, c); /* may change `base' (and `ra') */ /***/
555 luaC_checkGC(L); /***/ 555 luaC_checkGC(L); /***/
556 base = L->base; 556 base = L->base;
557 setobjs2s(RA(i), base+b); 557 setobjs2s(L, RA(i), base+b);
558 break; 558 break;
559 } 559 }
560 case OP_JMP: { 560 case OP_JMP: {
@@ -583,10 +583,10 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
583 break; 583 break;
584 } 584 }
585 case OP_TEST: { 585 case OP_TEST: {
586 TObject *rb = RB(i); 586 TValue *rb = RB(i);
587 if (l_isfalse(rb) == GETARG_C(i)) pc++; 587 if (l_isfalse(rb) == GETARG_C(i)) pc++;
588 else { 588 else {
589 setobjs2s(ra, rb); 589 setobjs2s(L, ra, rb);
590 dojump(pc, GETARG_sBx(*pc) + 1); 590 dojump(pc, GETARG_sBx(*pc) + 1);
591 } 591 }
592 break; 592 break;
@@ -617,7 +617,7 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
617 ra = RA(i); 617 ra = RA(i);
618 if (L->openupval) luaF_close(L, base); 618 if (L->openupval) luaF_close(L, base);
619 for (aux = 0; ra+aux < L->top; aux++) /* move frame down */ 619 for (aux = 0; ra+aux < L->top; aux++) /* move frame down */
620 setobjs2s(base+aux-1, ra+aux); 620 setobjs2s(L, base+aux-1, ra+aux);
621 (L->ci - 1)->top = L->top = base+aux; /* correct top */ 621 (L->ci - 1)->top = L->top = base+aux; /* correct top */
622 (L->ci - 1)->u.l.savedpc = L->ci->u.l.savedpc; 622 (L->ci - 1)->u.l.savedpc = L->ci->u.l.savedpc;
623 (L->ci - 1)->u.l.tailcalls++; /* one more call lost */ 623 (L->ci - 1)->u.l.tailcalls++; /* one more call lost */
@@ -659,9 +659,9 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
659 break; 659 break;
660 } 660 }
661 case OP_FORPREP: { /***/ 661 case OP_FORPREP: { /***/
662 const TObject *init = ra; 662 const TValue *init = ra;
663 const TObject *plimit = ra+1; 663 const TValue *plimit = ra+1;
664 const TObject *pstep = ra+2; 664 const TValue *pstep = ra+2;
665 L->ci->u.l.savedpc = pc; 665 L->ci->u.l.savedpc = pc;
666 if (!tonumber(init, ra)) 666 if (!tonumber(init, ra))
667 luaG_runerror(L, "`for' initial value must be a number"); 667 luaG_runerror(L, "`for' initial value must be a number");
@@ -675,9 +675,9 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
675 } 675 }
676 case OP_TFORLOOP: { 676 case OP_TFORLOOP: {
677 StkId cb = ra + 3; /* call base */ 677 StkId cb = ra + 3; /* call base */
678 setobjs2s(cb+2, ra+2); 678 setobjs2s(L, cb+2, ra+2);
679 setobjs2s(cb+1, ra+1); 679 setobjs2s(L, cb+1, ra+1);
680 setobjs2s(cb, ra); 680 setobjs2s(L, cb, ra);
681 L->top = cb+3; /* func. + 2 args (state and index) */ 681 L->top = cb+3; /* func. + 2 args (state and index) */
682 L->ci->u.l.savedpc = pc; 682 L->ci->u.l.savedpc = pc;
683 luaD_call(L, cb, GETARG_C(i)); /***/ 683 luaD_call(L, cb, GETARG_C(i)); /***/
@@ -687,15 +687,15 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
687 if (ttisnil(cb)) /* break loop? */ 687 if (ttisnil(cb)) /* break loop? */
688 pc++; /* skip jump (break loop) */ 688 pc++; /* skip jump (break loop) */
689 else { 689 else {
690 setobjs2s(cb-1, cb); /* save control variable */ 690 setobjs2s(L, cb-1, cb); /* save control variable */
691 dojump(pc, GETARG_sBx(*pc) + 1); /* jump back */ 691 dojump(pc, GETARG_sBx(*pc) + 1); /* jump back */
692 } 692 }
693 break; 693 break;
694 } 694 }
695 case OP_TFORPREP: { /* for compatibility only */ 695 case OP_TFORPREP: { /* for compatibility only */
696 if (ttistable(ra)) { 696 if (ttistable(ra)) {
697 setobjs2s(ra+1, ra); 697 setobjs2s(L, ra+1, ra);
698 setobj2s(ra, luaH_getstr(hvalue(gt(L)), luaS_new(L, "next"))); 698 setobj2s(L, ra, luaH_getstr(hvalue(gt(L)), luaS_new(L, "next")));
699 } 699 }
700 dojump(pc, GETARG_sBx(i)); 700 dojump(pc, GETARG_sBx(i));
701 break; 701 break;
@@ -716,8 +716,8 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
716 } 716 }
717 bc &= ~(LFIELDS_PER_FLUSH-1); /* bc = bc - bc%FPF */ 717 bc &= ~(LFIELDS_PER_FLUSH-1); /* bc = bc - bc%FPF */
718 for (; n > 0; n--) { 718 for (; n > 0; n--) {
719 TObject *val = ra+n; 719 TValue *val = ra+n;
720 setobj2t(luaH_setnum(L, h, bc+n), val); 720 setobj2t(L, luaH_setnum(L, h, bc+n), val);
721 luaC_barrier(L, h, val); 721 luaC_barrier(L, h, val);
722 } 722 }
723 break; 723 break;
@@ -742,7 +742,7 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
742 ncl->l.upvals[j] = luaF_findupval(L, base + GETARG_B(*pc)); 742 ncl->l.upvals[j] = luaF_findupval(L, base + GETARG_B(*pc));
743 } 743 }
744 } 744 }
745 setclvalue(ra, ncl); 745 setclvalue(L, ra, ncl);
746 L->ci->u.l.savedpc = pc; 746 L->ci->u.l.savedpc = pc;
747 luaC_checkGC(L); /***/ 747 luaC_checkGC(L); /***/
748 base = L->base; 748 base = L->base;