Implemented issue: #87

This commit is contained in:
UnlegitDqrk
2026-03-02 13:10:29 +01:00
parent 98437da1fa
commit db392c4763
219 changed files with 73 additions and 15 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -44,6 +44,8 @@ public class LexState extends Constants {
protected static final String RESERVED_LOCAL_VAR_FOR_STEP = "(for step)";
protected static final String RESERVED_LOCAL_VAR_FOR_LIMIT = "(for limit)";
protected static final String RESERVED_LOCAL_VAR_FOR_INDEX = "(for index)";
protected static final LuaString LOOP_LABEL_BREAK = LuaString.valueOf("break");
protected static final LuaString LOOP_LABEL_CONTINUE = LuaString.valueOf("continue");
// keywords array
protected static final String[] RESERVED_LOCAL_VAR_KEYWORDS = new String[] {
@@ -72,7 +74,8 @@ public class LexState extends Constants {
private static final boolean LUA_COMPAT_VARARG = true;
public static boolean isReservedKeyword(String varName) {
return RESERVED_LOCAL_VAR_KEYWORDS_TABLE.containsKey(varName);
return RESERVED_LOCAL_VAR_KEYWORDS_TABLE.containsKey(varName)
|| RESERVED.containsKey(LuaString.valueOf(varName));
}
/*
@@ -146,7 +149,7 @@ public class LexState extends Constants {
/* ORDER RESERVED */
final static String luaX_tokens [] = {
"and", "break", "do", "else", "elseif",
"and", "break", "continue", "do", "else", "elseif",
"end", "false", "for", "function", "goto", "if",
"in", "local", "nil", "not", "or", "repeat",
"return", "then", "true", "until", "while",
@@ -156,13 +159,13 @@ public class LexState extends Constants {
final static int
/* terminal symbols denoted by reserved words */
TK_AND=257, TK_BREAK=258, TK_DO=259, TK_ELSE=260, TK_ELSEIF=261,
TK_END=262, TK_FALSE=263, TK_FOR=264, TK_FUNCTION=265, TK_GOTO=266, TK_IF=267,
TK_IN=268, TK_LOCAL=269, TK_NIL=270, TK_NOT=271, TK_OR=272, TK_REPEAT=273,
TK_RETURN=274, TK_THEN=275, TK_TRUE=276, TK_UNTIL=277, TK_WHILE=278,
TK_AND=257, TK_BREAK=258, TK_CONTINUE=259, TK_DO=260, TK_ELSE=261, TK_ELSEIF=262,
TK_END=263, TK_FALSE=264, TK_FOR=265, TK_FUNCTION=266, TK_GOTO=267, TK_IF=268,
TK_IN=269, TK_LOCAL=270, TK_NIL=271, TK_NOT=272, TK_OR=273, TK_REPEAT=274,
TK_RETURN=275, TK_THEN=276, TK_TRUE=277, TK_UNTIL=278, TK_WHILE=279,
/* other terminal symbols */
TK_CONCAT=279, TK_DOTS=280, TK_IDIV=281, TK_SHL=282, TK_SHR=283, TK_EQ=284, TK_GE=285, TK_LE=286, TK_NE=287,
TK_DBCOLON=288, TK_EOS=289, TK_NUMBER=290, TK_NAME=291, TK_STRING=292;
TK_CONCAT=280, TK_DOTS=281, TK_IDIV=282, TK_SHL=283, TK_SHR=284, TK_EQ=285, TK_GE=286, TK_LE=287, TK_NE=288,
TK_DBCOLON=289, TK_EOS=290, TK_NUMBER=291, TK_NAME=292, TK_STRING=293;
final static int FIRST_RESERVED = TK_AND;
final static int NUM_RESERVED = TK_WHILE+1-FIRST_RESERVED;
@@ -1740,9 +1743,11 @@ public class LexState extends Constants {
int g;
if (testnext(TK_GOTO))
label = str_checkname();
else {
next(); /* skip break */
label = LuaString.valueOf("break");
else if (testnext(TK_BREAK)) {
label = LOOP_LABEL_BREAK;
} else {
checknext(TK_CONTINUE);
label = LOOP_LABEL_CONTINUE;
}
g = newlabelentry(dyd.gt =grow(dyd.gt, dyd.n_gt+1), dyd.n_gt++, label, line, pc);
findlabel(g); /* close it if label already defined */
@@ -1772,6 +1777,12 @@ public class LexState extends Constants {
}
void looplabel(LuaString label, int pc) {
int l = newlabelentry(dyd.label = grow(dyd.label, dyd.n_label + 1), dyd.n_label++, label, 0, pc);
findgotos(dyd.label[l]);
}
void whilestat (int line) {
/* whilestat -> WHILE cond DO block END */
FuncState fs = this.fs;
@@ -1784,6 +1795,7 @@ public class LexState extends Constants {
fs.enterblock(bl, true);
this.checknext(TK_DO);
this.block();
this.looplabel(LOOP_LABEL_CONTINUE, fs.getlabel());
fs.patchlist(fs.jump(), whileinit);
this.check_match(TK_END, TK_WHILE, line);
fs.leaveblock();
@@ -1802,6 +1814,7 @@ public class LexState extends Constants {
this.next(); /* skip REPEAT */
this.statlist();
this.check_match(TK_UNTIL, TK_REPEAT, line);
this.looplabel(LOOP_LABEL_CONTINUE, fs.getlabel());
condexit = this.cond(); /* read condition (inside scope block) */
if (bl2.upval) { /* upvalues? */
fs.patchclose(condexit, bl2.nactvar);
@@ -1835,6 +1848,7 @@ public class LexState extends Constants {
fs.reserveregs(nvars);
this.block();
fs.leaveblock(); /* end of scope for declared variables */
this.looplabel(LOOP_LABEL_CONTINUE, fs.getlabel());
fs.patchtohere(prep);
if (isnum) /* numeric for? */
endfor = fs.codeAsBx(Lua.OP_FORLOOP, base, NO_JUMP);
@@ -1927,7 +1941,7 @@ public class LexState extends Constants {
this.next(); /* skip IF or ELSEIF */
expr(v); /* read expression */
this.checknext(TK_THEN);
if (t.token == TK_GOTO || t.token == TK_BREAK) {
if (t.token == TK_GOTO || t.token == TK_BREAK || t.token == TK_CONTINUE) {
fs.goiffalse(v); /* will jump to label if condition is true */
fs.enterblock(bl, false); /* must enter block before 'goto' */
gotostat(v.t.i); /* handle goto/break */
@@ -2119,6 +2133,7 @@ public class LexState extends Constants {
break;
}
case TK_BREAK:
case TK_CONTINUE:
case TK_GOTO: { /* stat -> breakstat */
this.gotostat(fs.jump());
break;

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More