Skip to content

v.gen.native #

Constants #

const builtins = ['assert', 'print', 'eprint', 'println', 'eprintln', 'exit', 'C.syscall']

fn gen #

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

struct Amd64 #

struct Amd64 {
	g &Gen
// arm64 specific stuff for code generation

fn (Amd64) gen_exit #

fn (mut a Amd64) gen_exit(mut g Gen, node ast.Expr)

fn (Amd64) allocate_var #

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

struct Arm64 #

struct Arm64 {
	g &Gen
// arm64 specific stuff for code generation

fn (Arm64) allocate_var #

fn (mut x Arm64) allocate_var(name string, size int, initial_val int)

fn (Arm64) gen_exit #

fn (mut c Arm64) gen_exit(mut g Gen, expr ast.Expr)

struct Gen #

struct Gen {
	out_name string
	pref     &pref.Preferences // Preferences shared from V struct
	code_gen             CodeGen
	table                &ast.Table
	buf                  []u8
	sect_header_name_pos int
	offset               i64
	stackframe_size      int
	file_size_pos        i64
	main_fn_addr         i64
	code_start_pos       i64 // location of the start of the assembly instructions
	fn_addr              map[string]i64
	var_offset           map[string]int // local var stack offset
	stack_var_pos        int
	debug_pos            int
	errors               []errors.Error
	warnings             []errors.Warning
	syms                 []Symbol
	size_pos             []int
	nlines               int
	callpatches          []CallPatch
	strs                 []String

fn (Gen) add #

fn (mut g Gen) add(reg Register, val int)

fn (Gen) add8 #

fn (mut g Gen) add8(reg Register, val int)

fn (Gen) allocate_array #

fn (mut g Gen) allocate_array(name string, size int, items int) int

fn (Gen) allocate_string #

fn (mut g Gen) allocate_string(s string, opsize int, typ RelocType) int

fn (Gen) allocate_var #

fn (mut g Gen) allocate_var(name string, size int, initial_val int) int

fn (Gen) apicall #

fn (mut g Gen) apicall(s string)

fn (Gen) call_fn #

fn (mut g Gen) call_fn(node ast.CallExpr)

fn (Gen) call_fn_arm64 #

fn (mut g Gen) call_fn_arm64(node ast.CallExpr)

fn (Gen) cld_repne_scasb #

fn (mut g Gen) cld_repne_scasb()

fn (Gen) create_executable #

fn (mut g Gen) create_executable()

fn (Gen) fn_decl_arm64 #

fn (mut g Gen) fn_decl_arm64(node ast.FnDecl)

fn (Gen) gen_amd64_exit #

fn (mut g Gen) gen_amd64_exit(expr ast.Expr)

fn (Gen) gen_arm64_exit #

fn (mut g Gen) gen_arm64_exit(expr ast.Expr)

fn (Gen) gen_exit #

fn (mut g Gen) gen_exit(node ast.Expr)

fn (Gen) gen_loop_end #

fn (mut g Gen) gen_loop_end(to int, label int)

fn (Gen) gen_loop_start #

fn (mut g Gen) gen_loop_start(from int) int

returns label's relative address

fn (Gen) gen_print #

fn (mut g Gen) gen_print(s string, fd int)

fn (Gen) gen_print_from_expr #

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

fn (Gen) gen_print_reg #

fn (mut g Gen) gen_print_reg(r Register, n int, fd int)

TODO: strlen of string at runtime

fn (Gen) generate_elf_header #

fn (mut g Gen) generate_elf_header()

fn (Gen) generate_header #

fn (mut g Gen) generate_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) inline_strlen #

fn (mut g Gen) inline_strlen(r Register)

return length in .rax of string pointed by given register

fn (Gen) n_error #

fn (mut g Gen) n_error(s string)

fn (Gen) pop #

fn (mut g Gen) pop(reg Register)

fn (Gen) pos #

fn (g &Gen) pos() i64

fn (Gen) push #

fn (mut g Gen) push(reg Register)

fn (Gen) register_function_address #

fn (mut g Gen) register_function_address(name string)

fn (Gen) ret #

fn (mut g Gen) ret()

fn (Gen) stmts #

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

fn (Gen) sub #

fn (mut g Gen) sub(reg Register, val int)

fn (Gen) sub32 #

fn (mut g Gen) sub32(reg Register, val int)

fn (Gen) sub8 #

fn (mut g Gen) sub8(reg Register, val 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) xor #

fn (mut g Gen) xor(r Register, v int)

fn (Gen) zeroes #

fn (mut g Gen) zeroes(n int)