Skip to content

v.gen.native #

Constants #

const inline_builtins = ['assert', 'print', 'eprint', 'println', 'eprintln', 'exit', 'C.syscall'] // classic V builtin functios accessible to the user get inlined

fn gen #

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

fn macho_test_new_gen #

fn macho_test_new_gen(p &pref.Preferences, out_name string) &Gen

used in macho_test.v

struct Amd64 #

struct Amd64 {
	g &Gen = unsafe { nil }
// arm64 specific stuff for code generation
	is_16bit_aligned bool

fn (Amd64) pop #

fn (mut c Amd64) pop(reg Amd64Register)

fn (Amd64) sub8 #

fn (mut c Amd64) sub8(reg Amd64Register, val int)

fn (Amd64) sub #

fn (mut c Amd64) sub(reg Amd64Register, val int)

fn (Amd64) add #

fn (mut c Amd64) add(reg Amd64Register, val int)

fn (Amd64) add8 #

fn (mut c Amd64) add8(reg Amd64Register, val int)

fn (Amd64) var_zero #

fn (mut c Amd64) var_zero(vo int, size int)

not used?

fn (Amd64) rep_stosb #

fn (mut c Amd64) rep_stosb()

fn (Amd64) std #

fn (mut c Amd64) std()

fn (Amd64) cld #

fn (mut c Amd64) cld()

fn (Amd64) cld_repne_scasb #

fn (mut c Amd64) cld_repne_scasb()

fn (Amd64) xor #

fn (mut c Amd64) xor(r Amd64Register, v int)

fn (Amd64) test_reg #

fn (mut c Amd64) test_reg(r Amd64Register)

fn (Amd64) inline_strlen #

fn (mut c Amd64) inline_strlen(r Amd64Register)

return length in .rax of string pointed by given register

fn (Amd64) apicall #

fn (mut c Amd64) apicall(call ApiCall)

fn (Amd64) gen_print_reg #

fn (mut c Amd64) gen_print_reg(r Register, n int, fd int)

TODO: strlen of string at runtime

fn (Amd64) gen_exit #

fn (mut c Amd64) gen_exit(expr ast.Expr)

fn (Amd64) call_fn #

fn (mut c Amd64) call_fn(node ast.CallExpr)

fn (Amd64) builtin_decl #

fn (mut c Amd64) builtin_decl(builtin BuiltinFn)

fn (Amd64) allocate_var_two_step #

fn (mut c Amd64) allocate_var_two_step(name string, size int, initial_val int) int

fn (Amd64) allocate_var #

fn (mut c Amd64) allocate_var(name string, size int, initial_val int) int

struct Arm64 #

struct Arm64 {
	g &Gen = unsafe { nil }
// arm64 specific stuff for code generation

fn (Arm64) fn_decl #

fn (mut c Arm64) fn_decl(node ast.FnDecl)

fn (Arm64) call_fn #

fn (mut c Arm64) call_fn(node ast.CallExpr)

fn (Arm64) gen_exit #

fn (mut c Arm64) gen_exit(expr ast.Expr)

fn (Arm64) gen_arm64_exit #

fn (mut c Arm64) gen_arm64_exit(expr ast.Expr)

struct Gen #

struct Gen {
	out_name string
	pref     &pref.Preferences = unsafe { nil } // Preferences shared from V struct
	files    []&ast.File
	code_gen             CodeGen
	table                &ast.Table = unsafe { nil }
	buf                  []u8
	sect_header_name_pos int
	offset               i64
	file_size_pos        i64
	elf_text_header_addr i64 = -1
	elf_rela_section     Section
	main_fn_addr         i64
	main_fn_size         i64
	start_symbol_addr    i64
	code_start_pos       i64 // location of the start of the assembly instructions
	symbol_table         []SymbolTableSection
	extern_symbols       []string
	extern_fn_calls      map[i64]string
	fn_addr              map[string]i64
	var_offset           map[string]int // local var stack offset
	var_alloc_size       map[string]int // local var allocation size
	stack_var_pos        int
	debug_pos            int
	errors               []errors.Error
	warnings             []errors.Warning
	syms                 []Symbol
	size_pos             []int
	nlines               int
	callpatches          []CallPatch
	strs                 []String
	labels               &LabelTable = unsafe { nil }
	defer_stmts          []ast.DeferStmt
	builtins             map[Builtin]BuiltinFn
	structs              []Struct
	eval                 eval.Eval
	enum_vals            map[string]Enum
	return_type          ast.Type
// macho specific
	macho_ncmds   int
	macho_cmdsize int

	requires_linking bool

fn (Gen) ast_has_external_functions #

fn (mut g Gen) ast_has_external_functions() bool

fn (Gen) calculate_all_size_align #

fn (mut g Gen) calculate_all_size_align()

fn (Gen) calculate_enum_fields #

fn (mut g Gen) calculate_enum_fields()

fn (Gen) call_builtin #

fn (mut g Gen) call_builtin(name Builtin)

fn (Gen) create_executable #

fn (mut g Gen) create_executable()

fn (Gen) elf_string_table #

fn (mut g Gen) elf_string_table()

fn (Gen) find_o_path #

fn (mut g Gen) find_o_path(fname string) string

fn (Gen) gen_print_from_expr #

fn (mut g Gen) gen_print_from_expr(expr ast.Expr, typ ast.Type, name string)

fn (Gen) gen_rela_section #

fn (mut g Gen) gen_rela_section()

fn (Gen) generate_builtins #

fn (mut g Gen) generate_builtins()

fn (Gen) generate_header #

fn (mut g Gen) generate_header()

fn (Gen) generate_linkable_elf_header #

fn (mut g Gen) generate_linkable_elf_header()

fn (Gen) generate_macho_header #

fn (mut g Gen) generate_macho_header()

fn (Gen) generate_macho_object_header #

fn (mut g Gen) generate_macho_object_header()

fn (Gen) generate_pe_header #

fn (mut g Gen) generate_pe_header()

fn (Gen) generate_simple_elf_header #

fn (mut g Gen) generate_simple_elf_header()

fn (Gen) get_builtin_arg_reg #

fn (mut g Gen) get_builtin_arg_reg(name Builtin, index int) Register

fn (Gen) get_lpaths #

fn (mut g Gen) get_lpaths() string

fn (Gen) init_builtins #

fn (mut g Gen) init_builtins()

fn (Gen) n_error #

fn (mut g Gen) n_error(s string)

fn (Gen) pos #

fn (g &Gen) pos() i64

fn (Gen) prepend_vobjpath #

fn (mut g Gen) prepend_vobjpath(paths []string) []string

fn (Gen) register_function_address #

fn (mut g Gen) register_function_address(name string)

fn (Gen) stmts #

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

fn (Gen) symtab_get_index #

fn (mut g Gen) symtab_get_index(symbols []SymbolTableSection, name string) int

fn (Gen) typ #

fn (mut g Gen) typ(a int) &ast.TypeSymbol

fn (Gen) v_error #

fn (mut g Gen) v_error(s string, pos token.Pos)

fn (Gen) warning #

fn (mut g Gen) warning(s string, pos token.Pos)

fn (Gen) write_dos_header #

fn (mut g Gen) write_dos_header()

fn (Gen) write_dos_stub #

fn (mut g Gen) write_dos_stub()

size is 0xb8

fn (Gen) write_pe_header #

fn (mut g Gen) write_pe_header()

fn (Gen) zeroes #

fn (mut g Gen) zeroes(n int)