Skip to content

v3.transform

Constants #

const option_unwrap_marker = '?opt'

option_unwrap_marker tags a SmartcastContext produced by an x != none condition: variant_name holds the option's base type and the access is lowered to the option's .value field instead of a sum union field.

fn erase_generic_templates #

fn erase_generic_templates(mut a flat.FlatAst, tc &types.TypeChecker, used_fns map[string]bool) map[string]bool

fn monomorphize_with_used #

fn monomorphize_with_used(mut a flat.FlatAst, tc &types.TypeChecker, used_fns map[string]bool) map[string]bool

fn monomorphize_with_used_checked #

fn monomorphize_with_used_checked(mut a flat.FlatAst, tc &types.TypeChecker, used_fns map[string]bool) (map[string]bool, []string)

monomorphize_with_used_checked also reports semantic errors that can only be resolved after generic parameters have concrete types.

fn monomorphize_with_used_checked_config #

fn monomorphize_with_used_checked_config(mut a flat.FlatAst, tc &types.TypeChecker, used_fns map[string]bool, parallel bool) (map[string]bool, []string)

monomorphize_with_used_checked_config controls whether independent generic specializations can be cloned concurrently.

fn monomorphize_with_used_checked_config_scoped #

fn monomorphize_with_used_checked_config_scoped(mut a flat.FlatAst, tc &types.TypeChecker, used_fns map[string]bool, parallel bool, stage_scope voidptr) (map[string]bool, []string)

monomorphize_with_used_checked_config_scoped keeps transient specialization state in stage_scope while promoting escaping AST payloads directly to its parent arena.

fn monomorphize_with_used_checked_config_scoped_cached #

fn monomorphize_with_used_checked_config_scoped_cached(mut a flat.FlatAst, tc &types.TypeChecker, used_fns map[string]bool, parallel bool, stage_scope voidptr, cached_specs []MonomorphCacheSpec) (map[string]bool, []string, []MonomorphCacheSpec)

monomorphize_with_used_checked_config_scoped_cached restores concrete generic signatures from cached_specs and returns the complete specialization set. A restored signature rewrites current program calls normally, while its unchanged dependency body can remain in the persistent compiled prefix.

fn promote_scoped_checker_node_caches_parallel #

fn promote_scoped_checker_node_caches_parallel(mut tc types.TypeChecker, a &flat.FlatAst, scope voidptr, generated_start int) bool

promote_scoped_checker_node_caches_parallel runs the per-id loops of the checker node-cache promotion over the shared worker pool. Returns false when no pool is available so the caller can run them serially instead.

fn promote_scoped_texts_parallel #

fn promote_scoped_texts_parallel(mut a flat.FlatAst, scope voidptr) bool

promote_scoped_texts_parallel publishes every transform-scope-owned node text over the shared worker pool, replacing the serial canonicalize + promote pair for builds without retained regions. Returns false when no pool is available so the caller can run the serial walks instead.

fn register_cached_monomorph_signatures #

fn register_cached_monomorph_signatures(a &flat.FlatAst, tc &types.TypeChecker, used_fns map[string]bool, cached_specs []MonomorphCacheSpec)

register_cached_monomorph_signatures installs persistent concrete signatures and their named signature types before the disposable monomorphization arena is entered.

fn reserve_parallel_transform_ast #

fn reserve_parallel_transform_ast(mut a flat.FlatAst, skip_generics bool)

reserve_parallel_transform_ast reserves persistent append regions before a disposable transform arena is entered.

fn reserve_parallel_transform_cache_ast #

fn reserve_parallel_transform_cache_ast(mut a flat.FlatAst, skip_generics bool)

reserve_parallel_transform_cache_ast adds overflow headroom for cache population, which transforms every module body rather than just the program-reachable subset.

fn scan_scoped_text_flags_parallel #

fn scan_scoped_text_flags_parallel(a &flat.FlatAst, scope voidptr, mut flags []u8) bool

