From 87c426dcfd849c558cdd7b83ee5955aa3713c6a8 Mon Sep 17 00:00:00 2001 From: Chronos Ouroboros Date: Tue, 4 Jun 2019 19:31:08 -0300 Subject: [PATCH] Really fixed arrays of dynarrays this time. --- src/scripting/backend/codegen.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/scripting/backend/codegen.cpp b/src/scripting/backend/codegen.cpp index ba1db831c4..cfff89412a 100644 --- a/src/scripting/backend/codegen.cpp +++ b/src/scripting/backend/codegen.cpp @@ -7424,7 +7424,6 @@ ExpEmit FxArrayElement::Emit(VMFunctionBuilder *build) { bool ismeta = Array->ExprType == EFX_ClassMember && static_cast(Array)->membervar->Flags & VARF_Meta; - arrayvar.Free(build); start = ExpEmit(build, REGT_POINTER); build->Emit(OP_LP, start.RegNum, arrayvar.RegNum, build->GetConstantInt(0)); @@ -7444,18 +7443,18 @@ ExpEmit FxArrayElement::Emit(VMFunctionBuilder *build) arraymemberbase->membervar = origmembervar; arraymemberbase->AddressRequested = origaddrreq; Array->ValueType = origvaluetype; + + arrayvar.Free(build); } else if (Array->ExprType == EFX_ArrayElement && Array->isStaticArray()) { - bool ismeta = Array->ExprType == EFX_ClassMember && static_cast(Array)->membervar->Flags & VARF_Meta; + bound = ExpEmit(build, REGT_INT); + build->Emit(OP_LW, bound.RegNum, arrayvar.RegNum, build->GetConstantInt(myoffsetof(FArray, Count))); 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; @@ -7513,7 +7512,7 @@ ExpEmit FxArrayElement::Emit(VMFunctionBuilder *build) else { ExpEmit indexv(index->Emit(build)); - if (SizeAddr != ~0u) + if (SizeAddr != ~0u || nestedarray) { build->Emit(OP_BOUND_R, indexv.RegNum, bound.RegNum); bound.Free(build);