Skip to content

v.gen.c #

array_like_type supports array like type handling for c.

fn cache_c_flag_input_files #

fn cache_c_flag_input_files(flags []string) []string

cache_c_flag_input_files returns forced include/macro files whose contents affect every cached object compiled with the supplied C flags.

fn cache_directive_flags #

fn cache_directive_flags(a &flat.FlatAst, vroot string, target pref.Target, compile_values map[string]string) []string

cache_directive_flags resolves source C flags that affect early C cache keys.

fn cache_external_input_files #

fn cache_external_input_files(a &flat.FlatAst, vroot string, source_modules map[string]bool, initial_c_flags []string, target pref.Target) (map[string][]string, map[string][]string, bool)

cache_external_input_files returns local include/embed inputs grouped by the module whose cached object incorporates their contents, plus the ordered root native source includes for each module. Forced-include inputs affect every object and are kept in a configuration-wide group. The last result reports include forms whose dependencies cannot be resolved statically.

fn cache_external_input_files_with_resolved_flags #

fn cache_external_input_files_with_resolved_flags(a &flat.FlatAst, vroot string, source_modules map[string]bool, c_flags []string, target pref.Target, program_files map[string]bool, compiler_macros map[string]string, compiler_macro_environment_complete bool) (map[string][]string, map[string][]string, map[string][]string, map[string][]string, map[string][]string, []string, []string, bool)

cache_external_input_files_with_resolved_flags collects cache inputs without resolving source #flag directives a second time. unscoped_inputs contains the dependency trees of native source roots and direct non-source includes whose linkage can cross generated units. resolution_dirs contains every searched include directory whose contents can change path resolution; missing_resolution_paths are the first nonexistent path components searched. Directives from program_files belong to the program translation unit even when a library test declares that module.

fn cache_external_input_snapshot_with_resolved_flags #

fn cache_external_input_snapshot_with_resolved_flags(a &flat.FlatAst, vroot string, source_modules map[string]bool, c_flags []string, target pref.Target, program_files map[string]bool, compiler_macros map[string]string, compiler_macro_environment_complete bool) (map[string][]string, map[string][]string, map[string][]string, map[string][]string, map[string][]string, []string, []string, map[string]string, bool)

cache_external_input_snapshot_with_resolved_flags also returns SHA-256 digests of the exact native buffers used to resolve the dependency tree.

fn cache_native_flag_input_files #

fn cache_native_flag_input_files(a &flat.FlatAst, vroot string, target pref.Target) []string

cache_native_flag_input_files returns the native sources and objects that #flag directives name outright, for example #flag @VEXEROOT/thirdparty/sqlite/sqlite3.c or the prebuilt sqlite3.o used on Windows. The cache input scan follows #include/#insert and forced includes, so a file named this way is compiled or linked into the binary while being invisible to every other input record.

Only directives that survive comptime branch resolution are seen, so a #flag guarded by an $if for another platform is correctly left out.

fn cache_native_input_language #

fn cache_native_input_language(path string, c_flags []string, c99_mode bool, target pref.Target) string

cache_native_input_language reports the exact preprocessor language cgen selects for a native input. The dependency probe and privacy preprocessing must use it so they observe the same predefined macros as the real build; an .mm source, for example, is Objective-C++ and defines both __OBJC__ and __cplusplus, so probing it as plain C or Objective-C omits __cplusplus and wrongly discards branches guarded by it.

fn cache_native_input_path_needs_objective_c #

fn cache_native_input_path_needs_objective_c(path string, c_flags []string, c99_mode bool, target pref.Target) bool

cache_native_input_path_needs_objective_c reports whether a native input must use the Objective-C preprocessor language selected by cgen.

fn cache_native_inputs_language #

fn cache_native_inputs_language(a &flat.FlatAst, vroot string, c_flags []string, c99_mode bool, ccompiler string, target pref.Target) string

cache_native_inputs_language reports the richest preprocessor language any native input requires. The shared compiler-macro probe uses it so it never omits a language macro (__OBJC__, __cplusplus) that an input's active branches depend on.

fn cache_native_inputs_need_objective_c #

fn cache_native_inputs_need_objective_c(a &flat.FlatAst, vroot string, c_flags []string, c99_mode bool, ccompiler string, target pref.Target) bool

cache_native_inputs_need_objective_c reports whether cgen must implicitly compile the generated translation unit as Objective-C because of a native input rather than an explicit compiler flag.

fn cache_program_file_set #

fn cache_program_file_set(a &flat.FlatAst, files []string) map[string]bool

cache_program_file_set is the set that set_cache_program_files keeps: each program file by the path it was given and by its real path, so that a caller outside the generator (the driver deciding which $embed_file payloads are assembled, see embed_incbin_payloads) tests membership the same way.

