Fixed continue keyword, was pointing at break's target

This commit is contained in:
2025-02-02 16:15:20 +11:00
parent 3c0a50c4cd
commit 63cc530899
3 changed files with 30 additions and 11 deletions

11
scripts/yuki.toy Normal file
View File

@@ -0,0 +1,11 @@
var loops = 0;
while (true) {
if (++loops < 15532) {
continue;
}
break;
}
assert loops == 15532, "Yuki loop failed (break + continue)";

View File

@@ -617,7 +617,7 @@ static unsigned int writeInstructionWhileThen(Toy_ModuleBuilder** mb, Toy_AstWhi
unsigned int diff = depth - (*mb)->currentScopeDepth;
OVERWRITE_INT(mb, code, addr, CURRENT_ADDRESS(mb, code) - (addr + 8)); //tell continue to return to the start AFTER reading the instruction
OVERWRITE_INT(mb, code, addr, beginAddr - (addr + 8)); //tell continue to return to the start AFTER reading the instruction
OVERWRITE_INT(mb, code, addr, diff);
//tick down

View File

@@ -16,8 +16,6 @@ while (flag1) {
assert false, "continue failed";
}
print "done";
//-------------------------
//test break
@@ -34,8 +32,6 @@ while (flag2) {
assert false, "continue failed";
}
print "done";
//-------------------------
//test break
@@ -52,8 +48,6 @@ while (flag3) {
assert false, "continue failed";
}
print "done";
//-------------------------
{
@@ -70,8 +64,6 @@ print "done";
continue;
assert false, "continue failed";
}
print "done";
}
//-------------------------
@@ -94,8 +86,6 @@ print "done";
}
assert false, "continue failed";
}
print "done";
}
//-------------------------
@@ -122,3 +112,21 @@ print "done";
count += 1;
}
}
//-------------------------
{
//make sure break and continue point to the correct locations
var loops = 0;
while (true) {
if (++loops < 15532) {
continue;
}
break;
}
assert loops == 15532, "Yuki loop failed (break + continue)";
}