Module v.gen.c stdlib

v.gen.c
Version:
0.3.3
License:
MIT
Dependencies from vmod:
0
Imports:
12
Imported by:
1
Repository:
OS-specific
Show selected OS-specific symbols.
Backend-specific
Show selected Backend-specific symbols.

Dependencies defined in v.mod

This section is empty.

Imported by

Aliases

This section is empty.

Constants

This section is empty.

Sum types

This section is empty.

Functions

#fn gen

fn gen(files []&v.ast.File, table &v.ast.Table, pref_ &v.pref.Preferences) (string, string, string, []int)

#fn get_guarded_include_text

fn get_guarded_include_text(iname string, imessage string) string

Structs

#struct Gen

pub struct Gen {
	pref                &pref.Preferences = unsafe { nil }
	field_data_type     ast.Type // cache her to avoid map lookups
	enum_data_type      ast.Type // cache her to avoid map lookups
	module_built        string
	timers_should_print bool
	table               &ast.Table = unsafe { nil }
mut:
	out                       strings.Builder
	cheaders                  strings.Builder
	preincludes               strings.Builder // allows includes to go before `definitions`
	includes                  strings.Builder // all C #includes required by V modules
	typedefs                  strings.Builder
	enum_typedefs             strings.Builder // enum types
	definitions               strings.Builder // typedefs, defines etc (everything that goes to the top of the file)
	type_definitions          strings.Builder // typedefs, defines etc (everything that goes to the top of the file)
	alias_definitions         strings.Builder // alias fixed array of non-builtin
	hotcode_definitions       strings.Builder // -live declarations & functions
	channel_definitions       strings.Builder // channel related code
	thread_definitions        strings.Builder // thread defines
	comptime_definitions      strings.Builder // custom defines, given by -d/-define flags on the CLI
	cleanup                   strings.Builder
	cleanups                  map[string]strings.Builder // contents of `void _vcleanup(){}`
	gowrappers                strings.Builder // all go callsite wrappers
	auto_str_funcs            strings.Builder // function bodies of all auto generated _str funcs
	dump_funcs                strings.Builder // function bodies of all auto generated _str funcs
	pcs_declarations          strings.Builder // -prof profile counter declarations for each function
	embedded_data             strings.Builder // data to embed in the executable/binary
	shared_types              strings.Builder // shared/lock types
	shared_functions          strings.Builder // shared constructors
	out_options_forward       strings.Builder // forward `option_xxxx` types
	out_options               strings.Builder // `option_xxxx` types
	out_results_forward       strings.Builder // forward`result_xxxx` types
	out_results               strings.Builder // `result_xxxx` types
	json_forward_decls        strings.Builder // json type forward decls
	sql_buf                   strings.Builder // for writing exprs to args via `sqlite3_bind_int()` etc
	global_const_defs         map[string]GlobalConstDef
	sorted_global_const_names []string
	file                      &ast.File = unsafe { nil }
	unique_file_path_hash     u64 // a hash of file.path, used for making auxilary fn generation unique (like `compare_xyz`)
	fn_decl                   &ast.FnDecl = unsafe { nil } // pointer to the FnDecl we are currently inside otherwise 0
	last_fn_c_name            string
	tmp_count                 int         // counter for unique tmp vars (_tmp1, _tmp2 etc); resets at the start of each fn.
	tmp_count_af              int  // a separate tmp var counter for autofree fn calls
	tmp_count_declarations    int  // counter for unique tmp names (_d1, _d2 etc); does NOT reset, used for C declarations
	global_tmp_count          int  // like tmp_count but global and not resetted in each function
	discard_or_result         bool // do not safe last ExprStmt of `or` block in tmp variable to defer ongoing expr usage
	is_direct_array_access    bool // inside a `[direct_array_access fn a() {}` function
	is_assign_lhs             bool // inside left part of assign expr (for array_set(), etc)
	is_void_expr_stmt         bool // ExprStmt whos result is discarded
	is_arraymap_set           bool // map or array set value state
	is_amp                    bool // for `&Foo{}` to merge PrefixExpr `&` and StructInit `Foo{}`; also for `&u8(0)` etc
	is_sql                    bool // Inside `sql db{}` statement, generating sql instead of C (e.g. `and` instead of `&&` etc)
	is_shared                 bool // for initialization of hidden mutex in `[rw]shared` literals
	is_vlines_enabled         bool // is it safe to generate #line directives when -g is passed
	is_autofree               bool // false, inside the bodies of fns marked with [manualfree], otherwise === g.pref.autofree
	is_builtin_mod            bool
	is_json_fn                bool // inside json.encode()
	is_js_call                bool // for handling a special type arg #1 `json.decode(User, ...)`
	is_fn_index_call          bool
	is_cc_msvc                bool     // g.pref.ccompiler == 'msvc'
	vlines_path               string   // set to the proper path for generating #line directives
	options_pos_forward       int      // insertion point to forward
	options_forward           []string // to forward
	options                   map[string]string // to avoid duplicates
	results_forward           []string // to forward
	results                   map[string]string // to avoid duplicates
	done_options              shared []string   // to avoid duplicates
	done_results              shared []string   // to avoid duplicates
	chan_pop_options          map[string]string // types for `x := <-ch or {...}`
	chan_push_options         map[string]string // types for `ch <- x or {...}`
	mtxs                      string // array of mutexes if the `lock` has multiple variables
	labeled_loops             map[string]&ast.Stmt
	inner_loop                &ast.Stmt = unsafe { nil }
	shareds                   map[int]string // types with hidden mutex for which decl has been emitted
	inside_ternary            int  // ?: comma separated statements on a single line
	inside_map_postfix        bool // inside map++/-- postfix expr
	inside_map_infix          bool // inside map<
	inside_assign             bool
	inside_map_index          bool
	inside_array_index        bool
	inside_opt_or_res         bool
	inside_opt_data           bool
	inside_if_option          bool
	inside_if_result          bool
	inside_match_option       bool
	inside_match_result       bool
	inside_vweb_tmpl          bool
	inside_return             bool
	inside_return_tmpl        bool
	inside_struct_init        bool
	inside_or_block           bool
	inside_call               bool
	inside_curry_call         bool // inside foo()()!, foo()()?, foo()()
	inside_for_c_stmt         bool
	inside_comptime_for_field bool
	inside_cast_in_heap       int // inside cast to interface type in heap (resolve recursive calls)
	inside_const              bool
	inside_const_opt_or_res   bool
	inside_lambda             bool
	inside_cinit              bool
	last_tmp_call_var         []string
	loop_depth                int
	ternary_names             map[string]string
	ternary_level_names       map[string][]string
	arraymap_set_pos          int   // map or array set value position
	stmt_path_pos             []int // positions of each statement start, for inserting C statements before the current statement
	skip_stmt_pos             bool  // for handling if expressions + autofree (since both prepend C statements)
	left_is_opt               bool  // left hand side on assignment is an option
	right_is_opt              bool  // right hand side on assignment is an option
	indent                    int
	empty_line                bool
	assign_op                 token.Kind // *=, =, etc (for array_set)
	defer_stmts               []ast.DeferStmt
	defer_ifdef               string
	defer_profile_code        string
	defer_vars                []string
	str_types                 []StrType       // types that need automatic str() generation
	generated_str_fns         []StrType       // types that already have a str() function
	str_fn_names              []string        // remove duplicate function names
	threaded_fns              shared []string // for generating unique wrapper types and fns for `go xxx()`
	waiter_fns                shared []string // functions that wait for `go xxx()` to finish
	needed_equality_fns       []ast.Type
	generated_eq_fns          []ast.Type
	array_sort_fn             shared []string
	array_contains_types      []ast.Type
	array_index_types         []ast.Type
	auto_fn_definitions       []string // auto generated functions definition list
	sumtype_casting_fns       []SumtypeCastingFn
	anon_fn_definitions       []string     // anon generated functions definition list
	sumtype_definitions       map[int]bool // `_TypeA_to_sumtype_TypeB()` fns that have been generated
	json_types                []ast.Type   // to avoid json gen duplicates
	pcs                       []ProfileCounterMeta // -prof profile counter fn_names => fn counter name
	hotcode_fn_names          []string
	hotcode_fpaths            []string
	embedded_files            []ast.EmbeddedFile
	sql_i                     int
	sql_stmt_name             string
	sql_bind_name             string
	sql_idents                []string
	sql_idents_types          []ast.Type
	sql_left_type             ast.Type
	sql_table_name            string
	sql_fkey                  string
	sql_parent_id             string
	sql_side                  SqlExprSide // left or right, to distinguish idents in `name == name`
	strs_to_free0             []string    // strings.Builder
	// strs_to_free          []string // strings.Builder
	// tmp_arg_vars_to_free  []string
	// autofree_pregen       map[string]string
	// autofree_pregen_buf   strings.Builder
	// autofree_tmp_vars     []string // to avoid redefining the same tmp vars in a single function
	// nr_vars_to_free       int
	// doing_autofree_tmp    bool
	comptime_for_method              string // $for method in T.methods {}
	comptime_for_method_var          string // $for method in T.methods {}; the variable name
	comptime_for_field_var           string // $for field in T.fields {}; the variable name
	comptime_for_field_value         ast.StructField // value of the field variable
	comptime_for_field_type          ast.Type        // type of the field variable inferred from `$if field.typ is T {}`
	comptime_enum_field_value        string // value of enum name
	comptime_var_type_map            map[string]ast.Type
	comptime_values_stack            []CurrentComptimeValues // stores the values from the above on each $for loop, to make nesting them easier
	prevent_sum_type_unwrapping_once bool // needed for assign new values to sum type
	// used in match multi branch
	// TypeOne, TypeTwo {}
	// where an aggregate (at least two types) is generated
	// sum type deref needs to know which index to deref because unions take care of the correct field
	aggregate_type_idx  int
	branch_parent_pos   int    // used in BranchStmt (continue/break) for autofree stop position
	returned_var_name   string // to detect that a var doesn't need to be freed since it's being returned
	infix_left_var_name string // a && if expr
	called_fn_name      string
	timers              &util.Timers = util.get_timers()
	force_main_console  bool // true when [console] used on fn main()
	as_cast_type_names  map[string]string // table for type name lookup in runtime (for __as_cast)
	obf_table           map[string]string
	referenced_fns      shared map[string]bool // functions that have been referenced
	nr_closures         int
	expected_cast_type  ast.Type // for match expr of sumtypes
	or_expr_return_type ast.Type // or { 0, 1 } return type
	anon_fn             bool
	tests_inited        bool
	has_main            bool
	// main_fn_decl_node  ast.FnDecl
	cur_mod                ast.Module
	cur_concrete_types     []ast.Type  // do not use table.cur_concrete_types because table is global, so should not be accessed by different threads
	cur_fn                 &ast.FnDecl = unsafe { nil } // same here
	cur_lock               ast.LockExpr
	cur_struct_init_typ    ast.Type
	autofree_methods       map[int]bool
	generated_free_methods map[int]bool
	autofree_scope_stmts   []string
	use_segfault_handler   bool = true
	test_function_names    []string
	/////////
	// out_parallel []strings.Builder
	// out_idx      int
	out_fn_start_pos []int  // for generating multiple .c files, stores locations of all fn positions in `out` string builder
	static_modifier  string // for parallel_cc

