diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2025-02-17 09:47:49 +0000 |
|---|---|---|
| committer | gingerBill <gingerBill@users.noreply.github.com> | 2025-02-17 09:47:49 +0000 |
| commit | 4eba3698aa1dde15abd22de1452229293282efee (patch) | |
| tree | 28b312308274c44400e00236047835f8a85cda21 /src | |
| parent | 2a5933513ca47d75c1f29efae2e9f948c3ae8103 (diff) | |
Begin work on nested declarations
Diffstat (limited to 'src')
| -rw-r--r-- | src/types.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/types.cpp b/src/types.cpp index c88878b9c..42530eccc 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -4919,6 +4919,12 @@ gb_internal u64 type_hash_canonical_type(Type *type) { return hash; } +gb_internal String type_to_canonical_string(gbAllocator allocator, Type *type) { + gbString w = gb_string_make(allocator, ""); + w = write_type_to_canonical_string(w, type); + return make_string(cast(u8 const *)w, gb_string_length(w)); +} + // NOTE(bill): This exists so that we deterministically hash a type by serializing it to a canonical string gb_internal gbString write_type_to_canonical_string(gbString w, Type *type) { if (type == nullptr) { @@ -5101,6 +5107,15 @@ gb_internal gbString write_type_to_canonical_string(gbString w, Type *type) { case Type_Named: if (type->Named.type_name != nullptr) { Entity *e = type->Named.type_name; + + if ((e->scope->flags & (ScopeFlag_File | ScopeFlag_Pkg)) == 0 || + e->flags & EntityFlag_NotExported) { + if (e->scope->flags & ScopeFlag_Proc) { + GB_PANIC("NESTED IN PROC\n"); + } else if (e->scope->flags & ScopeFlag_File) { + GB_PANIC("PRIVATE TO FILE\n"); + } + } if (e->pkg != nullptr) { w = gb_string_append_length(w, e->pkg->name.text, e->pkg->name.len); w = gb_string_appendc(w, "."); |