fn embed_incbin_payloads #

fn embed_incbin_payloads(a &flat.FlatAst, program_files map[string]bool, module_cache bool) []EmbedIncbinPayload

embed_incbin_payloads lists the payloads that take the .incbin path when the driver has enabled it: every payload too long for a string literal, in AST order, except, under the module cache, those that a cached module refers to. A cached module is a file outside program_files; its object is reused by later builds that do not assemble this build's objects, so its payloads stay self contained C arrays. The same bytes referred to from both sides are one symbol, and go the self contained way too. The driver and the generator derive the list from the same inputs, so they agree on which objects exist.

fn module_const_init_order #

fn module_const_init_order(a &flat.FlatAst, tc &types.TypeChecker) []string

module_const_init_order returns the dependency-safe constant initialization order that declaration-only module headers must preserve.

fn msvc_compat_c_source #

fn msvc_compat_c_source(src string) string

msvc_compat_c_source rewrites generated C source so MSVC's cl can compile it.

fn tokenize_c_flag #

fn tokenize_c_flag(value string) []string

tokenize_c_flag splits a C flag on unquoted whitespace while preserving quotes.

fn FlatGen.new #

fn FlatGen.new() FlatGen

new creates a FlatGen value for c.

struct EmbedIncbinPayload #

struct EmbedIncbinPayload {
pub:
	symbol  string // the suffix of the `_v_embed_blob_` object the generated C names
	payload string // the bytes that object holds
}

EmbedIncbinPayload is one $embed_file payload that the C build stores through the assembler's .incbin directive rather than a C array initializer.

struct FlatGen #