	has_reflection     bool
	reflection_strings &map[string]int
}

#fn (&Gen) array_init

fn (mut g &Gen) array_init(node v.ast.ArrayInit, var_name string)

#fn (&Gen) fixed_array_init

fn (mut g &Gen) fixed_array_init(node v.ast.ArrayInit, array_type Type, var_name string)

#fn (&Gen) struct_has_array_or_map_field

fn (mut g &Gen) struct_has_array_or_map_field(elem_typ v.ast.Type) bool

#fn (&Gen) array_init_with_fields

fn (mut g &Gen) array_init_with_fields(node v.ast.ArrayInit, elem_type Type, is_amp bool, shared_styp string, var_name string)

[]int{len: 6, cap: 10, init: index * index}

#fn (&Gen) write_closure_fn

fn (mut g &Gen) write_closure_fn(mut expr &v.ast.AnonFn)

#fn (&Gen) gen_array_map

fn (mut g &Gen) gen_array_map(node v.ast.CallExpr)

nums.map(it % 2 == 0)

#fn (&Gen) gen_array_sort

fn (mut g &Gen) gen_array_sort(node v.ast.CallExpr)

users.sort(a.age < b.age)

#fn (&Gen) gen_array_sort_call

fn (mut g &Gen) gen_array_sort_call(node v.ast.CallExpr, compare_fn string)

#fn (&Gen) gen_array_filter

fn (mut g &Gen) gen_array_filter(node v.ast.CallExpr)

nums.filter(it % 2 == 0)

#fn (&Gen) gen_array_insert

fn (mut g &Gen) gen_array_insert(node v.ast.CallExpr)

nums.insert(0, 2) nums.insert(0, [2,3,4])

#fn (&Gen) gen_array_prepend

fn (mut g &Gen) gen_array_prepend(node v.ast.CallExpr)

nums.prepend(2) nums.prepend([2,3,4])

#fn (&Gen) get_array_contains_method

fn (mut g &Gen) get_array_contains_method(typ v.ast.Type) string

#fn (&Gen) gen_array_contains_methods

fn (mut g &Gen) gen_array_contains_methods()

#fn (&Gen) gen_array_contains

fn (mut g &Gen) gen_array_contains(typ v.ast.Type, left v.ast.Expr, right v.ast.Expr)

nums.contains(2)

#fn (&Gen) get_array_index_method

fn (mut g &Gen) get_array_index_method(typ v.ast.Type) string

#fn (&Gen) gen_array_index_methods

fn (mut g &Gen) gen_array_index_methods()

#fn (&Gen) gen_array_index

fn (mut g &Gen) gen_array_index(node v.ast.CallExpr)

nums.index(2)

#fn (&Gen) gen_array_wait

fn (mut g &Gen) gen_array_wait(node v.ast.CallExpr)

#fn (&Gen) gen_array_any

fn (mut g &Gen) gen_array_any(node v.ast.CallExpr)

#fn (&Gen) gen_array_all

fn (mut g &Gen) gen_array_all(node v.ast.CallExpr)

#fn (&Gen) write_prepared_tmp_value

fn (mut g &Gen) write_prepared_tmp_value(tmp string, node &v.ast.CallExpr, tmp_stype string, initial_value string) bool

#fn (&Gen) write_prepared_it

fn (mut g &Gen) write_prepared_it(inp_info v.ast.Array, inp_elem_type string, tmp string, i string)

#fn (&Gen) assert_stmt

fn (mut g &Gen) assert_stmt(original_assert_statement v.ast.AssertStmt)

#fn (&Gen) assert_subexpression_to_ctemp

fn (mut g &Gen) assert_subexpression_to_ctemp(expr v.ast.Expr, expr_type v.ast.Type) !v.ast.Expr

#fn (&Gen) gen_assert_postfailure_mode

fn (mut g &Gen) gen_assert_postfailure_mode(node v.ast.AssertStmt)

#fn (&Gen) gen_assert_metainfo

fn (mut g &Gen) gen_assert_metainfo(node v.ast.AssertStmt, kind AssertMetainfoKind) string

#fn (&Gen) gen_assert_single_expr

fn (mut g &Gen) gen_assert_single_expr(expr v.ast.Expr, typ v.ast.Type)

#fn (&Gen) expr_with_opt_or_block

fn (mut g &Gen) expr_with_opt_or_block(expr v.ast.Expr, expr_typ v.ast.Type, var_expr v.ast.Expr, ret_typ v.ast.Type)

#fn (&Gen) expr_opt_with_cast

fn (mut g &Gen) expr_opt_with_cast(expr v.ast.Expr, expr_typ v.ast.Type, ret_typ v.ast.Type) string

expr_opt_with_cast is used in cast expr when converting compatible option types e.g. ?int(?u8(0))

#fn (&Gen) expr_with_opt

fn (mut g &Gen) expr_with_opt(expr v.ast.Expr, expr_typ v.ast.Type, ret_typ v.ast.Type) string

expr_with_opt is used in assigning an expression to an option variable e.g. x = y (option lhs and rhs), mut x = ?int(123), y = none

#fn (&Gen) assign_stmt

fn (mut g &Gen) assign_stmt(node_ v.ast.AssignStmt)

#fn (&Gen) gen_multi_return_assign

fn (mut g &Gen) gen_multi_return_assign(node &v.ast.AssignStmt, return_type v.ast.Type, return_sym v.ast.TypeSymbol)

#fn (&Gen) gen_assign_vars_autofree

fn (mut g &Gen) gen_assign_vars_autofree(node &v.ast.AssignStmt)

#fn (&Gen) gen_cross_var_assign

fn (mut g &Gen) gen_cross_var_assign(node &v.ast.AssignStmt)

#fn (&Gen) gen_cross_tmp_variable

fn (mut g &Gen) gen_cross_tmp_variable(left []v.ast.Expr, val v.ast.Expr)

#fn (&Gen) equality_fn

fn (mut g &Gen) equality_fn(typ v.ast.Type) string

#fn (&Gen) gen_equality_fns

fn (mut g &Gen) gen_equality_fns()

#fn (&Gen) gen_sumtype_equality_fn

fn (mut g &Gen) gen_sumtype_equality_fn(left_type v.ast.Type) string

#fn (&Gen) read_opt

inline
fn (mut g &Gen) read_opt(typ v.ast.Type, var_name string) string

read_opt generates C code accessing option data

