diff options
Diffstat (limited to 'Compiler.cpp')
-rw-r--r-- | Compiler.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/Compiler.cpp b/Compiler.cpp index 68052e27..47729964 100644 --- a/Compiler.cpp +++ b/Compiler.cpp @@ -376,9 +376,9 @@ bool Compiler::visit(FunctionDefinition const& _function) } for (ASTPointer<VariableDeclaration const> const& variable: _function.getReturnParameters()) - m_context.addAndInitializeVariable(*variable); + appendStackVariableInitialisation(*variable); for (VariableDeclaration const* localVariable: _function.getLocalVariables()) - m_context.addAndInitializeVariable(*localVariable); + appendStackVariableInitialisation(*localVariable); if (_function.isConstructor()) if (auto c = m_context.getNextConstructor(dynamic_cast<ContractDefinition const&>(*_function.getScope()))) @@ -623,7 +623,7 @@ void Compiler::appendModifierOrFunctionCode() modifier.getParameters()[i]->getType()); } for (VariableDeclaration const* localVariable: modifier.getLocalVariables()) - m_context.addAndInitializeVariable(*localVariable); + appendStackVariableInitialisation(*localVariable); unsigned const c_stackSurplus = CompilerUtils::getSizeOnStack(modifier.getParameters()) + CompilerUtils::getSizeOnStack(modifier.getLocalVariables()); @@ -637,6 +637,13 @@ void Compiler::appendModifierOrFunctionCode() } } +void Compiler::appendStackVariableInitialisation(VariableDeclaration const& _variable) +{ + CompilerContext::LocationSetter location(m_context, _variable); + m_context.addVariable(_variable); + ExpressionCompiler(m_context).appendStackVariableInitialisation(*_variable.getType()); +} + void Compiler::compileExpression(Expression const& _expression, TypePointer const& _targetType) { ExpressionCompiler expressionCompiler(m_context, m_optimize); |