diff options
Diffstat (limited to 'boot/semantic.cc')
| -rw-r--r-- | boot/semantic.cc | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/boot/semantic.cc b/boot/semantic.cc index 29925c2..d8a3c41 100644 --- a/boot/semantic.cc +++ b/boot/semantic.cc @@ -35,6 +35,8 @@ namespace elna::boot return "Type '" + identifier + "' not declared"; case kind::already: return "Symbol '" + identifier + "' has been already declared"; + case kind::local_export: + return "Local symbol '" + this->identifier + "' cannot be exported"; default: __builtin_unreachable(); } @@ -906,6 +908,10 @@ namespace elna::boot { type->accept(this); } + for (procedure_declaration *const procedure : unit->procedures) + { + procedure->accept(this); + } } void declaration_visitor::visit(type_declaration *declaration) @@ -919,6 +925,43 @@ namespace elna::boot } } + void declaration_visitor::visit(procedure_declaration *declaration) + { + if (!declaration->body.has_value()) + { + return; + } + for (constant_declaration *const constant : declaration->body.value().constants()) + { + constant->accept(this); + } + for (variable_declaration *const variable : declaration->body.value().variables()) + { + variable->accept(this); + } + } + + void declaration_visitor::visit(variable_declaration *declaration) + { + for (const identifier_definition& variable_identifier : declaration->identifiers) + { + if (variable_identifier.exported) + { + add_error<declaration_error>(declaration_error::kind::local_export, + variable_identifier.name, declaration->position()); + } + } + } + + void declaration_visitor::visit(constant_declaration *declaration) + { + if (declaration->identifier.exported) + { + add_error<declaration_error>(declaration_error::kind::local_export, + declaration->identifier.name, declaration->position()); + } + } + bool is_base_of(std::shared_ptr<record_type> base, std::shared_ptr<record_type> derived) { type current = derived->base; |
