Skip to content
Permalink
Browse files

- fixed variable's stack offset for implicit dynarray clearing

  • Loading branch information...
alexey-lysiuk committed Oct 22, 2019
1 parent 4fa6678 commit 9a727f6c2fc81115b65d499d350e0d835a23f034
Showing with 9 additions and 8 deletions.
  1. +9 −8 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;
}

0 comments on commit 9a727f6

Please sign in to comment.
You can’t perform that action at this time.