summaryrefslogtreecommitdiff
path: root/lvm.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2008-08-26 10:27:42 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2008-08-26 10:27:42 -0300
commitf94cd2201c3a8d341db448f2719dfb0ae4338adf (patch)
tree34f49a3e607098699b1f9e3af9358c062ec8425e /lvm.c
parentfdbb243ff9980870c54676f3b2597b110ab82864 (diff)
downloadlua-f94cd2201c3a8d341db448f2719dfb0ae4338adf.tar.gz
lua-f94cd2201c3a8d341db448f2719dfb0ae4338adf.tar.bz2
lua-f94cd2201c3a8d341db448f2719dfb0ae4338adf.zip
better control of call status through CallInfo
Diffstat (limited to 'lvm.c')
-rw-r--r--lvm.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/lvm.c b/lvm.c
index c499913a..e18afe52 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 2.74 2008/04/02 16:16:06 roberto Exp roberto $ 2** $Id: lvm.c,v 2.75 2008/08/13 17:02:42 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*/
@@ -280,11 +280,14 @@ void luaV_concat (lua_State *L, int total, int last) {
280 if (!(ttisstring(top-2) || ttisnumber(top-2)) || !tostring(L, top-1)) { 280 if (!(ttisstring(top-2) || ttisnumber(top-2)) || !tostring(L, top-1)) {
281 if (!call_binTM(L, top-2, top-1, top-2, TM_CONCAT)) 281 if (!call_binTM(L, top-2, top-1, top-2, TM_CONCAT))
282 luaG_concaterror(L, top-2, top-1); 282 luaG_concaterror(L, top-2, top-1);
283 } else if (tsvalue(top-1)->len == 0) { /* second operand is empty? */ 283 }
284 else if (tsvalue(top-1)->len == 0) { /* second operand is empty? */
284 (void)tostring(L, top - 2); /* result is first operand */ ; 285 (void)tostring(L, top - 2); /* result is first operand */ ;
285 } else if (ttisstring(top-2) && tsvalue(top-2)->len == 0) { 286 }
287 else if (ttisstring(top-2) && tsvalue(top-2)->len == 0) {
286 setsvalue2s(L, top-2, rawtsvalue(top-1)); /* result is second op. */ 288 setsvalue2s(L, top-2, rawtsvalue(top-1)); /* result is second op. */
287 } else { 289 }
290 else {
288 /* at least two (non-empty) string values; get as many as possible */ 291 /* at least two (non-empty) string values; get as many as possible */
289 size_t tl = tsvalue(top-1)->len; 292 size_t tl = tsvalue(top-1)->len;
290 char *buffer; 293 char *buffer;
@@ -397,7 +400,7 @@ static void Arith (lua_State *L, StkId ra, const TValue *rb,
397 400
398 401
399 402
400void luaV_execute (lua_State *L, int nexeccalls) { 403void luaV_execute (lua_State *L) {
401 LClosure *cl; 404 LClosure *cl;
402 StkId base; 405 StkId base;
403 TValue *k; 406 TValue *k;
@@ -601,7 +604,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
601 continue; 604 continue;
602 } 605 }
603 else { /* Lua function */ 606 else { /* Lua function */
604 nexeccalls++; 607 L->ci->callstatus |= CIST_REENTRY;
605 goto reentry; /* restart luaV_execute over new Lua function */ 608 goto reentry; /* restart luaV_execute over new Lua function */
606 } 609 }
607 } 610 }
@@ -636,9 +639,9 @@ void luaV_execute (lua_State *L, int nexeccalls) {
636 if (b != 0) L->top = ra+b-1; 639 if (b != 0) L->top = ra+b-1;
637 if (L->openupval) luaF_close(L, base); 640 if (L->openupval) luaF_close(L, base);
638 b = luaD_poscall(L, ra); 641 b = luaD_poscall(L, ra);
639 if (--nexeccalls == 0) /* was previous function running `here'? */ 642 if (!((L->ci + 1)->callstatus & CIST_REENTRY))
640 return; /* no: return */ 643 return; /* external invocation: return */
641 else { /* yes: continue its execution */ 644 else { /* invocation via reentry: continue execution */
642 if (b) L->top = L->ci->top; 645 if (b) L->top = L->ci->top;
643 lua_assert(isLua(L->ci)); 646 lua_assert(isLua(L->ci));
644 lua_assert(GET_OPCODE(*((L->ci)->savedpc - 1)) == OP_CALL); 647 lua_assert(GET_OPCODE(*((L->ci)->savedpc - 1)) == OP_CALL);