aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Pall <mike>2012-10-03 11:53:18 +0200
committerMike Pall <mike>2012-10-03 11:53:18 +0200
commit2e9f4efd200487b613af9ad90cee099f6d6d0af8 (patch)
tree0e831740fcd459afbeb07823788466cfb1ca24db /src
parent8d8dbf27b83a9b1246e3338e48eb444fb7fa84d3 (diff)
downloadluajit-2e9f4efd200487b613af9ad90cee099f6d6d0af8.tar.gz
luajit-2e9f4efd200487b613af9ad90cee099f6d6d0af8.tar.bz2
luajit-2e9f4efd200487b613af9ad90cee099f6d6d0af8.zip
Fix scope for resolving break labels.
Diffstat (limited to 'src')
-rw-r--r--src/lj_parse.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/lj_parse.c b/src/lj_parse.c
index 2bb8c92f..a3a96535 100644
--- a/src/lj_parse.c
+++ b/src/lj_parse.c
@@ -1189,9 +1189,9 @@ static void gola_close(LexState *ls, VarInfo *vg)
1189} 1189}
1190 1190
1191/* Resolve pending forward gotos for label. */ 1191/* Resolve pending forward gotos for label. */
1192static void gola_resolve(LexState *ls, MSize idx) 1192static void gola_resolve(LexState *ls, FuncScope *bl, MSize idx)
1193{ 1193{
1194 VarInfo *vg = ls->vstack + ls->fs->bl->vstart; 1194 VarInfo *vg = ls->vstack + bl->vstart;
1195 VarInfo *vl = ls->vstack + idx; 1195 VarInfo *vl = ls->vstack + idx;
1196 for (; vg < vl; vg++) 1196 for (; vg < vl; vg++)
1197 if (gcrefeq(vg->name, vl->name) && gola_isgoto(vg)) { 1197 if (gcrefeq(vg->name, vl->name) && gola_isgoto(vg)) {
@@ -1199,6 +1199,7 @@ static void gola_resolve(LexState *ls, MSize idx)
1199 GCstr *name = strref(var_get(ls, ls->fs, gola_nactvar(vg)).name); 1199 GCstr *name = strref(var_get(ls, ls->fs, gola_nactvar(vg)).name);
1200 lua_assert((uintptr_t)name >= VARNAME__MAX); 1200 lua_assert((uintptr_t)name >= VARNAME__MAX);
1201 ls->linenumber = ls->fs->bcbase[vg->startpc].line; 1201 ls->linenumber = ls->fs->bcbase[vg->startpc].line;
1202 lua_assert(strref(vg->name) != NAME_BREAK);
1202 lj_lex_error(ls, 0, LJ_ERR_XGSCOPE, 1203 lj_lex_error(ls, 0, LJ_ERR_XGSCOPE,
1203 strdata(strref(vg->name)), strdata(name)); 1204 strdata(strref(vg->name)), strdata(name));
1204 } 1205 }
@@ -1280,7 +1281,7 @@ static void fscope_end(FuncState *fs)
1280 if ((bl->flags & FSCOPE_LOOP)) { 1281 if ((bl->flags & FSCOPE_LOOP)) {
1281 MSize idx = gola_new(ls, NAME_BREAK, VSTACK_LABEL, fs->pc); 1282 MSize idx = gola_new(ls, NAME_BREAK, VSTACK_LABEL, fs->pc);
1282 ls->vtop = idx; /* Drop break label immediately. */ 1283 ls->vtop = idx; /* Drop break label immediately. */
1283 gola_resolve(ls, idx); 1284 gola_resolve(ls, bl, idx);
1284 return; 1285 return;
1285 } /* else: need the fixup step to propagate the breaks. */ 1286 } /* else: need the fixup step to propagate the breaks. */
1286 } else if (!(bl->flags & FSCOPE_GOLA)) { 1287 } else if (!(bl->flags & FSCOPE_GOLA)) {
@@ -2404,7 +2405,7 @@ static void parse_label(LexState *ls)
2404 /* Trailing label is considered to be outside of scope. */ 2405 /* Trailing label is considered to be outside of scope. */
2405 if (endofblock(ls->token) && ls->token != TK_until) 2406 if (endofblock(ls->token) && ls->token != TK_until)
2406 ls->vstack[idx].endpc = fs->bl->nactvar | VSTACK_LABEL; 2407 ls->vstack[idx].endpc = fs->bl->nactvar | VSTACK_LABEL;
2407 gola_resolve(ls, idx); 2408 gola_resolve(ls, fs->bl, idx);
2408} 2409}
2409 2410
2410/* -- Blocks, loops and conditional statements ---------------------------- */ 2411/* -- Blocks, loops and conditional statements ---------------------------- */