#fn (&Gen) read_field

inline
fn (mut g &Gen) read_field(struct_type v.ast.Type, field_name string, var_name string) string

read_field generates C code for reading option/no-option struct field

#fn (&Gen) read_opt_field

inline
fn (mut g &Gen) read_opt_field(struct_type v.ast.Type, field_name string, var_name string, field_typ v.ast.Type) string

read_opt_field generates C code for reading option/no-option struct field

#fn (&Gen) gen_struct_equality_fn

fn (mut g &Gen) gen_struct_equality_fn(left_type v.ast.Type) string

#fn (&Gen) gen_alias_equality_fn

fn (mut g &Gen) gen_alias_equality_fn(left_type v.ast.Type) string

#fn (&Gen) gen_array_equality_fn

fn (mut g &Gen) gen_array_equality_fn(left_type v.ast.Type) string

#fn (&Gen) gen_fixed_array_equality_fn

fn (mut g &Gen) gen_fixed_array_equality_fn(left_type v.ast.Type) string

#fn (&Gen) gen_map_equality_fn

fn (mut g &Gen) gen_map_equality_fn(left_type v.ast.Type) string

#fn (&Gen) gen_interface_equality_fn

fn (mut g &Gen) gen_interface_equality_fn(left_type v.ast.Type) string

#fn (&Gen) get_free_method

fn (mut g &Gen) get_free_method(typ v.ast.Type) string

#fn (&Gen) gen_free_methods

fn (mut g &Gen) gen_free_methods()

#fn (&Gen) gen_free_method

fn (mut g &Gen) gen_free_method(typ v.ast.Type) string

#fn (&Gen) gen_free_for_struct

fn (mut g &Gen) gen_free_for_struct(info v.ast.Struct, styp string, fn_name string)

#fn (&Gen) gen_free_for_array

fn (mut g &Gen) gen_free_for_array(info v.ast.Array, styp string, fn_name string)

#fn (&Gen) gen_free_for_map

fn (mut g &Gen) gen_free_for_map(info v.ast.Map, styp string, fn_name string)

#fn (&Gen) gen_str_default

fn (mut g &Gen) gen_str_default(sym v.ast.TypeSymbol, styp string, str_fn_name string)

#fn (&Gen) get_str_fn

fn (mut g &Gen) get_str_fn(typ v.ast.Type) string

#fn (&Gen) final_gen_str

fn (mut g &Gen) final_gen_str(typ StrType)

#fn (&Gen) gen_str_for_option

fn (mut g &Gen) gen_str_for_option(typ v.ast.Type, styp string, str_fn_name string)

#fn (&Gen) gen_str_for_result

fn (mut g &Gen) gen_str_for_result(typ v.ast.Type, styp string, str_fn_name string)

#fn (&Gen) gen_str_for_alias

fn (mut g &Gen) gen_str_for_alias(info v.ast.Alias, styp string, str_fn_name string)

#fn (&Gen) gen_str_for_multi_return

fn (mut g &Gen) gen_str_for_multi_return(info v.ast.MultiReturn, styp string, str_fn_name string)

#fn (&Gen) gen_str_for_enum

fn (mut g &Gen) gen_str_for_enum(info v.ast.Enum, styp string, str_fn_name string)

#fn (&Gen) gen_str_for_interface

fn (mut g &Gen) gen_str_for_interface(info v.ast.Interface, styp string, typ_str string, str_fn_name string)

#fn (&Gen) gen_str_for_union_sum_type

fn (mut g &Gen) gen_str_for_union_sum_type(info v.ast.SumType, styp string, typ_str string, str_fn_name string)

#fn (&Gen) fn_decl_str

fn (mut g &Gen) fn_decl_str(info v.ast.FnType) string

#fn (&Gen) gen_str_for_fn_type

fn (mut g &Gen) gen_str_for_fn_type(info v.ast.FnType, styp string, str_fn_name string)

#fn (&Gen) gen_str_for_chan

fn (mut g &Gen) gen_str_for_chan(info v.ast.Chan, styp string, str_fn_name string)

#fn (&Gen) gen_str_for_thread

fn (mut g &Gen) gen_str_for_thread(info v.ast.Thread, styp string, str_fn_name string)

#fn (&Gen) gen_str_for_array

fn (mut g &Gen) gen_str_for_array(info v.ast.Array, styp string, str_fn_name string)

#fn (&Gen) gen_str_for_array_fixed

fn (mut g &Gen) gen_str_for_array_fixed(info v.ast.ArrayFixed, styp string, str_fn_name string)

#fn (&Gen) gen_str_for_map

fn (mut g &Gen) gen_str_for_map(info v.ast.Map, styp string, str_fn_name string)

#fn (&Gen) type_to_fmt

fn (g &Gen) type_to_fmt(typ v.ast.Type) StrIntpType

#fn (&Gen) gen_str_for_struct

fn (mut g &Gen) gen_str_for_struct(info v.ast.Struct, lang v.ast.Language, styp string, typ_str string, str_fn_name string)

#fn (&Gen) free_builders

unsafe
fn (mut g &Gen) free_builders()

free_builders should be called only when a Gen would NOT be used anymore it frees the bulk of the memory that is private to the Gen instance (the various string builders)

#fn (&Gen) gen_file

fn (mut g &Gen) gen_file()

#fn (&Gen) hashes

fn (g &Gen) hashes() string

#fn (&Gen) init

fn (mut g &Gen) init()

#fn (&Gen) finish

fn (mut g &Gen) finish()

#fn (&Gen) write_typeof_functions

fn (mut g &Gen) write_typeof_functions()

#fn (&Gen) typ

fn (mut g &Gen) typ(t v.ast.Type) string

V type to C typecc

#fn (&Gen) base_type

fn (mut g &Gen) base_type(_t v.ast.Type) string

#fn (&Gen) generic_fn_name

fn (mut g &Gen) generic_fn_name(types []v.ast.Type, before string) string

#fn (&Gen) expr_string

fn (mut g &Gen) expr_string(expr v.ast.Expr) string

#fn (&Gen) expr_string_with_cast

fn (mut g &Gen) expr_string_with_cast(expr v.ast.Expr, typ v.ast.Type, exp v.ast.Type) string

#fn (&Gen) expr_string_surround

fn (mut g &Gen) expr_string_surround(prepend string, expr v.ast.Expr, append string) string

Surround a potentially multi-statement expression safely with prepend and append.

(and create a statement)

#fn (&Gen) option_type_name

fn (mut g &Gen) option_type_name(t v.ast.Type) (string, string)

TODO this really shouldnt be seperate from typ but I(emily) would rather have this generation all unified in one place so that it doesnt break if one location changes

#fn (&Gen) result_type_name

fn (mut g &Gen) result_type_name(t v.ast.Type) (string, string)

#fn (&Gen) option_type_text

fn (g &Gen) option_type_text(styp string, base string) string

#fn (&Gen) result_type_text

fn (g &Gen) result_type_text(styp string, base string) string

#fn (&Gen) register_option

fn (mut g &Gen) register_option(t v.ast.Type) string

#fn (&Gen) register_result

fn (mut g &Gen) register_result(t v.ast.Type) string

#fn (&Gen) write_options

fn (mut g &Gen) write_options()

#fn (&Gen) write_results

fn (mut g &Gen) write_results()

#fn (&Gen) find_or_register_shared

fn (mut g &Gen) find_or_register_shared(t v.ast.Type, base string) string

#fn (&Gen) write_shareds

fn (mut g &Gen) write_shareds()

#fn (&Gen) register_thread_void_wait_call

fn (mut g &Gen) register_thread_void_wait_call()

#fn (&Gen) register_thread_array_wait_call

fn (mut g &Gen) register_thread_array_wait_call(eltyp string) string

#fn (&Gen) register_chan_pop_option_call

fn (mut g &Gen) register_chan_pop_option_call(opt_el_type string, styp string)

#fn (&Gen) write_chan_pop_option_fns

fn (mut g &Gen) write_chan_pop_option_fns()

#fn (&Gen) register_chan_push_option_fn

fn (mut g &Gen) register_chan_push_option_fn(el_type string, styp string)

#fn (&Gen) write_chan_push_option_fns

fn (mut g &Gen) write_chan_push_option_fns()

#fn (&Gen) cc_type

fn (mut g &Gen) cc_type(typ v.ast.Type, is_prefix_struct bool) string

cc_type whether to prefix 'struct' or not (C__Foo -> struct Foo)

#fn (&Gen) type_sidx

inline
fn (g &Gen) type_sidx(t v.ast.Type) string

#fn (&Gen) write_typedef_types

fn (mut g &Gen) write_typedef_types()

#fn (&Gen) write_alias_typesymbol_declaration

fn (mut g &Gen) write_alias_typesymbol_declaration(sym v.ast.TypeSymbol)

#fn (&Gen) write_interface_typedef