scan_scoped_text_flags_parallel fills flags (one byte per node id in [0, flags.len)) for nodes whose text is owned by scope, using the shared worker pool. Returns false when no pool is available so the caller can walk every node serially instead.

fn sum_eq_helper_name #

fn sum_eq_helper_name(sum_name string) string

sum_eq_helper_name is the global C-level name of the synthesized deep-equality helper for a sum type.

fn transform #

fn transform(mut a flat.FlatAst, tc &types.TypeChecker)

transform supports transform handling for transform.

fn transform_selected_functions #

fn transform_selected_functions(mut a flat.FlatAst, tc &types.TypeChecker, selected map[string]bool) (map[string]bool, []string, []string)

transform_selected_functions lowers only the named function bodies after the incremental driver has proved that declarations and every other body are unchanged. Whole-program interface and comptime scans remain lazy: lowering a selected body still triggers them if that body actually needs the metadata. It also returns synthesized helper names that incremental Cgen must emit.

fn transform_with_used #

fn transform_with_used(mut a flat.FlatAst, tc &types.TypeChecker, used_fns map[string]bool) map[string]bool

transform_with_used transforms transform with used data for transform.

fn transform_with_used_opt #

fn transform_with_used_opt(mut a flat.FlatAst, tc &types.TypeChecker, used_fns map[string]bool, want_parallel bool) (map[string]bool, bool)

transform_with_used_opt is transform_with_used with an opt-in for parallel function-body transform. It returns the augmented used-fn set and whether the function bodies were actually transformed across threads (false when parallel was not requested, the build lacks thread support, or there was too little work).

fn transform_with_used_opt_config #

fn transform_with_used_opt_config(mut a flat.FlatAst, tc &types.TypeChecker, used_fns map[string]bool, want_parallel bool, skip_generics bool) (map[string]bool, bool)

transform_with_used_opt_config is transform_with_used_opt with extra pipeline switches for self-host builds.

fn transform_with_used_opt_config_scoped_workers #

fn transform_with_used_opt_config_scoped_workers(mut a flat.FlatAst, tc &types.TypeChecker, used_fns map[string]bool, want_parallel bool, skip_generics bool, scope_parallel_workers bool) (map[string]bool, bool)

transform_with_used_opt_config_scoped_workers optionally gives parallel helpers disposable prealloc arenas. It is used by prealloc self-host builds to retain parallel latency without retaining every helper's scratch memory.

fn transform_with_used_opt_config_scoped_workers_checked #

fn transform_with_used_opt_config_scoped_workers_checked(mut a flat.FlatAst, tc &types.TypeChecker, used_fns map[string]bool, want_parallel bool, skip_generics bool, scope_parallel_workers bool, building_v bool) (map[string]bool, bool, []string)

transform_with_used_opt_config_scoped_workers_checked also returns diagnostics selected while normal comptime reflection loops are unrolled.

fn transform_with_used_opt_config_scoped_workers_checked_owned #

fn transform_with_used_opt_config_scoped_workers_checked_owned(mut a flat.FlatAst, tc &types.TypeChecker, used_fns map[string]bool, want_parallel bool, skip_generics bool, scope_parallel_workers bool, building_v bool, stage_scope voidptr) (map[string]bool, bool, []string, []int, []ScopedTransformRegion)

transform_with_used_opt_config_scoped_workers_checked_owned additionally reports source AST nodes whose owned payloads were replaced during a scoped transform, so the driver can promote exactly those escaping values.

fn SqlDynamicDataKind.from #

fn SqlDynamicDataKind.from[W](input W) !SqlDynamicDataKind

fn SqlTransformStmtKind.from #

fn SqlTransformStmtKind.from[W](input W) !SqlTransformStmtKind

struct FieldInfo #

struct FieldInfo {
pub:
	name         string
	typ          string
	raw_typ      string
	default_expr flat.NodeId
	is_embedded  bool
}

FieldInfo stores field info metadata used by transform.

struct MonomorphCacheSpec #

struct MonomorphCacheSpec {
pub:
	decl_key string
	module   string
	args     []string
}

