From b8b97dbe66697fa3827cdbb5d9fe43442cf43985 Mon Sep 17 00:00:00 2001 From: Stephane Del Pino <stephane.delpino44@gmail.com> Date: Wed, 2 Oct 2019 11:45:25 +0200 Subject: [PATCH] Add node value evaluation for function definition In an expression such as `` let f : R -> R, x -> x+1; `` the `1` value was not computed thus, its AST node value contained nothing. Now node values evaluation treats also functions expressions. --- src/language/ASTNodeValueBuilder.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/language/ASTNodeValueBuilder.cpp b/src/language/ASTNodeValueBuilder.cpp index 45108d64d..4e9c0d445 100644 --- a/src/language/ASTNodeValueBuilder.cpp +++ b/src/language/ASTNodeValueBuilder.cpp @@ -5,6 +5,9 @@ #include <EscapedString.hpp> +#include <FunctionTable.hpp> +#include <SymbolTable.hpp> + void ASTNodeValueBuilder::_buildNodeValue(ASTNode& n) { @@ -46,10 +49,19 @@ ASTNodeValueBuilder::_buildNodeValue(ASTNode& n) } } -ASTNodeValueBuilder::ASTNodeValueBuilder(ASTNode& n) +ASTNodeValueBuilder::ASTNodeValueBuilder(ASTNode& node) { - Assert(n.is_root()); - n.m_data_type = ASTNodeDataType::void_t; - this->_buildNodeValue(n); + Assert(node.is_root()); + node.m_data_type = ASTNodeDataType::void_t; + this->_buildNodeValue(node); + + FunctionTable& function_table = node.m_symbol_table->functionTable(); + for (size_t function_id = 0; function_id < function_table.size(); ++function_id) { + FunctionDescriptor& function_descriptor = function_table[function_id]; + ASTNode& function_expression = function_descriptor.definitionNode(); + + this->_buildNodeValue(function_expression); + } + std::cout << " - build node data types\n"; } -- GitLab