fn (mut g &Gen) write_interface_typedef(sym v.ast.TypeSymbol)

#fn (&Gen) write_interface_typesymbol_declaration

fn (mut g &Gen) write_interface_typesymbol_declaration(sym v.ast.TypeSymbol)

#fn (&Gen) write_fn_typesymbol_declaration

fn (mut g &Gen) write_fn_typesymbol_declaration(sym v.ast.TypeSymbol)

#fn (&Gen) write_multi_return_types

fn (mut g &Gen) write_multi_return_types()

#fn (&Gen) new_tmp_var

fn (mut g &Gen) new_tmp_var() string

#fn (&Gen) new_global_tmp_var

fn (mut g &Gen) new_global_tmp_var() string

#fn (&Gen) new_tmp_declaration_name

fn (mut g &Gen) new_tmp_declaration_name() string

#fn (&Gen) current_tmp_var

fn (mut g &Gen) current_tmp_var() string

#fn (&Gen) reset_tmp_count

fn (mut g &Gen) reset_tmp_count()

#fn (&Gen) decrement_inside_ternary

fn (mut g &Gen) decrement_inside_ternary()

#fn (&Gen) stmts

fn (mut g &Gen) stmts(stmts []v.ast.Stmt)

#fn (&Gen) stmts_with_tmp_var

fn (mut g &Gen) stmts_with_tmp_var(stmts []v.ast.Stmt, tmp_var string) bool

stmts_with_tmp_var is used in if or match branches.

It returns true, if the last statement was a return

#fn (&Gen) expr_with_tmp_var

fn (mut g &Gen) expr_with_tmp_var(expr v.ast.Expr, expr_typ v.ast.Type, ret_typ v.ast.Type, tmp_var string)

expr_with_tmp_var is used in assign expr to option or result type.

applicable to situations where the expr_typ does not have option and result, e.g. field default: "foo ?int = 1", field assign: "foo = 1", field init: "foo: 1"

#fn (&Gen) write_v_source_line_info

inline
fn (mut g &Gen) write_v_source_line_info(pos v.token.Pos)

#fn (&Gen) stmt

fn (mut g &Gen) stmt(node v.ast.Stmt)

#fn (&Gen) write_defer_stmts

fn (mut g &Gen) write_defer_stmts()

#fn (&Gen) get_sumtype_casting_fn

fn (mut g &Gen) get_sumtype_casting_fn(got_ v.ast.Type, exp_ v.ast.Type) string

#fn (&Gen) write_sumtype_casting_fn

fn (mut g &Gen) write_sumtype_casting_fn(fun SumtypeCastingFn)

#fn (&Gen) call_cfn_for_casting_expr

fn (mut g &Gen) call_cfn_for_casting_expr(fname string, expr v.ast.Expr, exp_is_ptr bool, exp_styp string, got_is_ptr bool, got_is_fn bool, got_styp string)

#fn (&Gen) expr_with_cast

fn (mut g &Gen) expr_with_cast(expr v.ast.Expr, got_type_raw v.ast.Type, expected_type v.ast.Type)

use instead of expr() when you need to cast to a different type

#fn (&Gen) gen_attrs

fn (mut g &Gen) gen_attrs(attrs []v.ast.Attr)

#fn (&Gen) asm_stmt

fn (mut g &Gen) asm_stmt(stmt v.ast.AsmStmt)

#fn (&Gen) asm_arg

fn (mut g &Gen) asm_arg(arg v.ast.AsmArg, stmt v.ast.AsmStmt)

#fn (&Gen) gen_asm_ios

fn (mut g &Gen) gen_asm_ios(ios []v.ast.AsmIO)

#fn (&Gen) write_fn_ptr_decl

fn (mut g &Gen) write_fn_ptr_decl(func &v.ast.FnType, ptr_name string)

#fn (&Gen) register_ternary_name

fn (mut g &Gen) register_ternary_name(name string)

#fn (&Gen) get_ternary_name

fn (mut g &Gen) get_ternary_name(name string) string

#fn (&Gen) gen_clone_assignment

fn (mut g &Gen) gen_clone_assignment(val v.ast.Expr, typ v.ast.Type, add_eq bool) bool

#fn (&Gen) autofree_scope_vars

fn (mut g &Gen) autofree_scope_vars(pos int, line_nr int, free_parent_scopes bool)

#fn (&Gen) autofree_scope_vars_stop

fn (mut g &Gen) autofree_scope_vars_stop(pos int, line_nr int, free_parent_scopes bool, stop_pos int)

#fn (&Gen) trace_autofree

trace_autofree ?
fn (mut g &Gen) trace_autofree(line string)

#fn (&Gen) autofree_scope_vars2

fn (mut g &Gen) autofree_scope_vars2(scope &v.ast.Scope, start_pos int, end_pos int, line_nr int, free_parent_scopes bool, stop_pos int)

#fn (&Gen) autofree_variable

fn (mut g &Gen) autofree_variable(v v.ast.Var)

#fn (&Gen) autofree_var_call

fn (mut g &Gen) autofree_var_call(free_fn_name string, v v.ast.Var)

#fn (&Gen) map_fn_ptrs

fn (mut g &Gen) map_fn_ptrs(key_typ v.ast.TypeSymbol) (string, string, string, string)

#fn (&Gen) expr

fn (mut g &Gen) expr(node_ v.ast.Expr)

#fn (&Gen) char_literal

fn (mut g &Gen) char_literal(node v.ast.CharLiteral)

#fn (&Gen) type_name

fn (mut g &Gen) type_name(raw_type v.ast.Type)

T.name, typeof(expr).name

#fn (&Gen) typeof_expr

fn (mut g &Gen) typeof_expr(node v.ast.TypeOf)

#fn (&Gen) selector_expr

fn (mut g &Gen) selector_expr(node v.ast.SelectorExpr)

#fn (&Gen) enum_decl

fn (mut g &Gen) enum_decl(node v.ast.EnumDecl)

#fn (&Gen) enum_expr

fn (mut g &Gen) enum_expr(node v.ast.Expr)

#fn (&Gen) lock_expr

fn (mut g &Gen) lock_expr(node v.ast.LockExpr)

#fn (&Gen) unlock_locks

fn (mut g &Gen) unlock_locks()

#fn (&Gen) map_init

fn (mut g &Gen) map_init(node v.ast.MapInit)

#fn (&Gen) select_expr

fn (mut g &Gen) select_expr(node v.ast.SelectExpr)

#fn (&Gen) is_generic_param_var

inline
fn (mut g &Gen) is_generic_param_var(node v.ast.Expr) bool

#fn (&Gen) is_comptime_var

inline
fn (mut g &Gen) is_comptime_var(node v.ast.Expr) bool

#fn (&Gen) ident

fn (mut g &Gen) ident(node v.ast.Ident)

#fn (&Gen) cast_expr

fn (mut g &Gen) cast_expr(node v.ast.CastExpr)

#fn (&Gen) concat_expr

fn (mut g &Gen) concat_expr(node v.ast.ConcatExpr)

#fn (&Gen) expr_is_multi_return_call

inline
fn (g &Gen) expr_is_multi_return_call(expr v.ast.Expr) bool

#fn (&Gen) gen_result_error

fn (mut g &Gen) gen_result_error(target_type v.ast.Type, expr v.ast.Expr)

#fn (&Gen) gen_option_error

fn (mut g &Gen) gen_option_error(target_type v.ast.Type, expr v.ast.Expr)

NB: remove this when option has no errors anymore

#fn (&Gen) hash_stmt

fn (mut g &Gen) hash_stmt(node v.ast.HashStmt)

#fn (&Gen) branch_stmt

fn (mut g &Gen) branch_stmt(node v.ast.BranchStmt)

#fn (&Gen) return_stmt

fn (mut g &Gen) return_stmt(node v.ast.Return)

#fn (&Gen) const_decl

fn (mut g &Gen) const_decl(node v.ast.ConstDecl)

#fn (&Gen) const_decl_precomputed

fn (mut g &Gen) const_decl_precomputed(mod string, name string, field_name string, ct_value v.ast.ComptTimeConstValue, typ v.ast.Type) bool

#fn (&Gen) const_decl_write_precomputed

fn (mut g &Gen) const_decl_write_precomputed(mod string, styp string, cname string, field_name string, ct_value string)

#fn (&Gen) const_decl_simple_define

fn (mut g &Gen) const_decl_simple_define(mod string, name string, val string)

#fn (&Gen) c_const_name

fn (mut g &Gen) c_const_name(name string) string

#fn (&Gen) const_decl_init_later

fn (mut g &Gen) const_decl_init_later(mod string, name string, expr v.ast.Expr, typ v.ast.Type, unwrap_option bool)

#fn (&Gen) global_decl

fn (mut g &Gen) global_decl(node v.ast.GlobalDecl)

#fn (&Gen) assoc

fn (mut g &Gen) assoc(node v.ast.Assoc)

#fn (&Gen) error

noreturn
fn (g &Gen) error(s string, pos v.token.Pos)

#fn (&Gen) checker_bug

fn (g &Gen) checker_bug(s string, pos v.token.Pos)

#fn (&Gen) write_debug_calls_typeof_functions

fn (mut g &Gen) write_debug_calls_typeof_functions()

write_debug_calls_typeof_functions inserts calls to all typeof functions for interfaces and sum-types in debug mode so that the compiler does not optimize them.

These functions are needed to be able to get the name of a specific structure/type in the debugger.

#fn (&Gen) write_init_function

fn (mut g &Gen) write_init_function()

#fn (&Gen) write_builtin_types

fn (mut g &Gen) write_builtin_types()

#fn (&Gen) write_sorted_types

fn (mut g &Gen) write_sorted_types()

C struct definitions, ordered Sort the types, make sure types that are referenced by other types are added before them.

#fn (&Gen) write_types

fn (mut g &Gen) write_types(symbols []&v.ast.TypeSymbol)

#fn (&Gen) sort_globals_consts

fn (mut g &Gen) sort_globals_consts()

#fn (&Gen) sort_structs

fn (mut g &Gen) sort_structs(typesa []&v.ast.TypeSymbol) []&v.ast.TypeSymbol

sort structs by dependent fields

#fn (&Gen) gen_or_block_stmts

fn (mut g &Gen) gen_or_block_stmts(cvar_name string, cast_typ string, stmts []v.ast.Stmt, return_type v.ast.Type, is_option bool)

#fn (&Gen) or_block

fn (mut g &Gen) or_block(var_name string, or_block v.ast.OrExpr, return_type v.ast.Type)

If user is accessing the return value eg. in assigment, pass the variable name.

If the user is not using the option return value. We need to pass a temp var to access its fields (.ok, error etc) os.cp(...) => Option bool tmp = os__cp(...); if (tmp.state != 0) { ... } Returns the type of the last stmt

#fn (&Gen) type_default

fn (mut g &Gen) type_default(typ_ v.ast.Type) string

#fn (&Gen) get_all_test_function_names

fn (g &Gen) get_all_test_function_names() []string

#fn (&Gen) get_type

inline
fn (mut g &Gen) get_type(typ v.ast.Type) v.ast.Type

#fn (&Gen) size_of

fn (mut g &Gen) size_of(node v.ast.SizeOf)

#fn (&Gen) gen_enum_prefix

inline
fn (mut g &Gen) gen_enum_prefix(typ v.ast.Type) string

#fn (&Gen) enum_val

fn (mut g &Gen) enum_val(node v.ast.EnumVal)

#fn (&Gen) as_cast

fn (mut g &Gen) as_cast(node v.ast.AsCast)

#fn (&Gen) as_cast_name_table

fn (g &Gen) as_cast_name_table() string

#fn (&Gen) has_been_referenced

fn (g &Gen) has_been_referenced(fn_name string) bool

#fn (&Gen) interface_table

fn (mut g &Gen) interface_table() string

Generates interface table and interface indexes

#fn (&Gen) panic_debug_info

fn (mut g &Gen) panic_debug_info(pos v.token.Pos) (int, string, string, string)

#fn (&Gen) trace

fn (mut g &Gen) trace(fbase string, message string)

#fn (&Gen) get_array_depth

fn (mut g &Gen) get_array_depth(el_typ v.ast.Type) int

#fn (&Gen) contains_ptr

fn (mut g &Gen) contains_ptr(el_typ v.ast.Type) bool

returns true if t includes any pointer(s) - during garbage collection heap regions that contain no pointers do not have to be scanned

#fn (&Gen) check_noscan

fn (mut g &Gen) check_noscan(elem_typ v.ast.Type) string

#fn (&Gen) gen_c_main

fn (mut g &Gen) gen_c_main()

#fn (&Gen) gen_vlines_reset

fn (mut g &Gen) gen_vlines_reset()

#fn (&Gen) gen_c_main_function_only_header

fn (mut g &Gen) gen_c_main_function_only_header()

#fn (&Gen) gen_c_main_function_header

fn (mut g &Gen) gen_c_main_function_header()

#fn (&Gen) gen_c_main_header

fn (mut g &Gen) gen_c_main_header()

#fn (&Gen) gen_c_android_sokol_main

fn (mut g &Gen) gen_c_android_sokol_main()

#fn (&Gen) write_tests_definitions

fn (mut g &Gen) write_tests_definitions()

#fn (&Gen) gen_failing_error_propagation_for_test_fn

fn (mut g &Gen) gen_failing_error_propagation_for_test_fn(or_block v.ast.OrExpr, cvar_name string)

#fn (&Gen) gen_failing_return_error_for_test_fn

fn (mut g &Gen) gen_failing_return_error_for_test_fn(return_stmt v.ast.Return, cvar_name string)

#fn (&Gen) gen_c_main_profile_hook

fn (mut g &Gen) gen_c_main_profile_hook()

#fn (&Gen) gen_c_main_for_tests

fn (mut g &Gen) gen_c_main_for_tests()

#fn (&Gen) filter_only_matching_fn_names

fn (mut g &Gen) filter_only_matching_fn_names(fnames []string) []string

#fn (&Gen) gen_c_main_trace_calls_hook

fn (mut g &Gen) gen_c_main_trace_calls_hook()

#fn (&Gen) get_comptime_selector_key_type

fn (mut g &Gen) get_comptime_selector_key_type(val v.ast.ComptimeSelector) string

#fn (&Gen) get_comptime_selector_var_type

fn (mut g &Gen) get_comptime_selector_var_type(node v.ast.ComptimeSelector) (v.ast.StructField, string)

#fn (&Gen) get_comptime_selector_bool_field

fn (mut g &Gen) get_comptime_selector_bool_field(field_name string) bool

#fn (&Gen) comptime_selector

fn (mut g &Gen) comptime_selector(node v.ast.ComptimeSelector)

#fn (&Gen) comptime_call

fn (mut g &Gen) comptime_call(mut node &v.ast.ComptimeCall)

#fn (&Gen) comptime_at

fn (mut g &Gen) comptime_at(node v.ast.AtExpr)

#fn (&Gen) comptime_if

fn (mut g &Gen) comptime_if(node v.ast.IfExpr)

#fn (&Gen) get_expr_type

fn (mut g &Gen) get_expr_type(cond v.ast.Expr) v.ast.Type

#fn (&Gen) comptime_if_cond

fn (mut g &Gen) comptime_if_cond(cond v.ast.Expr, pkg_exist bool) (bool, bool)

returns the value of the bool comptime expression and if next branches may be discarded returning false means the statements inside the $if can be skipped

#fn (&Gen) push_existing_comptime_values

fn (mut g &Gen) push_existing_comptime_values()

#fn (&Gen) pop_existing_comptime_values

fn (mut g &Gen) pop_existing_comptime_values()

#fn (&Gen) is_comptime_selector_field_name

inline
fn (mut g &Gen) is_comptime_selector_field_name(node v.ast.SelectorExpr, field_name string) bool

is_comptime_selector_field_name checks if the SelectorExpr is related to $for variable accessing specific field name provided by field_name

#fn (&Gen) is_comptime_selector_type

inline
fn (mut g &Gen) is_comptime_selector_type(node v.ast.SelectorExpr) bool

check_comptime_is_field_selector checks if the SelectorExpr is related to $for variable accessing .typ field

#fn (&Gen) get_comptime_var_type

fn (mut g &Gen) get_comptime_var_type(node v.ast.Expr) v.ast.Type

#fn (&Gen) resolve_comptime_type

fn (mut g &Gen) resolve_comptime_type(node v.ast.Expr, default_type v.ast.Type) v.ast.Type

#fn (&Gen) comptime_for

fn (mut g &Gen) comptime_for(node v.ast.ComptimeFor)

#fn (&Gen) comptime_if_to_ifdef

fn (mut g &Gen) comptime_if_to_ifdef(name string, is_comptime_option bool) !string

#fn (&Gen) new_ctemp_var

fn (mut g &Gen) new_ctemp_var(expr v.ast.Expr, expr_type v.ast.Type) v.ast.CTempVar

#fn (&Gen) new_ctemp_var_then_gen

fn (mut g &Gen) new_ctemp_var_then_gen(expr v.ast.Expr, expr_type v.ast.Type) v.ast.CTempVar

#fn (&Gen) gen_ctemp_var

fn (mut g &Gen) gen_ctemp_var(tvar v.ast.CTempVar)

#fn (&Gen) dump_expr

fn (mut g &Gen) dump_expr(node v.ast.DumpExpr)

#fn (&Gen) dump_expr_definitions

fn (mut g &Gen) dump_expr_definitions()

#fn (&Gen) writeln_fn_header

