aboutsummaryrefslogtreecommitdiff
path: root/ldo.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-08-29 11:33:31 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-08-29 11:33:31 -0300
commitac12f4db4b2f715b1556722b6ed65804cfd6348a (patch)
tree4c15a7988e19c766ed9e88451db92140200fd041 /ldo.c
parentb691d4344bb67a1a09203466812877595b3bd744 (diff)
downloadlua-ac12f4db4b2f715b1556722b6ed65804cfd6348a.tar.gz
lua-ac12f4db4b2f715b1556722b6ed65804cfd6348a.tar.bz2
lua-ac12f4db4b2f715b1556722b6ed65804cfd6348a.zip
C upvalues are the last arguments to a function
Diffstat (limited to 'ldo.c')
-rw-r--r--ldo.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/ldo.c b/ldo.c
index 074638c3..f2e36f67 100644
--- a/ldo.c
+++ b/ldo.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldo.c,v 1.85 2000/08/10 19:50:47 roberto Exp roberto $ 2** $Id: ldo.c,v 1.86 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*/
@@ -136,20 +136,14 @@ static void luaD_callHook (lua_State *L, StkId func, lua_Hook callhook,
136static StkId callCclosure (lua_State *L, const struct Closure *cl, StkId base) { 136static StkId callCclosure (lua_State *L, const struct Closure *cl, StkId base) {
137 int nup = cl->nupvalues; /* number of upvalues */ 137 int nup = cl->nupvalues; /* number of upvalues */
138 StkId old_Cbase = L->Cbase; 138 StkId old_Cbase = L->Cbase;
139 int nres; /* number of results */ 139 int n;
140 if (nup > 0) {
141 int n = L->top - base; /* number of arguments */
142 luaD_checkstack(L, nup);
143 /* open space for upvalues as extra arguments */
144 while (n--) *(base+nup+n) = *(base+n);
145 L->top += nup;
146 /* copy upvalues into stack */
147 while (nup--) *(base+nup) = cl->upvalue[nup];
148 }
149 L->Cbase = base; /* new base for C function */ 140 L->Cbase = base; /* new base for C function */
150 nres = (*cl->f.c)(L); /* do the actual call */ 141 luaD_checkstack(L, nup);
142 for (n=0; n<nup; n++) /* copy upvalues as extra arguments */
143 *(L->top++) = cl->upvalue[n];
144 n = (*cl->f.c)(L); /* do the actual call */
151 L->Cbase = old_Cbase; /* restore old C base */ 145 L->Cbase = old_Cbase; /* restore old C base */
152 return L->top - nres; /* return index of first result */ 146 return L->top - n; /* return index of first result */
153} 147}
154 148
155 149