struct FlatGen {
mut:
	sb                             strings.Builder
	indent                         int
	a                              &flat.FlatAst    = unsafe { nil }
	used_fns                       &map[string]bool = unsafe { nil }
	used_fn_names                  []string
	fn_gen_items                   []FlatFnGenItem
	top_level_node_ids             []i32
	ast_string_literals            []string
	ast_string_literals_ready      bool
	fn_segs                        []string
	fn_seg_chunk_indexes           []int
	parallel_chunk_wrapper_defs    []ParallelChunkWrapperDefs
	parallel_chunk_wrapper_capture int = -1
	parallel_type_decls            string
	parallel_global_decls          string
	parallel_forward_decls         string
	parallel_support_decls         string
	parallel_enum_str_defs         string
	parallel_interface_stubs       string
	parallel_init_defs             string
	parallel_const_code            string
	parallel_support_ready         bool
	test_files                     map[string]bool
	show_test_stats                bool
	show_test_summary              bool
	show_test_file_results         bool
	test_run_only                  []string
	assert_expr_overrides          map[int]string
	callback_target_overrides      map[int]string
	print_fn_names                 []string
	profile_file                   string
	profile_no_inline              bool
	profile_fns                    []string
	profile_counters               []ProfileCounterMeta
	profile_fn_active              bool
	profile_fn_restore_enabled     bool
	is_prod                        bool
	is_debug                       bool
	check_overflow                 bool
	ignore_overflow                bool
	force_bounds_checking          bool
	is_shared                      bool
	interface_exports              []string
	object_file_mode               bool
	suppress_main                  bool
	coverage_dir                   string
	coverage_build_options         string
	race                           bool
	line_directives                bool
	line_directive_paths           map[string]string
	line_directive_fn_start        int
	coverage_files                 map[string]&CoverageInfo
	coverage_counter_count         int
	cache_program_files            map[string]bool
	incremental_fn_names           map[string]bool
	str_lits                       []string
	str_lit_ids                    map[string]int
	str_lits_shared                bool
	// Worker snapshots inherit this immutable prefix from their parent generator.
	str_lits_base_len int
	global_types      map[string]types.Type
	// Globals declared `volatile`. A kernel writes these where the hardware or
	// the bootloader can see them, so the qualifier has to survive into the C.
	global_volatile_names          map[string]bool
	global_raw_type_texts          map[string]string
	enum_vals                      map[string]int
	enum_value_exprs               map[string]string
	enum_modules                   map[string]string
	defers                         []flat.NodeId
	defer_cleanup_stack            []flat.NodeId // already emitted by the active cleanup path
	scope_defer_starts             []int
	fn_defers                      []flat.NodeId
	fn_defer_counts                map[int]string
	defer_capture_names            []string
	defer_capture_types            map[string]types.Type
	uses_recover                   bool   // the program calls `recover()`, so every `defer` links a panic frame
	cur_fn_panic_owner             bool   // the current function declared the `_v_unwind_owner` of its frames
	cur_panic_frame                string // frame of the deferred block being emitted, which `recover()` asks for
	interfaces                     map[string][]string
	const_vals                     map[string]flat.NodeId
	const_modules                  map[string]string
	const_files                    map[string]string // const name -> declaring file (for import-alias type resolution)
	const_init_order               []string
	fixed_storage_consts           map[string]bool
	global_modules                 map[string]string
	global_files                   map[string]string      // qualified global name -> declaring file (for import-alias type resolution)
	global_inits                   map[string]flat.NodeId // qualified global name -> initializer value node
	global_init_order              []string               // qualified global names, in declaration order
	in_global_array_pointer_init   bool
	enum_backing_infos             map[string]EnumBackingInfo
	iface_impls                    map[string][]string // interface name -> implementing concrete type names
	interface_dispatch_required    map[string]bool     // source/lowered concrete method names required by emitted interface dispatch
	iface_type_ids                 map[string]int      // "${iface}::${concrete}" -> 1-based type id
	interface_boxed_types          map[string]bool
	interface_boxed_types_done     bool
	ierror_method_emit_names       map[string]bool   // names/lowered names of concrete IError msg/code methods
	ierror_stack_pointer_aliases   []map[string]bool // scoped local pointer aliases to stack subobjects
	ierror_owned_pointer_by_owner  map[string]bool   // exact scope binding owner -> local owns its pointer allocation
	recursive_drop_helpers         map[string]string // expansion key -> concrete struct type name
	local_pointer_storage_by_owner map[string]bool   // exact scope binding owner -> C storage is already a pointer
	local_c_type_by_owner          map[string]string // exact scope binding owner -> emitted C declaration type
	local_mutable_by_owner         map[string]bool
	local_pointer_alias_by_owner   map[string]string            // exact scope binding owner -> stack local whose address is stored
	local_pointer_alias_mut_param  map[string]bool              // exact scope binding owner -> alias source is a mut parameter
	local_raw_type_by_owner        map[string]string            // exact scope binding owner -> source-level raw type text
	local_indirect_value_by_owner  map[string]types.Type        // exact scope binding owner -> semantic value behind indirect C storage
	local_implicit_deref_by_owner  map[string]bool              // exact scope binding owner -> C pointer storage read as a semantic value
	local_shared_storage_by_owner  map[string]bool              // exact scope binding owner -> C storage is a shared wrapper pointer
	local_fn_value_c_name_by_owner map[string]string            // exact scope binding owner -> lifted fn-literal C name
	sum_name_lookup                map[string]string            // full/short sum type name -> canonical sum type name
	sum_variant_lookup             map[string]map[string]string // sum name -> exact/short variant -> canonical variant
	sum_variant_actual_cache       &SumVariantActualCache = &SumVariantActualCache{} // sum name + semantic actual type -> canonical variant (empty means miss)
	module_init_fns                []string            // C names of module-level `init()` fns, in source order
	module_init_fn_modules         map[string]string   // C init fn name -> V module name
	module_cleanup_fns             []string            // C names of module-level `cleanup()` fns, in source order
	module_cleanup_fn_modules      map[string]string   // C cleanup fn name -> V module name
	module_imports                 map[string][]string // module -> imported modules
	c_directives                   []CDirective
	preinclude_directives          []string
	postinclude_directives         []string
	early_c_source_directives      map[string]bool
	native_source_contexts         map[string][]NativeSourceContextDirective
	objective_cpp_source_requests  []ObjectiveCppSourceRequest
	native_source_wrapper_index    int
	inlined_c_structs              map[string]bool
	cache_native_c_symbols         map[string]bool
	inlined_c_typedef_names        map[string]bool
	inlined_c_fns                  map[string]bool
	inlined_c_declared_fns         map[string]bool
	files_with_c_includes          map[string]bool
	files_with_c_postincludes      map[string]bool
	files_linking_c_sources        map[string]bool
	mods_with_c_libs               map[string]bool
	mods_with_c_includes           map[string]bool
	inlined_c_active_macros        map[string]bool
	inlined_c_static_fns           map[string]bool
	cache_omitted_c_fns            map[string]bool
	initial_c_flags                []string
	c_flags                        []string
	libc_compat_fns                map[string]bool
	tc                             &types.TypeChecker = unsafe { nil }
	has_builtins                   bool
	tmp_count                      int
	line_start                     bool
	field_name_set                 map[string]bool   // every struct field's C name (lazy) — for const/field collision checks
	modules                        map[string]string // alias -> full module name
	fn_ptr_types                   map[string]string // fn_ptr:ret|params -> typedef name
	used_fn_ptr_types              map[string]bool   // signatures referenced by emitted C
	multi_return_types             []types.Type
	multi_return_type_names        map[string]bool
	multi_return_types_ready       bool
	decl_types_ready               bool
	optional_types_ready           bool
	fixed_array_ret_wrappers       map[string]bool // bare fixed-array c_type name -> has a return wrapper struct
	emitted_fixed_array_typedefs   map[string]bool // bare fixed-array typedefs already written (shared across passes)
	concrete_optional_abi_fns      map[string]bool // emitted fn names whose option/result params use __v_option_T ABI
	fixed_array_typedefs_needed    map[string]FixedArrayTypedefInfo
	fixed_array_typedefs_ready     bool
	fixed_array_map_key_types      map[string]types.ArrayFixed
	fn_decl_param_types            map[string][]types.Type
	fn_decl_variadic               map[string]bool
	fn_decl_variadic_short_counts  map[string]int
	fn_decl_shared_params          map[string][]bool
	fn_shared_params_resolved      map[string][]bool
	shared_param_index_empty       bool
	has_shared_params              bool
	fn_decl_mut_receivers          map[string]bool
	fn_decl_ret_types              map[string]types.Type // fn decl name (and qualified variants) -> return type
	// Const dependency analysis follows helper calls. Keep declaration indexes so
	// resolving each call does not scan the whole flattened AST.
	fn_decl_nodes_by_name         map[string]flat.NodeId
	fn_decl_nodes_by_short        map[string]flat.NodeId
	fn_decl_nodes_by_module_short map[string]flat.NodeId
	// set of `${module}\x01${name}` for every non-generic fn decl, built once in
	// precompute_non_generic_fn_index. Replaces the former full-node scan in
	// non_generic_fn_decl_exists_in_module (O(nodes) per call, hot in cgen).
	non_generic_fn_names_by_module map[string]bool
	// indexes over tc.fn_generic_params keys, built once in
	// precompute_generic_fn_key_index. They replace the former full-map scan in
	// generic_plain_fn_base_for_call (O(generic fns) with two string allocations
	// per key, run for nearly every emitted call). The ordinal preserves the
	// map's iteration order so multi-match resolution stays byte-identical.
	generic_fn_keys_by_short      map[string][]string
	generic_fn_keys_by_cname      map[string][]string
	generic_fn_key_ordinal        map[string]int
	struct_decl_infos             map[string]StructDeclInfo
	struct_decl_short_infos       map[string]StructDeclInfo
	decl_attrs                    map[int][]string
	decl_attrs_by_source_position map[u64][]string
	c_decl_abi_names              map[string]string
	c_extern_forced_decls         map[string]bool
	export_c_abi_decls            map[string]flat.NodeId
	main_export_owners            map[string][]string
	c_extern_global_names         map[string]string
	export_global_names           map[string]string
	global_linker_sections        map[string]string
	global_cinit_names            map[string]bool
	static_c_initializer          bool
	const_init_depth              int                       // >0 while a const initializer is inlined; see ident_is_local_binding
	shared_type_names             map[string]SharedTypeInfo // __shared__ wrapper name -> wrapped type metadata
	shared_alias_pointer_shorts   map[string]string         // alias short name -> shared inner type; '' means ambiguous
	shared_alias_index_ready      bool
	needs_shared_runtime          bool
	needs_pthread_header          bool
	needs_thread_type             bool
	needs_thread_runtime          bool
	spawn_detached                bool // the spawn being emitted has its handle discarded
	spawn_comparable              bool // keep a discarded spawn's handle until its comparison finishes
	detached_spawn_drop           bool // ownership traversal also joins nested handles and destroys closures
	spawn_return_type             types.Type = types.Type(types.void_)
	const_runtime_inits           []string
	const_runtime_init_modules    []string
	runtime_inits                 []string
	runtime_init_modules          []string
	compiler_vroot                string
	compiler_vexe                 string
	compiler_vexe_env_setup       bool = true
	ccompiler                     string
	target                        pref.Target
	// output_cross_c keeps every target-dependent `$if` in the output, guarded by
	// the C preprocessor, so one generated snapshot compiles on any target.
	output_cross_c bool
	// cross_directive_guards maps a `#include`/`#flag` node to the C preprocessor
	// condition of the `$if` it was written in, for portable output.
	cross_directive_guards map[int]string
	// compile_defines are the `-d`/`-define` names of this build, reported in the
	// generated header the way the reference compiler did.
	compile_defines               []string
	subsystem                     pref.Subsystem
	target_libc_headers           bool
	windows_entry_point_generated bool
	windows_gui_entry_point       bool
	// C spelling for V's platform-width `int`: `i64` on 64-bit targets, `i32` on
	// 32-bit. Used by hand-written runtime helpers that operate on `[]int`
	// elements or `int` values directly (kept in sync with set_target).
	int_ct                          string = 'i64'
	thread_stack_size               int    = 8 * 1024 * 1024
	compile_values                  map[string]string // explicit `-d` values used by `$d(...)` in C directives
	output_path                     string
	output_error                    string
	c99_mode                        bool
	trace_calls                     bool // -d trace: custom call-site hooks
	is_trace_calls                  bool // -trace-calls: function-entry logging
	trace_fns                       []string
	track_heap                      bool
	inside_trace_call               bool
	skip_generics                   bool
	skip_enum_autostr               bool
	placeholder_check_forced        bool
	cur_fn_name                     string
	cur_fn_source_file              string
	cur_fn_is_specialized           bool
	cur_fn_assert_continues         bool
	current_decl_is_mut             bool
	direct_array_access             bool
	struct_default_module           string
	struct_default_generic_params   []string
	struct_default_generic_args     []string
	default_value_stack             map[string]bool
	shallow_default_value_depth     int
	shadowed_global_locals          map[string]bool
	cur_param_names                 []string
	cur_param_type_values           []types.Type
	cur_param_types                 map[string]types.Type
	cur_param_name_bits             u64
	cur_concrete_optional_params    map[string]bool
	cur_mut_params                  map[string]bool
	cur_mut_pointer_params          map[string]bool
	cur_explicit_mut_pointer_params map[string]bool
	cur_mut_param_owners            map[string]types.ScopeBindingOwner
	cur_c_fn_calls                  map[string]bool
	cur_fn_ret                      types.Type = types.Type(types.void_)
	cur_fn_ret_is_optional          bool
	cur_fn_ret_base                 types.Type = types.Type(types.void_)
	defer_return_tmp_var            string
	active_locks                    []ActiveLock
	unsafe_depth                    int
	loop_depth                      int
	conditional_branch_scopes       []&types.Scope
	conditional_branch_depths       []int
	conditional_branch_depth        int
	loop_label_depths               map[string]int
	loop_defer_starts               []int
	loop_label_defer_starts         map[string]int
	loop_control_copybacks          []LoopControlCopyback
	map_loop_copyback_guards        []MapLoopCopybackGuard
	emitted_loop_break_labels       map[string]bool
	goto_label_c_names              map[string]string
	goto_label_count                int
	goto_label_lock_scopes          map[string][]int
	pending_loop_label              string
	// in_return is true only while generating a `return` statement's value, so a bare
	// generic literal (`return Box{...}`) may adopt `cur_fn_ret`'s concrete instance —
	// but a literal in a local decl / argument elsewhere in the body does not.
	in_return                      bool
	cur_return_node_id             int = -1
	ownership_return_index         int
	ownership_seen_return_sources  map[string]bool
	ownership_propagation_index    int
	ownership_loop_control_index   int
	ownership_loop_iteration_index int
	ownership_scope_index          int
	cur_return_drops               []types.OwnershipDropEntry
	pending_return_scope_drops     []types.OwnershipDropEntry
	expected_expr_type             types.Type = types.Type(types.void_)
	expected_enum                  string
	known_expr_type_id             int        = -1
	known_expr_type                types.Type = types.Type(types.void_)
	memo_usable_expr_types         bool
	cache_struct_fields            bool
	dedup_fn_decl_aliases          bool
	prefix_param_scan              bool
	lean_parallel_worker_init      bool
	lazy_param_abi_merge           bool
	usable_expr_type_memo          &UsableExprTypeMemo  = unsafe { nil }
	import_key_cache               &util.KeyRecentCache = unsafe { nil }
	selective_import_key_cache     &util.KeyRecentCache = unsafe { nil }
	needed_optional_types          map[string]string
	// cabi_int_out_args maps a C-call argument node to the C spelling to emit in its
	// place (the address of a temporary C `int`), while a `&int` out-parameter is
	// bridged by a temporary + copy-back around the wrapped call. Keyed by node id so
	// nested calls never collide.
	cabi_int_out_args               map[flat.NodeId]string
	emitted_optional_types          map[string]bool
	array_method_cache              map[string]string
	param_types_cache               map[string][]types.Type // (name|fallback) -> resolved param types
	interface_receiver_cache        &StringLookupCache        = unsafe { nil }
	normalize_call_cache            &StringLookupCache        = unsafe { nil }
	flattened_generic_name_cache    &StringLookupCache        = unsafe { nil }
	generic_struct_context_ct_cache &StringLookupCache        = unsafe { nil }
	struct_cname_cache              &StringLookupCache        = unsafe { nil }
	unique_struct_ct_cache          &StringLookupCache        = unsafe { nil }
	alias_method_cache              &StringLookupCache        = unsafe { nil }
	import_alias_cache              &ContextStringLookupCache = unsafe { nil }
	enum_selector_cache             &ContextStringLookupCache = unsafe { nil }
	enum_method_cache               &ContextStringLookupCache = unsafe { nil }
	qualified_enum_method_cache     &ContextStringLookupCache = unsafe { nil }
	import_type_cache               &ImportTypeCache          = unsafe { nil }
	embedded_fields_by_type         map[string][]types.StructField // type name -> its embedded fields (usually empty)
	param_types_by_short            map[string][]types.Type        // method short-name suffix -> param types (fallback index)
	generic_method_candidates       map[string][]GenericMethodCandidate
	spawn_wrapper_names             map[string]string
	spawn_wrapper_defs              []string
	spawn_wrapper_defs_seen         map[string]bool
	callback_wrapper_names          map[string]string
	callback_wrapper_defs           []string
	callback_wrapper_defs_seen      map[string]bool
	callback_identity_used          bool
	parallel_used                   bool
	c_name_cache                    &CNameCache = unsafe { nil }
	emitted_fn_ptr_typedefs         map[string]bool
	c_extern_refs                   map[string]bool
	c_extern_refs_ready             bool
	parallel_prepared               bool
	scoped_fn_items_scope           voidptr
	scoped_fn_output_path           string
	scoped_fn_output_paths          []string
	const_short_index               &ConstShortIndex      = unsafe { nil }
	mut_recv_facts                  &FnNameFactCache      = unsafe { nil }
	local_typedef_shadow_facts      &FnNameFactCache      = unsafe { nil }
	local_global_shadow_facts       &ContextNameFactCache = unsafe { nil }
	local_global_suffix_names       map[string]bool
	local_global_suffix_names_ready bool
	generic_app_cache               &GenericAppCache = unsafe { nil }
	want_parallel_prep              bool
	want_parallel_c_extern_prep     bool
	// Set while selected items' C-extern refs still have to be collected: the
	// fused prep walk defers them to the parallel exact-cost pass, which falls
	// back to a serial top-up when it cannot run.
	prep_externs_pending   bool
	prep_costs_pending     bool
	prep_typ_text_cache    &PrepTypTextCache = unsafe { nil }
	prep_alias_short_names map[string]bool
	preseed_type_seen      &PreseedTypeSeen = unsafe { nil }
	// Separate seen-cache for the declaration preseed family
	// (preseed_fn_ptr_type has optional-typedef side effects the body-walk
	// preseed does not); armed only for the contiguous pre-dispatch preseed
	// block, while no arena scope can be freed and reused.
	preseed_sig_type_seen              &PreseedTypeSeen     = unsafe { nil }
	struct_decl_pref_cache             &StructDeclPrefCache = unsafe { nil }
	qualified_struct_c_types_by_suffix map[string][]string
	qualified_struct_c_types_ready     bool
	unused_param_seen                  &UnusedParamSeen = unsafe { nil }
	cache_split                        bool
	cache_stable_symbols               bool
	parallel_cc                        bool
	// Set when the driver stores long `$embed_file` payloads through the
	// assembler (see embed_incbin_payloads); the set of objects it does that for
	// is derived on first use.
	embed_incbin               bool
	embed_incbin_syms          map[string]bool
	embed_incbin_syms_ready    bool
	cache_native_input_paths   map[string]bool
	program_body_only          bool
	cached_support_identifiers map[string]bool
	// Set when the target is built with -prealloc / -d prealloc: the bump
	// arena's base block pointer must be thread-local (matching V1's cgen),
	// or every spawned thread would race on the same arena.
	prealloc                  bool
	scope_parallel_workers    bool
	worker_scope              voidptr
	parallel_worker_scopes    []voidptr
	type_metadata_node_ids    []i32
	type_metadata_nodes_ready bool
}

