aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lparser.c12
-rw-r--r--lparser.h8
2 files changed, 11 insertions, 9 deletions
diff --git a/lparser.c b/lparser.c
index 2d482489..8ca5d8d5 100644
--- a/lparser.c
+++ b/lparser.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lparser.c,v 1.211 2003/05/14 21:02:39 roberto Exp roberto $ 2** $Id: lparser.c,v 1.212 2003/07/09 15:36:38 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*/
@@ -139,7 +139,7 @@ static int luaI_registerlocalvar (LexState *ls, TString *varname) {
139 FuncState *fs = ls->fs; 139 FuncState *fs = ls->fs;
140 Proto *f = fs->f; 140 Proto *f = fs->f;
141 luaM_growvector(ls->L, f->locvars, fs->nlocvars, f->sizelocvars, 141 luaM_growvector(ls->L, f->locvars, fs->nlocvars, f->sizelocvars,
142 LocVar, MAX_INT, ""); 142 LocVar, USHRT_MAX, "too many local variables");
143 f->locvars[fs->nlocvars].varname = varname; 143 f->locvars[fs->nlocvars].varname = varname;
144 return fs->nlocvars++; 144 return fs->nlocvars++;
145} 145}
@@ -148,7 +148,8 @@ static int luaI_registerlocalvar (LexState *ls, TString *varname) {
148static void new_localvar (LexState *ls, TString *name, int n) { 148static void new_localvar (LexState *ls, TString *name, int n) {
149 FuncState *fs = ls->fs; 149 FuncState *fs = ls->fs;
150 luaX_checklimit(ls, fs->nactvar+n+1, MAXVARS, "local variables"); 150 luaX_checklimit(ls, fs->nactvar+n+1, MAXVARS, "local variables");
151 fs->actvar[fs->nactvar+n] = luaI_registerlocalvar(ls, name); 151 fs->actvar[fs->nactvar+n] = cast(unsigned short,
152 luaI_registerlocalvar(ls, name));
152} 153}
153 154
154 155
@@ -187,8 +188,9 @@ static int indexupvalue (FuncState *fs, TString *name, expdesc *v) {
187 luaM_growvector(fs->L, fs->f->upvalues, f->nups, fs->f->sizeupvalues, 188 luaM_growvector(fs->L, fs->f->upvalues, f->nups, fs->f->sizeupvalues,
188 TString *, MAX_INT, ""); 189 TString *, MAX_INT, "");
189 fs->f->upvalues[f->nups] = name; 190 fs->f->upvalues[f->nups] = name;
190 fs->upvalues[f->nups].k = v->k; 191 lua_assert(v->k == VLOCAL || v->k == VUPVAL);
191 fs->upvalues[f->nups].info = v->info; 192 fs->upvalues[f->nups].k = cast(lu_byte, v->k);
193 fs->upvalues[f->nups].info = cast(lu_byte, v->info);
192 return f->nups++; 194 return f->nups++;
193} 195}
194 196
diff --git a/lparser.h b/lparser.h
index 7c052f08..1cb52623 100644
--- a/lparser.h
+++ b/lparser.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lparser.h,v 1.47 2003/02/11 10:46:24 roberto Exp roberto $ 2** $Id: lparser.h,v 1.48 2003/07/09 15:36:38 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*/
@@ -42,8 +42,8 @@ typedef struct expdesc {
42 42
43 43
44typedef struct upvaldesc { 44typedef struct upvaldesc {
45 expkind k; 45 lu_byte k;
46 int info; 46 lu_byte info;
47} upvaldesc; 47} upvaldesc;
48 48
49 49
@@ -67,7 +67,7 @@ typedef struct FuncState {
67 int nlocvars; /* number of elements in `locvars' */ 67 int nlocvars; /* number of elements in `locvars' */
68 lu_byte nactvar; /* number of active local variables */ 68 lu_byte nactvar; /* number of active local variables */
69 upvaldesc upvalues[MAXUPVALUES]; /* upvalues */ 69 upvaldesc upvalues[MAXUPVALUES]; /* upvalues */
70 int actvar[MAXVARS]; /* declared-variable stack */ 70 unsigned short actvar[MAXVARS]; /* declared-variable stack */
71} FuncState; 71} FuncState;
72 72
73 73