mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 14:51:51 +00:00
- fixed local vector array initialization.
This commit is contained in:
parent
3ff27b4281
commit
2f56ff3833
1 changed files with 11 additions and 29 deletions
|
@ -11156,9 +11156,10 @@ ExpEmit FxLocalArrayDeclaration::Emit(VMFunctionBuilder *build)
|
|||
ClearDynamicArray(build);
|
||||
}
|
||||
|
||||
auto zero = build->GetConstantInt(0);
|
||||
auto elementSizeConst = build->GetConstantInt(static_cast<PArray *>(ValueType)->ElementSize);
|
||||
auto arrOffsetReg = build->Registers[REGT_INT].Get(1);
|
||||
build->Emit(OP_LK, arrOffsetReg, build->GetConstantInt(StackOffset));
|
||||
build->Emit(OP_ADDA_RK, arrOffsetReg, build->FramePointer.RegNum, build->GetConstantInt(StackOffset));
|
||||
|
||||
for (auto v : values)
|
||||
{
|
||||
|
@ -11178,59 +11179,40 @@ ExpEmit FxLocalArrayDeclaration::Emit(VMFunctionBuilder *build)
|
|||
if (emitval.Konst)
|
||||
{
|
||||
auto constval = static_cast<FxConstant *>(v);
|
||||
int regNum = build->Registers[regtype].Get(1);
|
||||
auto regNum = build->Registers[regtype].Get(1);
|
||||
switch (regtype)
|
||||
{
|
||||
default:
|
||||
case REGT_INT:
|
||||
build->Emit(OP_LK, regNum, build->GetConstantInt(constval->GetValue().GetInt()));
|
||||
build->Emit(OP_SW_R, build->FramePointer.RegNum, regNum, arrOffsetReg);
|
||||
build->Emit(OP_SW_R, arrOffsetReg, regNum, zero);
|
||||
break;
|
||||
|
||||
case REGT_FLOAT:
|
||||
build->Emit(OP_LKF, regNum, build->GetConstantFloat(constval->GetValue().GetFloat()));
|
||||
build->Emit(OP_SDP_R, build->FramePointer.RegNum, regNum, arrOffsetReg);
|
||||
build->Emit(OP_SDP_R, arrOffsetReg, regNum, zero);
|
||||
break;
|
||||
|
||||
case REGT_POINTER:
|
||||
build->Emit(OP_LKP, regNum, build->GetConstantAddress(constval->GetValue().GetPointer()));
|
||||
build->Emit(OP_SP_R, build->FramePointer.RegNum, regNum, arrOffsetReg);
|
||||
build->Emit(OP_SP_R, arrOffsetReg, regNum, zero);
|
||||
break;
|
||||
|
||||
case REGT_STRING:
|
||||
build->Emit(OP_LKS, regNum, build->GetConstantString(constval->GetValue().GetString()));
|
||||
build->Emit(OP_SS_R, build->FramePointer.RegNum, regNum, arrOffsetReg);
|
||||
build->Emit(OP_SS_R, arrOffsetReg, regNum, zero);
|
||||
break;
|
||||
}
|
||||
build->Registers[regtype].Return(regNum, 1);
|
||||
|
||||
emitval.Free(build);
|
||||
build->Registers[regtype].Return(regNum, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (regtype)
|
||||
{
|
||||
default:
|
||||
case REGT_INT:
|
||||
build->Emit(OP_SW_R, build->FramePointer.RegNum, emitval.RegNum, arrOffsetReg);
|
||||
break;
|
||||
|
||||
case REGT_FLOAT:
|
||||
build->Emit(OP_SDP_R, build->FramePointer.RegNum, emitval.RegNum, arrOffsetReg);
|
||||
break;
|
||||
|
||||
case REGT_POINTER:
|
||||
build->Emit(OP_SP_R, build->FramePointer.RegNum, emitval.RegNum, arrOffsetReg);
|
||||
break;
|
||||
|
||||
case REGT_STRING:
|
||||
build->Emit(OP_SS_R, build->FramePointer.RegNum, emitval.RegNum, arrOffsetReg);
|
||||
break;
|
||||
}
|
||||
emitval.Free(build);
|
||||
build->Emit(v->ValueType->GetStoreOp(), arrOffsetReg, emitval.RegNum, zero);
|
||||
}
|
||||
emitval.Free(build);
|
||||
|
||||
build->Emit(OP_ADD_RK, arrOffsetReg, arrOffsetReg, elementSizeConst);
|
||||
build->Emit(OP_ADDA_RK, arrOffsetReg, arrOffsetReg, elementSizeConst);
|
||||
}
|
||||
build->Registers[REGT_INT].Return(arrOffsetReg, 1);
|
||||
|
||||
|
|
Loading…
Reference in a new issue