FlatGen emits flat gen output used by c.

fn (FlatGen) was_parallel #

fn (g &FlatGen) was_parallel() bool

was_parallel reports whether the last fn codegen actually ran across threads.

fn (FlatGen) c_flags #

fn (g &FlatGen) c_flags() []string

fn (FlatGen) set_initial_c_flags #

fn (mut g FlatGen) set_initial_c_flags(flags []string)

set_initial_c_flags makes command-line C flags available while collecting directives.

fn (FlatGen) set_c99_mode #

fn (mut g FlatGen) set_c99_mode(enabled bool)

set_c99_mode configures whether generated C should support strict C99 builds.

fn (FlatGen) set_ccompiler #

fn (mut g FlatGen) set_ccompiler(name string)

set_ccompiler records the selected C compiler for compiler-specific output constraints.

fn (FlatGen) set_prod #

fn (mut g FlatGen) set_prod(enabled bool)

set_prod controls production-only code generation such as removing assertions.

fn (FlatGen) set_debug #

fn (mut g FlatGen) set_debug(enabled bool)

set_debug enables source-aware panic reporting for debug builds.

fn (FlatGen) set_check_overflow #

fn (mut g FlatGen) set_check_overflow(enabled bool)

set_check_overflow enables runtime checks for integer addition, subtraction, and multiplication.

