diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-09-07 14:39:10 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-09-07 14:39:10 -0300 |
commit | abdbe883a86bbc7fbf1d1bfc50756e1b42fc45b5 (patch) | |
tree | 051a7571c8acaf5451b5c9b7d67f1796a345c565 /lapi.c | |
parent | 4d0935ec0ffed827aade5594216fae15bed7c6b5 (diff) | |
download | lua-abdbe883a86bbc7fbf1d1bfc50756e1b42fc45b5.tar.gz lua-abdbe883a86bbc7fbf1d1bfc50756e1b42fc45b5.tar.bz2 lua-abdbe883a86bbc7fbf1d1bfc50756e1b42fc45b5.zip |
first implementation of unrestricted static scoping
Diffstat (limited to 'lapi.c')
-rw-r--r-- | lapi.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -248,7 +248,7 @@ LUA_API size_t lua_strlen (lua_State *L, int index) { | |||
248 | 248 | ||
249 | LUA_API lua_CFunction lua_tocfunction (lua_State *L, int index) { | 249 | LUA_API lua_CFunction lua_tocfunction (lua_State *L, int index) { |
250 | StkId o = luaA_indexAcceptable(L, index); | 250 | StkId o = luaA_indexAcceptable(L, index); |
251 | return (o == NULL || !iscfunction(o)) ? NULL : clvalue(o)->f.c; | 251 | return (o == NULL || !iscfunction(o)) ? NULL : clvalue(o)->u.c.f; |
252 | } | 252 | } |
253 | 253 | ||
254 | 254 | ||
@@ -310,9 +310,16 @@ LUA_API void lua_pushstring (lua_State *L, const l_char *s) { | |||
310 | 310 | ||
311 | 311 | ||
312 | LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) { | 312 | LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) { |
313 | Closure *cl; | ||
313 | lua_lock(L); | 314 | lua_lock(L); |
314 | api_checknelems(L, n); | 315 | api_checknelems(L, n); |
315 | luaV_Cclosure(L, fn, n); | 316 | cl = luaF_newCclosure(L, n); |
317 | cl->u.c.f = fn; | ||
318 | L->top -= n; | ||
319 | while (n--) | ||
320 | setobj(&cl->u.c.upvalue[n], L->top+n); | ||
321 | setclvalue(L->top, cl); | ||
322 | incr_top; | ||
316 | lua_unlock(L); | 323 | lua_unlock(L); |
317 | } | 324 | } |
318 | 325 | ||