_ prefixed top-level symbols now file-local

This commit is contained in:
2026-07-11 23:37:30 +02:00
parent 6dd6b7ff54
commit 220b1c6e82
15 changed files with 282 additions and 90 deletions
+19 -6
View File
@@ -102,6 +102,7 @@ Node :: struct {
c_layout: bool,
opaque: bool,
declared: bool,
file_hidden: bool,
explicit_backing: bool,
}
@@ -185,24 +186,36 @@ intern :: proc(store: ^Store, candidate: Node) -> Type {
return id
}
named :: proc(store: ^Store, pkg, name: u32, qualifier: u32 = 0, file: u32 = 0xffff_ffff) -> Type {
normalized_file := file if qualifier != 0 else u32(0)
named :: proc(store: ^Store, pkg, name: u32, qualifier: u32 = 0, file: u32 = 0xffff_ffff, file_hidden := false) -> Type {
normalized_file := file if qualifier != 0 || file_hidden else u32(0)
for existing, index in store.nodes {
visibility_matches := existing.file_hidden == file_hidden &&
(!file_hidden || existing.file == normalized_file)
if (existing.kind == .Named || existing.kind == .Alias || existing.kind == .Distinct ||
existing.kind == .Enum || existing.kind == .Struct || existing.kind == .Union) &&
existing.pkg == pkg && existing.name == name && existing.qualifier == qualifier &&
existing.file == normalized_file {
(visibility_matches || qualifier == 0 && existing.file_hidden != file_hidden) {
return DYNAMIC_START+Type(index)
}
}
return intern(store, Node{kind=.Named, pkg=pkg, name=name, qualifier=qualifier, file=normalized_file})
return intern(store, Node{kind=.Named, pkg=pkg, name=name, qualifier=qualifier, file=normalized_file, file_hidden=file_hidden})
}
find_named :: proc(store: ^Store, pkg, name: u32, qualifier: u32 = 0) -> Type {
find_named :: proc(store: ^Store, pkg, name: u32, qualifier: u32 = 0, file: u32 = 0xffff_ffff) -> Type {
if file != 0xffff_ffff {
for existing, index in store.nodes {
if (existing.kind == .Named || existing.kind == .Alias || existing.kind == .Distinct ||
existing.kind == .Enum || existing.kind == .Struct || existing.kind == .Union) &&
existing.pkg == pkg && existing.name == name && existing.qualifier == qualifier &&
existing.file_hidden && existing.file == file {
return DYNAMIC_START+Type(index)
}
}
}
for existing, index in store.nodes {
if (existing.kind == .Named || existing.kind == .Alias || existing.kind == .Distinct ||
existing.kind == .Enum || existing.kind == .Struct || existing.kind == .Union) &&
existing.pkg == pkg && existing.name == name && existing.qualifier == qualifier {
existing.pkg == pkg && existing.name == name && existing.qualifier == qualifier && !existing.file_hidden {
return DYNAMIC_START+Type(index)
}
}