Documentation
¶
Overview ¶
Package registry provides type deduplication for the naga IR. It ensures each unique type is registered exactly once, which is required by SPIR-V and other backends that need unique type declarations.
Index ¶
- type TypeRegistry
- func (r *TypeRegistry) Append(name string, inner ir.TypeInner) ir.TypeHandle
- func (r *TypeRegistry) Count() int
- func (r *TypeRegistry) GetOrCreate(name string, inner ir.TypeInner) ir.TypeHandle
- func (r *TypeRegistry) GetTypes() []ir.Type
- func (r *TypeRegistry) Lookup(handle ir.TypeHandle) (ir.Type, bool)
- func (r *TypeRegistry) SetName(handle ir.TypeHandle, name string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TypeRegistry ¶
type TypeRegistry struct {
// contains filtered or unexported fields
}
TypeRegistry ensures type deduplication for SPIR-V emission. SPIR-V requires that each unique type is declared exactly once.
func NewTypeRegistry ¶
func NewTypeRegistry() *TypeRegistry
NewTypeRegistry creates a new type registry for deduplication.
func NewTypeRegistryWithCap ¶
func NewTypeRegistryWithCap(initialCap int) *TypeRegistry
NewTypeRegistryWithCap creates a new type registry with pre-allocated capacity. Use this when the expected number of types is known to avoid slice regrowth.
func (*TypeRegistry) Append ¶
func (r *TypeRegistry) Append(name string, inner ir.TypeInner) ir.TypeHandle
Append adds a type without deduplication, always creating a new entry. This matches Rust naga's Arena behavior where each append() creates a new entry even for structurally identical types. Use this for array types that Rust naga does not deduplicate.
func (*TypeRegistry) Count ¶
func (r *TypeRegistry) Count() int
Count returns the number of unique types registered.
func (*TypeRegistry) GetOrCreate ¶
func (r *TypeRegistry) GetOrCreate(name string, inner ir.TypeInner) ir.TypeHandle
GetOrCreate returns an existing handle for the type if it exists, or creates a new one if it's unique. Named struct types are never deduplicated with each other (different names mean different types), matching Rust naga's Arena behavior.
func (*TypeRegistry) GetTypes ¶
func (r *TypeRegistry) GetTypes() []ir.Type
GetTypes returns all registered types.
func (*TypeRegistry) Lookup ¶
func (r *TypeRegistry) Lookup(handle ir.TypeHandle) (ir.Type, bool)
Lookup finds a type by its handle.
func (*TypeRegistry) SetName ¶
func (r *TypeRegistry) SetName(handle ir.TypeHandle, name string)
SetName renames an existing type in the registry and updates the dedup key. Used when a type alias renames an anonymous type in-place (e.g., `alias rq = ray_query;` renames the anonymous RayQuery entry to "rq").