MonomorphCacheSpec identifies one concrete generic function body. Dependency specialization caches use it to restore signatures without cloning unchanged module templates into the program AST.

struct ScopedTransformRegion #

struct ScopedTransformRegion {
pub:
	scope      voidptr
	new_start  int
	new_end    int
	base_nodes []int
}

ScopedTransformRegion describes AST payloads owned by one retained worker arena. The driver canonicalizes this region before releasing the arena.

struct SmartcastContext #

struct SmartcastContext {
pub:
	expr_name     string // the expression being smartcast (e.g. "node")
	variant_name  string // the variant type name (e.g. "Ident")
	sum_type_name string // the parent sum type name (e.g. "Expr")
}

SmartcastContext stores smartcast context state used by transform.

struct StructInfo #

struct StructInfo {
pub:
	name       string
	module     string
	is_params  bool
	is_aligned bool
	alignment  string
	fields     []FieldInfo
}

StructInfo stores struct info metadata used by transform.

struct SumEqRequest #

struct SumEqRequest {
pub:
	module        string
	file          string
	helper_module string
}

SumEqRequest records where a sum type's equality helper was first requested, so the helper body is built under that module/file resolution context. The helper module can differ for program-specific generic specializations, whose generated functions and helpers must stay in the main cache segment.

struct Transformer #

