Save procedure info in the symbol table

This commit is contained in:
2025-03-31 12:48:30 +02:00
parent f2e2da4a34
commit 013bf91fbd
4 changed files with 96 additions and 77 deletions

View File

@ -51,6 +51,8 @@ namespace elna::boot
type current_type;
std::shared_ptr<symbol_table> symbols;
procedure_type build_procedure(procedure_type_expression& type_expression);
public:
std::unordered_map<std::string, std::shared_ptr<alias_type>> unresolved;

View File

@ -33,6 +33,7 @@ namespace elna::boot
class union_type;
class pointer_type;
class array_type;
class procedure_type;
class type
{
@ -44,7 +45,8 @@ namespace elna::boot
record,
_union,
pointer,
array
array,
procedure
};
type_tag tag{ type_tag::empty };
union
@ -55,6 +57,7 @@ namespace elna::boot
std::shared_ptr<union_type> _union;
std::shared_ptr<pointer_type> pointer;
std::shared_ptr<array_type> array;
std::shared_ptr<procedure_type> procedure;
};
void copy(const type& other);
@ -68,6 +71,7 @@ namespace elna::boot
explicit type(std::shared_ptr<union_type> _union);
explicit type(std::shared_ptr<pointer_type> pointer);
explicit type(std::shared_ptr<array_type> array);
explicit type(std::shared_ptr<procedure_type> procedure);
type(const type& other);
type& operator=(const type& other);
@ -138,6 +142,7 @@ namespace elna::boot
};
class type_info;
class procedure_info;
class info : public std::enable_shared_from_this<info>
{
@ -145,6 +150,7 @@ namespace elna::boot
virtual ~info() = 0;
virtual std::shared_ptr<type_info> is_type();
virtual std::shared_ptr<procedure_info> is_procedure();
};
class type_info : public info
@ -157,6 +163,17 @@ namespace elna::boot
std::shared_ptr<type_info> is_type() override;
};
class procedure_info : public info
{
public:
const procedure_type symbol;
const std::vector<std::string> names;
procedure_info(const procedure_type symbol, const std::vector<std::string> names);
std::shared_ptr<procedure_info> is_procedure() override;
};
/**
* Symbol table.
*/