mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 14:51:51 +00:00
Fixed: conditionals didn't properly compile to vm code
This commit is contained in:
parent
bbdc64a955
commit
bdeb233849
1 changed files with 6 additions and 2 deletions
|
@ -1838,6 +1838,7 @@ FxExpression *FxConditional::Resolve(FCompileContext& ctx)
|
|||
|
||||
ExpEmit FxConditional::Emit(VMFunctionBuilder *build)
|
||||
{
|
||||
size_t truejump, falsejump;
|
||||
ExpEmit out;
|
||||
|
||||
// The true and false expressions ought to be assigned to the
|
||||
|
@ -1848,7 +1849,7 @@ ExpEmit FxConditional::Emit(VMFunctionBuilder *build)
|
|||
|
||||
// Test condition.
|
||||
build->Emit(OP_EQ_K, 1, cond.RegNum, build->GetConstantInt(0));
|
||||
size_t patchspot = build->Emit(OP_JMP, 0);
|
||||
falsejump = build->Emit(OP_JMP, 0);
|
||||
|
||||
// Evaluate true expression.
|
||||
if (truex->isConstant() && truex->ValueType->GetRegType() == REGT_INT)
|
||||
|
@ -1872,9 +1873,11 @@ ExpEmit FxConditional::Emit(VMFunctionBuilder *build)
|
|||
out = trueop;
|
||||
}
|
||||
}
|
||||
// Make sure to skip the false path.
|
||||
truejump = build->Emit(OP_JMP, 0);
|
||||
|
||||
// Evaluate false expression.
|
||||
build->BackpatchToHere(patchspot);
|
||||
build->BackpatchToHere(falsejump);
|
||||
if (falsex->isConstant() && falsex->ValueType->GetRegType() == REGT_INT)
|
||||
{
|
||||
build->EmitLoadInt(out.RegNum, static_cast<FxConstant *>(falsex)->GetValue().GetInt());
|
||||
|
@ -1904,6 +1907,7 @@ ExpEmit FxConditional::Emit(VMFunctionBuilder *build)
|
|||
}
|
||||
}
|
||||
}
|
||||
build->BackpatchToHere(truejump);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue