diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-03-29 17:19:20 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-03-29 17:19:20 -0300 |
commit | a69356e9e0a7525b1cebadc928a0efcce8c39b46 (patch) | |
tree | c676ee2997c699d3e0b036323ecbafa7ea0d786f /lapi.c | |
parent | b53dc0c4853c56694dda727793e5f6188de39dd8 (diff) | |
download | lua-a69356e9e0a7525b1cebadc928a0efcce8c39b46.tar.gz lua-a69356e9e0a7525b1cebadc928a0efcce8c39b46.tar.bz2 lua-a69356e9e0a7525b1cebadc928a0efcce8c39b46.zip |
no more special cases for closures with 0 upvalues (performance is the same,
memory use a little higher, code much simpler).
Diffstat (limited to 'lapi.c')
-rw-r--r-- | lapi.c | 23 |
1 files changed, 5 insertions, 18 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lapi.c,v 1.75 2000/03/20 19:14:54 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 1.76 2000/03/27 20:10:21 roberto Exp roberto $ |
3 | ** Lua API | 3 | ** Lua API |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -30,17 +30,6 @@ const char lua_ident[] = "$Lua: " LUA_VERSION " " LUA_COPYRIGHT " $\n" | |||
30 | 30 | ||
31 | 31 | ||
32 | 32 | ||
33 | |||
34 | const TObject *luaA_protovalue (const TObject *o) { | ||
35 | switch (ttype(o)) { | ||
36 | case TAG_CCLOSURE: case TAG_LCLOSURE: | ||
37 | return protovalue(o); | ||
38 | default: | ||
39 | return o; | ||
40 | } | ||
41 | } | ||
42 | |||
43 | |||
44 | void luaA_checkCargs (lua_State *L, int nargs) { | 33 | void luaA_checkCargs (lua_State *L, int nargs) { |
45 | if (nargs > L->top-L->Cstack.base) | 34 | if (nargs > L->top-L->Cstack.base) |
46 | luaL_verror(L, "Lua API error - " | 35 | luaL_verror(L, "Lua API error - " |
@@ -210,7 +199,8 @@ int lua_isuserdata (lua_State *L, lua_Object o) { | |||
210 | } | 199 | } |
211 | 200 | ||
212 | int lua_iscfunction (lua_State *L, lua_Object o) { | 201 | int lua_iscfunction (lua_State *L, lua_Object o) { |
213 | return (lua_tag(L, o) == TAG_CPROTO); | 202 | UNUSED(L); |
203 | return (o != LUA_NOOBJECT) && (ttype(o) == TAG_CCLOSURE); | ||
214 | } | 204 | } |
215 | 205 | ||
216 | int lua_isnumber (lua_State *L, lua_Object o) { | 206 | int lua_isnumber (lua_State *L, lua_Object o) { |
@@ -266,7 +256,7 @@ void *lua_getuserdata (lua_State *L, lua_Object obj) { | |||
266 | lua_CFunction lua_getcfunction (lua_State *L, lua_Object obj) { | 256 | lua_CFunction lua_getcfunction (lua_State *L, lua_Object obj) { |
267 | if (!lua_iscfunction(L, obj)) | 257 | if (!lua_iscfunction(L, obj)) |
268 | return NULL; | 258 | return NULL; |
269 | else return fvalue(luaA_protovalue(obj)); | 259 | else return clvalue(obj)->f.c; |
270 | } | 260 | } |
271 | 261 | ||
272 | 262 | ||
@@ -299,10 +289,7 @@ void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) { | |||
299 | if (fn == NULL) | 289 | if (fn == NULL) |
300 | lua_error(L, "Lua API error - attempt to push a NULL Cfunction"); | 290 | lua_error(L, "Lua API error - attempt to push a NULL Cfunction"); |
301 | luaA_checkCargs(L, n); | 291 | luaA_checkCargs(L, n); |
302 | ttype(L->top) = TAG_CPROTO; | 292 | luaV_Cclosure(L, fn, n); |
303 | fvalue(L->top) = fn; | ||
304 | incr_top; | ||
305 | luaV_closure(L, n); | ||
306 | luaC_checkGC(L); | 293 | luaC_checkGC(L); |
307 | } | 294 | } |
308 | 295 | ||