aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-06-19 15:27:20 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-06-19 15:27:20 -0300
commit89b56e7d84d84de58fcc9d540c2003c6c2f8c134 (patch)
tree85ba9c3aa3cdb5ff57fd4f82bf322fb2e75e7292
parent14929f5764a7990dfb62c8792cfdfe03c061da21 (diff)
downloadlua-89b56e7d84d84de58fcc9d540c2003c6c2f8c134.tar.gz
lua-89b56e7d84d84de58fcc9d540c2003c6c2f8c134.tar.bz2
lua-89b56e7d84d84de58fcc9d540c2003c6c2f8c134.zip
more precision between closure types ('LClosure' x 'CClosure')
-rw-r--r--lapi.c8
-rw-r--r--ldo.c8
-rw-r--r--lfunc.c18
-rw-r--r--lfunc.h6
-rw-r--r--lparser.c10
-rw-r--r--lparser.h6
-rw-r--r--lundump.c16
-rw-r--r--lundump.h6
-rw-r--r--lvm.c20
9 files changed, 49 insertions, 49 deletions
diff --git a/lapi.c b/lapi.c
index 106da209..a4b51194 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 2.217 2014/06/10 19:13:26 roberto Exp roberto $ 2** $Id: lapi.c,v 2.218 2014/06/12 19:07:30 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*/
@@ -580,15 +580,15 @@ LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) {
580 setfvalue(L->top, fn); 580 setfvalue(L->top, fn);
581 } 581 }
582 else { 582 else {
583 Closure *cl; 583 CClosure *cl;
584 api_checknelems(L, n); 584 api_checknelems(L, n);
585 api_check(L, n <= MAXUPVAL, "upvalue index too large"); 585 api_check(L, n <= MAXUPVAL, "upvalue index too large");
586 luaC_checkGC(L); 586 luaC_checkGC(L);
587 cl = luaF_newCclosure(L, n); 587 cl = luaF_newCclosure(L, n);
588 cl->c.f = fn; 588 cl->f = fn;
589 L->top -= n; 589 L->top -= n;
590 while (n--) { 590 while (n--) {
591 setobj2n(L, &cl->c.upvalue[n], L->top + n); 591 setobj2n(L, &cl->upvalue[n], L->top + n);
592 /* does not need barrier because closure is white */ 592 /* does not need barrier because closure is white */
593 } 593 }
594 setclCvalue(L, L->top, cl); 594 setclCvalue(L, L->top, cl);
diff --git a/ldo.c b/ldo.c
index 6b131d46..d23ba47d 100644
--- a/ldo.c
+++ b/ldo.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldo.c,v 2.121 2014/06/11 16:01:55 roberto Exp roberto $ 2** $Id: ldo.c,v 2.122 2014/06/12 19:07:30 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*/
@@ -667,7 +667,7 @@ static void checkmode (lua_State *L, const char *mode, const char *x) {
667 667
668 668
669static void f_parser (lua_State *L, void *ud) { 669static void f_parser (lua_State *L, void *ud) {
670 Closure *cl; 670 LClosure *cl;
671 struct SParser *p = cast(struct SParser *, ud); 671 struct SParser *p = cast(struct SParser *, ud);
672 int c = zgetc(p->z); /* read first character */ 672 int c = zgetc(p->z); /* read first character */
673 if (c == LUA_SIGNATURE[0]) { 673 if (c == LUA_SIGNATURE[0]) {
@@ -678,8 +678,8 @@ static void f_parser (lua_State *L, void *ud) {
678 checkmode(L, p->mode, "text"); 678 checkmode(L, p->mode, "text");
679 cl = luaY_parser(L, p->z, &p->buff, &p->dyd, p->name, c); 679 cl = luaY_parser(L, p->z, &p->buff, &p->dyd, p->name, c);
680 } 680 }
681 lua_assert(cl->l.nupvalues == cl->l.p->sizeupvalues); 681 lua_assert(cl->nupvalues == cl->p->sizeupvalues);
682 luaF_initupvals(L, &cl->l); 682 luaF_initupvals(L, cl);
683} 683}
684 684
685 685
diff --git a/lfunc.c b/lfunc.c
index 999c35a5..21f826b0 100644
--- a/lfunc.c
+++ b/lfunc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lfunc.c,v 2.41 2014/02/18 13:39:37 roberto Exp roberto $ 2** $Id: lfunc.c,v 2.42 2014/06/18 22:59:29 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*/
@@ -20,20 +20,20 @@
20 20
21 21
22 22
23Closure *luaF_newCclosure (lua_State *L, int n) { 23CClosure *luaF_newCclosure (lua_State *L, int n) {
24 GCObject *o = luaC_newobj(L, LUA_TCCL, sizeCclosure(n)); 24 GCObject *o = luaC_newobj(L, LUA_TCCL, sizeCclosure(n));
25 Closure *c = gco2cl(o); 25 CClosure *c = gco2ccl(o);
26 c->c.nupvalues = cast_byte(n); 26 c->nupvalues = cast_byte(n);
27 return c; 27 return c;
28} 28}
29 29
30 30
31Closure *luaF_newLclosure (lua_State *L, int n) { 31LClosure *luaF_newLclosure (lua_State *L, int n) {
32 GCObject *o = luaC_newobj(L, LUA_TLCL, sizeLclosure(n)); 32 GCObject *o = luaC_newobj(L, LUA_TLCL, sizeLclosure(n));
33 Closure *c = gco2cl(o); 33 LClosure *c = gco2lcl(o);
34 c->l.p = NULL; 34 c->p = NULL;
35 c->l.nupvalues = cast_byte(n); 35 c->nupvalues = cast_byte(n);
36 while (n--) c->l.upvals[n] = NULL; 36 while (n--) c->upvals[n] = NULL;
37 return c; 37 return c;
38} 38}
39 39
diff --git a/lfunc.h b/lfunc.h
index 3ca72075..5951f9ea 100644
--- a/lfunc.h
+++ b/lfunc.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lfunc.h,v 2.12 2014/02/15 13:12:01 roberto Exp roberto $ 2** $Id: lfunc.h,v 2.13 2014/02/18 13:39:37 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*/
@@ -41,8 +41,8 @@ struct UpVal {
41 41
42 42
43LUAI_FUNC Proto *luaF_newproto (lua_State *L); 43LUAI_FUNC Proto *luaF_newproto (lua_State *L);
44LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems); 44LUAI_FUNC CClosure *luaF_newCclosure (lua_State *L, int nelems);
45LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems); 45LUAI_FUNC LClosure *luaF_newLclosure (lua_State *L, int nelems);
46LUAI_FUNC void luaF_initupvals (lua_State *L, LClosure *cl); 46LUAI_FUNC void luaF_initupvals (lua_State *L, LClosure *cl);
47LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); 47LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level);
48LUAI_FUNC void luaF_close (lua_State *L, StkId level); 48LUAI_FUNC void luaF_close (lua_State *L, StkId level);
diff --git a/lparser.c b/lparser.c
index 86582565..9ad4b8db 100644
--- a/lparser.c
+++ b/lparser.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lparser.c,v 2.137 2013/12/18 14:12:03 roberto Exp roberto $ 2** $Id: lparser.c,v 2.138 2013/12/30 20:47:58 roberto Exp roberto $
3** Lua Parser 3** Lua Parser
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -1618,17 +1618,17 @@ static void mainfunc (LexState *ls, FuncState *fs) {
1618} 1618}
1619 1619
1620 1620
1621Closure *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, 1621LClosure *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff,
1622 Dyndata *dyd, const char *name, int firstchar) { 1622 Dyndata *dyd, const char *name, int firstchar) {
1623 LexState lexstate; 1623 LexState lexstate;
1624 FuncState funcstate; 1624 FuncState funcstate;
1625 Closure *cl = luaF_newLclosure(L, 1); /* create main closure */ 1625 LClosure *cl = luaF_newLclosure(L, 1); /* create main closure */
1626 setclLvalue(L, L->top, cl); /* anchor it (to avoid being collected) */ 1626 setclLvalue(L, L->top, cl); /* anchor it (to avoid being collected) */
1627 incr_top(L); 1627 incr_top(L);
1628 lexstate.h = luaH_new(L); /* create table for scanner */ 1628 lexstate.h = luaH_new(L); /* create table for scanner */
1629 sethvalue(L, L->top, lexstate.h); /* anchor it */ 1629 sethvalue(L, L->top, lexstate.h); /* anchor it */
1630 incr_top(L); 1630 incr_top(L);
1631 funcstate.f = cl->l.p = luaF_newproto(L); 1631 funcstate.f = cl->p = luaF_newproto(L);
1632 funcstate.f->source = luaS_new(L, name); /* create and anchor TString */ 1632 funcstate.f->source = luaS_new(L, name); /* create and anchor TString */
1633 luaC_objbarrier(L, funcstate.f, funcstate.f->source); 1633 luaC_objbarrier(L, funcstate.f, funcstate.f->source);
1634 lexstate.buff = buff; 1634 lexstate.buff = buff;
diff --git a/lparser.h b/lparser.h
index c6a78a79..3ee6f7f0 100644
--- a/lparser.h
+++ b/lparser.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lparser.h,v 1.71 2013/04/16 18:46:28 roberto Exp roberto $ 2** $Id: lparser.h,v 1.72 2013/08/30 16:01:37 roberto Exp roberto $
3** Lua Parser 3** Lua Parser
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -113,8 +113,8 @@ typedef struct FuncState {
113} FuncState; 113} FuncState;
114 114
115 115
116LUAI_FUNC Closure *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, 116LUAI_FUNC LClosure *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff,
117 Dyndata *dyd, const char *name, int firstchar); 117 Dyndata *dyd, const char *name, int firstchar);
118 118
119 119
120#endif 120#endif
diff --git a/lundump.c b/lundump.c
index f5d6fcf9..2a9eac28 100644
--- a/lundump.c
+++ b/lundump.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lundump.c,v 2.38 2014/06/18 13:19:17 roberto Exp roberto $ 2** $Id: lundump.c,v 2.39 2014/06/18 18:35:43 roberto Exp roberto $
3** load precompiled Lua chunks 3** load precompiled Lua chunks
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -248,10 +248,10 @@ static void checkHeader (LoadState *S) {
248/* 248/*
249** load precompiled chunk 249** load precompiled chunk
250*/ 250*/
251Closure *luaU_undump(lua_State *L, ZIO *Z, Mbuffer *buff, 251LClosure *luaU_undump(lua_State *L, ZIO *Z, Mbuffer *buff,
252 const char *name) { 252 const char *name) {
253 LoadState S; 253 LoadState S;
254 Closure *cl; 254 LClosure *cl;
255 if (*name == '@' || *name == '=') 255 if (*name == '@' || *name == '=')
256 S.name = name + 1; 256 S.name = name + 1;
257 else if (*name == LUA_SIGNATURE[0]) 257 else if (*name == LUA_SIGNATURE[0])
@@ -265,10 +265,10 @@ Closure *luaU_undump(lua_State *L, ZIO *Z, Mbuffer *buff,
265 cl = luaF_newLclosure(L, LoadByte(&S)); 265 cl = luaF_newLclosure(L, LoadByte(&S));
266 setclLvalue(L, L->top, cl); 266 setclLvalue(L, L->top, cl);
267 incr_top(L); 267 incr_top(L);
268 cl->l.p = luaF_newproto(L); 268 cl->p = luaF_newproto(L);
269 LoadFunction(&S, cl->l.p, NULL); 269 LoadFunction(&S, cl->p, NULL);
270 lua_assert(cl->l.nupvalues == cl->l.p->sizeupvalues); 270 lua_assert(cl->nupvalues == cl->p->sizeupvalues);
271 luai_verifycode(L, buff, cl->l.p); 271 luai_verifycode(L, buff, cl->p);
272 return cl; 272 return cl;
273} 273}
274 274
diff --git a/lundump.h b/lundump.h
index 67f6b57c..45194532 100644
--- a/lundump.h
+++ b/lundump.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lundump.h,v 1.42 2014/03/11 14:22:54 roberto Exp roberto $ 2** $Id: lundump.h,v 1.43 2014/04/15 14:28:20 roberto Exp roberto $
3** load precompiled Lua chunks 3** load precompiled Lua chunks
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -23,8 +23,8 @@
23#define LUAC_FORMAT 0 /* this is the official format */ 23#define LUAC_FORMAT 0 /* this is the official format */
24 24
25/* load one chunk; from lundump.c */ 25/* load one chunk; from lundump.c */
26LUAI_FUNC Closure* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, 26LUAI_FUNC LClosure* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff,
27 const char* name); 27 const char* name);
28 28
29/* dump one chunk; from ldump.c */ 29/* dump one chunk; from ldump.c */
30LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, 30LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w,
diff --git a/lvm.c b/lvm.c
index ec3d29ba..e86008c7 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 2.214 2014/05/26 17:10:22 roberto Exp roberto $ 2** $Id: lvm.c,v 2.215 2014/06/10 18:53:18 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*/
@@ -503,15 +503,15 @@ lua_Integer luaV_shiftl (lua_Integer x, lua_Integer y) {
503** whether there is a cached closure with the same upvalues needed by 503** whether there is a cached closure with the same upvalues needed by
504** new closure to be created. 504** new closure to be created.
505*/ 505*/
506static Closure *getcached (Proto *p, UpVal **encup, StkId base) { 506static LClosure *getcached (Proto *p, UpVal **encup, StkId base) {
507 Closure *c = p->cache; 507 LClosure *c = p->cache;
508 if (c != NULL) { /* is there a cached closure? */ 508 if (c != NULL) { /* is there a cached closure? */
509 int nup = p->sizeupvalues; 509 int nup = p->sizeupvalues;
510 Upvaldesc *uv = p->upvalues; 510 Upvaldesc *uv = p->upvalues;
511 int i; 511 int i;
512 for (i = 0; i < nup; i++) { /* check whether it has right upvalues */ 512 for (i = 0; i < nup; i++) { /* check whether it has right upvalues */
513 TValue *v = uv[i].instack ? base + uv[i].idx : encup[uv[i].idx]->v; 513 TValue *v = uv[i].instack ? base + uv[i].idx : encup[uv[i].idx]->v;
514 if (c->l.upvals[i]->v != v) 514 if (c->upvals[i]->v != v)
515 return NULL; /* wrong upvalue; cannot reuse closure */ 515 return NULL; /* wrong upvalue; cannot reuse closure */
516 } 516 }
517 } 517 }
@@ -530,15 +530,15 @@ static void pushclosure (lua_State *L, Proto *p, UpVal **encup, StkId base,
530 int nup = p->sizeupvalues; 530 int nup = p->sizeupvalues;
531 Upvaldesc *uv = p->upvalues; 531 Upvaldesc *uv = p->upvalues;
532 int i; 532 int i;
533 Closure *ncl = luaF_newLclosure(L, nup); 533 LClosure *ncl = luaF_newLclosure(L, nup);
534 ncl->l.p = p; 534 ncl->p = p;
535 setclLvalue(L, ra, ncl); /* anchor new closure in stack */ 535 setclLvalue(L, ra, ncl); /* anchor new closure in stack */
536 for (i = 0; i < nup; i++) { /* fill in its upvalues */ 536 for (i = 0; i < nup; i++) { /* fill in its upvalues */
537 if (uv[i].instack) /* upvalue refers to local variable? */ 537 if (uv[i].instack) /* upvalue refers to local variable? */
538 ncl->l.upvals[i] = luaF_findupval(L, base + uv[i].idx); 538 ncl->upvals[i] = luaF_findupval(L, base + uv[i].idx);
539 else /* get upvalue from enclosing function */ 539 else /* get upvalue from enclosing function */
540 ncl->l.upvals[i] = encup[uv[i].idx]; 540 ncl->upvals[i] = encup[uv[i].idx];
541 ncl->l.upvals[i]->refcount++; 541 ncl->upvals[i]->refcount++;
542 /* new closure is white, so we do not need a barrier here */ 542 /* new closure is white, so we do not need a barrier here */
543 } 543 }
544 if (!isblack(obj2gco(p))) /* cache will not break GC invariant? */ 544 if (!isblack(obj2gco(p))) /* cache will not break GC invariant? */
@@ -1109,7 +1109,7 @@ void luaV_execute (lua_State *L) {
1109 ) 1109 )
1110 vmcase(OP_CLOSURE, 1110 vmcase(OP_CLOSURE,
1111 Proto *p = cl->p->p[GETARG_Bx(i)]; 1111 Proto *p = cl->p->p[GETARG_Bx(i)];
1112 Closure *ncl = getcached(p, cl->upvals, base); /* cached closure */ 1112 LClosure *ncl = getcached(p, cl->upvals, base); /* cached closure */
1113 if (ncl == NULL) /* no match? */ 1113 if (ncl == NULL) /* no match? */
1114 pushclosure(L, p, cl->upvals, base, ra); /* create a new one */ 1114 pushclosure(L, p, cl->upvals, base, ra); /* create a new one */
1115 else 1115 else