v3.types #
Type aliases type values used by types.
Constants #
const bool_ = Primitive{
props: .boolean
}
const int_ = Primitive{
props: .integer
}
const i8_ = Primitive{
props: .integer
size: 8
}
const i16_ = Primitive{
props: .integer
size: 16
}
const i32_ = Primitive{
props: .integer
size: 32
}
const i64_ = Primitive{
props: .integer
size: 64
}
const u8_ = Primitive{
props: .integer | .unsigned
size: 8
}
const u16_ = Primitive{
props: .integer | .unsigned
size: 16
}
const u32_ = Primitive{
props: .integer | .unsigned
size: 32
}
const u64_ = Primitive{
props: .integer | .unsigned
size: 64
}
const f32_ = Primitive{
props: .float
size: 32
}
const f64_ = Primitive{
props: .float
size: 64
}
const string_ = String{}
const char_ = Char{}
const rune_ = Rune{}
const isize_ = ISize{}
const usize_ = USize{}
const void_ = Void{}
const nil_ = Nil{}
const none_ = None{}
const voidptr_ = Pointer{
base_type: Type(Void{})
}
const charptr_ = Pointer{
base_type: Type(Char{})
}
const byteptr_ = Pointer{
base_type: Type(Primitive{
props: .integer | .unsigned
size: 8
})
}
fn builtin_type #
fn builtin_type(name string) ?Type
builtin_type returns the Type for a builtin type name, or none otherwise.
fn builtin_type_value #
fn builtin_type_value(name string) Type
builtin_type_value returns the Type for a known builtin type name.
fn clone_owned_type #
fn clone_owned_type(value Type) Type
clone_owned_type clones a type and all nested owned metadata.
fn clone_owned_types #
fn clone_owned_types(values []Type) []Type
clone_owned_types clones a list of types and all nested owned metadata.
fn generic_base_name #
fn generic_base_name(name string) string
generic_base_name returns the declaration part of a concrete generic type name.
fn is_builtin_type_name #
fn is_builtin_type_name(name string) bool
is_builtin_type_name reports whether name is one of V's builtin type names.
fn new_scope #
fn new_scope(parent &Scope) &Scope
new_scope returns a reusable type-checker scope with an optional parent.
fn stable_interface_type_ids #
fn stable_interface_type_ids(impl_names []string) map[string]int
stable_interface_type_ids assigns deterministic nonzero _typ dispatch IDs to interface implementers in caller-supplied order. Hash collisions are resolved with linear probing after earlier names keep their IDs, so late generic implementers appended after transform cannot shift IDs already emitted for existing interface values/checks.
fn stable_interface_type_ids_preserving_prefix #
fn stable_interface_type_ids_preserving_prefix(prefix []string, impl_names []string) map[string]int
stable_interface_type_ids_preserving_prefix assigns IDs for impl_names while keeping all prefix IDs exactly as they would be when assigned alone.
fn unsigned_shift_result_type #
fn unsigned_shift_result_type(t Type) Type
unsigned_shift_result_type returns the unsigned counterpart used as the result of >>>.
fn unwrap_pointer #
fn unwrap_pointer(t Type) Type
unwrap_pointer transforms unwrap pointer data for types.
fn Properties.from #
fn Properties.from[W](input W) !Properties
fn Properties.zero #
fn Properties.zero() Properties
fn TypeChecker.new #
fn TypeChecker.new(a &flat.FlatAst) TypeChecker
new creates a TypeChecker value for types.
fn TypeErrorKind.from #
fn TypeErrorKind.from[W](input W) !TypeErrorKind
type SymbolId #
type SymbolId = u32
SymbolId is the stable identity of a resolved declaration name in one compilation. Zero denotes no symbol.
type Type #
type Type = Void
| Unknown
| Primitive
| String
| Char
| Rune
| ISize
| USize
| Nil
| None
| Array
| ArrayFixed
| Channel
| Map
| Pointer
| FnType
| OptionType
| ResultType
| Struct
| Interface
| Enum
| SumType
| Alias
| MultiReturn
fn (Type) is_pointer #
fn (t Type) is_pointer() bool
is_pointer reports whether is pointer applies in types.
fn (Type) is_string #
fn (t Type) is_string() bool
is_string reports whether is string applies in types.
fn (Type) is_integer #
fn (t Type) is_integer() bool
is_integer reports whether is integer applies in types.
fn (Type) is_float #
fn (t Type) is_float() bool
is_float reports whether is float applies in types.
fn (Type) name #
fn (t Type) name() string
name returns name data for Type.
type TypeId #
type TypeId = u32
TypeId is the stable identity of a canonical semantic type in one compilation. Type values remain the public compatibility representation; caches and equality-heavy internals can use this compact identity.
enum Properties #
enum Properties {
boolean
float
integer
unsigned
untyped
}
Properties lists properties values used by types.
fn (Properties) all #
fn (e &Properties) all(flag_ Properties) bool
fn (Properties) clear #
fn (mut e Properties) clear(flag_ Properties)
fn (Properties) clear_all #
fn (mut e Properties) clear_all()
fn (Properties) has #
fn (e &Properties) has(flag_ Properties) bool
fn (Properties) is_empty #
fn (e &Properties) is_empty() bool
fn (Properties) set #
fn (mut e Properties) set(flag_ Properties)
fn (Properties) set_all #
fn (mut e Properties) set_all()
fn (Properties) toggle #
fn (mut e Properties) toggle(flag_ Properties)
enum TypeErrorKind #
enum TypeErrorKind {
unknown_ident
unknown_type
unknown_fn
unknown_field
cannot_index
if_branch_mismatch
assignment_mismatch
return_mismatch
call_arg_mismatch
condition_mismatch
duplicate_decl
unhandled_node
unsupported_generic
compile_error
}
TypeErrorKind lists type error kind values used by types.
struct Alias #
struct Alias {
pub:
name string
base_type Type
}
Alias represents alias data used by types.
struct Array #
struct Array {
pub:
elem_type Type
}
Array represents array data used by types.
struct ArrayFixed #
struct ArrayFixed {
pub:
elem_type Type
len int
len_expr string
}
ArrayFixed represents array fixed data used by types.
struct CallInfo #
struct CallInfo {
pub:
name string
params []Type
shared_params []bool
return_type Type
has_receiver bool
is_variadic bool
is_c_variadic bool
params_known bool
has_implicit_veb_ctx bool
arg_offset int
}
CallInfo stores call info metadata used by types.
struct Channel #
struct Channel {
pub:
elem_type Type
}
Channel represents channel data used by types.
struct Char #
struct Char {
dummy_ u8
}
Char represents char data used by types.
struct Enum #
struct Enum {
pub:
name string
is_flag bool
}
Enum represents enum data used by types.
struct FnType #
struct FnType {
pub:
params []Type
return_type Type
}
FnType represents fn type data used by types.
struct ISize #
struct ISize {
dummy_ u8
}
ISize represents isize data used by types.
struct Interface #
struct Interface {
pub:
name string
}
Interface represents interface data used by types.
struct Map #
struct Map {
pub:
key_type Type
value_type Type
}
Map represents map data used by types.
struct MultiReturn #
struct MultiReturn {
pub:
types []Type
}
MultiReturn represents multi return data used by types.
struct Nil #
struct Nil {
dummy_ u8
}
Nil represents nil data used by types.
struct None #
struct None {
dummy_ u8
}
None represents none data used by types.
struct OptionType #
struct OptionType {
pub:
base_type Type
}
OptionType represents option type data used by types.
struct OwnershipDropEntry #
struct OwnershipDropEntry {
pub:
name string
type_name string
optional_wrapper bool
}
struct Pointer #
struct Pointer {
pub:
base_type Type
}
Pointer represents pointer data used by types.
struct Primitive #
struct Primitive {
pub:
props Properties
size u8
}
Primitive represents primitive data used by types.
struct ResultType #
struct ResultType {
pub:
base_type Type
}
ResultType represents result type data used by types.
struct Rune #
struct Rune {
dummy_ u8
}
Rune represents rune data used by types.
struct Scope #
struct Scope {
pub mut:
parent &Scope = unsafe { nil }
names []string
types []Type
name_indexes map[string]int
generations []int
next_generation int
lifetime int
}
Scope represents scope data used by types.
fn (Scope) reset #
fn (mut s Scope) reset(parent &Scope)
reset retargets a pooled scope, clearing its bindings while keeping the backing storage capacity so reuse does not reallocate. Without this clear a pooled scope's arrays accumulate every binding ever inserted across all generations, turning lookup/insert into an O(n) scan over dead entries.
fn (Scope) lookup #
fn (s &Scope) lookup(name string) ?Type
lookup returns the nearest visible type binding for name.
fn (Scope) lookup_owner #
fn (s &Scope) lookup_owner(name string) ?ScopeBindingOwner
lookup_owner returns the nearest scope that owns a visible binding for name.
fn (Scope) nearest_binding_owned_by #
fn (s &Scope) nearest_binding_owned_by(name string, owner ScopeBindingOwner) bool
nearest_binding_owned_by reports whether the nearest visible binding for name belongs to owner.
fn (Scope) insert #
fn (mut s Scope) insert(name string, typ Type)
insert records or updates a type binding in this scope.
fn (Scope) insert_with_owner #
fn (mut s Scope) insert_with_owner(name string, typ Type) ScopeBindingOwner
insert_with_owner records or updates a type binding and returns the exact binding identity now visible for name.
struct ScopeBindingOwner #
struct ScopeBindingOwner {
scope &Scope = unsafe { nil }
index int = -1
generation int
lifetime int
name string
}
fn (ScopeBindingOwner) storage_key #
fn (owner ScopeBindingOwner) storage_key() string
storage_key returns a stable key for this binding owner while its scope is live.
fn (ScopeBindingOwner) belongs_to_scope #
fn (owner ScopeBindingOwner) belongs_to_scope(scope &Scope) bool
belongs_to_scope reports whether this binding owner was declared directly in scope.
fn (ScopeBindingOwner) belongs_to_scope_chain_until #
fn (owner ScopeBindingOwner) belongs_to_scope_chain_until(scope &Scope, stop &Scope) bool
belongs_to_scope_chain_until reports whether this binding owner was declared between scope and stop, inclusive.
struct String #
struct String {
dummy_ u8
}
String represents string data used by types.
struct Struct #
struct Struct {
pub:
name string
}
Struct represents struct data used by types.
struct StructField #
struct StructField {
pub:
name string
typ Type
}
StructField represents struct field data used by types.
struct SumType #
struct SumType {
pub:
name string
}
SumType represents sum type data used by types.
struct TransformForkOverlay #
struct TransformForkOverlay {
pub mut:
resolved_call_names map[int]string
resolved_fn_values map[int]string
}
TransformForkOverlay holds the call/fn-value resolutions a parallel-transform worker records for its transform-created (cloned) nodes. It lives on the heap (like TypeCache) so a worker's &TypeChecker fork can write through the pointer without mutating the shared node-indexed arrays; reads consult the overlay before those arrays, and merge_worker replays the entries into the master under the shifted node ids.
struct TypeCacheStats #
struct TypeCacheStats {
pub:
parse_hits i64
parse_misses i64
c_hits i64
c_misses i64
}
TypeCacheStats reports semantic cache effectiveness for compiler telemetry.
struct TypeChecker #
struct TypeChecker {
pub mut:
a &flat.FlatAst = unsafe { nil }
fn_ret_types map[string]Type
fn_param_types map[string][]Type
fn_shared_params map[string][]bool
fn_ret_type_texts map[string]string // generic struct method key -> original return type text (e.g. `Box[T].clone` -> `Box[T]`)
fn_param_type_texts map[string][]string // generic struct method key -> original param type texts (receiver first)
fn_type_files map[string]string
fn_type_modules map[string]string
fn_generic_params map[string][]string
specialized_generic_fns map[string]bool
fn_variadic map[string]bool
c_variadic_fns map[string]bool
fn_implicit_veb_ctx map[string]bool
receiver_method_suffix_index map[string]string
structs map[string][]StructField
struct_modules map[string]string
struct_files map[string]string
soa_structs map[string]bool
// set of `${file}\x01${module}\x01${name}` keys for every source-level
// struct/type/interface/enum declaration, built once in `collect`. Replaces
// the former full-node scan in `source_declares_type_in_scope`, which was
// O(nodes) per call and dominated check/transform/cgen (called via qualify_name).
declared_type_scope_keys map[string]bool
struct_error_embeds_shadow_builtin map[string]bool
struct_generic_params map[string][]string // generic struct base name -> type-param names (e.g. Vec4 -> [T])
struct_implements map[string][]string
struct_shared_fields map[string]bool
struct_field_c_abi_fns map[string]string
// concrete `Box[int].method` -> substituted CallInfo for a method *value* on a
// generic receiver. The open `Box[T].method` registration is gone by cgen time, so
// the checker stashes the resolved signature here for gen_method_value_closure.
generic_method_value_info map[string]CallInfo
params_structs map[string]bool
unions map[string]bool
type_aliases map[string]string
type_alias_c_abi_fns map[string]string
sum_types map[string][]string
sum_generic_params map[string][]string // generic sum type base name -> type-param names (e.g. Tree -> [T])
enum_names map[string]bool
enum_fields map[string][]string
flag_enums map[string]bool
interface_names map[string]bool
interface_fields map[string][]StructField
interface_embeds map[string][]string
interface_abstract_methods map[string][]string // iface -> abstract (declared) method names
interface_impl_name_snapshots map[string][]string
c_globals map[string]Type
const_types map[string]Type
const_exprs map[string]flat.NodeId
const_modules map[string]string
const_files map[string]string
const_suffixes map[string]string // dot-suffix -> full const key (O(1) lookup; '' if ambiguous)
imports map[string]string // alias -> short module name
file_imports map[string]string
file_selective_imports map[string][]string
file_imports_by_file map[string]&FileImportInfo
file_modules map[string]string
file_scope &Scope = unsafe { nil }
cur_scope &Scope = unsafe { nil }
scope_pool []&Scope
scope_pool_index int
has_builtins bool
cur_module string
cur_file string
unsafe_depth int
errors []TypeError
resolved_call_names []string // node_id -> resolved function name
resolved_call_set []bool
resolved_fn_value_names []string // node_id -> resolved function value name
resolved_fn_value_set []bool
statement_nodes []bool
// Exact call/function-value dependencies recorded while each function is
// checked. Consumers such as markused can walk these resolved Symbol-like
// names instead of reconstructing import and receiver resolution from syntax.
direct_dependencies_by_fn map[int][]SymbolId // enclosing fn node id -> resolved function identities
// Methods used as *values* (`recv.method` passed as a callback), recorded per enclosing
// function during semantic checking — which has full scope/type info, runs before
// markused, and (unlike a call) routes a value-context selector through check_selector.
// markused seeds these (keeping the wrapper-only method out of the dead-code pruner)
// only when their enclosing function is reachable.
method_values_by_fn map[int][]string // enclosing fn node id -> method-value `Type.method` keys
// Local variables bound to a method value (`cb := c.report`) in the current function.
// Such an alias shares the same per-site static receiver slot as the bare selector, so it
// escapes (and corrupts other live callbacks) just like `return c.report`; the escape
// checks below treat a reference to one of these locals as a method value. Reset per fn.
method_value_locals map[string]bool
// Scope depth at which each method-value local was marked, so a reassignment to a
// non-method value only clears the marker when it dominates later uses (same-or-shallower
// scope); a reassignment in a deeper conditional/loop scope keeps the maybe-method marker.
method_value_local_depth map[string]int
capturing_fn_literal_locals map[string]bool
capturing_fn_literal_local_depth map[string]int
capturing_fn_literal_return_unsupported map[string]bool
cur_fn_node_id int = -1
cur_fn_mut_param_base_types map[string]Type
cur_fn_mut_param_binding_owners map[string]ScopeBindingOwner
cur_fn_mut_local_binding_owners map[string]ScopeBindingOwner
cur_fn_shared_binding_owners map[string]ScopeBindingOwner
cur_comptime_variant_loop_vars []string
expr_type_values []Type // node_id -> complex/contextual resolved type
expr_type_set []bool
checking_nodes []bool
parallel_check_sparse bool
scope_parallel_check_workers bool
// Node id range [check_range_lo, check_range_hi] of the fn item currently
// being checked. Fn subtrees are disjoint contiguous ranges (each fn_decl at
// index i owns (prev_top_level_idx, i]), so while parallel_check_sparse is
// set, cache entries for in-range ids are written straight into the shared
// node-indexed arrays (this checker is the range's only writer) and only
// out-of-range ids (consts, other decls' nodes) go through the private
// sparse maps that are merged after join.
check_range_lo int = -1
check_range_hi int = -1
sparse_resolved_call_names map[int]string
sparse_resolved_fn_values map[int]string
sparse_statement_nodes map[int]bool
sparse_expr_type_values map[int]Type
sparse_checking_nodes map[int]bool
diagnose_unknown_calls bool
reject_unlowered_map_mutation bool
reject_unsupported_generics bool
diagnostic_files map[string]bool
has_spawn_expr int = -1
inactive_top_level_node_ids []int
selected_file_called_fns map[string]bool
// Names newly inserted into selected_file_called_fns and not yet chased by
// the transitive closure in collect_selected_file_called_fns_transitively.
selected_file_worklist []string
// During the parallel check region the called-fns closure is computed on its
// own thread, so `selected_file_called_fns` is not yet available. Sites that
// would gate on it park their candidate error here instead; the master
// filters the list against the finished set after joining the thread.
defer_ierror_gating bool
pending_ierror_errors []PendingIerrorError
// Node indices of every top-level declaration node (file markers, module/import
// decls, type-level decls, consts, globals, fn/c-fn decls), in AST order. These
// kinds only occur at the top level, so a pass iterating this index visits the
// same nodes in the same order as a full `a.nodes` scan that matches on them —
// without streaming the ~100x larger node array each time. Built once in
// `collect`; no later phase of the check step appends declarations. Phases
// after the check (transform) may grow the AST: top_level_idx_nodes_len
// records the node count the index covers.
top_level_idx []int
top_level_idx_nodes_len int
expected_expr_id int = -1
expected_expr_type Type = Type(void_)
cur_fn_ret_type Type = Type(void_)
smartcasts map[string]Type
ownership &OwnershipState = unsafe { nil }
selfhost bool
// resolution_type_mode is enabled only after semantic checking, while transform
// and codegen read synthesized generic-specialization type text. Source annotations
// must keep normal module scoping and never enable this fallback.
resolution_type_mode bool
// fork_overlay is non-nil only on parallel-transform worker forks; see
// TransformForkOverlay and fork_for_parallel_transform.
fork_overlay &TransformForkOverlay = unsafe { nil }
mut:
// Includes method-value aliases and binding-owner maps; all backing maps are
// replaced together at every function/worker boundary.
fn_context FunctionCheckContext
type_cache &TypeCache = unsafe { nil }
type_interner &TypeInterner = unsafe { nil }
symbols &SymbolInterner = unsafe { nil }
}
TypeChecker represents type checker data used by types.
fn (TypeChecker) annotate_types #
fn (mut tc TypeChecker) annotate_types()
annotate_types performs a scope-aware walk over every function body, tracking local variable types as they are declared, and records complex/contextual expression types. This mirrors what the v2 transformer relies on: the type checker runs BEFORE the transformer and publishes per-expression types, so the transformer can own type-dependent lowering (string ops, in membership, ...) instead of the backend.
It uses a single flat scope per function (an over-approximation: a local stays visible after its block ends), which is harmless for type lookup since variable names are effectively unique within a function.
fn (TypeChecker) annotate_types_with_used #
fn (mut tc TypeChecker) annotate_types_with_used(used_fns map[string]bool)
annotate_types_with_used annotates only functions that can be emitted when used_fns is non-empty. This mirrors transform/cgen pruning and avoids resolving types in dead, untransformed function bodies after markused.
fn (TypeChecker) begin_sparse_transform_node_caches #
fn (mut tc TypeChecker) begin_sparse_transform_node_caches(base_nodes int)
begin_sparse_transform_node_caches keeps source-node entries in their dense checked arrays and records transform-created node metadata sparsely.
fn (TypeChecker) c_type #
fn (tc &TypeChecker) c_type(t Type) string
c_type supports c type handling for TypeChecker.
fn (TypeChecker) cached_c_name #
fn (tc &TypeChecker) cached_c_name(name string) string
cached_c_name memoizes naming.c_name results in the type cache (falling back to the frozen base cache read-only, like every other entry kind). c_name is pure and called on hot resolution paths in every phase.
fn (TypeChecker) canonical_symbol #
fn (tc &TypeChecker) canonical_symbol(name string) string
canonical_symbol returns the compilation-owned canonical spelling of name.
fn (TypeChecker) check_semantics #
fn (mut tc TypeChecker) check_semantics()
check_semantics validates check semantics state for types.
fn (TypeChecker) check_semantics_opt #
fn (mut tc TypeChecker) check_semantics_opt(want_parallel bool) bool
check_semantics_opt runs semantic checks, using worker threads for independent function bodies when requested and there is enough work.
fn (TypeChecker) clear_field_lookup_cache #
fn (tc &TypeChecker) clear_field_lookup_cache()
fn (TypeChecker) collect #
fn (mut tc TypeChecker) collect(a &flat.FlatAst)
collect supports collect handling for TypeChecker.
fn (TypeChecker) concrete_method_signature_key #
fn (tc &TypeChecker) concrete_method_signature_key(concrete_name string, method string) ?string
fn (TypeChecker) const_int_value #
fn (tc &TypeChecker) const_int_value(name string, seen []string) ?int
const_int_value supports const int value handling for TypeChecker.
fn (TypeChecker) const_int_value_in_module #
fn (tc &TypeChecker) const_int_value_in_module(name string, module_name string, seen []string) ?int
const_int_value_in_module supports const int value handling for a specific module.
fn (TypeChecker) copy_cloned_resolution #
fn (mut tc TypeChecker) copy_cloned_resolution(src_id flat.NodeId, dst_id flat.NodeId)
copy_cloned_resolution copies checker-owned call/function-value resolution metadata from an original node to a transform-created clone.
fn (TypeChecker) direct_dependencies #
fn (tc &TypeChecker) direct_dependencies(fn_node_id int) []string
direct_dependencies returns canonical dependency names for compatibility.
fn (TypeChecker) direct_dependency_ids #
fn (tc &TypeChecker) direct_dependency_ids(fn_node_id int) []SymbolId
direct_dependency_ids returns the checker-resolved function dependency identities of a function declaration node. The slice is read-only.
fn (TypeChecker) enable_scoped_parallel_workers #
fn (mut tc TypeChecker) enable_scoped_parallel_workers()
enable_scoped_parallel_workers uses disposable prealloc arenas for parallel checker helpers. Ownership checking keeps its existing long-lived workers.
fn (TypeChecker) expr_type #
fn (tc &TypeChecker) expr_type(id flat.NodeId) ?Type
expr_type returns the resolved type recorded for a node during annotate_types.
fn (TypeChecker) fixed_array_len_value #
fn (tc &TypeChecker) fixed_array_len_value(arr ArrayFixed) ?int
fixed_array_len_value returns the evaluated fixed-array length when it can be resolved.
fn (TypeChecker) fn_param_types_for_name #
fn (tc &TypeChecker) fn_param_types_for_name(name string) []Type
fn_param_types_for_name returns the collected parameter types for a resolved call name.
fn (TypeChecker) fork_for_parallel_transform #
fn (tc &TypeChecker) fork_for_parallel_transform(ast &flat.FlatAst) &TypeChecker
fork_for_parallel_transform returns a TypeChecker that shares all of tc's read-only data (semantic maps and node-indexed cache arrays, which the transform pass only reads) but owns a fresh, private type_cache and a private AST view. During transform the only hidden mutation a TypeChecker performs through its & receiver is memoization into type_cache (parse_type / c_type); giving each worker its own cache makes concurrent use race-free without cloning the large semantic maps. ast must be the worker's own (cloned) FlatAst so that any expr_type lookup on a freshly-created node id indexes a valid array.
fn (TypeChecker) free_parallel_transform_caches #
fn (mut tc TypeChecker) free_parallel_transform_caches()
free_parallel_transform_caches releases private memoization maps owned by a forked transform checker and leaves it valid if it is accidentally read again.
fn (TypeChecker) freeze_interface_impl_names #
fn (mut tc TypeChecker) freeze_interface_impl_names()
freeze_interface_impl_names snapshots the interface implementation order used by transform-generated _typ checks before later metadata cleanup can remove unused generic declarations and shift cgen's ids.
fn (TypeChecker) freeze_type_cache_for_forks #
fn (tc &TypeChecker) freeze_type_cache_for_forks()
freeze_type_cache_for_forks freezes this checker's warm type cache as the shared read-only base for parallel forks (fork_for_parallel_transform picks it up) and switches the checker itself to a private overlay so its own memoization writes cannot race fork reads. Callable on a shared reference: the transformer holds the checker as &TypeChecker.
fn (TypeChecker) generic_type_name_matches #
fn (tc &TypeChecker) generic_type_name_matches(a string, b string) bool
fn (TypeChecker) ierror_impl_names #
fn (tc &TypeChecker) ierror_impl_names() []string
ierror_impl_names returns the concrete struct names that can be boxed as IError.
fn (TypeChecker) index_operator_call_info #
fn (tc &TypeChecker) index_operator_call_info(base_type Type, op string) ?CallInfo
fn (TypeChecker) index_overload_call_info #
fn (tc &TypeChecker) index_overload_call_info(typ Type, setter bool) ?CallInfo
fn (TypeChecker) inherit_ownership_codegen_metadata_from #
fn (mut tc TypeChecker) inherit_ownership_codegen_metadata_from(_ &TypeChecker)
fn (TypeChecker) interface_abstract_method_names #
fn (tc &TypeChecker) interface_abstract_method_names(iface_name string) []string
interface_abstract_method_names returns the methods an implementer must provide: the interface's own declared (abstract) methods plus those of any embedded interfaces. Default methods defined directly on the interface are excluded.
fn (TypeChecker) interface_accepts_implicit_str #
fn (tc &TypeChecker) interface_accepts_implicit_str(iface_name string) bool
fn (TypeChecker) interface_field_list #
fn (tc &TypeChecker) interface_field_list(iface_name string) []StructField
interface_field_list supports interface field list handling for TypeChecker.
fn (TypeChecker) interface_impl_names #
fn (tc &TypeChecker) interface_impl_names(iface_name string) []string
interface_impl_names returns the concrete type names (structs and type aliases) that implement iface_name. Once a snapshot is frozen, its names stay first so transform-emitted interface IDs are preserved; later implementers are appended in deterministic discovery order.
fn (TypeChecker) interface_impl_set_signature #
fn (tc &TypeChecker) interface_impl_set_signature() string
interface_impl_set_signature returns the complete deterministic interface implementer set that controls collision-resolved dispatch IDs for the current program.
fn (TypeChecker) interface_implements_interface #
fn (tc &TypeChecker) interface_implements_interface(actual_name string, expected_name string) bool
interface_implements_interface supports interface implements interface handling for TypeChecker.
fn (TypeChecker) interface_metadata_name #
fn (tc &TypeChecker) interface_metadata_name(name string) string
fn (TypeChecker) interface_method_signature_key #
fn (tc &TypeChecker) interface_method_signature_key(iface_name string, method string) ?string
fn (TypeChecker) interface_type_ids #
fn (tc &TypeChecker) interface_type_ids(iface_name string) map[string]int
interface_type_ids returns the _typ dispatch IDs for an interface, preserving any snapshot IDs emitted before late generic implementers were discovered.
fn (TypeChecker) invalidate_short_type_name_index #
fn (tc &TypeChecker) invalidate_short_type_name_index()
invalidate_short_type_name_index drops memoized type-name-derived indexes; callers that add or remove entries in the type-name maps after the checker ran (the monomorphizer specializing generic structs/sum types) must invalidate them.
fn (TypeChecker) iterator_for_in_elem_type #
fn (tc &TypeChecker) iterator_for_in_elem_type(typ Type) ?Type
fn (TypeChecker) iterator_for_in_next_call_info #
fn (tc &TypeChecker) iterator_for_in_next_call_info(typ Type) ?CallInfo
fn (TypeChecker) multi_expr_tail_types_for_transform #
fn (tc &TypeChecker) multi_expr_tail_types_for_transform(expr_id flat.NodeId, count int) ?[]Type
multi_expr_tail_types_for_transform returns promoted multi-expression tail types for transform lowering without duplicating checker compatibility rules.
fn (TypeChecker) named_type_compatible_with_ierror #
fn (tc &TypeChecker) named_type_compatible_with_ierror(concrete_name string) bool
fn (TypeChecker) named_type_implements_interface #
fn (tc &TypeChecker) named_type_implements_interface(concrete_name string, iface_name string) bool
named_type_implements_interface supports helper handling in types.
fn (TypeChecker) named_type_implements_marker #
fn (tc &TypeChecker) named_type_implements_marker(concrete_name string, target string) bool
fn (TypeChecker) ownership_default_clone_missing_method #
fn (tc &TypeChecker) ownership_default_clone_missing_method(_ Type) ?string
fn (TypeChecker) ownership_drop_entries_at_fn_exit #
fn (tc &TypeChecker) ownership_drop_entries_at_fn_exit(_ string) []OwnershipDropEntry
fn (TypeChecker) ownership_drop_entries_at_loop_control #
fn (tc &TypeChecker) ownership_drop_entries_at_loop_control(_ string, _ int) []OwnershipDropEntry
fn (TypeChecker) ownership_drop_entries_at_loop_iteration #
fn (tc &TypeChecker) ownership_drop_entries_at_loop_iteration(_ string, _ int) []OwnershipDropEntry
fn (TypeChecker) ownership_drop_entries_at_propagation #
fn (tc &TypeChecker) ownership_drop_entries_at_propagation(_ string, _ int) []OwnershipDropEntry
fn (TypeChecker) ownership_drop_entries_at_return #
fn (tc &TypeChecker) ownership_drop_entries_at_return(_ string, _ int) []OwnershipDropEntry
fn (TypeChecker) ownership_drop_entries_at_return_node #
fn (tc &TypeChecker) ownership_drop_entries_at_return_node(_ string, _ flat.NodeId) []OwnershipDropEntry
fn (TypeChecker) ownership_drop_entries_at_scope_exit #
fn (tc &TypeChecker) ownership_drop_entries_at_scope_exit(_ string, _ int) []OwnershipDropEntry
fn (TypeChecker) ownership_drop_type_names #
fn (tc &TypeChecker) ownership_drop_type_names() []string
fn (TypeChecker) ownership_expr_creates_owned_value #
fn (tc &TypeChecker) ownership_expr_creates_owned_value(_ flat.NodeId) bool
fn (TypeChecker) ownership_expr_moves_storage #
fn (tc &TypeChecker) ownership_expr_moves_storage(_ flat.NodeId, _ flat.NodeId) bool
fn (TypeChecker) ownership_fn_value_returns_owned #
fn (tc &TypeChecker) ownership_fn_value_returns_owned(_ flat.NodeId, _ string, _ string) bool
fn (TypeChecker) ownership_index_read_moves_value #
fn (tc &TypeChecker) ownership_index_read_moves_value(_ flat.NodeId) bool
fn (TypeChecker) ownership_type_requires_destruction #
fn (tc &TypeChecker) ownership_type_requires_destruction(_ Type) bool
fn (TypeChecker) ownership_type_requires_drop #
fn (tc &TypeChecker) ownership_type_requires_drop(_ Type) bool
fn (TypeChecker) parse_canonical_type #
fn (tc &TypeChecker) parse_canonical_type(typ string) Type
parse_canonical_type parses compiler-produced type text while preserving an exact known qualified symbol before consulting the current file's import aliases. Source text must continue to use parse_type, where aliases take precedence; this entry point is for semantic names carried between phases.
fn (TypeChecker) parse_resolution_type #
fn (tc &TypeChecker) parse_resolution_type(typ string) Type
parse_resolution_type parses type text that can mix declaration-local names with concrete generic arguments from another module.
fn (TypeChecker) parse_type #
fn (tc &TypeChecker) parse_type(typ string) Type
parse_type converts a V type string (from parser) to a structured Type.
fn (TypeChecker) pop_scope #
fn (mut tc TypeChecker) pop_scope()
pop_scope updates pop scope state for TypeChecker.
fn (TypeChecker) prepare_threads_condition #
fn (mut tc TypeChecker) prepare_threads_condition()
prepare_threads_condition caches whether selected inputs or their reachable imports use spawn.
fn (TypeChecker) promote_scoped_transform_interners #
fn (mut tc TypeChecker) promote_scoped_transform_interners(type_start int, symbol_start int, scope voidptr)
promote_scoped_transform_interners moves additions made by a scoped transform into the current compilation arena before that scope is freed.
fn (TypeChecker) prune_inactive_top_level_comptime #
fn (tc &TypeChecker) prune_inactive_top_level_comptime(mut a flat.FlatAst)
prune_inactive_top_level_comptime removes declarations and expressions from inactive top-level compile-time branches after semantic checking and before later compiler stages.
fn (TypeChecker) push_scope #
fn (mut tc TypeChecker) push_scope()
push_scope updates push scope state for TypeChecker.
fn (TypeChecker) qualify_fn_name #
fn (tc &TypeChecker) qualify_fn_name(name string) string
qualify_fn_name supports qualify fn name handling for TypeChecker.
fn (TypeChecker) qualify_name #
fn (tc &TypeChecker) qualify_name(name string) string
qualify_name supports qualify name handling for TypeChecker.
fn (TypeChecker) rebuild_scoped_transform_signature_maps #
fn (mut tc TypeChecker) rebuild_scoped_transform_signature_maps()
rebuild_scoped_transform_signature_maps moves signature-map backing storage into the current arena after a disposable transform scope has been left.
fn (TypeChecker) register_synth_type #
fn (mut tc TypeChecker) register_synth_type(id flat.NodeId, typ Type)
register_synth_type records the type of a generated or transformed node.
fn (TypeChecker) reserve_scoped_transform_metadata #
fn (mut tc TypeChecker) reserve_scoped_transform_metadata(signature_headroom int)
reserve_scoped_transform_metadata keeps tables that receive escaping transform additions in the compilation arena in the common case while scratch allocations use a disposable arena. The signature maps are rebuilt after promotion, so this headroom is an optimization rather than an ownership requirement.
fn (TypeChecker) reserve_transform_node_caches #
fn (mut tc TypeChecker) reserve_transform_node_caches(n int)
reserve_transform_node_caches reserves node-indexed semantic storage before a scoped transform starts, keeping the escaping slabs in the compilation arena.
fn (TypeChecker) resolve_generic_struct_method #
fn (tc &TypeChecker) resolve_generic_struct_method(type_name string, method string) ?CallInfo
resolve_type_name_for_method resolves resolve type name for method information for types. resolve_generic_struct_method resolves a method call on a generic-struct instance (e.g. Vec4[f32].r_sqrt). The method is registered against the generic form (Vec4[T].r_sqrt); this maps the instance's concrete type arguments onto the generic parameters and substitutes them into the method's signature, so the pre-transform checker accepts the call. The transformer's monomorphize pass later materialises the concrete method body.
fn (TypeChecker) resolve_generic_sum_method #
fn (tc &TypeChecker) resolve_generic_sum_method(type_name string, method string) ?CallInfo
fn (TypeChecker) resolve_ierror_payload_name #
fn (tc &TypeChecker) resolve_ierror_payload_name(name string) string
resolve_ierror_payload_name resolves scoped Error/MessageError names before falling back to the builtin error structs.
fn (TypeChecker) resolve_imported_type_text_in_file #
fn (tc &TypeChecker) resolve_imported_type_text_in_file(typ string, file string) string
fn (TypeChecker) resolve_type #
fn (tc &TypeChecker) resolve_type(id flat.NodeId) Type
resolve_type resolves resolve type information for types.
fn (TypeChecker) resolved_call_name #
fn (tc &TypeChecker) resolved_call_name(id flat.NodeId) ?string
resolved_call_name returns the checker-resolved function name for a call node.
fn (TypeChecker) resolved_call_never_returns #
fn (tc &TypeChecker) resolved_call_never_returns(id flat.NodeId) bool
resolved_call_never_returns reports whether a call node resolved to a known no-return function.
fn (TypeChecker) resolved_fn_value_name #
fn (tc &TypeChecker) resolved_fn_value_name(id flat.NodeId) ?string
resolved_fn_value_name returns the checker-resolved function name for a function value node.
fn (TypeChecker) scoped_parallel_workers_enabled #
fn (tc &TypeChecker) scoped_parallel_workers_enabled() bool
scoped_parallel_workers_enabled reports whether compiler stages should use short-lived worker arenas with this checker.
fn (TypeChecker) selector_const_type #
fn (tc &TypeChecker) selector_const_type(node flat.Node) ?Type
selector_const_type returns the declared type for a selector const expression.
fn (TypeChecker) set_fresh_type_cache #
fn (mut tc TypeChecker) set_fresh_type_cache(parse_enabled bool)
set_fresh_type_cache attaches a new empty TypeCache. Parallel-cgen worker checkers use this so the lazily-built lookup indexes and memoizations work per worker instead of falling back to their uncached full scans.
fn (TypeChecker) set_fresh_type_cache_based_on #
fn (mut tc TypeChecker) set_fresh_type_cache_based_on(src &TypeChecker, parse_enabled bool)
set_fresh_type_cache_based_on attaches a new empty TypeCache that falls back read-only to src's frozen base cache (see freeze_type_cache_for_forks), so parallel-cgen workers start with every type memoized by the check/transform phases instead of re-deriving them from a cold cache.
fn (TypeChecker) struct_field_c_abi_fn_ptr_type #
fn (tc &TypeChecker) struct_field_c_abi_fn_ptr_type(struct_name string, field_name string) ?string
struct_field_c_abi_fn_ptr_type returns the C ABI function-pointer type for a struct field.
fn (TypeChecker) struct_field_type_name #
fn (tc &TypeChecker) struct_field_type_name(struct_name string, field_name string) ?string
struct_field_type_name returns the canonical type name for a struct field.
fn (TypeChecker) struct_fields_for_type #
fn (tc &TypeChecker) struct_fields_for_type(struct_name string) []StructField
struct_fields_for_type returns the fields of struct_name, with generic parameters substituted when struct_name is a concrete generic instance.
fn (TypeChecker) sum_variant_type_for_pattern #
fn (tc &TypeChecker) sum_variant_type_for_pattern(sum_name string, variant_name string) ?string
fn (TypeChecker) symbol_count #
fn (tc &TypeChecker) symbol_count() int
symbol_count returns the number of resolved names interned by the checker.
fn (TypeChecker) symbol_name #
fn (tc &TypeChecker) symbol_name(id SymbolId) string
symbol_name resolves a checker symbol identity to its canonical name.
fn (TypeChecker) threads_condition_value #
fn (tc &TypeChecker) threads_condition_value() bool
threads_condition_value reports the cached $if threads condition, scanning lazily for direct TypeChecker users that do not run the regular compiler setup.
fn (TypeChecker) type_cache_parse_enabled #
fn (tc &TypeChecker) type_cache_parse_enabled() bool
type_cache_parse_enabled reports whether parse_type memoization is enabled on this checker's type cache.
fn (TypeChecker) type_cache_stats #
fn (tc &TypeChecker) type_cache_stats() TypeCacheStats
type_cache_stats returns cache counters accumulated by this checker.
fn (TypeChecker) type_count #
fn (tc &TypeChecker) type_count() int
type_count reports the number of unique canonical semantic types observed by this compilation.
fn (TypeChecker) type_has_implicit_str_method #
fn (tc &TypeChecker) type_has_implicit_str_method(name string) bool
fn (TypeChecker) type_name #
fn (tc &TypeChecker) type_name(t Type) string
type_name lazily formats and memoizes the canonical spelling of a semantic type. Hot compiler paths should prefer this to repeated recursive Type.name construction.
fn (TypeChecker) type_text_implements_interface #
fn (mut tc TypeChecker) type_text_implements_interface(actual_text string, iface_text string) bool
type_text_implements_interface reports whether a concrete type expression satisfies an interface type expression in the current checker module context.
fn (TypeChecker) unfreeze_type_cache_after_forks #
fn (tc &TypeChecker) unfreeze_type_cache_after_forks()
unfreeze_type_cache_after_forks folds the private overlay back into the frozen base once every fork has been joined, and reattaches the base as the live cache.
struct TypeError #
struct TypeError {
pub:
msg string
kind TypeErrorKind
node flat.NodeId
file string
node_kind string
node_value string
node_pos string
}
TypeError represents type error data used by types.
struct USize #
struct USize {
dummy_ u8
}
USize represents usize data used by types.
struct Unknown #
struct Unknown {
pub:
reason string
}
Unknown represents unknown data used by types.
struct Void #
struct Void {
dummy_ u8
}
Void represents void data used by types.
- README
- Constants
- fn builtin_type
- fn builtin_type_value
- fn clone_owned_type
- fn clone_owned_types
- fn generic_base_name
- fn is_builtin_type_name
- fn new_scope
- fn stable_interface_type_ids
- fn stable_interface_type_ids_preserving_prefix
- fn unsigned_shift_result_type
- fn unwrap_pointer
- fn Properties.from
- fn Properties.zero
- fn TypeChecker.new
- fn TypeErrorKind.from
- type SymbolId
- type Type
- type TypeId
- enum Properties
- enum TypeErrorKind
- struct Alias
- struct Array
- struct ArrayFixed
- struct CallInfo
- struct Channel
- struct Char
- struct Enum
- struct FnType
- struct ISize
- struct Interface
- struct Map
- struct MultiReturn
- struct Nil
- struct None
- struct OptionType
- struct OwnershipDropEntry
- struct Pointer
- struct Primitive
- struct ResultType
- struct Rune
- struct Scope
- struct ScopeBindingOwner
- struct String
- struct Struct
- struct StructField
- struct SumType
- struct TransformForkOverlay
- struct TypeCacheStats
- struct TypeChecker
- fn annotate_types
- fn annotate_types_with_used
- fn begin_sparse_transform_node_caches
- fn c_type
- fn cached_c_name
- fn canonical_symbol
- fn check_semantics
- fn check_semantics_opt
- fn clear_field_lookup_cache
- fn collect
- fn concrete_method_signature_key
- fn const_int_value
- fn const_int_value_in_module
- fn copy_cloned_resolution
- fn direct_dependencies
- fn direct_dependency_ids
- fn enable_scoped_parallel_workers
- fn expr_type
- fn fixed_array_len_value
- fn fn_param_types_for_name
- fn fork_for_parallel_transform
- fn free_parallel_transform_caches
- fn freeze_interface_impl_names
- fn freeze_type_cache_for_forks
- fn generic_type_name_matches
- fn ierror_impl_names
- fn index_operator_call_info
- fn index_overload_call_info
- fn inherit_ownership_codegen_metadata_from
- fn interface_abstract_method_names
- fn interface_accepts_implicit_str
- fn interface_field_list
- fn interface_impl_names
- fn interface_impl_set_signature
- fn interface_implements_interface
- fn interface_metadata_name
- fn interface_method_signature_key
- fn interface_type_ids
- fn invalidate_short_type_name_index
- fn iterator_for_in_elem_type
- fn iterator_for_in_next_call_info
- fn multi_expr_tail_types_for_transform
- fn named_type_compatible_with_ierror
- fn named_type_implements_interface
- fn named_type_implements_marker
- fn ownership_default_clone_missing_method
- fn ownership_drop_entries_at_fn_exit
- fn ownership_drop_entries_at_loop_control
- fn ownership_drop_entries_at_loop_iteration
- fn ownership_drop_entries_at_propagation
- fn ownership_drop_entries_at_return
- fn ownership_drop_entries_at_return_node
- fn ownership_drop_entries_at_scope_exit
- fn ownership_drop_type_names
- fn ownership_expr_creates_owned_value
- fn ownership_expr_moves_storage
- fn ownership_fn_value_returns_owned
- fn ownership_index_read_moves_value
- fn ownership_type_requires_destruction
- fn ownership_type_requires_drop
- fn parse_canonical_type
- fn parse_resolution_type
- fn parse_type
- fn pop_scope
- fn prepare_threads_condition
- fn promote_scoped_transform_interners
- fn prune_inactive_top_level_comptime
- fn push_scope
- fn qualify_fn_name
- fn qualify_name
- fn rebuild_scoped_transform_signature_maps
- fn register_synth_type
- fn reserve_scoped_transform_metadata
- fn reserve_transform_node_caches
- fn resolve_generic_struct_method
- fn resolve_generic_sum_method
- fn resolve_ierror_payload_name
- fn resolve_imported_type_text_in_file
- fn resolve_type
- fn resolved_call_name
- fn resolved_call_never_returns
- fn resolved_fn_value_name
- fn scoped_parallel_workers_enabled
- fn selector_const_type
- fn set_fresh_type_cache
- fn set_fresh_type_cache_based_on
- fn struct_field_c_abi_fn_ptr_type
- fn struct_field_type_name
- fn struct_fields_for_type
- fn sum_variant_type_for_pattern
- fn symbol_count
- fn symbol_name
- fn threads_condition_value
- fn type_cache_parse_enabled
- fn type_cache_stats
- fn type_count
- fn type_has_implicit_str_method
- fn type_name
- fn type_text_implements_interface
- fn unfreeze_type_cache_after_forks
- struct TypeError
- struct USize
- struct Unknown
- struct Void