diff options
Diffstat (limited to 'ldo.c')
-rw-r--r-- | ldo.c | 15 |
1 files changed, 8 insertions, 7 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldo.c,v 1.101 2000/10/04 12:16:08 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 1.102 2000/10/05 12:14:08 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 | */ |
@@ -142,10 +142,11 @@ static StkId callCclosure (lua_State *L, const struct Closure *cl, StkId base) { | |||
142 | } | 142 | } |
143 | 143 | ||
144 | 144 | ||
145 | void luaD_callTM (lua_State *L, const TObject *f, int nParams, int nResults) { | 145 | void luaD_callTM (lua_State *L, Closure *f, int nParams, int nResults) { |
146 | StkId base = L->top - nParams; | 146 | StkId base = L->top - nParams; |
147 | luaD_openstack(L, base); | 147 | luaD_openstack(L, base); |
148 | *base = *f; | 148 | clvalue(base) = f; |
149 | ttype(base) = LUA_TFUNCTION; | ||
149 | luaD_call(L, base, nResults); | 150 | luaD_call(L, base, nResults); |
150 | } | 151 | } |
151 | 152 | ||
@@ -163,12 +164,12 @@ void luaD_call (lua_State *L, StkId func, int nResults) { | |||
163 | Closure *cl; | 164 | Closure *cl; |
164 | if (ttype(func) != LUA_TFUNCTION) { | 165 | if (ttype(func) != LUA_TFUNCTION) { |
165 | /* `func' is not a function; check the `function' tag method */ | 166 | /* `func' is not a function; check the `function' tag method */ |
166 | const TObject *im = luaT_getimbyObj(L, func, IM_FUNCTION); | 167 | Closure *tm = luaT_gettmbyObj(L, func, TM_FUNCTION); |
167 | if (ttype(im) == LUA_TNIL) | 168 | if (tm == NULL) |
168 | luaG_typeerror(L, func, "call"); | 169 | luaG_typeerror(L, func, "call"); |
169 | luaD_openstack(L, func); | 170 | luaD_openstack(L, func); |
170 | *func = *im; /* tag method is the new function to be called */ | 171 | clvalue(func) = tm; /* tag method is the new function to be called */ |
171 | LUA_ASSERT(ttype(func) == LUA_TFUNCTION, "invalid tag method"); | 172 | ttype(func) = LUA_TFUNCTION; |
172 | } | 173 | } |
173 | cl = clvalue(func); | 174 | cl = clvalue(func); |
174 | ci.func = cl; | 175 | ci.func = cl; |