struct Transformer {
mut:
	a                             &flat.FlatAst      = unsafe { nil }
	tc                            &types.TypeChecker = unsafe { nil }
	structs                       map[string]StructInfo
	embedded_fields               map[string][]FieldInfo
	struct_short_name_index       map[string]string
	struct_short_name_index_ready bool
	unique_fields                 map[string]string
	alias_methods                 map[string]string
	globals                       map[string]string
	sum_types                     map[string][]string
	sum_variant_parents           map[string][]string
	sum_variant_names             map[string]bool
	sum_variant_fields            map[string]string
	qualified_types               map[string]string
	fn_ret_types                  map[string]string
	multi_return_fn_ret_types     map[string]types.Type
	receiver_method_suffix_index  map[string]string
	variadic_suffix_index         map[string]i8
	const_suffixes                map[string]string
	// const_array_fixed_storage_cache avoids rescanning the complete AST for
	// repeated uses of the same array constant in one transform worker.
	const_array_fixed_storage_cache map[string]i8
	enum_types                      map[string][]string
	enum_backing_types              map[string]string
	runtime_type_indexes            map[string]int
	cur_file                        string
	cur_module                      string
	cur_fn_name                     string
	cur_fn_ret_type                 string
	cur_fn_is_generic               bool
	cur_fn_variadic_param           string
	skip_generics                   bool
	building_v                      bool
	var_types                       []VarTypeBinding
	var_type_indices                map[string]int
	var_type_cache                  &VarTypeIndexCache = unsafe { nil }
	refined_node_types              map[int]string
	fn_value_locals                 map[string]string
	mut_param_values                map[string]bool
	fixed_array_param_values        map[string]bool
	mut_value_ident_nodes           map[int]bool
	pointer_value_lvalues           map[string]bool
	pointer_value_rvalues           map[string]bool
	addr_lvalue_pointer_locals      map[string]bool
	orm_initialized_fields          map[string][]string
	sql_query_data_aliases          map[string][]string
	bound_method_arrays             map[string]BoundMethodArrayInfo
	temp_counter                    int
	global_temp_counter             int
	pending_stmts                   []flat.NodeId
	smartcast_stack                 []SmartcastContext
	invalidated_smartcasts          map[string]bool
	in_call_callee                  bool
	in_monomorphize_scan            bool
	validating_generic_spec         bool
	monomorph_errors                []string
	monomorph_error_seen            map[string]bool
	in_spawn_expr                   bool
	has_spawn_expr                  bool
	in_const_init                   bool
	in_return_expr                  bool
	in_string_interp_part           bool
	expected_expr_node              int = -1
	expected_expr_type              string
	in_selector_base                bool
	autolock_depth                  int
	alias_cache                     &AliasCache              = unsafe { nil }
	sum_cache                       &AliasCache              = unsafe { nil }
	module_type_cache               &AliasCache              = unsafe { nil }
	struct_guess_cache              &AliasCache              = unsafe { nil }
	generic_unresolved_cache        &GenericUnresolvedCache  = unsafe { nil }
	struct_field_type_cache         &LookupCache             = unsafe { nil }
	variant_short_name_cache        &AliasCache              = unsafe { nil }
	selector_type_cache             &SelectorTypeCache       = unsafe { nil }
	resolved_call_return_cache      &ResolvedCallReturnCache = unsafe { nil }
	variant_match_cache             &VariantMatchCache       = unsafe { nil }
	interface_type_cache            &ContextLookupCache      = unsafe { nil }
	enum_expected_cache             &LookupCache             = unsafe { nil }
	type_alias_name_cache           &ContextBoolLookupCache  = unsafe { nil }
	interface_box_param_cache       &BoolLookupCache         = unsafe { nil }
	alias_receiver_method_cache     &LookupCache             = unsafe { nil }
	receiver_method_cache           &ReceiverMethodCache     = unsafe { nil }
	promote_text_cache              &PromoteTextCache        = unsafe { nil }
	call_variadic_cache             &BoolLookupCache         = unsafe { nil }
	str_alias_cache                 &LookupCache             = unsafe { nil }
	generic_alias_names             map[string]bool
	local_decl_nodes_by_name        map[string][]int
	struct_field_decl_metas_cache   map[string]map[string]FieldDeclMeta
	comptime_field_metas_cache      map[string][]FieldMeta
	call_param_types_decl_cache     map[int][]types.Type
	call_param_types_decl_misses    map[string]bool
	call_param_types_decl_index     map[string]FnParamDeclRef
	call_param_types_index_ready    bool
	used_fns                        map[string]bool
	used_fns_parent                 &map[string]bool = unsafe { nil }
	used_fns_root                   &map[string]bool = unsafe { nil }
	comptime_reflected_params       map[string][]ParamMeta
	// sum_eq_types records sum types whose deep-equality helper fn
	// (__v3_sum_eq_<name>) is called somewhere, keyed by sum name with the
	// module/file context of the requesting call site (type resolution inside
	// the helper body needs that context). The helpers are synthesized
	// serially after the (possibly parallel) transform completes.
	sum_eq_types                 map[string]SumEqRequest
	sum_eq_synthesized           map[string]bool
	sum_eq_helper_module         string
	auto_str_types               map[string]AutoStrRequest
	auto_str_synthesized         map[string]bool
	auto_str_helper_module       string
	auto_str_synthesis_type      string
	interface_boxed_types        map[string]bool
	interface_boxed_types_done   bool
	interface_boxed_types_frozen bool
	interface_impl_indexes       map[string]&types.InterfaceImplIndex
	interface_impl_spec_count    int
	ierror_none_type_id          int
	interface_var_concrete_types map[string]string
	// used_struct_operator_fns holds the callee names of direct calls seen during
	// monomorphize. Infix operators on generic instances are lowered to direct calls
	// (`Vec_int__plus(a, b)`) before this pass, so an operator overload is specialized for
	// an instantiated generic struct only when its mangled name appears here — an instance
	// whose type argument never has the operator applied is not emitted with a body that
	// would fail C compilation.
	used_struct_operator_fns map[string]bool
	// active_generic_params holds the generic parameter names of the decl currently
	// being specialized/rewritten, in the same order as the inferred type `args`.
	// It lets type-text substitution map placeholders by name (so non-canonical
	// params like `D`/`F` resolve to the right arg) instead of by the positional
	// `generic_param_index` heuristic (which collapses anything outside the T/U/C
	// sequences to index 0). Empty for struct-generic specialization, which keeps
	// the legacy positional behaviour.
	active_generic_params []string
	// cloning_comptime_for_depth > 0 while a generic clone descends into a `$for` body: nested
	// generic calls there must not be specialized (the loop var members are not resolved yet).
	cloning_comptime_for_depth int
	cloning_comptime_for_vars  []string
	// ignored_comptime_for_nodes marks source `$for` subtrees replaced by concrete
	// unrolled nodes. Keeping the marker outside the shared flat AST lets parallel
	// workers record their own discarded nodes without racing.
	ignored_comptime_for_nodes  []bool
	ignored_comptime_for_log    []int
	ignored_comptime_log_active bool
	// cloning_generic_fn_depth > 0 while a generic specialization is cloned with a live,
	// seeded parameter scope. Ident inference should use that scope rather than scan annotations.
	cloning_generic_fn_depth  int
	specialization_node_start int = -1
	// escaping_amp_ptrs holds the names of pointer locals `p` declared as `p := &v`
	// (v a value local) whose pointer escapes the function (is returned or retained
	// in nonlocal storage). V semantics auto-heap such a `v`; v3 otherwise takes the
	// address of a stack local that dies on return. Recomputed per function (structural
	// pre-pass in transform_fn_body), consumed when the `p := &v` decl is transformed
	// (RHS rewritten to a heap copy).
	escaping_amp_ptrs map[string]bool
	// escaping_amp_sources holds the source locals `v` of such `p := &v` escapes. A returned
	// pointer local can collect more than one source through later assignments (`p = &w`);
	// each possible source whose address may leave the frame is moved to the heap at its
	// declaration so mutations before the return remain visible to the caller.
	escaping_amp_sources map[string]bool
	// heaped_amp_locals records which of those sources were actually moved to the heap, so
	// the `p := &v` alias emits `p = v` (the heap pointer) instead of a fresh memdup copy.
	heaped_amp_locals map[string]bool
	// escaping_interface_box_locals holds interface locals boxed from stack-backed pointer
	// sources and later returned. The box can alias the stack value while in scope, but its
	// `_object` needs a heap copy before the interface value leaves the frame.
	escaping_interface_box_locals map[string]bool
	// local_closure_cleanup_decls maps source declaration node ids to runtime
	// closure locals that do not escape their lexical scope.
	local_closure_cleanup_decls map[int]string
	// local_closure_cleanup_values maps individual RHS expression node ids in
	// multi-variable declarations to their non-escaping closure bindings.
	local_closure_cleanup_values map[int]string
	// local_closure_cleanup_assigns maps source assignment node ids to the exact
	// scope-owned closure binding they overwrite. Identifier spelling alone is
	// insufficient because disjoint lexical scopes may reuse the same name.
	local_closure_cleanup_assigns map[int]string
	// local_closure_field_cleanups contains assignments and aggregate initializer values that
	// create a fresh closure in a non-escaping lexical local. Their generated temporary owns the
	// allocation until that lexical scope exits.
	local_closure_field_cleanups map[int]bool
	// exclusive_closure_return_fns contains source functions proven to return a newly
	// allocated closure without storing, passing, or otherwise aliasing that closure.
	// Discarded call results may be reclaimed only for functions in this frozen pre-pass map.
	exclusive_closure_return_fns   map[string]bool
	exclusive_closure_returns_done bool
	// mut_fixed_array_capture_sources records locals captured as `mut` fixed arrays by
	// closures that are not proven local. Their storage is moved to the heap so the outer
	// binding and escaped closure context keep sharing the same durable array.
	mut_fixed_array_capture_sources    map[string]bool
	active_specialization_args         []string
	active_specialization_main_types   map[string]bool
	specialization_main_type_closures  map[string]map[string]bool
	generic_specialization_args        map[string][]string
	generic_specialization_args_parent &map[string][]string = unsafe { nil }
	generic_fn_specs_in_progress       map[string]bool
	generic_fn_spec_nodes              map[string]flat.NodeId
	monomorph_cache_specs              map[string]MonomorphCacheSpec
	generic_clone_children             []flat.NodeId
	node_context_stack                 []flat.NodeId
	specialization_decl_nodes_by_name  map[string][]int
	defer_nested_generic_emissions     bool
	parallel_monomorphize              bool
	parallel_monomorph_worker          bool
	generic_signatures_pre_registered  bool
	pending_generic_fn_specs           []PendingGenericFnSpec
	pending_generic_fn_spec_keys       map[string]bool
	generic_fn_decls_cache             map[string]GenericFnDecl
	generic_receiver_methods_by_name   map[string][]string
	generic_fn_decls_ready             bool
	generic_struct_specs_cache         map[string]string
	generic_sum_specs_cache            map[string]GenericSpecContext
	generic_materialization_scan_from  int
	generic_materialization_ready      bool
	parallel_monomorph_scan_nodes      []int
	parallel_monomorph_scan_start      int
	parallel_monomorph_scan_end        int
	fn_scan_costs                      []int
	parallel_monomorph_struct_specs    map[string]string
	parallel_monomorph_sum_specs       map[string]GenericSpecContext
	generic_call_spec_cache            map[int]GenericCallSpec
	generic_call_spec_misses           map[int]bool
	stringify_stack                    []string
	stringify_depth_cap                int = max_stringify_nesting_depth
	str_expansion_memo                 map[string]int
	deferred_str_items                 []FnWorkItem
	deferred_str_count                 int
	node_module_map_cache              []string
	node_file_map_cache                []string
	node_module_map_nodes              int = -1
	// used_fns_log records names newly inserted into used_fns while the
	// late-used-fn-bodies pass runs, so that pass can tell "was this name
	// already used before the current body's transform" without cloning the
	// whole used_fns map per function (those clones dominated the pass's time
	// and, under -gc none, were never freed).
	used_fns_log        []string
	used_fns_log_active bool
	// transformed_fns[i] is set when the fn_decl at node id i has had its body
	// transformed (main pass, any thread — worker chunks are marked at merge).
	// The late-used-fn-bodies pass excludes these candidates: lowered bodies
	// surface sanitized call spellings (`seed__time_seed_array`) that the
	// used-set (holding `seed.time_seed_array`) cannot filter, which used to
	// re-transform hundreds of already-transformed bodies every build.
	transformed_fns []bool
	// Shared-base (clone-free) parallel transform: all threads operate on views
	// of the master arrays, appending into pre-partitioned capacity regions.
	// While base_write_intercept is set, in-place writes to base-range node
	// slots outside the current item's subtree range [item_range_lo,
	// item_range_hi] are dropped (workers — matching the old clone path, where
	// such writes stayed in the discarded clone) or deferred until after join
	// (master, defer_oor_writes — matching the old path where the master's
	// writes landed on the shared AST).
	base_write_intercept bool
	defer_oor_writes     bool
	shared_base_nodes    int = -1
	item_range_lo        int = -1
	item_range_hi        int = -1
	deferred_base_writes []DeferredBaseWrite
	// Prealloc self-host builds put helper-thread scratch allocations in
	// disposable arenas. The worker's surviving AST strings are cloned by the
	// master before that arena is released.
	scope_parallel_workers  bool
	worker_scope            voidptr
	scoped_base_nodes       int = -1
	scoped_owned_base_nodes map[int]bool
	scoped_owned_base_log   []int
	scoped_base_log_active  bool
	scoped_promoted_texts   map[string]string
	retain_worker_results   bool
	retained_worker_regions []ScopedTransformRegion
	stage_scope             voidptr
	scoped_monomorphize     bool
}

