aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-06-08 16:01:38 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-06-08 16:01:38 -0300
commitcbc59592ff684b646b21766a66630df1f7974b25 (patch)
tree1e28529cda3b8f6baa63285f6a2571767c3ed05e
parent4905fdd1350bde68cd818b9198f28f5a47c208b0 (diff)
downloadlua-cbc59592ff684b646b21766a66630df1f7974b25.tar.gz
lua-cbc59592ff684b646b21766a66630df1f7974b25.tar.bz2
lua-cbc59592ff684b646b21766a66630df1f7974b25.zip
new definition for `luaD_call' and `luaD_adjusttop'
-rw-r--r--lapi.c16
-rw-r--r--lcode.c8
-rw-r--r--ldebug.c4
-rw-r--r--ldo.c55
-rw-r--r--ldo.h6
-rw-r--r--lgc.c10
-rw-r--r--lopcodes.h4
-rw-r--r--lparser.c10
-rw-r--r--lvm.c76
9 files changed, 94 insertions, 95 deletions
diff --git a/lapi.c b/lapi.c
index 7f4c6e7f..9f8eca5b 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 1.142 2001/06/05 18:17:01 roberto Exp roberto $ 2** $Id: lapi.c,v 1.143 2001/06/06 18:00:19 roberto Exp roberto $
3** Lua API 3** Lua API
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -95,11 +95,13 @@ LUA_API int lua_gettop (lua_State *L) {
95 95
96LUA_API void lua_settop (lua_State *L, int index) { 96LUA_API void lua_settop (lua_State *L, int index) {
97 lua_lock(L); 97 lua_lock(L);
98 if (index >= 0) 98 if (index >= 0) {
99 luaD_adjusttop(L, L->ci->base, index); 99 api_check(L, index <= L->stack_last - L->ci->base);
100 luaD_adjusttop(L, L->ci->base+index);
101 }
100 else { 102 else {
101 api_check(L, -(index+1) <= (L->top - L->ci->base)); 103 api_check(L, -(index+1) <= (L->top - L->ci->base));
102 L->top = L->top+index+1; /* index is negative */ 104 L->top += index+1; /* `subtract' index (index is negative) */
103 } 105 }
104 lua_unlock(L); 106 lua_unlock(L);
105} 107}
@@ -545,9 +547,13 @@ LUA_API int lua_ref (lua_State *L, int lock) {
545*/ 547*/
546 548
547LUA_API void lua_rawcall (lua_State *L, int nargs, int nresults) { 549LUA_API void lua_rawcall (lua_State *L, int nargs, int nresults) {
550 StkId func;
548 lua_lock(L); 551 lua_lock(L);
549 api_checknelems(L, nargs+1); 552 api_checknelems(L, nargs+1);
550 luaD_call(L, L->top-(nargs+1), nresults); 553 func = L->top - (nargs+1);
554 luaD_call(L, func);
555 if (nresults != LUA_MULTRET)
556 luaD_adjusttop(L, func + nresults);
551 lua_unlock(L); 557 lua_unlock(L);
552} 558}
553 559
diff --git a/lcode.c b/lcode.c
index e869dac3..ad0c05d2 100644
--- a/lcode.c
+++ b/lcode.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lcode.c,v 1.71 2001/06/07 15:01:21 roberto Exp roberto $ 2** $Id: lcode.c,v 1.72 2001/06/08 12:29:27 roberto Exp roberto $
3** Code generator for Lua 3** Code generator for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -261,10 +261,12 @@ static int number_constant (FuncState *fs, lua_Number r) {
261 261
262void luaK_setcallreturns (FuncState *fs, expdesc *e, int nresults) { 262void luaK_setcallreturns (FuncState *fs, expdesc *e, int nresults) {
263 if (e->k == VCALL) { /* expression is an open function call? */ 263 if (e->k == VCALL) { /* expression is an open function call? */
264 SETARG_C(getcode(fs, e), nresults); /* set number of results */ 264 int a = GETARG_A(getcode(fs, e));
265 int c = (nresults == LUA_MULTRET) ? NO_REG : a + nresults;
266 SETARG_C(getcode(fs, e), c);
265 if (nresults == 1) { /* `regular' expression? */ 267 if (nresults == 1) { /* `regular' expression? */
266 e->k = VNONRELOC; 268 e->k = VNONRELOC;
267 e->u.i.info = GETARG_A(getcode(fs, e)); 269 e->u.i.info = a;
268 } 270 }
269 } 271 }
270} 272}
diff --git a/ldebug.c b/ldebug.c
index 108a89c7..62372fca 100644
--- a/ldebug.c
+++ b/ldebug.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldebug.c,v 1.79 2001/06/07 14:44:51 roberto Exp roberto $ 2** $Id: ldebug.c,v 1.80 2001/06/08 12:29:27 roberto Exp roberto $
3** Debug Interface 3** Debug Interface
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -421,7 +421,7 @@ static Instruction luaG_symbexec (const Proto *pt, int lastpc, int reg) {
421 } 421 }
422 check(b > a); 422 check(b > a);
423 checkreg(pt, b-1); 423 checkreg(pt, b-1);
424 checkreg(pt, a+c-1); 424 checkreg(pt, c-1);
425 if (reg >= a) last = pc; /* affect all registers above base */ 425 if (reg >= a) last = pc; /* affect all registers above base */
426 break; 426 break;
427 } 427 }
diff --git a/ldo.c b/ldo.c
index cbaca68c..c2d0e92d 100644
--- a/ldo.c
+++ b/ldo.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldo.c,v 1.134 2001/04/11 18:39:37 roberto Exp roberto $ 2** $Id: ldo.c,v 1.135 2001/06/05 19:27:32 roberto Exp roberto $
3** Stack and Call structure of Lua 3** Stack and Call structure of Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -62,19 +62,12 @@ void luaD_stackerror (lua_State *L) {
62 62
63 63
64/* 64/*
65** Adjust stack. Set top to base+extra, pushing NILs if needed. 65** adjust top to new value; assume that new top is valid
66** (we cannot add base+extra unless we are sure it fits in the stack;
67** otherwise the result of such operation on pointers is undefined)
68*/ 66*/
69void luaD_adjusttop (lua_State *L, StkId base, int extra) { 67void luaD_adjusttop (lua_State *L, StkId newtop) {
70 int diff = extra-(L->top-base); 68 while (L->top < newtop)
71 if (diff <= 0) 69 setnilvalue(L->top++);
72 L->top = base+extra; 70 L->top = newtop; /* `newtop' could be lower than `top' */
73 else {
74 luaD_checkstack(L, diff);
75 while (diff--)
76 setnilvalue(L->top++);
77 }
78} 71}
79 72
80 73
@@ -140,11 +133,10 @@ static StkId callCclosure (lua_State *L, const struct Closure *cl) {
140/* 133/*
141** Call a function (C or Lua). The function to be called is at *func. 134** Call a function (C or Lua). The function to be called is at *func.
142** The arguments are on the stack, right after the function. 135** The arguments are on the stack, right after the function.
143** When returns, the results are on the stack, starting at the original 136** When returns, all the results are on the stack, starting at the original
144** function position. 137** function position.
145** The number of results is nResults, unless nResults=LUA_MULTRET.
146*/ 138*/
147void luaD_call (lua_State *L, StkId func, int nResults) { 139void luaD_call (lua_State *L, StkId func) {
148 lua_Hook callhook; 140 lua_Hook callhook;
149 StkId firstResult; 141 StkId firstResult;
150 CallInfo ci; 142 CallInfo ci;
@@ -168,20 +160,9 @@ void luaD_call (lua_State *L, StkId func, int nResults) {
168 luaD_callHook(L, callhook, l_s("return")); 160 luaD_callHook(L, callhook, l_s("return"));
169 L->ci = ci.prev; /* unchain callinfo */ 161 L->ci = ci.prev; /* unchain callinfo */
170 /* move results to `func' (to erase parameters and function) */ 162 /* move results to `func' (to erase parameters and function) */
171 if (nResults == LUA_MULTRET) { 163 while (firstResult < L->top)
172 while (firstResult < L->top) /* copy all results */ 164 setobj(func++, firstResult++);
173 setobj(func++, firstResult++); 165 L->top = func;
174 L->top = func;
175 }
176 else { /* copy at most `nResults' */
177 for (; nResults > 0 && firstResult < L->top; nResults--)
178 setobj(func++, firstResult++);
179 L->top = func;
180 for (; nResults > 0; nResults--) { /* if there are not enough results */
181 setnilvalue(L->top); /* adjust the stack */
182 incr_top; /* must check stack space */
183 }
184 }
185 luaC_checkGC(L); 166 luaC_checkGC(L);
186} 167}
187 168
@@ -196,7 +177,9 @@ struct CallS { /* data to `f_call' */
196 177
197static void f_call (lua_State *L, void *ud) { 178static void f_call (lua_State *L, void *ud) {
198 struct CallS *c = (struct CallS *)ud; 179 struct CallS *c = (struct CallS *)ud;
199 luaD_call(L, c->func, c->nresults); 180 luaD_call(L, c->func);
181 if (c->nresults != LUA_MULTRET)
182 luaD_adjusttop(L, c->func + c->nresults);
200} 183}
201 184
202 185
@@ -307,12 +290,14 @@ struct lua_longjmp {
307 290
308 291
309static void message (lua_State *L, const l_char *s) { 292static void message (lua_State *L, const l_char *s) {
310 luaV_getglobal(L, luaS_newliteral(L, l_s(LUA_ERRORMESSAGE)), L->top); 293 StkId top = L->top;
311 if (ttype(L->top) == LUA_TFUNCTION) { 294 luaV_getglobal(L, luaS_newliteral(L, l_s(LUA_ERRORMESSAGE)), top);
295 if (ttype(top) == LUA_TFUNCTION) {
312 incr_top; 296 incr_top;
313 setsvalue(L->top, luaS_new(L, s)); 297 setsvalue(top+1, luaS_new(L, s));
314 incr_top; 298 incr_top;
315 luaD_call(L, L->top-2, 0); 299 luaD_call(L, top);
300 L->top = top;
316 } 301 }
317} 302}
318 303
diff --git a/ldo.h b/ldo.h
index eda4f526..618e8bee 100644
--- a/ldo.h
+++ b/ldo.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldo.h,v 1.32 2001/03/07 18:09:25 roberto Exp roberto $ 2** $Id: ldo.h,v 1.33 2001/06/05 19:41:24 roberto Exp roberto $
3** Stack and Call structure of Lua 3** Stack and Call structure of Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -23,9 +23,9 @@
23 23
24 24
25void luaD_init (lua_State *L, int stacksize); 25void luaD_init (lua_State *L, int stacksize);
26void luaD_adjusttop (lua_State *L, StkId base, int extra); 26void luaD_adjusttop (lua_State *L, StkId newtop);
27void luaD_lineHook (lua_State *L, int line, lua_Hook linehook); 27void luaD_lineHook (lua_State *L, int line, lua_Hook linehook);
28void luaD_call (lua_State *L, StkId func, int nResults); 28void luaD_call (lua_State *L, StkId func);
29void luaD_stackerror (lua_State *L); 29void luaD_stackerror (lua_State *L);
30 30
31void luaD_error (lua_State *L, const l_char *s); 31void luaD_error (lua_State *L, const l_char *s);
diff --git a/lgc.c b/lgc.c
index fcd22a86..e7d533d3 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.c,v 1.100 2001/06/06 18:00:19 roberto Exp roberto $ 2** $Id: lgc.c,v 1.101 2001/06/07 15:01:21 roberto Exp roberto $
3** Garbage Collector 3** Garbage Collector
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -338,12 +338,14 @@ static void callgcTM (lua_State *L, const TObject *obj) {
338 Closure *tm = luaT_gettmbyObj(G(L), obj, TM_GC); 338 Closure *tm = luaT_gettmbyObj(G(L), obj, TM_GC);
339 if (tm != NULL) { 339 if (tm != NULL) {
340 int oldah = L->allowhooks; 340 int oldah = L->allowhooks;
341 StkId top = L->top;
341 L->allowhooks = 0; /* stop debug hooks during GC tag methods */ 342 L->allowhooks = 0; /* stop debug hooks during GC tag methods */
342 luaD_checkstack(L, 2); 343 luaD_checkstack(L, 2);
343 setclvalue(L->top, tm); 344 setclvalue(top, tm);
344 setobj(L->top+1, obj); 345 setobj(top+1, obj);
345 L->top += 2; 346 L->top += 2;
346 luaD_call(L, L->top-2, 0); 347 luaD_call(L, top);
348 L->top = top; /* restore top */
347 L->allowhooks = oldah; /* restore hooks */ 349 L->allowhooks = oldah; /* restore hooks */
348 } 350 }
349} 351}
diff --git a/lopcodes.h b/lopcodes.h
index 5819c407..bbca12d9 100644
--- a/lopcodes.h
+++ b/lopcodes.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lopcodes.h,v 1.72 2001/04/06 18:25:00 roberto Exp roberto $ 2** $Id: lopcodes.h,v 1.73 2001/06/05 18:17:01 roberto Exp roberto $
3** Opcodes for Lua virtual machine 3** Opcodes for Lua virtual machine
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -165,7 +165,7 @@ OP_TESTF,/* A B test := not R(B); if (test) R(A) := nil */
165 165
166OP_NILJMP,/* A R(A) := nil; PC++; */ 166OP_NILJMP,/* A R(A) := nil; PC++; */
167 167
168OP_CALL,/* A B C R(A), ... ,R(A+C-1) := R(A)(R(A+1), ... ,R(B-1))*/ 168OP_CALL,/* A B C R(A), ... ,R(C-1) := R(A)(R(A+1), ... ,R(B-1)) */
169OP_RETURN,/* A B return R(A), ... ,R(B-1) (see (3)) */ 169OP_RETURN,/* A B return R(A), ... ,R(B-1) (see (3)) */
170 170
171OP_FORPREP,/* A sBc */ 171OP_FORPREP,/* A sBc */
diff --git a/lparser.c b/lparser.c
index 78b91cd6..8dff5638 100644
--- a/lparser.c
+++ b/lparser.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lparser.c,v 1.145 2001/06/07 14:44:51 roberto Exp roberto $ 2** $Id: lparser.c,v 1.146 2001/06/08 12:29:27 roberto Exp roberto $
3** LL(1) Parser and code generator for Lua 3** LL(1) Parser and code generator for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -424,7 +424,7 @@ static void funcargs (LexState *ls, expdesc *f) {
424 args.k = VVOID; 424 args.k = VVOID;
425 else { 425 else {
426 explist1(ls, &args); 426 explist1(ls, &args);
427 luaK_setcallreturns(fs, &args, NO_REG); 427 luaK_setcallreturns(fs, &args, LUA_MULTRET);
428 } 428 }
429 check_match(ls, l_c(')'), l_c('('), line); 429 check_match(ls, l_c(')'), l_c('('), line);
430 break; 430 break;
@@ -452,7 +452,7 @@ static void funcargs (LexState *ls, expdesc *f) {
452 luaK_exp2nextreg(fs, &args); /* close last argument */ 452 luaK_exp2nextreg(fs, &args); /* close last argument */
453 top = fs->freereg; 453 top = fs->freereg;
454 } 454 }
455 init_exp(f, VCALL, luaK_codeABC(fs, OP_CALL, base, top, 1)); 455 init_exp(f, VCALL, luaK_codeABC(fs, OP_CALL, base, top, base+1));
456 fs->freereg = base+1; /* call remove function and arguments and leaves 456 fs->freereg = base+1; /* call remove function and arguments and leaves
457 (unless changed) one result */ 457 (unless changed) one result */
458} 458}
@@ -530,7 +530,7 @@ static int listfields (LexState *ls, expdesc *t) {
530 n++; 530 n++;
531 } 531 }
532 if (v.k == VCALL) { 532 if (v.k == VCALL) {
533 luaK_setcallreturns(fs, &v, NO_REG); 533 luaK_setcallreturns(fs, &v, LUA_MULTRET);
534 luaK_codeABc(fs, OP_SETLISTO, t->u.i.info, n-1); 534 luaK_codeABc(fs, OP_SETLISTO, t->u.i.info, n-1);
535 } 535 }
536 else { 536 else {
@@ -1098,7 +1098,7 @@ static void retstat (LexState *ls) {
1098 else { 1098 else {
1099 int n = explist1(ls, &e); /* optional return values */ 1099 int n = explist1(ls, &e); /* optional return values */
1100 if (e.k == VCALL) { 1100 if (e.k == VCALL) {
1101 luaK_setcallreturns(fs, &e, NO_REG); 1101 luaK_setcallreturns(fs, &e, LUA_MULTRET);
1102 first = fs->nactloc; 1102 first = fs->nactloc;
1103 last1 = NO_REG; /* return all values */ 1103 last1 = NO_REG; /* return all values */
1104 } 1104 }
diff --git a/lvm.c b/lvm.c
index 29a6ea4d..c775b6c5 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 1.180 2001/06/05 19:27:32 roberto Exp roberto $ 2** $Id: lvm.c,v 1.181 2001/06/08 12:29:27 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*/
@@ -106,33 +106,35 @@ void luaV_Lclosure (lua_State *L, Proto *l, int nelems) {
106} 106}
107 107
108 108
109static void callTM (lua_State *L, const l_char *fmt, ...) { 109static void callTM (lua_State *L, Closure *f, const l_char *fmt, ...) {
110 va_list argp; 110 va_list argp;
111 StkId base = L->top; 111 StkId base = L->top;
112 int has_result = 0; 112 StkId result = NULL; /* result position */
113 va_start(argp, fmt); 113 va_start(argp, fmt);
114 setclvalue(L->top, f); /* push function */
115 incr_top;
116 if (*fmt == l_c('r')) {
117 fmt++;
118 result = va_arg(argp, TObject *); /* result position */
119 }
114 while (*fmt) { 120 while (*fmt) {
115 switch (*fmt++) { 121 if (*fmt++ == l_c('o')) {
116 case l_c('c'):
117 setclvalue(L->top, va_arg(argp, Closure *));
118 break;
119 case l_c('o'):
120 setobj(L->top, va_arg(argp, TObject *)); 122 setobj(L->top, va_arg(argp, TObject *));
121 break; 123 }
122 case l_c('s'): 124 else {
123 setsvalue(L->top, va_arg(argp, TString *)); 125 lua_assert(*(fmt-1) == l_c('s'));
124 break; 126 setsvalue(L->top, va_arg(argp, TString *));
125 case l_c('r'):
126 has_result = 1;
127 continue;
128 } 127 }
129 incr_top; 128 incr_top;
130 } 129 }
131 luaD_call(L, base, has_result); 130 luaD_call(L, base);
132 if (has_result) { 131 if (result) { /* need result? */
133 L->top--; 132 if (L->top == base) /* are there valid results? */
134 setobj(va_arg(argp, TObject *), L->top); 133 setnilvalue(result); /* function had no results */
134 else
135 setobj(result, base); /* get first result */
135 } 136 }
137 L->top = base; /* restore top */
136 va_end(argp); 138 va_end(argp);
137} 139}
138 140
@@ -162,7 +164,7 @@ void luaV_gettable (lua_State *L, StkId t, TObject *key, StkId res) {
162 if (tm == NULL) /* no tag method? */ 164 if (tm == NULL) /* no tag method? */
163 luaG_typeerror(L, t, l_s("index")); 165 luaG_typeerror(L, t, l_s("index"));
164 } 166 }
165 callTM(L, l_s("coor"), tm, t, key, res); 167 callTM(L, tm, l_s("roo"), res, t, key);
166} 168}
167 169
168 170
@@ -185,7 +187,7 @@ void luaV_settable (lua_State *L, StkId t, TObject *key, StkId val) {
185 if (tm == NULL) /* no tag method? */ 187 if (tm == NULL) /* no tag method? */
186 luaG_typeerror(L, t, l_s("index")); 188 luaG_typeerror(L, t, l_s("index"));
187 } 189 }
188 callTM(L, l_s("cooo"), tm, t, key, val); 190 callTM(L, tm, l_s("ooo"), t, key, val);
189} 191}
190 192
191 193
@@ -196,7 +198,7 @@ void luaV_getglobal (lua_State *L, TString *name, StkId res) {
196 (tm = luaT_gettmbyObj(G(L), value, TM_GETGLOBAL)) == NULL) { 198 (tm = luaT_gettmbyObj(G(L), value, TM_GETGLOBAL)) == NULL) {
197 setobj(res, value); /* default behavior */ 199 setobj(res, value); /* default behavior */
198 } else 200 } else
199 callTM(L, l_s("csor"), tm, name, value, res); 201 callTM(L, tm, l_s("rso"), res, name, value);
200} 202}
201 203
202 204
@@ -207,7 +209,7 @@ void luaV_setglobal (lua_State *L, TString *name, StkId val) {
207 (tm = luaT_gettmbyObj(G(L), oldvalue, TM_SETGLOBAL)) == NULL) { 209 (tm = luaT_gettmbyObj(G(L), oldvalue, TM_SETGLOBAL)) == NULL) {
208 setobj(oldvalue, val); /* raw set */ 210 setobj(oldvalue, val); /* raw set */
209 } else 211 } else
210 callTM(L, l_s("csoo"), tm, name, oldvalue, val); 212 callTM(L, tm, l_s("soo"), name, oldvalue, val);
211} 213}
212 214
213 215
@@ -224,7 +226,7 @@ static int call_binTM (lua_State *L, const TObject *p1, const TObject *p2,
224 } 226 }
225 } 227 }
226 opname = luaS_new(L, luaT_eventname[event]); 228 opname = luaS_new(L, luaT_eventname[event]);
227 callTM(L, l_s("coosr"), tm, p1, p2, opname, res); 229 callTM(L, tm, l_s("roos"), res, p1, p2, opname);
228 return 1; 230 return 1;
229} 231}
230 232
@@ -320,9 +322,12 @@ static void luaV_pack (lua_State *L, StkId firstelem) {
320 322
321static void adjust_varargs (lua_State *L, StkId base, int nfixargs) { 323static void adjust_varargs (lua_State *L, StkId base, int nfixargs) {
322 int nvararg = (L->top-base) - nfixargs; 324 int nvararg = (L->top-base) - nfixargs;
323 if (nvararg < 0) 325 StkId firstvar = base + nfixargs; /* position of first vararg */
324 luaD_adjusttop(L, base, nfixargs); 326 if (nvararg < 0) {
325 luaV_pack(L, base+nfixargs); 327 luaD_checkstack(L, -nvararg);
328 luaD_adjusttop(L, firstvar);
329 }
330 luaV_pack(L, firstvar);
326} 331}
327 332
328 333
@@ -368,7 +373,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) {
368 luaD_stackerror(L); 373 luaD_stackerror(L);
369 while (L->top < base+tf->maxstacksize) 374 while (L->top < base+tf->maxstacksize)
370 setnilvalue(L->top++); 375 setnilvalue(L->top++);
371 L->top = base+tf->maxstacksize; 376 L->top = base + tf->maxstacksize;
372 pc = tf->code; 377 pc = tf->code;
373 L->ci->pc = &pc; 378 L->ci->pc = &pc;
374 linehook = L->linehook; 379 linehook = L->linehook;
@@ -544,16 +549,15 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) {
544 break; 549 break;
545 } 550 }
546 case OP_CALL: { 551 case OP_CALL: {
547 int nres; 552 int c;
548 int b = GETARG_B(i); 553 int b = GETARG_B(i);
549 if (b != NO_REG) 554 if (b != NO_REG)
550 L->top = base+b; 555 L->top = base+b;
551 nres = GETARG_C(i); 556 luaD_call(L, ra);
552 if (nres == NO_REG) nres = LUA_MULTRET; 557 c = GETARG_C(i);
553 luaD_call(L, ra, nres); 558 if (c != NO_REG) {
554 if (nres != LUA_MULTRET) { 559 while (L->top < base+c) setnilvalue(L->top++);
555 lua_assert(L->top == ra+nres); 560 L->top = base + tf->maxstacksize;
556 L->top = base+tf->maxstacksize;
557 } 561 }
558 break; 562 break;
559 } 563 }
@@ -637,7 +641,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) {
637 luaV_checkGC(L, ra+nup); 641 luaV_checkGC(L, ra+nup);
638 L->top = ra+nup; 642 L->top = ra+nup;
639 luaV_Lclosure(L, p, nup); 643 luaV_Lclosure(L, p, nup);
640 L->top = base+tf->maxstacksize; 644 L->top = base + tf->maxstacksize;
641 break; 645 break;
642 } 646 }
643 } 647 }