new macro MAXUPVAL (maximum number of upvalues per closure)
This commit is contained in:
6
lapi.c
6
lapi.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lapi.c,v 2.128 2010/05/12 14:09:20 roberto Exp roberto $
|
** $Id: lapi.c,v 2.129 2010/05/14 13:15:26 roberto Exp roberto $
|
||||||
** Lua API
|
** Lua API
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -55,7 +55,7 @@ static TValue *index2addr (lua_State *L, int idx) {
|
|||||||
return &G(L)->l_registry;
|
return &G(L)->l_registry;
|
||||||
else { /* upvalues */
|
else { /* upvalues */
|
||||||
idx = LUA_REGISTRYINDEX - idx;
|
idx = LUA_REGISTRYINDEX - idx;
|
||||||
api_check(L, idx <= UCHAR_MAX + 1, "upvalue index too large");
|
api_check(L, idx <= MAXUPVAL + 1, "upvalue index too large");
|
||||||
if (ttislcf(ci->func)) /* light C function? */
|
if (ttislcf(ci->func)) /* light C function? */
|
||||||
return cast(TValue *, luaO_nilobject); /* it has no upvalues */
|
return cast(TValue *, luaO_nilobject); /* it has no upvalues */
|
||||||
else {
|
else {
|
||||||
@@ -507,7 +507,7 @@ LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) {
|
|||||||
else {
|
else {
|
||||||
Closure *cl;
|
Closure *cl;
|
||||||
api_checknelems(L, n);
|
api_checknelems(L, n);
|
||||||
api_check(L, n <= UCHAR_MAX, "upvalue index too large");
|
api_check(L, n <= MAXUPVAL, "upvalue index too large");
|
||||||
luaC_checkGC(L);
|
luaC_checkGC(L);
|
||||||
cl = luaF_newCclosure(L, n);
|
cl = luaF_newCclosure(L, n);
|
||||||
cl->c.f = fn;
|
cl->c.f = fn;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: llimits.h,v 1.80 2010/05/07 18:44:12 roberto Exp roberto $
|
** $Id: llimits.h,v 1.81 2010/05/24 19:29:46 roberto Exp roberto $
|
||||||
** Limits, basic types, and some other `installation-dependent' definitions
|
** Limits, basic types, and some other `installation-dependent' definitions
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -97,6 +97,11 @@ typedef LUAI_UACNUMBER l_uacNumber;
|
|||||||
#define LUAI_MAXCCALLS 200
|
#define LUAI_MAXCCALLS 200
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
** maximum number of upvalues in a closure (both C and Lua). (Value
|
||||||
|
** must fit in an unsigned char.)
|
||||||
|
*/
|
||||||
|
#define MAXUPVAL UCHAR_MAX
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lparser.c,v 2.85 2010/05/14 15:03:43 roberto Exp roberto $
|
** $Id: lparser.c,v 2.86 2010/05/15 13:32:02 roberto Exp roberto $
|
||||||
** Lua Parser
|
** Lua Parser
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -221,9 +221,9 @@ static int searchupvalue (FuncState *fs, TString *name) {
|
|||||||
static int newupvalue (FuncState *fs, TString *name, expdesc *v) {
|
static int newupvalue (FuncState *fs, TString *name, expdesc *v) {
|
||||||
Proto *f = fs->f;
|
Proto *f = fs->f;
|
||||||
int oldsize = f->sizeupvalues;
|
int oldsize = f->sizeupvalues;
|
||||||
checklimit(fs, fs->nups + 1, UCHAR_MAX, "upvalues");
|
checklimit(fs, fs->nups + 1, MAXUPVAL, "upvalues");
|
||||||
luaM_growvector(fs->L, f->upvalues, fs->nups, f->sizeupvalues,
|
luaM_growvector(fs->L, f->upvalues, fs->nups, f->sizeupvalues,
|
||||||
Upvaldesc, UCHAR_MAX, "upvalues");
|
Upvaldesc, MAXUPVAL, "upvalues");
|
||||||
while (oldsize < f->sizeupvalues) f->upvalues[oldsize++].name = NULL;
|
while (oldsize < f->sizeupvalues) f->upvalues[oldsize++].name = NULL;
|
||||||
f->upvalues[fs->nups].instack = (v->k == VLOCAL);
|
f->upvalues[fs->nups].instack = (v->k == VLOCAL);
|
||||||
f->upvalues[fs->nups].idx = cast_byte(v->u.s.info);
|
f->upvalues[fs->nups].idx = cast_byte(v->u.s.info);
|
||||||
|
|||||||
Reference in New Issue
Block a user