fn (FlatGen) set_force_bounds_checking #

fn (mut g FlatGen) set_force_bounds_checking(enabled bool)

set_force_bounds_checking ignores direct-array-access attributes so every generated array access retains its runtime bounds check.

fn (FlatGen) set_prealloc #

fn (mut g FlatGen) set_prealloc(on bool)

set_prealloc marks the build as using the -prealloc bump arena.

fn (FlatGen) set_skip_generics #

fn (mut g FlatGen) set_skip_generics(on bool)

set_skip_generics removes generic-only metadata work when reachability proved that the generated program has no generic instantiations.

fn (FlatGen) set_skip_enum_autostr #

fn (mut g FlatGen) set_skip_enum_autostr(on bool)

set_skip_enum_autostr omits synthesized enum string helpers when reachability proves the program cannot format an enum.

fn (FlatGen) set_compiler_vexe #

fn (mut g FlatGen) set_compiler_vexe(path string)

set_compiler_vexe sets the V executable path baked into generated test/runtime helpers.

fn (FlatGen) set_compiler_vexe_env_setup #

fn (mut g FlatGen) set_compiler_vexe_env_setup(enabled bool)

set_compiler_vexe_env_setup controls whether generated programs populate an unset VEXE.

fn (FlatGen) set_target #

fn (mut g FlatGen) set_target(target pref.Target)

