diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-08-29 11:48:16 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-08-29 11:48:16 -0300 |
| commit | 9d605982605db5ab8117b4cda71284bca2d25db8 (patch) | |
| tree | 968b70b828f62ee945134424fbec866b4fc0f1bc | |
| parent | 4e56c0d51412817a238f9de6453aaa16704a770d (diff) | |
| download | lua-9d605982605db5ab8117b4cda71284bca2d25db8.tar.gz lua-9d605982605db5ab8117b4cda71284bca2d25db8.tar.bz2 lua-9d605982605db5ab8117b4cda71284bca2d25db8.zip | |
better definitions for MULTRET
| -rw-r--r-- | ldo.c | 9 | ||||
| -rw-r--r-- | ldo.h | 3 | ||||
| -rw-r--r-- | llimits.h | 10 | ||||
| -rw-r--r-- | lopcodes.h | 11 | ||||
| -rw-r--r-- | lvm.c | 8 |
5 files changed, 21 insertions, 20 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ldo.c,v 1.86 2000/08/28 17:57:04 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 1.87 2000/08/29 14:33:31 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 | */ |
| @@ -92,7 +92,7 @@ void luaD_adjusttop (lua_State *L, StkId base, int extra) { | |||
| 92 | /* | 92 | /* |
| 93 | ** Open a hole inside the stack at `pos' | 93 | ** Open a hole inside the stack at `pos' |
| 94 | */ | 94 | */ |
| 95 | void luaD_openstack (lua_State *L, StkId pos) { | 95 | static void luaD_openstack (lua_State *L, StkId pos) { |
| 96 | int i = L->top-pos; | 96 | int i = L->top-pos; |
| 97 | while (i--) pos[i+1] = pos[i]; | 97 | while (i--) pos[i+1] = pos[i]; |
| 98 | incr_top; | 98 | incr_top; |
| @@ -160,7 +160,7 @@ void luaD_callTM (lua_State *L, const TObject *f, int nParams, int nResults) { | |||
| 160 | ** The arguments are on the stack, right after the function. | 160 | ** The arguments are on the stack, right after the function. |
| 161 | ** When returns, the results are on the stack, starting at the original | 161 | ** When returns, the results are on the stack, starting at the original |
| 162 | ** function position. | 162 | ** function position. |
| 163 | ** The number of results is nResults, unless nResults=MULT_RET. | 163 | ** The number of results is nResults, unless nResults=LUA_MULTRET. |
| 164 | */ | 164 | */ |
| 165 | void luaD_call (lua_State *L, StkId func, int nResults) { | 165 | void luaD_call (lua_State *L, StkId func, int nResults) { |
| 166 | StkId firstResult; | 166 | StkId firstResult; |
| @@ -197,7 +197,7 @@ void luaD_call (lua_State *L, StkId func, int nResults) { | |||
| 197 | if (callhook) /* same hook that was active at entry */ | 197 | if (callhook) /* same hook that was active at entry */ |
| 198 | luaD_callHook(L, func, callhook, "return"); | 198 | luaD_callHook(L, func, callhook, "return"); |
| 199 | /* adjust the number of results */ | 199 | /* adjust the number of results */ |
| 200 | if (nResults == MULT_RET) | 200 | if (nResults == LUA_MULTRET) |
| 201 | nResults = L->top - firstResult; | 201 | nResults = L->top - firstResult; |
| 202 | else | 202 | else |
| 203 | luaD_adjusttop(L, firstResult, nResults); | 203 | luaD_adjusttop(L, firstResult, nResults); |
| @@ -264,7 +264,6 @@ int lua_call (lua_State *L, int nargs, int nresults) { | |||
| 264 | StkId func = L->top - (nargs+1); /* function to be called */ | 264 | StkId func = L->top - (nargs+1); /* function to be called */ |
| 265 | struct lua_longjmp myErrorJmp; | 265 | struct lua_longjmp myErrorJmp; |
| 266 | chain_longjmp(L, &myErrorJmp); | 266 | chain_longjmp(L, &myErrorJmp); |
| 267 | if (nresults == LUA_MULTRET) nresults = MULT_RET; /* internal code */ | ||
| 268 | if (setjmp(myErrorJmp.b) == 0) { | 267 | if (setjmp(myErrorJmp.b) == 0) { |
| 269 | luaD_call(L, func, nresults); | 268 | luaD_call(L, func, nresults); |
| 270 | } | 269 | } |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ldo.h,v 1.22 2000/08/07 18:39:16 roberto Exp roberto $ | 2 | ** $Id: ldo.h,v 1.23 2000/08/28 17:57:04 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 | */ |
| @@ -21,7 +21,6 @@ | |||
| 21 | 21 | ||
| 22 | void luaD_init (lua_State *L, int stacksize); | 22 | void luaD_init (lua_State *L, int stacksize); |
| 23 | void luaD_adjusttop (lua_State *L, StkId base, int extra); | 23 | void luaD_adjusttop (lua_State *L, StkId base, int extra); |
| 24 | void luaD_openstack (lua_State *L, StkId pos); | ||
| 25 | void luaD_lineHook (lua_State *L, StkId func, int line, lua_Hook linehook); | 24 | void luaD_lineHook (lua_State *L, StkId func, int line, lua_Hook linehook); |
| 26 | void luaD_call (lua_State *L, StkId func, int nResults); | 25 | void luaD_call (lua_State *L, StkId func, int nResults); |
| 27 | void luaD_callTM (lua_State *L, const TObject *f, int nParams, int nResults); | 26 | void luaD_callTM (lua_State *L, const TObject *f, int nParams, int nResults); |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: llimits.h,v 1.12 2000/08/15 18:28:48 roberto Exp roberto $ | 2 | ** $Id: llimits.h,v 1.13 2000/08/28 17:57:04 roberto Exp roberto $ |
| 3 | ** Limits, basic types, and some other "installation-dependent" definitions | 3 | ** Limits, basic types, and some other "installation-dependent" definitions |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -157,14 +157,6 @@ typedef unsigned long Instruction; | |||
| 157 | #endif | 157 | #endif |
| 158 | 158 | ||
| 159 | 159 | ||
| 160 | /* special code for multiple returns */ | ||
| 161 | #define MULT_RET 255 /* (<=MAXARG_B) */ | ||
| 162 | #if MULT_RET>MAXARG_B | ||
| 163 | #undef MULT_RET | ||
| 164 | #define MULT_RET MAXARG_B | ||
| 165 | #endif | ||
| 166 | |||
| 167 | |||
| 168 | /* maximum number of variables in the left side of an assignment */ | 160 | /* maximum number of variables in the left side of an assignment */ |
| 169 | #ifndef MAXVARSLH | 161 | #ifndef MAXVARSLH |
| 170 | #define MAXVARSLH 100 /* arbitrary limit (<MULT_RET) */ | 162 | #define MAXVARSLH 100 /* arbitrary limit (<MULT_RET) */ |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lopcodes.h,v 1.65 2000/06/26 19:28:31 roberto Exp roberto $ | 2 | ** $Id: lopcodes.h,v 1.66 2000/08/15 18:28:48 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 | */ |
| @@ -156,4 +156,13 @@ OP_CLOSURE/* A B v_b-v_1 closure(KPROTO[a], v_1-v_b) */ | |||
| 156 | #define ISJUMP(o) (OP_JMPNE <= (o) && (o) <= OP_JMP) | 156 | #define ISJUMP(o) (OP_JMPNE <= (o) && (o) <= OP_JMP) |
| 157 | 157 | ||
| 158 | 158 | ||
| 159 | |||
| 160 | /* special code to fit a LUA_MULTRET inside an argB */ | ||
| 161 | #define MULT_RET 255 /* (<=MAXARG_B) */ | ||
| 162 | #if MULT_RET>MAXARG_B | ||
| 163 | #undef MULT_RET | ||
| 164 | #define MULT_RET MAXARG_B | ||
| 165 | #endif | ||
| 166 | |||
| 167 | |||
| 159 | #endif | 168 | #endif |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lvm.c,v 1.129 2000/08/22 20:53:30 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 1.130 2000/08/29 14:41:56 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 | */ |
| @@ -368,14 +368,16 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) { | |||
| 368 | return base+GETARG_U(i); | 368 | return base+GETARG_U(i); |
| 369 | } | 369 | } |
| 370 | case OP_CALL: { | 370 | case OP_CALL: { |
| 371 | int nres = GETARG_B(i); | ||
| 372 | if (nres == MULT_RET) nres = LUA_MULTRET; | ||
| 371 | L->top = top; | 373 | L->top = top; |
| 372 | luaD_call(L, base+GETARG_A(i), GETARG_B(i)); | 374 | luaD_call(L, base+GETARG_A(i), nres); |
| 373 | top = L->top; | 375 | top = L->top; |
| 374 | break; | 376 | break; |
| 375 | } | 377 | } |
| 376 | case OP_TAILCALL: { | 378 | case OP_TAILCALL: { |
| 377 | L->top = top; | 379 | L->top = top; |
| 378 | luaD_call(L, base+GETARG_A(i), MULT_RET); | 380 | luaD_call(L, base+GETARG_A(i), LUA_MULTRET); |
| 379 | return base+GETARG_B(i); | 381 | return base+GETARG_B(i); |
| 380 | } | 382 | } |
| 381 | case OP_PUSHNIL: { | 383 | case OP_PUSHNIL: { |
