aboutsummaryrefslogtreecommitdiff
path: root/boot/ast.cc
diff options
context:
space:
mode:
Diffstat (limited to 'boot/ast.cc')
-rw-r--r--boot/ast.cc27
1 files changed, 16 insertions, 11 deletions
diff --git a/boot/ast.cc b/boot/ast.cc
index d698cd4..69b15d3 100644
--- a/boot/ast.cc
+++ b/boot/ast.cc
@@ -352,7 +352,10 @@ namespace elna::boot
void walking_visitor::visit(variable_declaration *declaration)
{
- declaration->variable_type().accept(this);
+ if (declaration->variable_type != nullptr)
+ {
+ declaration->variable_type->accept(this);
+ }
if (declaration->initializer != nullptr)
{
declaration->initializer->accept(this);
@@ -895,17 +898,24 @@ namespace elna::boot
}
variable_declaration::variable_declaration(const source_position position,
- std::vector<identifier_definition>&& identifier, std::shared_ptr<type_expression> variable_type,
- expression *initializer)
- : node(position), m_variable_type(std::move(variable_type)), identifiers(std::move(identifier)), initializer(initializer)
+ std::vector<identifier_definition>&& identifier, type_expression *variable_type,
+ expression *initializer, const bool is_const)
+ : node(position), identifiers(std::move(identifier)), variable_type(variable_type),
+ initializer(initializer), is_const(is_const)
{
}
variable_declaration::variable_declaration(const source_position position,
- std::vector<identifier_definition>&& identifier, std::shared_ptr<type_expression> variable_type,
+ std::vector<identifier_definition>&& identifier, type_expression *variable_type,
std::monostate)
- : node(position), m_variable_type(std::move(variable_type)), identifiers(std::move(identifier)), is_extern(true)
+ : node(position), identifiers(std::move(identifier)), variable_type(variable_type),
+ is_extern(true)
+ {
+ }
+
+ variable_declaration::~variable_declaration()
{
+ delete this->variable_type;
}
void variable_declaration::accept(parser_visitor *visitor)
@@ -918,11 +928,6 @@ namespace elna::boot
return this->is_extern || this->initializer != nullptr;
}
- type_expression& variable_declaration::variable_type()
- {
- return *m_variable_type;
- }
-
procedure_type_expression::procedure_type_expression(const source_position position,
std::vector<field_declaration>&& parameters, type_expression *return_type)
: node(position), return_type(return_type), parameters(std::move(parameters))