aboutsummaryrefslogtreecommitdiff
path: root/ldo.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-12-18 16:32:39 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-12-18 16:32:39 -0200
commitde79e7fc586c0b60a04823c0e930b227af2828d8 (patch)
treee48cd57eba16106100fb18e2bd2c1ab19f841347 /ldo.c
parent8b5b42563c317f83318a0386551f0f0252e387dc (diff)
downloadlua-de79e7fc586c0b60a04823c0e930b227af2828d8.tar.gz
lua-de79e7fc586c0b60a04823c0e930b227af2828d8.tar.bz2
lua-de79e7fc586c0b60a04823c0e930b227af2828d8.zip
back to "lua_upvalue"... (seems better choice)
Diffstat (limited to 'ldo.c')
-rw-r--r--ldo.c18
1 files changed, 4 insertions, 14 deletions
diff --git a/ldo.c b/ldo.c
index 01af05c4..8ab4854f 100644
--- a/ldo.c
+++ b/ldo.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldo.c,v 1.15 1997/12/15 16:17:20 roberto Exp roberto $ 2** $Id: ldo.c,v 1.16 1997/12/17 20:57:20 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*/
@@ -140,22 +140,12 @@ void luaD_callHook (StkId base, TProtoFunc *tf, int isreturn)
140** Cstack.num is the number of arguments; Cstack.lua2C points to the 140** Cstack.num is the number of arguments; Cstack.lua2C points to the
141** first argument. Returns an index to the first result from C. 141** first argument. Returns an index to the first result from C.
142*/ 142*/
143static StkId callC (struct Closure *cl, lua_CFunction f, StkId base) 143static StkId callC (lua_CFunction f, StkId base)
144{ 144{
145 struct C_Lua_Stack *CS = &L->Cstack; 145 struct C_Lua_Stack *CS = &L->Cstack;
146 struct C_Lua_Stack oldCLS = *CS; 146 struct C_Lua_Stack oldCLS = *CS;
147 StkId firstResult; 147 StkId firstResult;
148 int numarg = (L->stack.top-L->stack.stack) - base; 148 int numarg = (L->stack.top-L->stack.stack) - base;
149 if (cl) { /* are there upvalues? */
150 int i;
151 luaD_checkstack(cl->nelems);
152 for (i=1; i<=numarg; i++) /* open space */
153 *(L->stack.top+cl->nelems-i) = *(L->stack.top-i);
154 /* copy upvalues to stack */
155 memcpy(L->stack.top-numarg, cl->consts+1, cl->nelems*sizeof(TObject));
156 L->stack.top += cl->nelems;
157 numarg += cl->nelems;
158 }
159 CS->num = numarg; 149 CS->num = numarg;
160 CS->lua2C = base; 150 CS->lua2C = base;
161 CS->base = base+numarg; /* == top-stack */ 151 CS->base = base+numarg; /* == top-stack */
@@ -192,7 +182,7 @@ void luaD_call (StkId base, int nResults)
192 switch (ttype(func)) { 182 switch (ttype(func)) {
193 case LUA_T_CPROTO: 183 case LUA_T_CPROTO:
194 ttype(func) = LUA_T_CMARK; 184 ttype(func) = LUA_T_CMARK;
195 firstResult = callC(NULL, fvalue(func), base); 185 firstResult = callC(fvalue(func), base);
196 break; 186 break;
197 case LUA_T_PROTO: 187 case LUA_T_PROTO:
198 ttype(func) = LUA_T_PMARK; 188 ttype(func) = LUA_T_PMARK;
@@ -203,7 +193,7 @@ void luaD_call (StkId base, int nResults)
203 TObject *proto = &(c->consts[0]); 193 TObject *proto = &(c->consts[0]);
204 ttype(func) = LUA_T_CLMARK; 194 ttype(func) = LUA_T_CLMARK;
205 firstResult = (ttype(proto) == LUA_T_CPROTO) ? 195 firstResult = (ttype(proto) == LUA_T_CPROTO) ?
206 callC(c, fvalue(proto), base) : 196 callC(fvalue(proto), base) :
207 luaV_execute(c, tfvalue(proto), base); 197 luaV_execute(c, tfvalue(proto), base);
208 break; 198 break;
209 } 199 }