set_target sets the canonical code-generation target.

fn (FlatGen) set_output_cross_c #

fn (mut g FlatGen) set_output_cross_c(enabled bool)

set_output_cross_c requests portable C that defers every target-dependent $if to the C preprocessor instead of resolving it for one target.

fn (FlatGen) set_compile_defines #

fn (mut g FlatGen) set_compile_defines(defines []string)

set_compile_defines records the -d/-define names to report in the header of the generated C.

fn (FlatGen) set_subsystem #

fn (mut g FlatGen) set_subsystem(subsystem pref.Subsystem)

set_subsystem configures the Windows executable subsystem.

fn (FlatGen) set_target_libc_headers #

fn (mut g FlatGen) set_target_libc_headers(target_libc_headers bool)

set_target_libc_headers marks a target that supplies the libc headers itself.

fn (FlatGen) generated_windows_gui_entry_point #

fn (g &FlatGen) generated_windows_gui_entry_point() ?bool

generated_windows_gui_entry_point reports the GUI decision when this generator emitted a Windows executable entry point, or none when the current generation did not emit one.

fn (FlatGen) set_thread_stack_size #

fn (mut g FlatGen) set_thread_stack_size(size int)

set_thread_stack_size configures the stack size used by generated worker threads.

fn (FlatGen) set_show_test_stats #

fn (mut g FlatGen) set_show_test_stats(enabled bool)

set_show_test_stats enables the per-test assertion summary used by v -stats test.

fn (FlatGen) set_show_test_summary #

fn (mut g FlatGen) set_show_test_summary(enabled bool)

set_show_test_summary enables the aggregate report used by the v test command.

fn (FlatGen) set_show_test_file_results #

fn (mut g FlatGen) set_show_test_file_results(enabled bool)

set_show_test_file_results enables the per-test-file OK/FAIL lines of v test.

fn (FlatGen) set_test_run_only #

fn (mut g FlatGen) set_test_run_only(patterns []string)

set_test_run_only limits the generated test harness to matching test functions.

fn (FlatGen) set_print_fn_names #

fn (mut g FlatGen) set_print_fn_names(names []string)

set_print_fn_names selects generated C functions to print to stdout.

fn (FlatGen) set_profile #

fn (mut g FlatGen) set_profile(file string, no_inline bool, fn_names []string)

set_profile configures V1-compatible per-function runtime profiling.

fn (FlatGen) set_shared #

fn (mut g FlatGen) set_shared(enabled bool)

set_shared configures shared-library entry point generation.

fn (FlatGen) set_object_file_mode #

fn (mut g FlatGen) set_object_file_mode(enabled bool)

set_object_file_mode gives generated runtime symbols translation-unit-local linkage while retaining public entry-module functions through C ABI wrappers.

fn (FlatGen) set_suppress_main #

fn (mut g FlatGen) set_suppress_main(enabled bool)

set_suppress_main disables executable entry point generation for -d no_main builds.

fn (FlatGen) set_compile_values #

fn (mut g FlatGen) set_compile_values(values map[string]string)

set_compile_values records explicit -d values so $d(...) inside C directives resolves configured values over fallbacks.

fn (FlatGen) set_track_heap #

fn (mut g FlatGen) set_track_heap(enabled bool)

set_track_heap records whether user-provided heap tracking hooks are required.

fn (FlatGen) set_cache_split #

fn (mut g FlatGen) set_cache_split(enabled bool)

set_cache_split enables stable cache markers and string symbols in generated C. The v3 driver uses them to split one checked program into independently cached module objects without changing regular -o file.c output.

fn (FlatGen) set_cache_stable_symbols #

fn (mut g FlatGen) set_cache_stable_symbols(enabled bool)

set_cache_stable_symbols turns on the content-addressed renaming of generated string-literal symbols. Only the module cache needs it, so that separately compiled generations agree on a symbol's name. A split C build shares one generated prefix with its own units, so it keeps the plain _str_N numbering and skips a rewrite pass over the whole translation unit.

fn (FlatGen) set_embed_incbin #

fn (mut g FlatGen) set_embed_incbin(enabled bool)

set_embed_incbin makes long $embed_file payloads refer to objects the driver assembles from the bytes with .incbin, instead of spelling the bytes out as C array initializers; see embed_incbin_payloads for which payloads that covers.

fn (FlatGen) set_parallel_cc #

fn (mut g FlatGen) set_parallel_cc(enabled bool)

set_parallel_cc marks safe top-level function batches for split C compilation.

fn (FlatGen) set_cache_native_input_paths #

fn (mut g FlatGen) set_cache_native_input_paths(paths []string)

set_cache_native_input_paths assigns native headers and sources to their owning cached module object instead of the shared generated declaration prefix.

fn (FlatGen) set_program_body_only #

fn (mut g FlatGen) set_program_body_only(enabled bool)

set_program_body_only omits the reusable declaration/type prefix. It is used when that prefix has already been validated and loaded from the module cache.

fn (FlatGen) set_cache_program_files #

fn (mut g FlatGen) set_cache_program_files(a &flat.FlatAst, files []string)

set_cache_program_files assigns entry-module source files to the program translation unit rather than an imported module cache object. Each file is resolved through a's table of resolved source paths.

fn (FlatGen) set_incremental_fn_names #

fn (mut g FlatGen) set_incremental_fn_names(names map[string]bool)

set_incremental_fn_names limits program-body generation to functions whose parsed bodies changed. An empty map preserves normal whole-program emission.

fn (FlatGen) set_cached_support_declarations #

fn (mut g FlatGen) set_cached_support_declarations(source string)

set_cached_support_declarations records C identifiers already supplied by the cached program prefix so body-only generation emits only newly needed typedefs.

fn (FlatGen) set_scope_parallel_workers #

fn (mut g FlatGen) set_scope_parallel_workers(enabled bool)

set_scope_parallel_workers makes cgen helpers use disposable prealloc arenas. The caller must release them with free_parallel_worker_scopes after consuming the generated C output and cgen metadata.

fn (FlatGen) free_parallel_worker_scopes #

fn (mut g FlatGen) free_parallel_worker_scopes()

free_parallel_worker_scopes releases scratch arenas retained by joined cgen helper threads.

fn (FlatGen) gen #

fn (mut g FlatGen) gen(a &flat.FlatAst) string

gen supports gen handling for FlatGen.

fn (FlatGen) gen_with_used #

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

gen_with_used emits with used output for c.

fn (FlatGen) gen_with_used_test_options #

fn (mut g FlatGen) gen_with_used_test_options(a &flat.FlatAst, used_fns map[string]bool, tc &types.TypeChecker, no_parallel bool, test_files []string) string

gen_with_used_test_options emits a like gen_with_used_options, generating the test harness for test_files. Each test file counts as written and as resolved through a's table of resolved source paths.

fn (FlatGen) gen_to_file_with_used_test_options #

fn (mut g FlatGen) gen_to_file_with_used_test_options(path string, a &flat.FlatAst, used_fns map[string]bool, tc &types.TypeChecker, no_parallel bool, test_files []string) !

gen_to_file_with_used_test_options writes the completed translation unit by transferring the builder buffer to the file writer, avoiding a second full-size string allocation.

fn (FlatGen) gen_with_used_options #

fn (mut g FlatGen) gen_with_used_options(a &flat.FlatAst, used_fns map[string]bool, tc &types.TypeChecker, no_parallel bool) string

gen_with_used_options emits with used options output for c.

fn (FlatGen) set_coverage #

fn (mut g FlatGen) set_coverage(dir string, build_options string)

set_coverage enables V-compatible line coverage output.

fn (FlatGen) set_race #

fn (mut g FlatGen) set_race(enabled bool)

set_race generates C for a race build (-race). The generated C maps every V statement back to its source line with #line directives, so the C debug info carries the V file:line positions that the race detector shows in its stack traces, and the few V constructs that read memory without the C compiler loading it do load it.

fn (FlatGen) set_trace_calls #

fn (mut g FlatGen) set_trace_calls(enabled bool, patterns []string)

set_trace_calls configures V1-compatible function-entry tracing. This is separate from the user-provided call-site hooks enabled with -d trace.