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

Continue preparation of function evaluation

Function table is now populated and FunctionDescriptor is no more an inner class
of FunctionTable.

BTW fixed few warnings
parent 96b0b342
No related branches found
No related tags found
1 merge request!37Feature/language
......@@ -29,6 +29,10 @@ ASTSymbolTableBuilder::buildSymbolTable(ASTNode& n, std::shared_ptr<SymbolTable>
for (auto& child : n.children) {
this->buildSymbolTable(*child, local_symbol_table);
}
size_t function_id = symbol_table->functionTable()->add(FunctionDescriptor{});
i_symbol->attributes().value() = function_id;
} else {
n.m_symbol_table = symbol_table;
if (n.has_content()) {
......
......@@ -12,22 +12,25 @@
#include <iostream>
class FunctionTable
{
class FunctionDescriptor
{
std::unique_ptr<ASTNode> m_domain_mapping_node;
std::unique_ptr<ASTNode> m_expression_node;
public:
FunctionDescriptor& operator=(const FunctionDescriptor&) = default;
FunctionDescriptor& operator=(FunctionDescriptor&&) = default;
FunctionDescriptor(std::unique_ptr<ASTNode>&& domain_mapping_node, std::unique_ptr<ASTNode>&& expression_node)
: m_domain_mapping_node(std::move(domain_mapping_node)), m_expression_node(std::move(expression_node))
{}
FunctionDescriptor(FunctionDescriptor&&) = default;
FunctionDescriptor() = default;
~FunctionDescriptor() = default;
};
class FunctionTable
{
private:
std::vector<FunctionDescriptor> m_function_descriptor_list;
......
......@@ -70,6 +70,9 @@ class SymbolTable
friend std::ostream&
operator<<(std::ostream& os, const Attributes& attributes)
{
if (attributes.m_data_type == ASTNodeDataType::function_t) {
os << "function_id:";
}
std::visit(
[&](const auto& value) {
using T = std::decay_t<decltype(value)>;
......@@ -124,7 +127,6 @@ class SymbolTable
Symbol(const Symbol&) = default;
Symbol(Symbol&&) = default;
Symbol() = default;
~Symbol() = default;
};
......@@ -134,6 +136,12 @@ class SymbolTable
std::shared_ptr<FunctionTable> m_function_table;
public:
auto
functionTable() const
{
return m_function_table;
}
friend std::ostream&
operator<<(std::ostream& os, const SymbolTable& symbol_table)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment