Skip to content

v.gen.wasm #

fn gen #

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

struct Gen #

struct Gen {
	out_name string
	pref     &pref.Preferences = unsafe { nil } // Preferences shared from V struct
	files    []&ast.File
	file_path     string // current ast.File path
	file_path_idx int    // current binaryen debug info index, see `BinaryenModuleAddDebugInfoFileName`
	warnings      []errors.Warning
	errors        []errors.Error
	table         &ast.Table = unsafe { nil }
	eval          eval.Eval
	enum_vals     map[string]Enum
	bp_idx            int // Base pointer temporary's index for function, if needed (-1 for none)
	stack_frame       int // Size of the current stack frame, if needed
	mod               binaryen.Module         // Current Binaryen WebAssembly module
	curr_ret          []ast.Type              // Current return value, multi returns will be split into an array
	local_temporaries []Temporary             // Local WebAssembly temporaries, referenced with an index
	local_addresses   map[string]Stack        // Local stack structures relative to `bp_idx`
	structs           map[ast.Type]StructInfo // Cached struct field offsets
	lbl                     int
	for_labels              []string // A stack of strings containing the names of blocks/loops to break/continue to
	stack_patches           []BlockPatch
	needs_stack             bool // If true, will use `memory` and `__vsp`
	constant_data           []ConstantData
	constant_data_offset    int = 1024 // Low 1KiB of data unused, for optimisations
	module_import_namespace string // `[wasm_import_namespace: 'wasi_snapshot_preview1']` else `env`
	globals                 map[string]GlobalData

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

fn (mut g Gen) w_error(s string)

fn (Gen) expr_stmts #

fn (mut g Gen) expr_stmts(stmts []ast.Stmt, expected ast.Type) binaryen.Expression

fn (Gen) toplevel_stmts #

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

fn (Gen) calculate_enum_fields #

fn (mut g Gen) calculate_enum_fields()