Transformer represents transformer data used by transform.

fn (Transformer) drain_pending #

fn (mut t Transformer) drain_pending(mut result []flat.NodeId)

drain_pending supports drain pending handling for Transformer.

fn (Transformer) find_smartcast #

fn (t &Transformer) find_smartcast(expr_name string) ?SmartcastContext

find_smartcast resolves find smartcast information for transform.

fn (Transformer) get_global_type #

fn (t &Transformer) get_global_type(name string) ?string

get_global_type returns get global type data for Transformer.

fn (Transformer) get_struct_info #

fn (t &Transformer) get_struct_info(name string) ?StructInfo

get_struct_info returns get struct info data for Transformer.

fn (Transformer) is_sum_variant #

fn (t &Transformer) is_sum_variant(name string) bool

is_sum_variant reports whether is sum variant applies in transform.

fn (Transformer) make_array_init #

fn (mut t Transformer) make_array_init(elem_type string) flat.NodeId

make_array_init builds make array init data for transform.

fn (Transformer) make_assign #

fn (mut t Transformer) make_assign(lhs flat.NodeId, rhs flat.NodeId) flat.NodeId

make_assign builds make assign data for transform.

fn (Transformer) make_assign_op #

fn (mut t Transformer) make_assign_op(lhs flat.NodeId, rhs flat.NodeId, op flat.Op) flat.NodeId

