Skip to content
Snippets Groups Projects
Commit b8b97dbe authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

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.
parent 92bff11f
No related branches found
No related tags found
1 merge request!37Feature/language
......@@ -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";
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment