aboutsummaryrefslogtreecommitdiff
path: root/boot/type_check.cc
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2026-09-27 11:23:17 +0200
committerEugen Wissner <belka@caraus.de>2026-09-27 11:23:17 +0200
commitc57a24b9fe37e233e7ec0e2e65405738d9c09c6e (patch)
tree99b5f4dc22d27d8159c3ba76f2cf3a455ed37fb6 /boot/type_check.cc
parentd048b633dd02014f8bff1b512ce4d5ae2b8b7903 (diff)
downloadelna-c57a24b9fe37e233e7ec0e2e65405738d9c09c6e.tar.gz
Reuse container visiting logic
Diffstat (limited to 'boot/type_check.cc')
-rw-r--r--boot/type_check.cc25
1 files changed, 14 insertions, 11 deletions
diff --git a/boot/type_check.cc b/boot/type_check.cc
index 71fd8ab..15a01dc 100644
--- a/boot/type_check.cc
+++ b/boot/type_check.cc
@@ -800,13 +800,19 @@ namespace elna::boot
}
}
- void type_analysis_visitor::visit_entry_point(unit *unit)
+ void type_analysis_visitor::visit(unit *unit)
{
- this->current_procedure = this->bag.lookup("")->is_procedure();
- this->bag.enter(this->current_procedure->scope);
- walking_visitor::visit_entry_point(unit);
- this->bag.leave();
- this->current_procedure.reset();
+ visit_all(this, unit->imports);
+ visit_all(this, unit->declarations);
+
+ if (unit->entry_point.has_value())
+ {
+ this->current_procedure = this->bag.lookup("")->is_procedure();
+ this->bag.enter(this->current_procedure->scope);
+ visit_all(this, unit->entry_point.value());
+ this->bag.leave();
+ this->current_procedure.reset();
+ }
}
void type_analysis_visitor::visit(variable_declaration *declaration)
@@ -885,7 +891,7 @@ namespace elna::boot
void type_analysis_visitor::traverse_block(block& body)
{
this->bag.enter(body.symbols);
- walking_visitor::traverse_block(body);
+ boot::traverse_block(this, body);
this->bag.leave();
}
@@ -1409,10 +1415,7 @@ namespace elna::boot
{
// Inference reads the argument types, so they are decorated
// before the parameter types they will be checked against exist.
- for (expression *const argument : call->arguments)
- {
- argument->accept(this);
- }
+ visit_all(this, call->arguments);
inferred = procedure;
callable_type = infer_call(*call, *reference, *procedure);