diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-12-23 16:19:57 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-12-23 16:19:57 -0200 |
commit | b1b0c219f5255a0cd0921ebc0a77a81f99b72532 (patch) | |
tree | 7cb4d9cbbdb1309b94794eb75694b02f2b08f75a /lvm.c | |
parent | be3212de781786c0a68365dee1d3510407b5c325 (diff) | |
download | lua-b1b0c219f5255a0cd0921ebc0a77a81f99b72532.tar.gz lua-b1b0c219f5255a0cd0921ebc0a77a81f99b72532.tar.bz2 lua-b1b0c219f5255a0cd0921ebc0a77a81f99b72532.zip |
new ttypes to distinguish between C closures and Lua closures.
Diffstat (limited to 'lvm.c')
-rw-r--r-- | lvm.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lvm.c,v 1.73 1999/12/14 18:31:20 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 1.74 1999/12/21 18:04:41 roberto Exp roberto $ |
3 | ** Lua virtual machine | 3 | ** Lua virtual machine |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -86,8 +86,10 @@ void luaV_closure (lua_State *L, int nelems) { | |||
86 | Closure *c = luaF_newclosure(L, nelems); | 86 | Closure *c = luaF_newclosure(L, nelems); |
87 | c->consts[0] = *(L->top-1); | 87 | c->consts[0] = *(L->top-1); |
88 | L->top -= nelems; | 88 | L->top -= nelems; |
89 | memcpy(&c->consts[1], L->top-1, nelems*sizeof(TObject)); | 89 | while (nelems--) |
90 | ttype(L->top-1) = LUA_T_CLOSURE; | 90 | c->consts[nelems+1] = *(L->top-1+nelems); |
91 | ttype(L->top-1) = (ttype(&c->consts[0]) == LUA_T_CPROTO) ? | ||
92 | LUA_T_CCLOSURE : LUA_T_LCLOSURE; | ||
91 | (L->top-1)->value.cl = c; | 93 | (L->top-1)->value.cl = c; |
92 | } | 94 | } |
93 | } | 95 | } |
@@ -577,6 +579,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, const TProtoFunc *tf, | |||
577 | *top++ = consts[aux]; | 579 | *top++ = consts[aux]; |
578 | L->top = top; | 580 | L->top = top; |
579 | aux = *pc++; /* number of upvalues */ | 581 | aux = *pc++; /* number of upvalues */ |
582 | LUA_ASSERT(L, aux>0, "closure with no upvalues"); | ||
580 | luaV_closure(L, aux); | 583 | luaV_closure(L, aux); |
581 | luaC_checkGC(L); | 584 | luaC_checkGC(L); |
582 | top -= aux; | 585 | top -= aux; |