make_assign_op builds make assign op data for transform.

fn (Transformer) make_block #

fn (mut t Transformer) make_block(stmts []flat.NodeId) flat.NodeId

make_block builds make block data for transform.

fn (Transformer) make_bool_literal #

fn (mut t Transformer) make_bool_literal(value bool) flat.NodeId

make_bool_literal builds make bool literal data for transform.

fn (Transformer) make_call #

fn (mut t Transformer) make_call(fn_name string, args []flat.NodeId) flat.NodeId

make_call builds make call data for transform.

fn (Transformer) make_call_expr_typed #

fn (mut t Transformer) make_call_expr_typed(fn_expr flat.NodeId, args []flat.NodeId, typ string) flat.NodeId

make_call_expr_typed builds make call expr typed data for transform.

fn (Transformer) make_call_typed #

fn (mut t Transformer) make_call_typed(fn_name string, args []flat.NodeId, typ string) flat.NodeId

make_call_typed builds make call typed data for transform.

fn (Transformer) make_cast #

fn (mut t Transformer) make_cast(target_type string, expr flat.NodeId, typ string) flat.NodeId

make_cast builds make cast data for transform.

fn (Transformer) make_decl_assign #

fn (mut t Transformer) make_decl_assign(name string, rhs flat.NodeId) flat.NodeId

