pub struct TypeRegistry { /* private fields */ }Implementations§
Source§impl TypeRegistry
impl TypeRegistry
pub fn new() -> Self
Sourcepub fn set_field_span(&mut self, ty: Symbol, field: Symbol, span: Span)
pub fn set_field_span(&mut self, ty: Symbol, field: Symbol, span: Span)
Record where field of ty was named in the source.
Sourcepub fn field_span(&self, ty: Symbol, field: Symbol) -> Option<Span>
pub fn field_span(&self, ty: Symbol, field: Symbol) -> Option<Span>
Where field of ty was named in the source, if recorded.
Sourcepub fn is_builtin_struct(&self, name: Symbol) -> bool
pub fn is_builtin_struct(&self, name: Symbol) -> bool
Whether name is one of BUILTIN_STRUCT_NAMES — a struct the compiler always
registers, never one this program declared or imported.
Sourcepub fn is_generic(&self, name: Symbol) -> bool
pub fn is_generic(&self, name: Symbol) -> bool
Check if a symbol is a generic type (takes parameters)
Sourcepub fn get_generics(&self, name: Symbol) -> Option<&[Symbol]>
pub fn get_generics(&self, name: Symbol) -> Option<&[Symbol]>
Phase 34: Get type parameters for a user-defined generic type
Sourcepub fn iter_types(&self) -> impl Iterator<Item = (&Symbol, &TypeDef)>
pub fn iter_types(&self) -> impl Iterator<Item = (&Symbol, &TypeDef)>
Iterate over all registered types (for codegen)
Sourcepub fn find_variant_candidates(
&self,
variant_name: Symbol,
) -> Vec<(Symbol, &VariantDef)>
pub fn find_variant_candidates( &self, variant_name: Symbol, ) -> Vec<(Symbol, &VariantDef)>
Every enum declaring a variant named variant_name, in a STABLE, deterministic order
— sorted by the enum’s own Symbol (its intern index, fixed by the deterministic
sequence discovery interns names in, never by self.types’ HashMap iteration order,
which is reseeded, and so reordered, every process run). Two (or more) enums sharing a
variant name is a real, checkable condition: empty means no such variant anywhere, one
entry means an ordinary unambiguous lookup, and more than one is an ambiguity a caller
can act on (an Inspect prefers whichever enum it has already established; a bare
construction with no such context has nothing to prefer and must refuse) — instead of a
coin flip that used to silently compile the same source differently from run to run.
Sourcepub fn find_distinct_variant_candidates(
&self,
variant_name: Symbol,
interner: &Interner,
) -> Vec<(Symbol, &VariantDef)>
pub fn find_distinct_variant_candidates( &self, variant_name: Symbol, interner: &Interner, ) -> Vec<(Symbol, &VariantDef)>
Self::find_variant_candidates with each twin pair (see Self::namespaced_twins) counted
once, as its namespaced member: Colors::Filter and the bare Filter the assembler spliced
beside it are one enum, so a variant both declare is not ambiguous.
Sourcepub fn namespaced_twins(&self, interner: &Interner) -> HashMap<Symbol, Symbol>
pub fn namespaced_twins(&self, interner: &Interner) -> HashMap<Symbol, Symbol>
Each bare type name that names a namespaced type, keyed by the bare name. The assembler
registers an imported module’s type under both its simple name (Point, from the inline
splice) and its canonical Geometry::Point; when exactly one namespaced type is called
Point, the bare spelling IS that type, and every consumer — the parser’s variant
resolution, the checker, the monomorphizer, the AOT emitter’s alias — gives both spellings
one identity. A simple name two namespaced types share stays ambiguous and maps to nothing,
and a bare type is only ever the twin of a namespaced type of its own kind.
Sourcepub fn canonical_type(&self, name: Symbol, interner: &Interner) -> Symbol
pub fn canonical_type(&self, name: Symbol, interner: &Interner) -> Symbol
The one identity a type named name has: its namespaced twin when the bare spelling names
one (see Self::namespaced_twins), else itself.
Sourcepub fn find_variant(
&self,
variant_name: Symbol,
) -> Option<(Symbol, &VariantDef)>
pub fn find_variant( &self, variant_name: Symbol, ) -> Option<(Symbol, &VariantDef)>
Phase 33: Check if a symbol is a known enum variant.
Returns Some((enum_name, variant_def)) for the first candidate in
Self::find_variant_candidates’s own deterministic order when the variant name is
declared by more than one enum — callers that must tell the difference (an ambiguous
bare construction) use find_variant_candidates directly instead.
Sourcepub fn is_variant(&self, name: Symbol) -> bool
pub fn is_variant(&self, name: Symbol) -> bool
Phase 33: Check if a symbol is an enum variant
Sourcepub fn variant_in(
&self,
enum_name: Symbol,
variant_name: Symbol,
) -> Option<&VariantDef>
pub fn variant_in( &self, enum_name: Symbol, variant_name: Symbol, ) -> Option<&VariantDef>
The variant named variant_name declared by enum_name SPECIFICALLY — for a
construction that already names its enum (a new Failure from Outcome), so the field
list checked against is the ONE the author pointed at, never
Self::find_variant’s own deterministic-first-candidate pick, which could be a
same-named variant of a DIFFERENT enum with a different field shape entirely.
Sourcepub fn variant_names_of(&self, enum_name: Symbol) -> Option<Vec<Symbol>>
pub fn variant_names_of(&self, enum_name: Symbol) -> Option<Vec<Symbol>>
Every variant name enum_name declares, for a “did you mean” suggestion when from <enum_name> names a real enum that does not declare the variant asked for. None when
enum_name is not an enum at all.
Sourcepub fn with_primitives(interner: &mut Interner) -> Self
pub fn with_primitives(interner: &mut Interner) -> Self
Pre-register primitives and intrinsic generics
Trait Implementations§
Source§impl Clone for TypeRegistry
impl Clone for TypeRegistry
Source§fn clone(&self) -> TypeRegistry
fn clone(&self) -> TypeRegistry
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more