diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2025-05-15 12:43:37 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2025-05-15 12:43:37 -0300 |
commit | 3fb7a77731e6140674a6b13b73979256bfb95ce3 (patch) | |
tree | e877e7bb99ac7d2d6c7bf6a9c7c94948f0ddaf65 /lparser.c | |
parent | fded0b4a844990b1a6d0cda1aba25df33eb5f46f (diff) | |
download | lua-3fb7a77731e6140674a6b13b73979256bfb95ce3.tar.gz lua-3fb7a77731e6140674a6b13b73979256bfb95ce3.tar.bz2 lua-3fb7a77731e6140674a6b13b73979256bfb95ce3.zip |
Internalized string "break" kept by the parser
The parser uses "break" as fake label to compile "break" as "goto
break". To avoid producing this string at each use, it keeps it
available in its state.
Diffstat (limited to 'lparser.c')
-rw-r--r-- | lparser.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -707,7 +707,7 @@ static void enterblock (FuncState *fs, BlockCnt *bl, lu_byte isloop) { | |||
707 | */ | 707 | */ |
708 | static l_noret undefgoto (LexState *ls, Labeldesc *gt) { | 708 | static l_noret undefgoto (LexState *ls, Labeldesc *gt) { |
709 | /* breaks are checked when created, cannot be undefined */ | 709 | /* breaks are checked when created, cannot be undefined */ |
710 | lua_assert(!eqstr(gt->name, luaS_newliteral(ls->L, "break"))); | 710 | lua_assert(!eqstr(gt->name, ls->brkn)); |
711 | luaK_semerror(ls, "no visible label '%s' for <goto> at line %d", | 711 | luaK_semerror(ls, "no visible label '%s' for <goto> at line %d", |
712 | getstr(gt->name), gt->line); | 712 | getstr(gt->name), gt->line); |
713 | } | 713 | } |
@@ -723,7 +723,7 @@ static void leaveblock (FuncState *fs) { | |||
723 | removevars(fs, bl->nactvar); /* remove block locals */ | 723 | removevars(fs, bl->nactvar); /* remove block locals */ |
724 | lua_assert(bl->nactvar == fs->nactvar); /* back to level on entry */ | 724 | lua_assert(bl->nactvar == fs->nactvar); /* back to level on entry */ |
725 | if (bl->isloop == 2) /* has to fix pending breaks? */ | 725 | if (bl->isloop == 2) /* has to fix pending breaks? */ |
726 | createlabel(ls, luaS_newliteral(ls->L, "break"), 0, 0); | 726 | createlabel(ls, ls->brkn, 0, 0); |
727 | solvegotos(fs, bl); | 727 | solvegotos(fs, bl); |
728 | if (bl->previous == NULL) { /* was it the last block? */ | 728 | if (bl->previous == NULL) { /* was it the last block? */ |
729 | if (bl->firstgoto < ls->dyd->gt.n) /* still pending gotos? */ | 729 | if (bl->firstgoto < ls->dyd->gt.n) /* still pending gotos? */ |
@@ -1497,7 +1497,7 @@ static void breakstat (LexState *ls, int line) { | |||
1497 | ok: | 1497 | ok: |
1498 | bl->isloop = 2; /* signal that block has pending breaks */ | 1498 | bl->isloop = 2; /* signal that block has pending breaks */ |
1499 | luaX_next(ls); /* skip break */ | 1499 | luaX_next(ls); /* skip break */ |
1500 | newgotoentry(ls, luaS_newliteral(ls->L, "break"), line); | 1500 | newgotoentry(ls, ls->brkn, line); |
1501 | } | 1501 | } |
1502 | 1502 | ||
1503 | 1503 | ||