make_decl_assign builds make decl assign data for transform.

fn (Transformer) make_empty #

fn (mut t Transformer) make_empty() flat.NodeId

make_empty builds make empty data for transform.

fn (Transformer) make_expr_stmt #

fn (mut t Transformer) make_expr_stmt(expr flat.NodeId) flat.NodeId

make_expr_stmt builds make expr stmt data for transform.

fn (Transformer) make_float_literal #

fn (mut t Transformer) make_float_literal(value string) flat.NodeId

make_float_literal builds make float literal data for transform.

fn (Transformer) make_float_literal_typed #

fn (mut t Transformer) make_float_literal_typed(value string, typ string) flat.NodeId

fn (Transformer) make_ident #

fn (mut t Transformer) make_ident(name string) flat.NodeId

make_ident builds make ident data for transform.

fn (Transformer) make_if #

fn (mut t Transformer) make_if(cond flat.NodeId, then_block flat.NodeId, else_block flat.NodeId) flat.NodeId

make_if builds make if data for transform.

fn (Transformer) make_if_with_skip_ownership_drops #

fn (mut t Transformer) make_if_with_skip_ownership_drops(cond flat.NodeId, then_block flat.NodeId, else_block flat.NodeId) flat.NodeId

make_if_with_skip_ownership_drops builds a synthetic if that must not consume ownership-drop metadata recorded for source control-flow nodes.

fn (Transformer) make_index #

fn (mut t Transformer) make_index(base flat.NodeId, index flat.NodeId, typ string) flat.NodeId

make_index builds make index data for transform.

fn (Transformer) make_infix #

fn (mut t Transformer) make_infix(op flat.Op, lhs flat.NodeId, rhs flat.NodeId) flat.NodeId

make_infix builds make infix data for transform.

fn (Transformer) make_int_literal #

