diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-10-17 19:12:57 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-10-17 19:12:57 -0200 |
commit | 1e81da51bab87148981486a84b846399050f4ef2 (patch) | |
tree | d2c94326ca096e032d1ae3fa75a5d0605f494cc6 /ldo.c | |
parent | 7cd37142f404462634a5049a840f572e85c5762b (diff) | |
download | lua-1e81da51bab87148981486a84b846399050f4ef2.tar.gz lua-1e81da51bab87148981486a84b846399050f4ef2.tar.bz2 lua-1e81da51bab87148981486a84b846399050f4ef2.zip |
new API for registry and C upvalues + new implementation for references
Diffstat (limited to 'ldo.c')
-rw-r--r-- | ldo.c | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldo.c,v 1.141 2001/09/25 17:05:49 roberto Exp $ | 2 | ** $Id: ldo.c,v 1.142 2001/10/02 16:45:03 roberto Exp $ |
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 | */ |
@@ -44,7 +44,8 @@ void luaD_init (lua_State *L, int stacksize) { | |||
44 | stacksize += EXTRA_STACK; | 44 | stacksize += EXTRA_STACK; |
45 | L->stack = luaM_newvector(L, stacksize, TObject); | 45 | L->stack = luaM_newvector(L, stacksize, TObject); |
46 | L->stacksize = stacksize; | 46 | L->stacksize = stacksize; |
47 | L->basefunc.base = L->top = L->stack; | 47 | setnilvalue(L->stack); /* the `initial' function */ |
48 | L->top = L->basefunc.base = L->stack + 1; | ||
48 | restore_stack_limit(L); | 49 | restore_stack_limit(L); |
49 | } | 50 | } |
50 | 51 | ||
@@ -119,12 +120,12 @@ static void luaD_callHook (lua_State *L, lua_Hook callhook, | |||
119 | 120 | ||
120 | 121 | ||
121 | static StkId callCclosure (lua_State *L, const struct CClosure *cl) { | 122 | static StkId callCclosure (lua_State *L, const struct CClosure *cl) { |
122 | int nup = cl->nupvalues; /* number of upvalues */ | ||
123 | int n; | 123 | int n; |
124 | luaD_checkstack(L, nup+LUA_MINSTACK); /* ensure minimum stack size */ | 124 | luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ |
125 | for (n=0; n<nup; n++) /* copy upvalues as extra arguments */ | ||
126 | setobj(L->top++, &cl->upvalue[n]); | ||
127 | lua_unlock(L); | 125 | lua_unlock(L); |
126 | #if LUA_COMPATUPVALUES | ||
127 | lua_pushupvalues(L); | ||
128 | #endif | ||
128 | n = (*cl->f)(L); /* do the actual call */ | 129 | n = (*cl->f)(L); /* do the actual call */ |
129 | lua_lock(L); | 130 | lua_lock(L); |
130 | return L->top - n; /* return index of first result */ | 131 | return L->top - n; /* return index of first result */ |