From 35d5b28faeee5e19d0dbbeb3c75454249d636abd Mon Sep 17 00:00:00 2001 From: Christian Date: Mon, 8 Dec 2014 22:18:19 +0100 Subject: Variable-size stack elements for expression compiler. --- Compiler.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'Compiler.cpp') diff --git a/Compiler.cpp b/Compiler.cpp index e7263da6..73b3e324 100644 --- a/Compiler.cpp +++ b/Compiler.cpp @@ -213,15 +213,9 @@ bool Compiler::visit(FunctionDefinition& _function) // Note that the fact that the return arguments are of increasing index is vital for this // algorithm to work. - unsigned argumentsSize = 0; - for (ASTPointer const& variable: _function.getParameters()) - argumentsSize += variable->getType()->getSizeOnStack(); - unsigned returnValuesSize = 0; - for (ASTPointer const& variable: _function.getReturnParameters()) - returnValuesSize += variable->getType()->getSizeOnStack(); - unsigned localVariablesSize = 0; - for (VariableDeclaration const* localVariable: _function.getLocalVariables()) - localVariablesSize += localVariable->getType()->getSizeOnStack(); + unsigned const argumentsSize = CompilerUtils::getSizeOnStack(_function.getParameters()); + unsigned const returnValuesSize = CompilerUtils::getSizeOnStack(_function.getReturnParameters()); + unsigned const localVariablesSize = CompilerUtils::getSizeOnStack(_function.getLocalVariables()); vector stackLayout; stackLayout.push_back(returnValuesSize); // target of return address -- cgit v1.2.3