From 9a727f6c2fc81115b65d499d350e0d835a23f034 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Tue, 22 Oct 2019 10:40:45 +0300 Subject: [PATCH] - fixed variable's stack offset for implicit dynarray clearing https://forum.zdoom.org/viewtopic.php?t=66187 https://forum.zdoom.org/viewtopic.php?t=66189 https://forum.zdoom.org/viewtopic.php?t=66198 --- src/scripting/backend/codegen.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/scripting/backend/codegen.cpp b/src/scripting/backend/codegen.cpp index c49902fc0c..786d6164cf 100644 --- a/src/scripting/backend/codegen.cpp +++ b/src/scripting/backend/codegen.cpp @@ -11292,14 +11292,6 @@ FxExpression *FxLocalVariableDeclaration::Resolve(FCompileContext &ctx) { CHECKRESOLVED(); - if (IsDynamicArray()) - { - auto stackVar = new FxStackVariable(ValueType, StackOffset, ScriptPosition); - FArgumentList argsList; - clearExpr = new FxMemberFunctionCall(stackVar, "Clear", argsList, ScriptPosition); - SAFE_RESOLVE(clearExpr, ctx); - } - if (ctx.Block == nullptr) { ScriptPosition.Message(MSG_ERROR, "Variable declaration outside compound statement"); @@ -11356,6 +11348,15 @@ FxExpression *FxLocalVariableDeclaration::Resolve(FCompileContext &ctx) } } } + + if (IsDynamicArray()) + { + auto stackVar = new FxStackVariable(ValueType, StackOffset, ScriptPosition); + FArgumentList argsList; + clearExpr = new FxMemberFunctionCall(stackVar, "Clear", argsList, ScriptPosition); + SAFE_RESOLVE(clearExpr, ctx); + } + ctx.Block->LocalVars.Push(this); return this; }