fn (mut t Transformer) make_int_literal(value int) flat.NodeId

make_int_literal builds make int literal data for transform.

fn (Transformer) make_int_literal_typed #

fn (mut t Transformer) make_int_literal_typed(value string, typ string) flat.NodeId

fn (Transformer) make_map_init #

fn (mut t Transformer) make_map_init(map_type string) flat.NodeId

make_map_init builds make map init data for transform.

fn (Transformer) make_method_call #

fn (mut t Transformer) make_method_call(receiver flat.NodeId, method_name string, args []flat.NodeId) flat.NodeId

make_method_call builds make method call data for transform.

fn (Transformer) make_paren #

fn (mut t Transformer) make_paren(expr flat.NodeId) flat.NodeId

make_paren builds make paren data for transform.

fn (Transformer) make_postfix #

fn (mut t Transformer) make_postfix(expr flat.NodeId, op flat.Op) flat.NodeId

make_postfix builds make postfix data for transform.

fn (Transformer) make_prefix #

fn (mut t Transformer) make_prefix(op flat.Op, expr flat.NodeId) flat.NodeId

make_prefix builds make prefix data for transform.

fn (Transformer) make_selector #

fn (mut t Transformer) make_selector(base flat.NodeId, field string, typ string) flat.NodeId

make_selector builds make selector data for transform.

fn (Transformer) make_selector_op #

fn (mut t Transformer) make_selector_op(base flat.NodeId, field string, typ string, op flat.Op) flat.NodeId

make_selector_op builds make selector op data for transform.

fn (Transformer) make_sizeof_type #

fn (mut t Transformer) make_sizeof_type(type_name string) flat.NodeId

make_sizeof_type builds make sizeof type data for transform.

fn (Transformer) make_string_literal #

fn (mut t Transformer) make_string_literal(value string) flat.NodeId

make_string_literal builds make string literal data for transform.

fn (Transformer) make_struct_init #

fn (mut t Transformer) make_struct_init(name string) flat.NodeId

make_struct_init builds make struct init data for transform.

fn (Transformer) make_sum_tag_selector #

fn (mut t Transformer) make_sum_tag_selector(base flat.NodeId, op flat.Op) flat.NodeId

make_sum_tag_selector builds an internal selector for a sumtype discriminator.

fn (Transformer) new_temp #

fn (mut t Transformer) new_temp(prefix string) string

new_temp supports new temp handling for Transformer.

fn (Transformer) pop_smartcast #

fn (mut t Transformer) pop_smartcast()

pop_smartcast updates pop smartcast state for Transformer.

fn (Transformer) push_smartcast #

fn (mut t Transformer) push_smartcast(expr_name string, variant string, sum_type string)

push_smartcast updates push smartcast state for Transformer.

fn (Transformer) synthesize_sum_eq_helpers #

fn (mut t Transformer) synthesize_sum_eq_helpers() []string

synthesize_sum_eq_helpers generates the fn_decl for every sum type whose equality helper was requested during the transform. Building one helper body can request helpers for nested sum types, so this drains a worklist. Runs serially on the merged AST (workers only record names). Returns the names newly marked used while building the helper bodies (e.g. a payload struct's overloaded ==), so the caller can run them through the late-used-fn pass — synthesis happens after that pass, so such functions would otherwise miss body transformation.

fn (Transformer) transform_expr #

fn (mut t Transformer) transform_expr(id flat.NodeId) flat.NodeId

transform_expr transforms transform expr data for transform.

fn (Transformer) transform_lvalue #

fn (mut t Transformer) transform_lvalue(id flat.NodeId) flat.NodeId

transform_lvalue transforms transform lvalue data for transform.

fn (Transformer) transform_stmt #

fn (mut t Transformer) transform_stmt(id flat.NodeId) []flat.NodeId

transform_stmt transforms transform stmt data for transform.

fn (Transformer) transform_stmts #

fn (mut t Transformer) transform_stmts(ids []flat.NodeId) []flat.NodeId

transform_stmts transforms transform stmts data for transform.