Skip to main content

TypeRegistry

Struct TypeRegistry 

Source
pub struct TypeRegistry { /* private fields */ }

Implementations§

Source§

impl TypeRegistry

Source

pub fn new() -> Self

Source

pub fn register(&mut self, name: Symbol, def: TypeDef)

Register a type definition

Source

pub fn set_field_span(&mut self, ty: Symbol, field: Symbol, span: Span)

Record where field of ty was named in the source.

Source

pub fn field_span(&self, ty: Symbol, field: Symbol) -> Option<Span>

Where field of ty was named in the source, if recorded.

Source

pub fn is_type(&self, name: Symbol) -> bool

Check if a symbol is a known type

Source

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.

Source

pub fn is_generic(&self, name: Symbol) -> bool

Check if a symbol is a generic type (takes parameters)

Source

pub fn get_generics(&self, name: Symbol) -> Option<&[Symbol]>

Phase 34: Get type parameters for a user-defined generic type

Source

pub fn get(&self, name: Symbol) -> Option<&TypeDef>

Get type definition

Source

pub fn iter_types(&self) -> impl Iterator<Item = (&Symbol, &TypeDef)>

Iterate over all registered types (for codegen)

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn is_variant(&self, name: Symbol) -> bool

Phase 33: Check if a symbol is an enum variant

Source

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.

Source

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.

Source

pub fn with_primitives(interner: &mut Interner) -> Self

Pre-register primitives and intrinsic generics

Trait Implementations§

Source§

impl Clone for TypeRegistry

Source§

fn clone(&self) -> TypeRegistry

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TypeRegistry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for TypeRegistry

Source§

fn default() -> TypeRegistry

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,