C4AulCompiler: Rename pLoopStack to active_loops

directional-lights
Nicolas Hake 2016-04-29 12:29:37 +02:00
parent d0dbe05876
commit 41000a8f9a
3 changed files with 14 additions and 14 deletions

View File

@ -375,20 +375,20 @@ void C4AulCompiler::PushLoop()
Loop *pNew = new Loop();
pNew->StackSize = iStack;
pNew->Controls = NULL;
pNew->Next = pLoopStack;
pLoopStack = pNew;
pNew->Next = active_loops;
active_loops = pNew;
}
void C4AulCompiler::PopLoop(int ContinueJump)
{
// Set targets for break/continue
for (Loop::Control *pCtrl = pLoopStack->Controls; pCtrl; pCtrl = pCtrl->Next)
for (Loop::Control *pCtrl = active_loops->Controls; pCtrl; pCtrl = pCtrl->Next)
if (pCtrl->Break)
SetJumpHere(pCtrl->Pos);
else
SetJump(pCtrl->Pos, ContinueJump);
// Delete loop controls
Loop *pLoop = pLoopStack;
Loop *pLoop = active_loops;
while (pLoop->Controls)
{
// Unlink
@ -398,20 +398,20 @@ void C4AulCompiler::PopLoop(int ContinueJump)
delete pCtrl;
}
// Unlink & delete
pLoopStack = pLoop->Next;
active_loops = pLoop->Next;
delete pLoop;
}
void C4AulCompiler::AddLoopControl(const char * SPos, bool fBreak)
{
// Insert code
if (pLoopStack->StackSize != iStack)
AddBCC(SPos, AB_STACK, pLoopStack->StackSize - iStack);
if (active_loops->StackSize != iStack)
AddBCC(SPos, AB_STACK, active_loops->StackSize - iStack);
Loop::Control *pNew = new Loop::Control();
pNew->Break = fBreak;
pNew->Pos = Fn->GetCodePos();
pNew->Next = pLoopStack->Controls;
pLoopStack->Controls = pNew;
pNew->Next = active_loops->Controls;
active_loops->Controls = pNew;
AddBCC(SPos, AB_JUMP);
}

View File

@ -54,14 +54,14 @@ public:
int StackSize;
Loop *Next;
};
Loop *pLoopStack = NULL;
Loop *active_loops = NULL;
void PushLoop();
void PopLoop(int ContinueJump);
void AddLoopControl(const char * SPos, bool fBreak);
~C4AulCompiler()
{
while (pLoopStack) PopLoop(0);
while (active_loops) PopLoop(0);
}
};

View File

@ -1201,7 +1201,7 @@ void C4AulParse::Parse_Statement()
if (Type == PARSER)
{
// Must be inside a loop
if (!codegen.pLoopStack)
if (!codegen.active_loops)
{
Error("'break' is only allowed inside loops");
}
@ -1217,7 +1217,7 @@ void C4AulParse::Parse_Statement()
if (Type == PARSER)
{
// Must be inside a loop
if (!codegen.pLoopStack)
if (!codegen.active_loops)
{
Error("'continue' is only allowed inside loops");
}
@ -1474,7 +1474,7 @@ void C4AulParse::Parse_DoWhile()
Parse_Statement();
int BeforeCond = -1;
if (Type == PARSER)
for (C4AulCompiler::Loop::Control *pCtrl2 = codegen.pLoopStack->Controls; pCtrl2; pCtrl2 = pCtrl2->Next)
for (C4AulCompiler::Loop::Control *pCtrl2 = codegen.active_loops->Controls; pCtrl2; pCtrl2 = pCtrl2->Next)
if (!pCtrl2->Break)
BeforeCond = codegen.JumpHere();
// Execute condition