v.gen.native #

Constants #

const builtins = ['println', 'exit']

fn gen #

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

struct Amd64 #

struct Amd64 {
mut:
	g &Gen
}

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 {
mut:
	g &Gen
}

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
mut:
	cgen                 CodeGen
	table                &ast.Table
	buf                  []byte
	sect_header_name_pos int
	offset               i64
	str_pos              []i64
	strings              []string
	file_size_pos        i64
	main_fn_addr         i64
	code_start_pos       i64
	fn_addr              map[string]i64
	var_offset           map[string]int
	stack_var_pos        int
	debug_pos            int
	errors               []errors.Error
	warnings             []errors.Warning
	syms                 []Symbol
	relocs               []Reloc
	size_pos             []int
	nlines               int
}

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) int

fn (Gen) allocate_var #

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

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) error_with_pos #

fn (mut g Gen) error_with_pos(s string, pos token.Position)

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)

fn (Gen) gen_print_from_expr #

fn (mut g Gen) gen_print_from_expr(expr ast.Expr, newline bool)

fn (Gen) gen_print_reg #

fn (mut g Gen) gen_print_reg(r Register, n 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) inline_strlen #

fn (mut g Gen) inline_strlen(r Register)

return length in .rax of string pointed by given register

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) save_main_fn_addr #

fn (mut g Gen) save_main_fn_addr()

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) xor #

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

fn (Gen) zeroes #

fn (mut g Gen) zeroes(n int)