aboutsummaryrefslogtreecommitdiff
path: root/boot/symbol.cc
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2026-07-15 17:23:42 +0200
committerEugen Wissner <belka@caraus.de>2026-07-15 17:23:42 +0200
commite7265af15f77abf60a899b3d53a59652b5ca71ea (patch)
tree50b5594c4517da87b185268e709194e964c236af /boot/symbol.cc
parent308a2addf655fe45f2098f8542f0ff1290612cd9 (diff)
downloadelna-e7265af15f77abf60a899b3d53a59652b5ca71ea.tar.gz
Track identifier positions for the diagnostics
Diffstat (limited to 'boot/symbol.cc')
-rw-r--r--boot/symbol.cc48
1 files changed, 48 insertions, 0 deletions
diff --git a/boot/symbol.cc b/boot/symbol.cc
index d7ceacb..a3a36c1 100644
--- a/boot/symbol.cc
+++ b/boot/symbol.cc
@@ -270,6 +270,54 @@ namespace elna::boot
return tag == type_tag::empty;
}
+ std::string type::to_string() const
+ {
+ switch (tag)
+ {
+ case type_tag::empty:
+ return "<empty>";
+ case type_tag::alias:
+ return alias.lock()->name;
+ case type_tag::primitive:
+ return primitive->identifier;
+ case type_tag::pointer:
+ return "^" + pointer->base.to_string();
+ case type_tag::array:
+ return "[" + std::to_string(array->size) + "]" + array->base.to_string();
+ case type_tag::record:
+ if (record->base.empty())
+ {
+ return "record ... end";
+ }
+ else
+ {
+ return "record(" + record->base.to_string() + ") ... end";
+ }
+ case type_tag::procedure:
+ {
+ std::string result = "proc(";
+ for (std::size_t i = 0; i < procedure->parameters.size(); ++i)
+ {
+ if (i > 0) result += ", ";
+ result += procedure->parameters[i].to_string();
+ }
+ result += ")";
+ if (procedure->return_type.no_return)
+ {
+ result += ": !";
+ }
+ else if (!procedure->return_type.proper_type.empty())
+ {
+ result += ": " + procedure->return_type.proper_type.to_string();
+ }
+ return result;
+ }
+ case type_tag::enumeration:
+ return "(enumeration)";
+ }
+ __builtin_unreachable();
+ }
+
alias_type::alias_type(const std::string& name)
: name(name), reference()
{