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

Fix return type evaluation for embedded C functions

previously it was forced to ASTNodeDataType::double_t
parent dc5f0422
No related branches found
No related tags found
1 merge request!37Feature/language
......@@ -4,6 +4,8 @@
#include <PugsAssert.hpp>
#include <SymbolTable.hpp>
#include <CFunctionEmbedder.hpp>
void
ASTNodeDataTypeBuilder::_buildNodeDataTypes(ASTNode& n)
{
......@@ -254,9 +256,17 @@ ASTNodeDataTypeBuilder::_buildNodeDataTypes(ASTNode& n)
n.m_data_type = data_type;
} else if (n.children[0]->m_data_type == ASTNodeDataType::c_function_t) {
std::cout << __FILE__ << ':' << __LINE__ << ": " << rang::fgB::red << "datatype is incorrectly defined!"
<< rang::style::reset << '\n';
n.m_data_type = ASTNodeDataType::double_t;
const std::string c_function_name = n.children[0]->string();
auto& symbol_table = *n.m_symbol_table;
auto [i_symbol, success] = symbol_table.find(c_function_name, n.begin());
Assert(success);
uint64_t c_function_id = std::get<uint64_t>(i_symbol->attributes().value());
auto c_function_embedder = symbol_table.cFunctionEbedderTable()[c_function_id];
Assert(c_function_embedder);
n.m_data_type = c_function_embedder->getReturnDataType();
} else {
std::ostringstream message;
message << "invalid function call\n"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment