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

Simplify function descriptor access from FunctionSymbolId

parent c2d4c08b
No related branches found
No related tags found
1 merge request!75Feature/language discretization
......@@ -52,9 +52,7 @@ UtilsModule::UtilsModule()
std::make_shared<BuiltinFunctionEmbedder<std::string(const FunctionSymbolId&)>>(
[](const FunctionSymbolId& function_symbol_id) -> std::string {
auto& function_table = function_symbol_id.symbolTable().functionTable();
const auto& function_descriptor = function_table[function_symbol_id.id()];
const auto& function_descriptor = function_symbol_id.descriptor();
std::ostringstream os;
os << function_descriptor.name() << ": domain mapping\n";
......
......@@ -22,6 +22,7 @@ add_library(PugsLanguageUtils
BinaryOperatorRegisterForZ.cpp
DataVariant.cpp
EmbeddedData.cpp
FunctionSymbolId.cpp
IncDecOperatorRegisterForN.cpp
IncDecOperatorRegisterForR.cpp
IncDecOperatorRegisterForZ.cpp
......
#include <language/utils/FunctionSymbolId.hpp>
#include <language/utils/SymbolTable.hpp>
const FunctionDescriptor&
FunctionSymbolId::descriptor() const
{
return m_symbol_table->functionTable()[m_function_id];
}
......@@ -8,7 +8,9 @@
#include <iostream>
#include <memory>
class FunctionDescriptor;
class SymbolTable;
class FunctionSymbolId
{
private:
......@@ -29,6 +31,8 @@ class FunctionSymbolId
return *m_symbol_table;
}
[[nodiscard]] const FunctionDescriptor& descriptor() const;
friend std::ostream&
operator<<(std::ostream& os, const FunctionSymbolId& function_symbol_id)
{
......
......@@ -119,10 +119,10 @@ class PugsFunctionAdapter<OutputType(InputType...)>
[[nodiscard]] PUGS_INLINE static auto&
getFunctionExpression(const FunctionSymbolId& function_symbol_id)
{
auto& function = function_symbol_id.symbolTable().functionTable()[function_symbol_id.id()];
_checkFunction(function);
auto& function_descriptor = function_symbol_id.descriptor();
_checkFunction(function_descriptor);
return *function.definitionNode().children[1];
return *function_descriptor.definitionNode().children[1];
}
[[nodiscard]] PUGS_INLINE static auto
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment