Implement enumeration type
This commit is contained in:
@ -114,7 +114,7 @@ namespace elna::boot
|
||||
unresolved_declaration->reference = this->current_type;
|
||||
}
|
||||
|
||||
void declaration_visitor::visit(primitive_type_expression *type_expression)
|
||||
void declaration_visitor::visit(named_type_expression *type_expression)
|
||||
{
|
||||
auto unresolved_alias = this->unresolved.find(type_expression->name);
|
||||
|
||||
@ -177,13 +177,23 @@ namespace elna::boot
|
||||
this->current_type = type(result_type);
|
||||
}
|
||||
|
||||
void declaration_visitor::visit(enumeration_type_expression *type_expression)
|
||||
{
|
||||
std::shared_ptr<enumeration_type> result_type = std::make_shared<enumeration_type>(type_expression->members);
|
||||
|
||||
this->current_type = type(result_type);
|
||||
}
|
||||
|
||||
void declaration_visitor::visit(variable_declaration *declaration)
|
||||
{
|
||||
declaration->variable_type().accept(this);
|
||||
}
|
||||
|
||||
void declaration_visitor::visit(constant_definition *)
|
||||
void declaration_visitor::visit(constant_definition *definition)
|
||||
{
|
||||
definition->body().accept(this);
|
||||
|
||||
this->symbols->enter(definition->identifier, std::make_shared<constant_info>(this->current_literal));
|
||||
}
|
||||
|
||||
void declaration_visitor::visit(procedure_definition *definition)
|
||||
@ -249,9 +259,9 @@ namespace elna::boot
|
||||
|
||||
void declaration_visitor::visit(return_statement *statement)
|
||||
{
|
||||
if (statement->return_expression() != nullptr)
|
||||
if (statement->return_expression != nullptr)
|
||||
{
|
||||
statement->return_expression()->accept(this);
|
||||
statement->return_expression->accept(this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -263,6 +273,22 @@ namespace elna::boot
|
||||
}
|
||||
}
|
||||
|
||||
void declaration_visitor::visit(case_statement *statement)
|
||||
{
|
||||
statement->condition().accept(this);
|
||||
for (const switch_case& case_block : statement->cases)
|
||||
{
|
||||
for (literal_expression *const case_label : case_block.labels)
|
||||
{
|
||||
case_label->accept(this);
|
||||
}
|
||||
for (struct statement *const statement : case_block.statements)
|
||||
{
|
||||
statement->accept(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void declaration_visitor::visit(procedure_call *call)
|
||||
{
|
||||
call->callable().accept(this);
|
||||
@ -333,31 +359,38 @@ namespace elna::boot
|
||||
expression->base().accept(this);
|
||||
}
|
||||
|
||||
void declaration_visitor::visit(literal<std::int32_t> *)
|
||||
void declaration_visitor::visit(literal<std::int32_t> *literal)
|
||||
{
|
||||
this->current_literal = literal->value;
|
||||
}
|
||||
|
||||
void declaration_visitor::visit(literal<std::uint32_t> *)
|
||||
void declaration_visitor::visit(literal<std::uint32_t> *literal)
|
||||
{
|
||||
this->current_literal = literal->value;
|
||||
}
|
||||
|
||||
void declaration_visitor::visit(literal<double> *)
|
||||
void declaration_visitor::visit(literal<double> *literal)
|
||||
{
|
||||
this->current_literal = literal->value;
|
||||
}
|
||||
|
||||
void declaration_visitor::visit(literal<bool> *)
|
||||
void declaration_visitor::visit(literal<bool> *literal)
|
||||
{
|
||||
this->current_literal = literal->value;
|
||||
}
|
||||
|
||||
void declaration_visitor::visit(literal<unsigned char> *)
|
||||
void declaration_visitor::visit(literal<unsigned char> *literal)
|
||||
{
|
||||
this->current_literal = literal->value;
|
||||
}
|
||||
|
||||
void declaration_visitor::visit(literal<std::nullptr_t> *)
|
||||
void declaration_visitor::visit(literal<std::nullptr_t> *literal)
|
||||
{
|
||||
this->current_literal = literal->value;
|
||||
}
|
||||
|
||||
void declaration_visitor::visit(literal<std::string> *)
|
||||
void declaration_visitor::visit(literal<std::string> *literal)
|
||||
{
|
||||
this->current_literal = literal->value;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user