forked from Mirrors/openclonk
Script: continue in a do-while loop jumps to test instead of start of loop
This matches C and other languages.stable-5.3
parent
6c531abbfe
commit
9f3489c053
|
@ -2012,11 +2012,12 @@ void C4AulParse::Parse_DoWhile()
|
|||
{
|
||||
Shift();
|
||||
// Save position for later jump back
|
||||
int iStart = JumpHere();
|
||||
int Start = JumpHere();
|
||||
// We got a loop
|
||||
PushLoop();
|
||||
// Execute body
|
||||
Parse_Statement();
|
||||
int BeforeCond = JumpHere();
|
||||
// Execute condition
|
||||
if (TokenType != ATT_IDTF || !SEqual(Idtf, C4AUL_While))
|
||||
UnexpectedToken("'while'");
|
||||
|
@ -2025,14 +2026,14 @@ void C4AulParse::Parse_DoWhile()
|
|||
Parse_Expression();
|
||||
Match(ATT_BCLOSE);
|
||||
// Jump back
|
||||
AddJump(AB_COND, iStart);
|
||||
AddJump(AB_COND, Start);
|
||||
if (Type != PARSER) return;
|
||||
// Set targets for break/continue
|
||||
for (Loop::Control *pCtrl = pLoopStack->Controls; pCtrl; pCtrl = pCtrl->Next)
|
||||
if (pCtrl->Break)
|
||||
SetJumpHere(pCtrl->Pos);
|
||||
else
|
||||
SetJump(pCtrl->Pos, iStart);
|
||||
SetJump(pCtrl->Pos, BeforeCond);
|
||||
PopLoop();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue