Module v.gen.wasm stdlib

v.gen.wasm
Version:
0.3.3
License:
MIT
Dependencies from vmod:
0
Imports:
11
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, out_name string, w_pref &v.pref.Preferences)

Structs

#struct Gen

heapminify
pub struct Gen {
	out_name string
	pref     &pref.Preferences = unsafe { nil } // Preferences shared from V struct
	files    []&ast.File
mut:
	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) is_signed

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

#fn (&Gen) unary_cast

fn (mut g &Gen) unary_cast(from binaryen.Type, is_signed bool, to binaryen.Type) binaryen.Op

#fn (&Gen) cast_t

fn (mut g &Gen) cast_t(expr binaryen.Expression, from v.ast.Type, to v.ast.Type) binaryen.Expression

#fn (&Gen) cast

fn (mut g &Gen) cast(expr binaryen.Expression, from binaryen.Type, is_signed bool, to binaryen.Type) binaryen.Expression

#fn (&Gen) v_error

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

#fn (&Gen) warning

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

#fn (&Gen) w_error

noreturn
fn (mut g &Gen) w_error(s string)

#fn (&Gen) vsp_leave

fn (mut g &Gen) vsp_leave() binaryen.Expression

#fn (&Gen) setup_stack_frame

fn (mut g &Gen) setup_stack_frame(body binaryen.Expression) binaryen.Expression

#fn (&Gen) function_return_wasm_type

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

#fn (&Gen) unpack_type

fn (g &Gen) unpack_type(typ v.ast.Type) []v.ast.Type

#fn (&Gen) fn_external_import

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

#fn (&Gen) bare_function_start

fn (mut g &Gen) bare_function_start()

#fn (&Gen) bare_function

fn (mut g &Gen) bare_function(name string, expr binaryen.Expression) binaryen.Function

#fn (&Gen) fn_decl

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

#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) binaryen.Expression

#fn (&Gen) literalint

fn (mut g &Gen) literalint(val i64, expected v.ast.Type) binaryen.Expression

#fn (&Gen) literal

fn (mut g &Gen) literal(val string, expected v.ast.Type) binaryen.Expression

#fn (&Gen) handle_ptr_arithmetic

fn (mut g &Gen) handle_ptr_arithmetic(typ v.ast.Type, expr binaryen.Expression) binaryen.Expression

#fn (&Gen) postfix_expr

fn (mut g &Gen) postfix_expr(node v.ast.PostfixExpr) binaryen.Expression

#fn (&Gen) infix_expr

fn (mut g &Gen) infix_expr(node v.ast.InfixExpr, expected v.ast.Type) binaryen.Expression

#fn (&Gen) prefix_expr

fn (mut g &Gen) prefix_expr(node v.ast.PrefixExpr) binaryen.Expression

#fn (&Gen) mknblock

fn (mut g &Gen) mknblock(name string, nodes []binaryen.Expression) binaryen.Expression

#fn (&Gen) mkblock

fn (mut g &Gen) mkblock(nodes []binaryen.Expression) binaryen.Expression

#fn (&Gen) if_branch

fn (mut g &Gen) if_branch(ifexpr v.ast.IfExpr, idx int) binaryen.Expression

#fn (&Gen) if_expr

fn (mut g &Gen) if_expr(ifexpr v.ast.IfExpr) binaryen.Expression

#fn (&Gen) wasm_builtin

fn (mut g &Gen) wasm_builtin(name string, node v.ast.CallExpr) binaryen.Expression

#fn (&Gen) assign_expr_to_var

fn (mut g &Gen) assign_expr_to_var(address LocalOrPointer, right v.ast.Expr, expected v.ast.Type, cfg AssignOpts) binaryen.Expression

#fn (&Gen) expr_impl

fn (mut g &Gen) expr_impl(node v.ast.Expr, expected v.ast.Type) binaryen.Expression

#fn (&Gen) expr

fn (mut g &Gen) expr(node v.ast.Expr, expected v.ast.Type) binaryen.Expression

#fn (&Gen) multi_assign_stmt

fn (mut g &Gen) multi_assign_stmt(node v.ast.AssignStmt) binaryen.Expression

#fn (&Gen) new_for_label

fn (mut g &Gen) new_for_label(node_label string) string

#fn (&Gen) pop_for_label

fn (mut g &Gen) pop_for_label()

#fn (&Gen) expr_stmt

fn (mut g &Gen) expr_stmt(node v.ast.Stmt, expected v.ast.Type) binaryen.Expression

#fn (&Gen) expr_stmts

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

#fn (&Gen) toplevel_stmt

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

#fn (&Gen) toplevel_stmts

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

#fn (&Gen) calculate_enum_fields

fn (mut g &Gen) calculate_enum_fields()

#fn (&Gen) is_pure_type

fn (g &Gen) is_pure_type(typ v.ast.Type) bool

#fn (&Gen) new_global_const

fn (mut g &Gen) new_global_const(obj v.ast.ScopeObject)

