From 29456bcdea6e9567a9655e49a948f9e57920ff7a Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 19 Feb 2025 11:12:32 +0000 Subject: [PATCH] Move docs to the header --- src/name_canonicalization.cpp | 30 +----------------------------- src/name_canonicalization.hpp | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 29 deletions(-) diff --git a/src/name_canonicalization.cpp b/src/name_canonicalization.cpp index b24bf91260e..043317ef0e2 100644 --- a/src/name_canonicalization.cpp +++ b/src/name_canonicalization.cpp @@ -1,26 +1,3 @@ -/* - General Rules for canonical name mangling - - * No spaces between any values - - * normal declarations - pkg::name - * builtin names - just their normal name e.g. `i32` or `string` - * nested - pkg::parent1::parent2::name - * file private - pkg::[file_name]::name - * Example: `pkg::[file.odin]::Type` - * polymorphic procedure/type - pkg::foo:TYPE - * naming convention for parameters - * type - * $typeid_based_name - * $$constant_parameter - * Example: `foo::to_thing:proc(u64)->([]u8)` - * nested decl in polymorphic procedure - pkg::foo:TYPE::name - * anonymous procedures - pkg::foo::$anon[file.odin:123] - * 123 is the file offset in bytes - - -*/ - gb_internal GB_COMPARE_PROC(type_info_pair_cmp) { TypeInfoPair *x = cast(TypeInfoPair *)a; TypeInfoPair *y = cast(TypeInfoPair *)b; @@ -397,11 +374,7 @@ gb_internal void write_canonical_parent_prefix(TypeWriter *w, Entity *e) { } type_writer_append_fmt(w, CANONICAL_NAME_SEPARATOR "[%.*s]" CANONICAL_NAME_SEPARATOR, LIT(file_name)); } - } else if (e->kind == Entity_Procedure) { - if (e->Procedure.is_export || e->Procedure.is_foreign) { - // no prefix - return; - } + } else { GB_PANIC("TODO(bill): handle entity kind: %d", e->kind); } if (e->kind == Entity_Procedure && e->Procedure.is_anonymous) { @@ -467,7 +440,6 @@ gb_internal void write_canonical_entity_name(TypeWriter *w, Entity *e) { if (e->scope->index > 0) { type_writer_append_fmt(w, CANONICAL_TYPE_SEPARATOR "[%d]", e->scope->index); } - // type_writer_append_fmt(w, CANONICAL_TYPE_SEPARATOR "[%d]", e->token.pos.offset); goto write_base_name; } else if ((s->flags & ScopeFlag_File) && s->file != nullptr) { diff --git a/src/name_canonicalization.hpp b/src/name_canonicalization.hpp index 1820a90fb1a..e289ed5b2d8 100644 --- a/src/name_canonicalization.hpp +++ b/src/name_canonicalization.hpp @@ -1,3 +1,25 @@ +/* + General Rules for canonical name mangling + + * No spaces between any values + + * normal declarations - pkg::name + * builtin names - just their normal name e.g. `i32` or `string` + * nested (zero level) - pkg::parent1::parent2::name + * nested (more scopes) - pkg::parent1::parent2::name[4] + * [4] indicates the 4th scope within a procedure numbered in depth-first order + * file private - pkg::[file_name]::name + * Example: `pkg::[file.odin]::Type` + * polymorphic procedure/type - pkg::foo:TYPE + * naming convention for parameters + * type + * $typeid_based_name + * $$constant_parameter + * Example: `foo::to_thing:proc(u64)->([]u8)` + * nested decl in polymorphic procedure - pkg::foo:TYPE::name + * anonymous procedures - pkg::foo::$anon[file.odin:123] + * 123 is the file offset in bytes +*/ #define CANONICAL_TYPE_SEPARATOR ":" #define CANONICAL_NAME_SEPARATOR "::"