summaryrefslogtreecommitdiff
path: root/lfunc.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2003-12-10 10:13:36 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2003-12-10 10:13:36 -0200
commit47fc57a2529c83376883f36954082cfe80ae588f (patch)
treec2e57e2f9f7d78279144bfd9cbd04a3b1b131f12 /lfunc.c
parent4d5fe1f54bc00850f77a7c42f9e95d0ff3f1ab5b (diff)
downloadlua-47fc57a2529c83376883f36954082cfe80ae588f.tar.gz
lua-47fc57a2529c83376883f36954082cfe80ae588f.tar.bz2
lua-47fc57a2529c83376883f36954082cfe80ae588f.zip
`TObject' renamed to `TValue' + other name changes and better assertions
for incremental garbage collection
Diffstat (limited to 'lfunc.c')
-rw-r--r--lfunc.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/lfunc.c b/lfunc.c
index 77193ad7..af27bf0d 100644
--- a/lfunc.c
+++ b/lfunc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lfunc.c,v 1.73 2003/12/03 20:03:07 roberto Exp roberto $ 2** $Id: lfunc.c,v 1.74 2003/12/09 16:56:11 roberto Exp roberto $
3** Auxiliary functions to manipulate prototypes and closures 3** Auxiliary functions to manipulate prototypes and closures
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -21,16 +21,16 @@
21 21
22Closure *luaF_newCclosure (lua_State *L, int nelems) { 22Closure *luaF_newCclosure (lua_State *L, int nelems) {
23 Closure *c = cast(Closure *, luaM_malloc(L, sizeCclosure(nelems))); 23 Closure *c = cast(Closure *, luaM_malloc(L, sizeCclosure(nelems)));
24 luaC_link(L, valtogco(c), LUA_TFUNCTION); 24 luaC_link(L, obj2gco(c), LUA_TFUNCTION);
25 c->c.isC = 1; 25 c->c.isC = 1;
26 c->c.nupvalues = cast(lu_byte, nelems); 26 c->c.nupvalues = cast(lu_byte, nelems);
27 return c; 27 return c;
28} 28}
29 29
30 30
31Closure *luaF_newLclosure (lua_State *L, int nelems, TObject *e) { 31Closure *luaF_newLclosure (lua_State *L, int nelems, TValue *e) {
32 Closure *c = cast(Closure *, luaM_malloc(L, sizeLclosure(nelems))); 32 Closure *c = cast(Closure *, luaM_malloc(L, sizeLclosure(nelems)));
33 luaC_link(L, valtogco(c), LUA_TFUNCTION); 33 luaC_link(L, obj2gco(c), LUA_TFUNCTION);
34 c->l.isC = 0; 34 c->l.isC = 0;
35 c->l.g = *e; 35 c->l.g = *e;
36 c->l.nupvalues = cast(lu_byte, nelems); 36 c->l.nupvalues = cast(lu_byte, nelems);
@@ -40,7 +40,7 @@ Closure *luaF_newLclosure (lua_State *L, int nelems, TObject *e) {
40 40
41UpVal *luaF_newupval (lua_State *L) { 41UpVal *luaF_newupval (lua_State *L) {
42 UpVal *uv = luaM_new(L, UpVal); 42 UpVal *uv = luaM_new(L, UpVal);
43 luaC_link(L, valtogco(uv), LUA_TUPVAL); 43 luaC_link(L, obj2gco(uv), LUA_TUPVAL);
44 uv->v = &uv->value; 44 uv->v = &uv->value;
45 setnilvalue(uv->v); 45 setnilvalue(uv->v);
46 return uv; 46 return uv;
@@ -60,7 +60,7 @@ UpVal *luaF_findupval (lua_State *L, StkId level) {
60 uv->marked = bitmask(FIXEDBIT); /* open upvalues cannot be collected */ 60 uv->marked = bitmask(FIXEDBIT); /* open upvalues cannot be collected */
61 uv->v = level; /* current value lives in the stack */ 61 uv->v = level; /* current value lives in the stack */
62 uv->next = *pp; /* chain it in the proper position */ 62 uv->next = *pp; /* chain it in the proper position */
63 *pp = valtogco(uv); 63 *pp = obj2gco(uv);
64 return uv; 64 return uv;
65} 65}
66 66
@@ -68,18 +68,18 @@ UpVal *luaF_findupval (lua_State *L, StkId level) {
68void luaF_close (lua_State *L, StkId level) { 68void luaF_close (lua_State *L, StkId level) {
69 UpVal *uv; 69 UpVal *uv;
70 while ((uv = ngcotouv(L->openupval)) != NULL && uv->v >= level) { 70 while ((uv = ngcotouv(L->openupval)) != NULL && uv->v >= level) {
71 setobj(&uv->value, uv->v); 71 setobj(L, &uv->value, uv->v);
72 luaC_barrier(L, uv, uv->v); 72 luaC_barrier(L, uv, uv->v);
73 uv->v = &uv->value; /* now current value lives here */ 73 uv->v = &uv->value; /* now current value lives here */
74 L->openupval = uv->next; /* remove from `open' list */ 74 L->openupval = uv->next; /* remove from `open' list */
75 luaC_link(L, valtogco(uv), LUA_TUPVAL); 75 luaC_link(L, obj2gco(uv), LUA_TUPVAL);
76 } 76 }
77} 77}
78 78
79 79
80Proto *luaF_newproto (lua_State *L) { 80Proto *luaF_newproto (lua_State *L) {
81 Proto *f = luaM_new(L, Proto); 81 Proto *f = luaM_new(L, Proto);
82 luaC_link(L, valtogco(f), LUA_TPROTO); 82 luaC_link(L, obj2gco(f), LUA_TPROTO);
83 f->k = NULL; 83 f->k = NULL;
84 f->sizek = 0; 84 f->sizek = 0;
85 f->p = NULL; 85 f->p = NULL;
@@ -105,7 +105,7 @@ Proto *luaF_newproto (lua_State *L) {
105void luaF_freeproto (lua_State *L, Proto *f) { 105void luaF_freeproto (lua_State *L, Proto *f) {
106 luaM_freearray(L, f->code, f->sizecode, Instruction); 106 luaM_freearray(L, f->code, f->sizecode, Instruction);
107 luaM_freearray(L, f->p, f->sizep, Proto *); 107 luaM_freearray(L, f->p, f->sizep, Proto *);
108 luaM_freearray(L, f->k, f->sizek, TObject); 108 luaM_freearray(L, f->k, f->sizek, TValue);
109 luaM_freearray(L, f->lineinfo, f->sizelineinfo, int); 109 luaM_freearray(L, f->lineinfo, f->sizelineinfo, int);
110 luaM_freearray(L, f->locvars, f->sizelocvars, struct LocVar); 110 luaM_freearray(L, f->locvars, f->sizelocvars, struct LocVar);
111 luaM_freearray(L, f->upvalues, f->sizeupvalues, TString *); 111 luaM_freearray(L, f->upvalues, f->sizeupvalues, TString *);