49 lines
1.4 KiB
C++
49 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include "elna/source/parser.hpp"
|
|
#include "elna/source/symbol_table.hpp"
|
|
|
|
namespace elna::source
|
|
{
|
|
class name_analysis_visitor final : public empty_visitor
|
|
{
|
|
std::shared_ptr<symbol_table> table = std::make_shared<symbol_table>();
|
|
|
|
std::shared_ptr<const type> convert_declaration_type(const type_expression& ast_type) const;
|
|
|
|
public:
|
|
name_analysis_visitor(std::shared_ptr<symbol_table> table);
|
|
|
|
void visit(constant_definition *definition) override;
|
|
void visit(declaration *declaration) override;
|
|
void visit(program *program) override;
|
|
void visit(procedure_definition *procedure) override;
|
|
};
|
|
|
|
/**
|
|
* Visitor which allocates registers and stack space for variables and
|
|
* parameters.
|
|
*/
|
|
class allocator_visitor final : public empty_visitor
|
|
{
|
|
std::ptrdiff_t local_offset;
|
|
std::ptrdiff_t argument_offset;
|
|
std::shared_ptr<symbol_table> table;
|
|
|
|
public:
|
|
allocator_visitor(std::shared_ptr<symbol_table> table);
|
|
|
|
void visit(declaration *declaration) override;
|
|
void visit(program *program) override;
|
|
void visit(procedure_definition *procedure) override;
|
|
void visit(call_statement *statement) override;
|
|
};
|
|
|
|
/**
|
|
* This visitor performs the type checking.
|
|
*/
|
|
class type_analysis_visitor final : public empty_visitor
|
|
{
|
|
};
|
|
}
|