#fn (&Gen) get_var_from_ident

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

#fn (&Gen) get_or_lea_lop

fn (mut g &Gen) get_or_lea_lop(lp LocalOrPointer, expected v.ast.Type) binaryen.Expression

#fn (&Gen) lea_lop

fn (mut g &Gen) lea_lop(lp LocalOrPointer, expected v.ast.Type) binaryen.Expression

#fn (&Gen) lea_var_from_expr

fn (mut g &Gen) lea_var_from_expr(node v.ast.Expr) binaryen.Expression

#fn (&Gen) local_or_pointer_add_offset

fn (mut g &Gen) local_or_pointer_add_offset(v Var, offset int) LocalOrPointer

#fn (&Gen) get_var_from_expr

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

TODO: return Var | binaryen.Expression

#fn (&Gen) get_local_temporary

fn (mut g &Gen) get_local_temporary(name string) int

#fn (&Gen) new_local_temporary_anon_wtyp

fn (mut g &Gen) new_local_temporary_anon_wtyp(w_typ binaryen.Type) int

#fn (&Gen) new_local_temporary_anon

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

#fn (&Gen) new_local_temporary

fn (mut g &Gen) new_local_temporary(name string, typ v.ast.Type) Temporary

#fn (&Gen) new_local

fn (mut g &Gen) new_local(var v.ast.Ident, typ v.ast.Type)

#fn (&Gen) deref

fn (mut g &Gen) deref(expr binaryen.Expression, expected v.ast.Type) binaryen.Expression

#fn (&Gen) get_field_offset

fn (mut g &Gen) get_field_offset(typ v.ast.Type, name string) int

#fn (&Gen) get_type_size_align

fn (mut g &Gen) get_type_size_align(typ v.ast.Type) (int, int)

#fn (&Gen) allocate_local_var

fn (mut g &Gen) allocate_local_var(name string, typ v.ast.Type) int

#fn (&Gen) get_bp

fn (mut g &Gen) get_bp() binaryen.Expression

#fn (&Gen) lea_address

fn (mut g &Gen) lea_address(address int) binaryen.Expression

#fn (&Gen) get_var_t

fn (mut g &Gen) get_var_t(var Var, ast_typ v.ast.Type) binaryen.Expression

Will automatcally cast value from var to ast_type, will ignore if struct value.

TODO: When supporting base types on the stack, actually cast them.

#fn (&Gen) set_to_address

fn (mut g &Gen) set_to_address(address_expr binaryen.Expression, expr binaryen.Expression, ast_typ v.ast.Type) binaryen.Expression

#fn (&Gen) set_var_v

fn (mut g &Gen) set_var_v(address Var, expr binaryen.Expression, cfg SetConfig) binaryen.Expression

#fn (&Gen) set_var

fn (mut g &Gen) set_var(address LocalOrPointer, expr binaryen.Expression, cfg SetConfig) binaryen.Expression

#fn (&Gen) zero_fill

fn (mut g &Gen) zero_fill(ast_typ v.ast.Type, address int) binaryen.Expression

zero out stack memory in known local address.

#fn (&Gen) blit_local

fn (mut g &Gen) blit_local(ptr binaryen.Expression, ast_typ v.ast.Type, address int) binaryen.Expression

memcpy from ptr to known local address in stack memory.

#fn (&Gen) blit

fn (mut g &Gen) blit(ptr binaryen.Expression, ast_typ v.ast.Type, dest binaryen.Expression) binaryen.Expression

memcpy from ptr to dest

#fn (&Gen) init_struct

fn (mut g &Gen) init_struct(var Var, init v.ast.StructInit) binaryen.Expression

#fn (&Gen) eval_escape_codes

fn (mut g &Gen) eval_escape_codes(str_lit v.ast.StringLiteral) string

From native, this should be taken out into StringLiteral.eval_escape_codes()

#fn (&Gen) constant_data_intern_offset

fn (mut g &Gen) constant_data_intern_offset(data []u8) ?(int, int)

#fn (&Gen) allocate_string

fn (mut g &Gen) allocate_string(node v.ast.StringLiteral) (int, int)

(offset, len)

#fn (&Gen) get_wasm_type

fn (mut g &Gen) get_wasm_type(typ_ v.ast.Type) binaryen.Type

"Register size" types such as int, i64 and bool boil down to their WASM counterparts.

Structures and unions are pointers, i32.

#fn (&Gen) infix_from_typ

fn (mut g &Gen) infix_from_typ(typ v.ast.Type, op v.token.Kind) binaryen.Op

#fn (&Gen) bake_constants_plus_initialisers

fn (mut g &Gen) bake_constants_plus_initialisers() []GlobalData

#fn (&Gen) make_vinit

fn (mut g &Gen) make_vinit() binaryen.Function

#fn (&Gen) housekeeping

fn (mut g &Gen) housekeeping()

Interfaces

This section is empty.

Enums

This section is empty.