- fixed code generation for if statements with empty 'true' part. For those the jump statement backpatching was not done correctly.

This commit is contained in:
Christoph Oelckers 2016-12-18 14:09:16 +01:00
parent 8dd91f7129
commit 1fa37aaeb7

View file

@ -8955,7 +8955,7 @@ ExpEmit FxIfStatement::Emit(VMFunctionBuilder *build)
size_t jumpspot = ~0u;
TArray<size_t> yes, no;
Condition->EmitCompare(build, false, yes, no);
Condition->EmitCompare(build, WhenTrue == nullptr, yes, no);
if (WhenTrue != nullptr)
{
@ -8964,11 +8964,14 @@ ExpEmit FxIfStatement::Emit(VMFunctionBuilder *build)
}
if (WhenFalse != nullptr)
{
if (WhenTrue != nullptr && !WhenTrue->CheckReturn()) jumpspot = build->Emit(OP_JMP, 0); // no need to emit a jump if the block returns.
build->BackpatchListToHere(no);
if (WhenTrue != nullptr)
{
if (!WhenTrue->CheckReturn()) jumpspot = build->Emit(OP_JMP, 0); // no need to emit a jump if the block returns.
build->BackpatchListToHere(no);
}
WhenFalse->EmitStatement(build);
if (jumpspot != ~0u) build->BackpatchToHere(jumpspot);
if (WhenTrue == nullptr) build->BackpatchListToHere(yes);
if (WhenTrue == nullptr) build->BackpatchListToHere(no);
}
else
{