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 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 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 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.
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
}
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 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
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
}
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.
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 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
// 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
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
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
// 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
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
expr_type_values []Type // node_id -> complex/contextual resolved type
expr_type_set []bool
checking_nodes []bool
parallel_check_sparse 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
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
cur_fn_ret_type Type = Type(void_)
smartcasts map[string]Type
ownership &OwnershipState = unsafe { nil }
selfhost 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:
type_cache &TypeCache = 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) 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) 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) 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) 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_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) 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) 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_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, sorted by name. The 1-based position in this list is the interface's _typ dispatch id; cgen (boxing, method dispatch) and the transform (iface is Concrete checks) must both derive ids from this single list so they stay in sync.
fn (TypeChecker) interface_method_signature_key #
fn (tc &TypeChecker) interface_method_signature_key(iface_name string, method string) ?string
fn (TypeChecker) invalidate_short_type_name_index #
fn (tc &TypeChecker) invalidate_short_type_name_index()
invalidate_short_type_name_index drops the memoized short-name index; callers that add or remove entries in the type-name maps after the checker ran (the monomorphizer specializing generic structs/sum types) must invalidate it so the next unique_qualified_type_name query rebuilds it.
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) 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) 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) 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) 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_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) 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) sum_variant_type_for_pattern #
fn (tc &TypeChecker) sum_variant_type_for_pattern(sum_name string, variant_name string) ?string
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_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 generic_base_name
- fn is_builtin_type_name
- fn new_scope
- fn unwrap_pointer
- fn Properties.from
- fn Properties.zero
- fn TypeChecker.new
- fn TypeErrorKind.from
- type Type
- 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 Pointer
- struct Primitive
- struct ResultType
- struct Rune
- struct Scope
- struct ScopeBindingOwner
- struct String
- struct Struct
- struct StructField
- struct SumType
- struct TransformForkOverlay
- struct TypeChecker
- fn annotate_types
- fn annotate_types_with_used
- fn c_type
- fn cached_c_name
- 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 expr_type
- fn fixed_array_len_value
- fn fork_for_parallel_transform
- fn free_parallel_transform_caches
- fn freeze_type_cache_for_forks
- fn ierror_impl_names
- fn interface_abstract_method_names
- fn interface_impl_names
- fn interface_method_signature_key
- 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 parse_type
- fn pop_scope
- fn push_scope
- fn qualify_fn_name
- fn qualify_name
- fn register_synth_type
- fn resolve_generic_struct_method
- fn resolve_generic_sum_method
- fn resolve_ierror_payload_name
- fn resolve_type
- fn resolved_call_name
- fn resolved_call_never_returns
- fn resolved_fn_value_name
- 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 sum_variant_type_for_pattern
- fn type_cache_parse_enabled
- fn type_text_implements_interface
- fn unfreeze_type_cache_after_forks
- struct TypeError
- struct USize
- struct Unknown
- struct Void