mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
Fixed continue keyword, was pointing at break's target
This commit is contained in:
11
scripts/yuki.toy
Normal file
11
scripts/yuki.toy
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
var loops = 0;
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
if (++loops < 15532) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert loops == 15532, "Yuki loop failed (break + continue)";
|
||||||
@@ -617,7 +617,7 @@ static unsigned int writeInstructionWhileThen(Toy_ModuleBuilder** mb, Toy_AstWhi
|
|||||||
|
|
||||||
unsigned int diff = depth - (*mb)->currentScopeDepth;
|
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);
|
OVERWRITE_INT(mb, code, addr, diff);
|
||||||
|
|
||||||
//tick down
|
//tick down
|
||||||
|
|||||||
@@ -16,8 +16,6 @@ while (flag1) {
|
|||||||
assert false, "continue failed";
|
assert false, "continue failed";
|
||||||
}
|
}
|
||||||
|
|
||||||
print "done";
|
|
||||||
|
|
||||||
//-------------------------
|
//-------------------------
|
||||||
|
|
||||||
//test break
|
//test break
|
||||||
@@ -34,8 +32,6 @@ while (flag2) {
|
|||||||
assert false, "continue failed";
|
assert false, "continue failed";
|
||||||
}
|
}
|
||||||
|
|
||||||
print "done";
|
|
||||||
|
|
||||||
//-------------------------
|
//-------------------------
|
||||||
|
|
||||||
//test break
|
//test break
|
||||||
@@ -52,8 +48,6 @@ while (flag3) {
|
|||||||
assert false, "continue failed";
|
assert false, "continue failed";
|
||||||
}
|
}
|
||||||
|
|
||||||
print "done";
|
|
||||||
|
|
||||||
//-------------------------
|
//-------------------------
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -70,8 +64,6 @@ print "done";
|
|||||||
continue;
|
continue;
|
||||||
assert false, "continue failed";
|
assert false, "continue failed";
|
||||||
}
|
}
|
||||||
|
|
||||||
print "done";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------
|
//-------------------------
|
||||||
@@ -94,8 +86,6 @@ print "done";
|
|||||||
}
|
}
|
||||||
assert false, "continue failed";
|
assert false, "continue failed";
|
||||||
}
|
}
|
||||||
|
|
||||||
print "done";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------
|
//-------------------------
|
||||||
@@ -122,3 +112,21 @@ print "done";
|
|||||||
count += 1;
|
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)";
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user