mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-25 05:31:00 +00:00
Fixed arrays of dynamic arrays causing a compilation error.
This commit is contained in:
parent
04bf975796
commit
8dea4f9523
1 changed files with 21 additions and 3 deletions
|
@ -7343,6 +7343,10 @@ FxExpression *FxArrayElement::Resolve(FCompileContext &ctx)
|
||||||
auto parentfield = static_cast<FxMemberBase *>(Array)->membervar;
|
auto parentfield = static_cast<FxMemberBase *>(Array)->membervar;
|
||||||
SizeAddr = parentfield->Offset + sizeof(void*);
|
SizeAddr = parentfield->Offset + sizeof(void*);
|
||||||
}
|
}
|
||||||
|
else if (Array->ExprType == EFX_ArrayElement)
|
||||||
|
{
|
||||||
|
SizeAddr = ~0u;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ScriptPosition.Message(MSG_ERROR, "Invalid resizable array");
|
ScriptPosition.Message(MSG_ERROR, "Invalid resizable array");
|
||||||
|
@ -7415,6 +7419,7 @@ ExpEmit FxArrayElement::Emit(VMFunctionBuilder *build)
|
||||||
ExpEmit arrayvar = Array->Emit(build);
|
ExpEmit arrayvar = Array->Emit(build);
|
||||||
ExpEmit start;
|
ExpEmit start;
|
||||||
ExpEmit bound;
|
ExpEmit bound;
|
||||||
|
bool nestedarray = false;
|
||||||
|
|
||||||
if (SizeAddr != ~0u)
|
if (SizeAddr != ~0u)
|
||||||
{
|
{
|
||||||
|
@ -7441,15 +7446,28 @@ ExpEmit FxArrayElement::Emit(VMFunctionBuilder *build)
|
||||||
arraymemberbase->AddressRequested = origaddrreq;
|
arraymemberbase->AddressRequested = origaddrreq;
|
||||||
Array->ValueType = origvaluetype;
|
Array->ValueType = origvaluetype;
|
||||||
}
|
}
|
||||||
|
else if (Array->ExprType == EFX_ArrayElement && Array->isStaticArray())
|
||||||
|
{
|
||||||
|
bool ismeta = Array->ExprType == EFX_ClassMember && static_cast<FxClassMember*>(Array)->membervar->Flags & VARF_Meta;
|
||||||
|
|
||||||
|
arrayvar.Free(build);
|
||||||
|
start = ExpEmit(build, REGT_POINTER);
|
||||||
|
build->Emit(OP_LP, start.RegNum, arrayvar.RegNum, build->GetConstantInt(0));
|
||||||
|
|
||||||
|
bound = ExpEmit(build, REGT_INT);
|
||||||
|
build->Emit(OP_LW, bound.RegNum, arrayvar.RegNum, build->GetConstantInt(sizeof(void*)));
|
||||||
|
|
||||||
|
nestedarray = true;
|
||||||
|
}
|
||||||
else start = arrayvar;
|
else start = arrayvar;
|
||||||
|
|
||||||
if (index->isConstant())
|
if (index->isConstant())
|
||||||
{
|
{
|
||||||
unsigned indexval = static_cast<FxConstant *>(index)->GetValue().GetInt();
|
unsigned indexval = static_cast<FxConstant *>(index)->GetValue().GetInt();
|
||||||
assert(SizeAddr != ~0u || (indexval < arraytype->ElementCount && "Array index out of bounds"));
|
assert(SizeAddr != ~0u || nestedarray || (indexval < arraytype->ElementCount && "Array index out of bounds"));
|
||||||
|
|
||||||
// For resizable arrays we even need to check the bounds if if the index is constant because they are not known at compile time.
|
// For resizable arrays we even need to check the bounds if if the index is constant because they are not known at compile time.
|
||||||
if (SizeAddr != ~0u)
|
if (SizeAddr != ~0u || nestedarray)
|
||||||
{
|
{
|
||||||
ExpEmit indexreg(build, REGT_INT);
|
ExpEmit indexreg(build, REGT_INT);
|
||||||
build->EmitLoadInt(indexreg.RegNum, indexval);
|
build->EmitLoadInt(indexreg.RegNum, indexval);
|
||||||
|
|
Loading…
Reference in a new issue