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

Continue types checking at function declaration [ci skip]

Seems to work for functions that maps to a single space (not a list)
parent 90478c9a
No related branches found
No related tags found
1 merge request!52Issue/21
...@@ -166,6 +166,7 @@ ASTNodeDataTypeBuilder::_buildNodeDataTypes(ASTNode& n) const ...@@ -166,6 +166,7 @@ ASTNodeDataTypeBuilder::_buildNodeDataTypes(ASTNode& n) const
n.children[0]->m_data_type = ASTNodeDataType::build<ASTNodeDataType::function_t>(); n.children[0]->m_data_type = ASTNodeDataType::build<ASTNodeDataType::function_t>();
const std::string& symbol = n.children[0]->string(); const std::string& symbol = n.children[0]->string();
auto [i_symbol, success] = n.m_symbol_table->find(symbol, n.children[0]->begin()); auto [i_symbol, success] = n.m_symbol_table->find(symbol, n.children[0]->begin());
auto& function_table = n.m_symbol_table->functionTable(); auto& function_table = n.m_symbol_table->functionTable();
...@@ -283,6 +284,7 @@ ASTNodeDataTypeBuilder::_buildNodeDataTypes(ASTNode& n) const ...@@ -283,6 +284,7 @@ ASTNodeDataTypeBuilder::_buildNodeDataTypes(ASTNode& n) const
// LCOV_EXCL_STOP // LCOV_EXCL_STOP
}; };
#warning probably useless now
if (image_domain_node.is_type<language::type_expression>()) { if (image_domain_node.is_type<language::type_expression>()) {
std::vector<std::shared_ptr<const ASTNodeDataType>> sub_data_type_list; std::vector<std::shared_ptr<const ASTNodeDataType>> sub_data_type_list;
sub_data_type_list.reserve(image_domain_node.children.size()); sub_data_type_list.reserve(image_domain_node.children.size());
...@@ -298,6 +300,10 @@ ASTNodeDataTypeBuilder::_buildNodeDataTypes(ASTNode& n) const ...@@ -298,6 +300,10 @@ ASTNodeDataTypeBuilder::_buildNodeDataTypes(ASTNode& n) const
check_image_type(image_domain_node); check_image_type(image_domain_node);
} }
this->_buildNodeDataTypes(image_expression_node);
ASTNodeNaturalConversionChecker(image_expression_node, image_domain_node.m_data_type);
n.m_data_type = ASTNodeDataType::build<ASTNodeDataType::void_t>(); n.m_data_type = ASTNodeDataType::build<ASTNodeDataType::void_t>();
return; return;
} else if (n.is_type<language::name>()) { } else if (n.is_type<language::name>()) {
...@@ -435,6 +441,7 @@ ASTNodeDataTypeBuilder::_buildNodeDataTypes(ASTNode& n) const ...@@ -435,6 +441,7 @@ ASTNodeDataTypeBuilder::_buildNodeDataTypes(ASTNode& n) const
} else if (n.is_type<language::function_evaluation>()) { } else if (n.is_type<language::function_evaluation>()) {
if (n.children[0]->m_data_type == ASTNodeDataType::function_t) { if (n.children[0]->m_data_type == ASTNodeDataType::function_t) {
const std::string& function_name = n.children[0]->string(); const std::string& function_name = n.children[0]->string();
auto [i_function_symbol, success] = n.m_symbol_table->find(function_name, n.children[0]->begin()); auto [i_function_symbol, success] = n.m_symbol_table->find(function_name, n.children[0]->begin());
auto& function_table = n.m_symbol_table->functionTable(); auto& function_table = n.m_symbol_table->functionTable();
...@@ -518,13 +525,5 @@ ASTNodeDataTypeBuilder::ASTNodeDataTypeBuilder(ASTNode& node) ...@@ -518,13 +525,5 @@ ASTNodeDataTypeBuilder::ASTNodeDataTypeBuilder(ASTNode& node)
this->_buildNodeDataTypes(node); this->_buildNodeDataTypes(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->_buildNodeDataTypes(function_expression);
}
std::cout << " - build node data types\n"; std::cout << " - build node data types\n";
} }
...@@ -28,8 +28,10 @@ ASTNodeNaturalConversionChecker::_checkIsNaturalExpressionConversion(const ASTNo ...@@ -28,8 +28,10 @@ ASTNodeNaturalConversionChecker::_checkIsNaturalExpressionConversion(const ASTNo
const ASTNodeDataType& data_type, const ASTNodeDataType& data_type,
const ASTNodeDataType& target_data_type) const const ASTNodeDataType& target_data_type) const
{ {
if (target_data_type == ASTNodeDataType::vector_t) { if (target_data_type == ASTNodeDataType::typename_t) {
switch (data_type) { this->_checkIsNaturalExpressionConversion(node, data_type, target_data_type.contentType());
} else if (target_data_type == ASTNodeDataType::vector_t) {
switch (node.m_data_type) {
case ASTNodeDataType::list_t: { case ASTNodeDataType::list_t: {
if (node.children.size() != target_data_type.dimension()) { if (node.children.size() != target_data_type.dimension()) {
throw ParseError("incompatible dimensions in affectation", std::vector{node.begin()}); throw ParseError("incompatible dimensions in affectation", std::vector{node.begin()});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment