v2.gen.cleanc #
fn Gen.new #
fn Gen.new(files []ast.File) &Gen
fn Gen.new_with_env #
fn Gen.new_with_env(files []ast.File, env &types.Environment) &Gen
fn Gen.new_with_env_and_pref #
fn Gen.new_with_env_and_pref(files []ast.File, env &types.Environment, p &pref.Preferences) &Gen
struct Gen #
struct Gen {
files []ast.File
env &types.Environment = unsafe { nil }
pref &pref.Preferences = unsafe { nil }
mut:
sb strings.Builder
indent int
cur_fn_scope &types.Scope = unsafe { nil }
cur_fn_name string
cur_fn_ret_type string
cur_module string
emitted_types map[string]bool
fn_param_is_ptr map[string][]bool
fn_param_types map[string][]string
fn_return_types map[string]string
runtime_local_types map[string]string
fixed_array_fields map[string]bool
fixed_array_field_elem map[string]string
fixed_array_globals map[string]bool
tuple_aliases map[string][]string
struct_field_types map[string]string
enum_value_to_enum map[string]string
enum_type_fields map[string]map[string]bool
array_aliases map[string]bool
map_aliases map[string]bool
result_aliases map[string]bool
option_aliases map[string]bool
emitted_result_structs map[string]bool
emitted_option_structs map[string]bool
embedded_field_owner map[string]string
collected_fixed_array_types map[string]FixedArrayInfo
collected_map_types map[string]MapTypeInfo
sum_type_variants map[string][]string
// Interface method signatures: interface_name -> [(method_name, cast_signature), ...]
interface_methods map[string][]InterfaceMethodInfo
interface_wrapper_specs map[string]InterfaceWrapperSpec
needed_interface_wrappers map[string]bool
ierror_wrapper_bases map[string]bool
needed_ierror_wrapper_bases map[string]bool
tmp_counter int
cur_fn_mut_params map[string]bool // names of mut params in current function
global_var_modules map[string]string // global var name → module name
primitive_type_aliases map[string]bool // type names that are aliases for primitive types
emit_modules map[string]bool // when set, emit consts/globals/fns only for these modules
export_const_symbols bool
cache_bundle_name string
cached_init_calls []string
exported_const_seen map[string]bool
exported_const_symbols []ExportedConstSymbol
cur_file_name string
in_array_init_index bool // true when generating init expr with `index`
used_fn_keys map[string]bool
called_fn_names map[string]bool
anon_fn_defs []string // lifted anonymous function definitions
pass5_start_pos int // position in sb where pass 5 starts
}
fn (Gen) gen #
fn (mut g Gen) gen() string
gen generates C source from the transformed AST files.
fn (Gen) set_cache_bundle_name #
fn (mut g Gen) set_cache_bundle_name(name string)
set_cache_bundle_name sets the cache bundle label used for emitting a deterministic cache-init function (e.g. __v2_cached_init_builtin).
fn (Gen) set_cached_init_calls #
fn (mut g Gen) set_cached_init_calls(calls []string)
fn (Gen) set_emit_modules #
fn (mut g Gen) set_emit_modules(modules []string)
set_emit_modules limits code emission to the provided module names. Type declarations and forward declarations are still emitted for all modules.
fn (Gen) set_export_const_symbols #
fn (mut g Gen) set_export_const_symbols(enable bool)
set_export_const_symbols controls whether emitted module const macros also get exported as linkable global symbols.
fn (Gen) set_used_fn_keys #
fn (mut g Gen) set_used_fn_keys(used map[string]bool)