aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-04-11 15:37:18 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-04-11 15:37:18 -0300
commit0433e42023a7121154470d5a14be9da903d6e42b (patch)
tree07bb64bf8d7b470d522cae0d4d0ff78553ae5f51
parent0810bc707f98f05a2d598e6a00cb33280d16cf89 (diff)
downloadlua-0433e42023a7121154470d5a14be9da903d6e42b.tar.gz
lua-0433e42023a7121154470d5a14be9da903d6e42b.tar.bz2
lua-0433e42023a7121154470d5a14be9da903d6e42b.zip
no more repeat ... end.
-rw-r--r--lparser.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/lparser.c b/lparser.c
index 61882800..39127e2a 100644
--- a/lparser.c
+++ b/lparser.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lparser.c,v 1.79 2000/04/07 19:35:20 roberto Exp roberto $ 2** $Id: lparser.c,v 1.80 2000/04/10 19:21:14 roberto Exp roberto $
3** LL(1) Parser and code generator for Lua 3** LL(1) Parser and code generator for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -214,8 +214,15 @@ static void adjustlocalvars (LexState *ls, int nvars, int line) {
214} 214}
215 215
216 216
217static void add_localvar (LexState *ls, TString *name) { 217static void removelocalvars (LexState *ls, int nvars, int line) {
218 store_localvar(ls, name, 0); 218 ls->fs->nlocalvar -= nvars;
219 while (nvars--)
220 luaI_unregisterlocalvar(ls, line);
221}
222
223
224static void add_localvar (LexState *ls, const char *name) {
225 store_localvar(ls, luaS_newfixed(ls->L, name), 0);
219 adjustlocalvars(ls, 1, 0); 226 adjustlocalvars(ls, 1, 0);
220} 227}
221 228
@@ -305,7 +312,7 @@ static void code_args (LexState *ls, int nparams, int dots) {
305 luaK_deltastack(fs, nparams); 312 luaK_deltastack(fs, nparams);
306 else { 313 else {
307 luaK_deltastack(fs, nparams+1); 314 luaK_deltastack(fs, nparams+1);
308 add_localvar(ls, luaS_newfixed(ls->L, "arg")); 315 add_localvar(ls, "arg");
309 } 316 }
310} 317}
311 318
@@ -830,8 +837,7 @@ static void block (LexState *ls) {
830 int nlocalvar = fs->nlocalvar; 837 int nlocalvar = fs->nlocalvar;
831 chunk(ls); 838 chunk(ls);
832 luaK_adjuststack(fs, fs->nlocalvar - nlocalvar); /* remove local variables */ 839 luaK_adjuststack(fs, fs->nlocalvar - nlocalvar); /* remove local variables */
833 for (; fs->nlocalvar > nlocalvar; fs->nlocalvar--) 840 removelocalvars(ls, fs->nlocalvar - nlocalvar, fs->lastsetline);
834 luaI_unregisterlocalvar(ls, fs->lastsetline);
835} 841}
836 842
837 843
@@ -892,16 +898,10 @@ static void repeatstat (LexState *ls, int line) {
892 enterbreak(fs, &bl); 898 enterbreak(fs, &bl);
893 setline_and_next(ls); /* trace REPEAT when looping */ 899 setline_and_next(ls); /* trace REPEAT when looping */
894 block(ls); 900 block(ls);
895 if (ls->token == TK_END) { 901 check_match(ls, TK_UNTIL, TK_REPEAT, line);
896 luaK_patchlist(fs, luaK_jump(fs), repeat_init); 902 expr(ls, &v);
897 next(ls); 903 luaK_goiftrue(fs, &v, 0);
898 } 904 luaK_patchlist(fs, v.u.l.f, repeat_init);
899 else {
900 check_match(ls, TK_UNTIL, TK_REPEAT, line);
901 expr(ls, &v);
902 luaK_goiftrue(fs, &v, 0);
903 luaK_patchlist(fs, v.u.l.f, repeat_init);
904 }
905 leavebreak(fs, &bl); 905 leavebreak(fs, &bl);
906} 906}
907 907
@@ -1135,7 +1135,7 @@ static void body (LexState *ls, int needself, int line) {
1135 new_fs.f->lineDefined = line; 1135 new_fs.f->lineDefined = line;
1136 check(ls, '('); 1136 check(ls, '(');
1137 if (needself) 1137 if (needself)
1138 add_localvar(ls, luaS_newfixed(ls->L, "self")); 1138 add_localvar(ls, "self");
1139 parlist(ls); 1139 parlist(ls);
1140 check(ls, ')'); 1140 check(ls, ')');
1141 chunk(ls); 1141 chunk(ls);