fn (mut g &Gen) writeln_fn_header(s string, mut sb &strings.Builder) bool

#fn (&Gen) should_really_embed_file

fn (mut g &Gen) should_really_embed_file() bool

#fn (&Gen) handle_embedded_files_finish

fn (mut g &Gen) handle_embedded_files_finish()

#fn (&Gen) gen_embed_file_init

fn (mut g &Gen) gen_embed_file_init(mut node &v.ast.ComptimeCall)

gen_embed_file_struct generates C code for $embed_file('...') calls.

#fn (&Gen) gen_embedded_metadata

fn (mut g &Gen) gen_embedded_metadata()

gen_embedded_metadata embeds all of the deduplicated metadata in g.embedded_files, into the V target executable, into a single generated function _v_embed_file_metadata, that accepts a hash of the absolute path of the embedded files.

#fn (&Gen) gen_embedded_data

fn (mut g &Gen) gen_embedded_data()

gen_embedded_data embeds data into the V target executable.

#fn (&Gen) is_used_by_main

fn (mut g &Gen) is_used_by_main(node v.ast.FnDecl) bool

#fn (&Gen) fn_decl

fn (mut g &Gen) fn_decl(node v.ast.FnDecl)

#fn (&Gen) gen_fn_decl

fn (mut g &Gen) gen_fn_decl(node &v.ast.FnDecl, skip bool)

#fn (&Gen) c_fn_name

fn (mut g &Gen) c_fn_name(node &v.ast.FnDecl) !string

#fn (&Gen) closure_ctx

fn (mut g &Gen) closure_ctx(node v.ast.FnDecl) string

#fn (&Gen) gen_anon_fn

fn (mut g &Gen) gen_anon_fn(mut node &v.ast.AnonFn)

#fn (&Gen) gen_anon_fn_decl

fn (mut g &Gen) gen_anon_fn_decl(mut node &v.ast.AnonFn)

#fn (&Gen) defer_flag_var

fn (g &Gen) defer_flag_var(stmt &v.ast.DeferStmt) string

#fn (&Gen) write_defer_stmts_when_needed

fn (mut g &Gen) write_defer_stmts_when_needed()

#fn (&Gen) fn_decl_params

fn (mut g &Gen) fn_decl_params(params []v.ast.Param, scope &v.ast.Scope, is_variadic bool) ([]string, []string, []bool)

#fn (&Gen) get_anon_fn_type_name

fn (mut g &Gen) get_anon_fn_type_name(mut node &v.ast.AnonFn, var_name string) string

#fn (&Gen) call_expr

fn (mut g &Gen) call_expr(node v.ast.CallExpr)

#fn (&Gen) conversion_function_call

fn (mut g &Gen) conversion_function_call(prefix string, postfix string, node v.ast.CallExpr)

#fn (&Gen) gen_arg_from_type

inline
fn (mut g &Gen) gen_arg_from_type(node_type v.ast.Type, node v.ast.Expr)

#fn (&Gen) gen_map_method_call

fn (mut g &Gen) gen_map_method_call(node v.ast.CallExpr, left_type v.ast.Type, left_sym v.ast.TypeSymbol) bool

#fn (&Gen) gen_array_method_call

fn (mut g &Gen) gen_array_method_call(node v.ast.CallExpr, left_type v.ast.Type) bool

#fn (&Gen) gen_to_str_method_call

fn (mut g &Gen) gen_to_str_method_call(node v.ast.CallExpr) bool

#fn (&Gen) get_gn_var_type

fn (mut g &Gen) get_gn_var_type(var v.ast.Ident) v.ast.Type

#fn (&Gen) get_generic_array_element_type

fn (g &Gen) get_generic_array_element_type(array v.ast.Array) v.ast.Type

#fn (&Gen) change_comptime_args

fn (mut g &Gen) change_comptime_args(func v.ast.Fn, mut node_ &v.ast.CallExpr, concrete_types []v.ast.Type) map[int]v.ast.Type

#fn (&Gen) method_call

fn (mut g &Gen) method_call(node v.ast.CallExpr)

#fn (&Gen) fn_call

fn (mut g &Gen) fn_call(node v.ast.CallExpr)

#fn (&Gen) autofree_call_pregen

fn (mut g &Gen) autofree_call_pregen(node v.ast.CallExpr)

#fn (&Gen) autofree_call_postgen

fn (mut g &Gen) autofree_call_postgen(node_pos int)

#fn (&Gen) call_args

fn (mut g &Gen) call_args(node v.ast.CallExpr)

#fn (&Gen) go_expr

fn (mut g &Gen) go_expr(node v.ast.GoExpr)

#fn (&Gen) get_cur_thread_stack_size

inline
fn (mut g &Gen) get_cur_thread_stack_size(name string) string

get current thread size, if fn hasn't defined return default

#fn (&Gen) keep_alive_call_pregen

fn (mut g &Gen) keep_alive_call_pregen(node v.ast.CallExpr) int

similar to autofree_call_pregen but only to to handle [keep_args_alive] for C functions

#fn (&Gen) keep_alive_call_postgen

fn (mut g &Gen) keep_alive_call_postgen(node v.ast.CallExpr, tmp_cnt_save int)

#fn (&Gen) ref_or_deref_arg

inline
fn (mut g &Gen) ref_or_deref_arg(arg v.ast.CallArg, expected_type v.ast.Type, lang v.ast.Language)

#fn (&Gen) is_gui_app

fn (mut g &Gen) is_gui_app() bool

#fn (&Gen) fileis

fn (g &Gen) fileis(s string) bool

#fn (&Gen) write_fn_attrs

fn (mut g &Gen) write_fn_attrs(attrs []v.ast.Attr) string

#fn (&Gen) for_c_stmt

fn (mut g &Gen) for_c_stmt(node v.ast.ForCStmt)

#fn (&Gen) for_stmt

fn (mut g &Gen) for_stmt(node v.ast.ForStmt)

#fn (&Gen) for_in_stmt

fn (mut g &Gen) for_in_stmt(node_ v.ast.ForInStmt)

#fn (&Gen) need_tmp_var_in_if

fn (mut g &Gen) need_tmp_var_in_if(node v.ast.IfExpr) bool

#fn (&Gen) need_tmp_var_in_expr

fn (mut g &Gen) need_tmp_var_in_expr(expr v.ast.Expr) bool

#fn (&Gen) needs_conds_order

fn (mut g &Gen) needs_conds_order(node v.ast.IfExpr) bool

#fn (&Gen) if_expr

fn (mut g &Gen) if_expr(node v.ast.IfExpr)

#fn (&Gen) index_expr

fn (mut g &Gen) index_expr(node v.ast.IndexExpr)

#fn (&Gen) index_range_expr

fn (mut g &Gen) index_range_expr(node v.ast.IndexExpr, range v.ast.RangeExpr)

#fn (&Gen) index_of_array

fn (mut g &Gen) index_of_array(node v.ast.IndexExpr, sym v.ast.TypeSymbol)

#fn (&Gen) index_of_fixed_array

fn (mut g &Gen) index_of_fixed_array(node v.ast.IndexExpr, sym v.ast.TypeSymbol)

#fn (&Gen) index_of_map

fn (mut g &Gen) index_of_map(node v.ast.IndexExpr, sym v.ast.TypeSymbol)

#fn (&Gen) infix_expr

fn (mut g &Gen) infix_expr(node v.ast.InfixExpr)

#fn (&Gen) infix_expr_arrow_op

fn (mut g &Gen) infix_expr_arrow_op(node v.ast.InfixExpr)

infix_expr_arrow_op generates C code for pushing into channels (chan <- val)

#fn (&Gen) infix_expr_eq_op

fn (mut g &Gen) infix_expr_eq_op(node v.ast.InfixExpr)

infix_expr_eq_op generates code for == and !=

#fn (&Gen) infix_expr_cmp_op

fn (mut g &Gen) infix_expr_cmp_op(node v.ast.InfixExpr)

infix_expr_cmp_op generates code for <, <=, >, >= It handles operator overloading when necessary

#fn (&Gen) infix_expr_in_sumtype_interface_array

fn (mut g &Gen) infix_expr_in_sumtype_interface_array(infix_exprs []v.ast.InfixExpr)

#fn (&Gen) infix_expr_in_op

fn (mut g &Gen) infix_expr_in_op(node v.ast.InfixExpr)

infix_expr_in_op generates code for in and !in

#fn (&Gen) infix_expr_in_optimization

fn (mut g &Gen) infix_expr_in_optimization(left v.ast.Expr, right v.ast.ArrayInit)

infix_expr_in_optimization optimizes <var> in <array> expressions, and transform them in a serie of equality comparison i.e. a in [1,2,3] => a == 1 || a == 2 || a == 3

#fn (&Gen) infix_expr_is_op

fn (mut g &Gen) infix_expr_is_op(node v.ast.InfixExpr)

infix_expr_is_op generates code for is and !is

#fn (&Gen) gen_interface_is_op

fn (mut g &Gen) gen_interface_is_op(node v.ast.InfixExpr)

#fn (&Gen) infix_expr_arithmetic_op

fn (mut g &Gen) infix_expr_arithmetic_op(node v.ast.InfixExpr)

infix_expr_arithmetic_op generates code for +, -, *, /, and % It handles operator overloading when necessary

#fn (&Gen) infix_expr_left_shift_op

fn (mut g &Gen) infix_expr_left_shift_op(node v.ast.InfixExpr)

infix_expr_left_shift_op generates code for the << operator This can either be a value pushed into an array or a bit shift

#fn (&Gen) need_tmp_var_in_array_call

fn (mut g &Gen) need_tmp_var_in_array_call(node v.ast.Expr) bool

#fn (&Gen) infix_expr_and_or_op

fn (mut g &Gen) infix_expr_and_or_op(node v.ast.InfixExpr)

infix_expr_and_or_op generates code for && and ||

#fn (&Gen) gen_is_none_check

fn (mut g &Gen) gen_is_none_check(node v.ast.InfixExpr)

#fn (&Gen) gen_plain_infix_expr

fn (mut g &Gen) gen_plain_infix_expr(node v.ast.InfixExpr)

gen_plain_infix_expr generates basic code for infix expressions, without any overloading of any kind i.e. va + 1 => ca + 1 It handles auto dereferencing of variables, as well as automatic casting (see Gen.expr_with_cast for more details)

#fn (&Gen) op_arg

fn (mut g &Gen) op_arg(expr v.ast.Expr, expected v.ast.Type, got v.ast.Type)

#fn (&Gen) gen_safe_integer_infix_expr

fn (mut g &Gen) gen_safe_integer_infix_expr(cfg GenSafeIntegerCfg)

gen_safe_integer_infix_expr generates code for comparison of unsigned and signed integers

#fn (&Gen) gen_json_for_type

fn (mut g &Gen) gen_json_for_type(typ v.ast.Type)

Codegen json_decode/encode funcs

#fn (&Gen) gen_jsons

fn (mut g &Gen) gen_jsons()

#fn (&Gen) gen_enum_to_str

inline
fn (mut g &Gen) gen_enum_to_str(utyp v.ast.Type, sym v.ast.TypeSymbol, enum_var string, result_var string, ident string, mut enc &strings.Builder)

#fn (&Gen) gen_str_to_enum

inline
fn (mut g &Gen) gen_str_to_enum(utyp v.ast.Type, sym v.ast.TypeSymbol, val_var string, result_var string, ident string, mut dec &strings.Builder)

#fn (&Gen) is_enum_as_int

inline
fn (mut g &Gen) is_enum_as_int(sym v.ast.TypeSymbol) bool

#fn (&Gen) gen_enum_enc_dec

inline
fn (mut g &Gen) gen_enum_enc_dec(utyp v.ast.Type, sym v.ast.TypeSymbol, mut enc &strings.Builder, mut dec &strings.Builder)

#fn (&Gen) gen_prim_enc_dec

inline
fn (mut g &Gen) gen_prim_enc_dec(typ v.ast.Type, mut enc &strings.Builder, mut dec &strings.Builder)

#fn (&Gen) gen_option_enc_dec

inline
fn (mut g &Gen) gen_option_enc_dec(typ v.ast.Type, mut enc &strings.Builder, mut dec &strings.Builder)

#fn (&Gen) gen_sumtype_enc_dec

inline
fn (mut g &Gen) gen_sumtype_enc_dec(utyp v.ast.Type, sym v.ast.TypeSymbol, mut enc &strings.Builder, mut dec &strings.Builder, ret_styp string)

#fn (&Gen) gen_struct_enc_dec

inline
fn (mut g &Gen) gen_struct_enc_dec(utyp v.ast.Type, type_info v.ast.TypeInfo, styp string, mut enc &strings.Builder, mut dec &strings.Builder)

#fn (&Gen) decode_array

fn (mut g &Gen) decode_array(utyp v.ast.Type, value_type v.ast.Type, fixed_array_size int, ret_styp string) string

#fn (&Gen) encode_array

fn (mut g &Gen) encode_array(utyp v.ast.Type, value_type v.ast.Type, fixed_array_size int) string

#fn (&Gen) decode_map

fn (mut g &Gen) decode_map(utyp v.ast.Type, key_type v.ast.Type, value_type v.ast.Type, ustyp string) string

#fn (&Gen) encode_map

fn (mut g &Gen) encode_map(utyp v.ast.Type, key_type v.ast.Type, value_type v.ast.Type) string

#fn (&Gen) generate_hotcode_reloading_declarations

fn (mut g &Gen) generate_hotcode_reloading_declarations()

#fn (&Gen) generate_hotcode_reloader_code

fn (mut g &Gen) generate_hotcode_reloader_code()

#fn (&Gen) generate_hotcode_reloading_main_caller

fn (mut g &Gen) generate_hotcode_reloading_main_caller()

#fn (&Gen) need_tmp_var_in_match

fn (mut g &Gen) need_tmp_var_in_match(node v.ast.MatchExpr) bool

#fn (&Gen) match_expr

fn (mut g &Gen) match_expr(node v.ast.MatchExpr)

#fn (&Gen) match_expr_sumtype

fn (mut g &Gen) match_expr_sumtype(node v.ast.MatchExpr, is_expr bool, cond_var string, tmp_var string)

#fn (&Gen) match_expr_switch

fn (mut g &Gen) match_expr_switch(node v.ast.MatchExpr, is_expr bool, cond_var string, tmp_var string, cond_fsym v.ast.TypeSymbol)

#fn (&Gen) should_check_low_bound_in_range_expr

fn (mut g &Gen) should_check_low_bound_in_range_expr(expr v.ast.RangeExpr, node_cond_type_unsigned bool) bool

#fn (&Gen) match_expr_classic

fn (mut g &Gen) match_expr_classic(node v.ast.MatchExpr, is_expr bool, cond_var string, tmp_var string)

#fn (&Gen) sql_select_expr

fn (mut g &Gen) sql_select_expr(node v.ast.SqlExpr)

sql_select_expr writes C code that calls ORM functions for selecting objects from the database, which is used by the select query.

#fn (&Gen) sql_stmt

fn (mut g &Gen) sql_stmt(node v.ast.SqlStmt)

sql_stmt writes C code that calls ORM functions for performing various database operations such as creating and dropping tables, as well as inserting and updating objects.

Can contain several queries. For example:

 sql db {
    create table User
    insert user into User
 }!


NOTE: Currently, in ORM only the select query is an expression.

The others are statements.

#fn (&Gen) sql_stmt_line

fn (mut g &Gen) sql_stmt_line(stmt_line v.ast.SqlStmtLine, connection_var_name string, or_expr v.ast.OrExpr)

sql_stmt_line writes C code that calls ORM functions for performing various database operations such as creating and dropping tables, as well as inserting and updating objects.

It is part of a multi-line query. For example, create table User

#fn (&Gen) write_orm_connection_init

fn (mut g &Gen) write_orm_connection_init(connection_var_name string, db_expr &v.ast.Expr)

write_orm_connection_init writes C code that saves the database connection into a variable for later use in ORM queries.

#fn (&Gen) write_orm_create_table

fn (mut g &Gen) write_orm_create_table(node v.ast.SqlStmtLine, table_name string, connection_var_name string, result_var_name string)

write_orm_create_table writes C code that calls ORM functions for creating tables.

#fn (&Gen) write_orm_drop_table

fn (mut g &Gen) write_orm_drop_table(table_name string, connection_var_name string, result_var_name string)

write_orm_drop_table writes C code that calls ORM functions for dropping tables.

#fn (&Gen) write_orm_insert

fn (mut g &Gen) write_orm_insert(node &v.ast.SqlStmtLine, table_name string, connection_var_name string, result_var_name string, or_expr &v.ast.OrExpr)

write_orm_insert writes C code that calls ORM functions for inserting structs into a table.

#fn (&Gen) write_orm_update

fn (mut g &Gen) write_orm_update(node &v.ast.SqlStmtLine, table_name string, connection_var_name string, result_var_name string)

write_orm_update writes C code that calls ORM functions for updating rows.

#fn (&Gen) write_orm_delete

fn (mut g &Gen) write_orm_delete(node &v.ast.SqlStmtLine, table_name string, connection_var_name string, result_var_name string)

write_orm_delete writes C code that calls ORM functions for deleting rows.

#fn (&Gen) write_orm_insert_with_last_ids

fn (mut g &Gen) write_orm_insert_with_last_ids(node v.ast.SqlStmtLine, connection_var_name string, table_name string, last_ids_arr string, res string, pid string, fkey string, or_expr v.ast.OrExpr)

write_orm_insert_with_last_ids writes C code that calls ORM functions for inserting a struct into a table, saving inserted id into a passed variable.

#fn (&Gen) write_orm_expr_to_primitive

fn (mut g &Gen) write_orm_expr_to_primitive(expr v.ast.Expr)

write_orm_expr_to_primitive writes C code for casting expressions into a primitive type by checking support expressions and their types.

#fn (&Gen) write_orm_primitive

fn (mut g &Gen) write_orm_primitive(t v.ast.Type, expr v.ast.Expr)

write_orm_primitive writes C code for casting expressions into a primitive type, which will be used in low-level database libs.

#fn (&Gen) write_orm_where

fn (mut g &Gen) write_orm_where(where_expr v.ast.Expr)

write_orm_where writes C code that generates the QueryData structure for passing it into ORM methods.

#fn (&Gen) write_orm_where_expr

fn (mut g &Gen) write_orm_where_expr(expr v.ast.Expr, mut fields &[]string, mut parentheses &[][]int, mut kinds &[]string, mut data &[]v.ast.Expr, mut is_and &[]bool)

write_orm_where_expr writes C code that generates expression which is used in the QueryData.

#fn (&Gen) write_orm_select

fn (mut g &Gen) write_orm_select(node v.ast.SqlExpr, connection_var_name string, left_expr_string string, or_expr v.ast.OrExpr)

write_orm_select writes C code that calls ORM functions for selecting rows.

#fn (&Gen) filter_struct_fields_by_orm_attrs

fn (_ &Gen) filter_struct_fields_by_orm_attrs(fields []v.ast.StructField) []v.ast.StructField

filter_struct_fields_by_orm_attrs filters struct fields taking into its attributes.

Used by non-create queries for skipping fields if it has a skip attribute or primary that inserts automatically.

#fn (&Gen) get_db_expr_type

fn (g &Gen) get_db_expr_type(expr v.ast.Expr) ?v.ast.Type

get_db_expr_type returns the database type from the database expression.

#fn (&Gen) get_table_name_by_struct_type

fn (g &Gen) get_table_name_by_struct_type(typ v.ast.Type) string

get_table_name_by_struct_type converts the struct type to a table name.

#fn (&Gen) get_orm_current_table_field

fn (g &Gen) get_orm_current_table_field(name string) v.ast.StructField

get_orm_current_table_field returns the current processing table's struct field by name.

#fn (&Gen) get_orm_column_name_from_struct_field

fn (g &Gen) get_orm_column_name_from_struct_field(field v.ast.StructField) string

get_orm_column_name_from_struct_field converts the struct field to a table column name.

#fn (&Gen) get_orm_struct_primary_field_name

fn (_ &Gen) get_orm_struct_primary_field_name(fields []v.ast.StructField) ?string

get_orm_struct_primary_field_name returns the table's primary column name.

#fn (&Gen) profile_fn

fn (mut g &Gen) profile_fn(fn_decl v.ast.FnDecl)

#fn (&Gen) gen_vprint_profile_stats

fn (mut g &Gen) gen_vprint_profile_stats()

#fn (&Gen) reflection_string

fn (mut g &Gen) reflection_string(str string) int

reflection_string maps string to its idx

#fn (&Gen) gen_reflection_strings

inline
fn (mut g &Gen) gen_reflection_strings()

gen_reflection_strings generates the reflectino string registration

#fn (&Gen) gen_empty_array

inline
fn (g &Gen) gen_empty_array(type_name string) string

gen_empty_array generates code for empty array

#fn (&Gen) gen_functionarg_array

inline
fn (g &Gen) gen_functionarg_array(type_name string, node v.ast.Fn) string

gen_functionarg_array generates the code for functionarg argument

#fn (&Gen) gen_function_array

inline
fn (mut g &Gen) gen_function_array(nodes []v.ast.Fn) string

gen_functionarg_array generates the code for functionarg argument

#fn (&Gen) gen_reflection_fn

inline
fn (mut g &Gen) gen_reflection_fn(node v.ast.Fn) string

gen_reflection_fn generates C code for Function struct

#fn (&Gen) gen_reflection_sym

inline
fn (mut g &Gen) gen_reflection_sym(tsym v.ast.TypeSymbol) string

gen_reflection_sym generates C code for TypeSymbol struct

#fn (&Gen) gen_attrs_array

inline
fn (g &Gen) gen_attrs_array(attrs []v.ast.Attr) string

gen_attrs_array generates C code for []Attr

#fn (&Gen) gen_fields_array

inline
fn (g &Gen) gen_fields_array(fields []v.ast.StructField) string

gen_fields_array generates C code for []StructField

#fn (&Gen) gen_type_array

inline
fn (g &Gen) gen_type_array(types []v.ast.Type) string

gen_type_array generates C code for []Type

#fn (&Gen) gen_string_array

inline
fn (g &Gen) gen_string_array(strs []string) string

gen_string_array generates C code for []string

#fn (&Gen) gen_reflection_sym_info

inline
fn (mut g &Gen) gen_reflection_sym_info(tsym v.ast.TypeSymbol) string

gen_reflection_sym_info generates C code for TypeSymbol's info sum type

#fn (&Gen) gen_reflection_data

fn (mut g &Gen) gen_reflection_data()

gen_reflection_data generates code to initilized V reflection metadata

#fn (&Gen) string_literal

fn (mut g &Gen) string_literal(node v.ast.StringLiteral)

#fn (&Gen) string_inter_literal_sb_optimized

fn (mut g &Gen) string_inter_literal_sb_optimized(call_expr v.ast.CallExpr)

optimize string interpolation in string builders:

sb.writeln('a=$a') => sb.writeln('a='); sb.writeln(a.str())

#fn (&Gen) gen_expr_to_string

fn (mut g &Gen) gen_expr_to_string(expr v.ast.Expr, etype v.ast.Type)

#fn (&Gen) get_default_fmt

fn (mut g &Gen) get_default_fmt(ftyp v.ast.Type, typ v.ast.Type) u8

#fn (&Gen) str_format

fn (mut g &Gen) str_format(node v.ast.StringInterLiteral, i int) (u64, string)

#fn (&Gen) str_val

fn (mut g &Gen) str_val(node v.ast.StringInterLiteral, i int)

#fn (&Gen) string_inter_literal

fn (mut g &Gen) string_inter_literal(node v.ast.StringInterLiteral)

#fn (&Gen) struct_init

fn (mut g &Gen) struct_init(node v.ast.StructInit)

#fn (&Gen) zero_struct_field

fn (mut g &Gen) zero_struct_field(field v.ast.StructField) bool

#fn (&Gen) is_empty_struct

fn (mut g &Gen) is_empty_struct(t Type) bool

#fn (&Gen) struct_decl

fn (mut g &Gen) struct_decl(s v.ast.Struct, name string, is_anon bool)

#fn (&Gen) struct_init_field

fn (mut g &Gen) struct_init_field(sfield v.ast.StructInitField, language v.ast.Language)

#fn (&Gen) write

fn (mut g &Gen) write(s string)

#fn (&Gen) writeln

fn (mut g &Gen) writeln(s string)

#fn (&Gen) go_back

fn (mut g &Gen) go_back(n int)

#fn (&Gen) go_back_to

fn (mut g &Gen) go_back_to(n int)

#fn (&Gen) nth_stmt_pos

inline
fn (g &Gen) nth_stmt_pos(n int) int

#fn (&Gen) set_current_pos_as_last_stmt_pos

inline
fn (mut g &Gen) set_current_pos_as_last_stmt_pos()

#fn (&Gen) go_before_stmt

fn (mut g &Gen) go_before_stmt(n int) string

#fn (&Gen) go_before_ternary

inline
fn (mut g &Gen) go_before_ternary() string

#fn (&Gen) insert_before_stmt

fn (mut g &Gen) insert_before_stmt(s string)

#fn (&Gen) insert_at

fn (mut g &Gen) insert_at(pos int, s string)

#fn (&Gen) unwrap_generic

fn (mut g &Gen) unwrap_generic(typ v.ast.Type) v.ast.Type

#fn (&Gen) unwrap

fn (mut g &Gen) unwrap(typ v.ast.Type) Type

unwrap returns the following variants of a type:

  • generics unwrapped * alias unwrapped

#fn (&Gen) fn_var_signature

fn (mut g &Gen) fn_var_signature(return_type v.ast.Type, arg_types []v.ast.Type, var_name string) string

generate function variable definition, e.g. void (*var_name) (int, string)

#fn (&Gen) dot_or_ptr

inline
fn (mut g &Gen) dot_or_ptr(val_type v.ast.Type) string

#struct ProfileCounterMeta

pub struct ProfileCounterMeta {
	fn_name   string
	vpc_name  string
	vpc_calls string
}

Interfaces

This section is empty.

Enums

This section is empty.