Module v.ast stdlib

Dependencies from vmod:
Imported by:
Show selected OS-specific symbols.
Show selected Backend-specific symbols.

Dependencies defined in v.mod

This section is empty.


#type EmptyExpr

type EmptyExpr = u8

#type Type

type Type = int

#fn (Type) atomic_typename

fn (t Type) atomic_typename() string

<atomic.h> defines special typenames

#fn (Type) share

fn (t Type) share() ShareType

#fn (Type) idx

fn (t Type) idx() int

return TypeSymbol idx for t

#fn (Type) is_void

fn (t Type) is_void() bool

#fn (Type) is_full

fn (t Type) is_full() bool

#fn (Type) nr_muls

fn (t Type) nr_muls() int

return nr_muls for t

#fn (Type) is_ptr

fn (t Type) is_ptr() bool

return true if t is a pointer (nr_muls>0)

#fn (Type) is_any_kind_of_pointer

fn (t Type) is_any_kind_of_pointer() bool

#fn (Type) set_nr_muls

fn (t Type) set_nr_muls(nr_muls int) Type

set nr_muls on t and return it

#fn (Type) ref

fn (t Type) ref() Type

increments nr_muls on t and return it

#fn (Type) deref

fn (t Type) deref() Type

decrement nr_muls on t and return it

#fn (Type) set_flag

fn (t Type) set_flag(flag TypeFlag) Type

set flag on t and return t

#fn (Type) clear_flag

fn (t Type) clear_flag(flag TypeFlag) Type

clear flag on t and return t

#fn (Type) clear_flags

fn (t Type) clear_flags(flags []TypeFlag) Type

clear all flags or multi flags

#fn (Type) has_flag

fn (t Type) has_flag(flag TypeFlag) bool

return true if flag is set on t

#fn (Type) str

fn (t Type) str() string

#fn (Type) debug

fn (t Type) debug() []string

debug returns a verbose representation of the information in the type t, useful for tracing/debugging

#fn (Type) derive

fn (t Type) derive(t_from Type) Type

copy flags & nr_muls from t_from to t and return t

#fn (Type) derive_add_muls

fn (t Type) derive_add_muls(t_from Type) Type

copy flags from t_from to t and return t

#fn (Type) is_pointer

fn (typ Type) is_pointer() bool

#fn (Type) is_voidptr

fn (typ Type) is_voidptr() bool

#fn (Type) is_real_pointer

fn (typ Type) is_real_pointer() bool

#fn (Type) is_float

fn (typ Type) is_float() bool

#fn (Type) is_int

fn (typ Type) is_int() bool

#fn (Type) is_int_valptr

fn (typ Type) is_int_valptr() bool

#fn (Type) is_float_valptr

fn (typ Type) is_float_valptr() bool

#fn (Type) is_pure_int

fn (typ Type) is_pure_int() bool

#fn (Type) is_pure_float

fn (typ Type) is_pure_float() bool

#fn (Type) is_signed

fn (typ Type) is_signed() bool

#fn (Type) is_unsigned

fn (typ Type) is_unsigned() bool

#fn (Type) flip_signedness

fn (typ Type) flip_signedness() Type

#fn (Type) is_int_literal

fn (typ Type) is_int_literal() bool

#fn (Type) is_number

fn (typ Type) is_number() bool

#fn (Type) is_string

fn (typ Type) is_string() bool

#fn (Type) is_bool

fn (typ Type) is_bool() bool


#constant empty_expr

empty_expr = Expr(EmptyExpr(0))

#constant empty_stmt

empty_stmt = Stmt(EmptyStmt{})

#constant empty_node

empty_node = Node(EmptyNode{})

#constant x86_no_number_register_list

x86_no_number_register_list = {
	8:  ['al', 'ah', 'bl', 'bh', 'cl', 'ch', 'dl', 'dh', 'bpl', 'sil', 'dil', 'spl']
	16: ['ax', 'bx', 'cx', 'dx', 'bp', 'si', 'di', 'sp', /* segment registers */ 'cs', 'ss',
		'ds', 'es', 'fs', 'gs', 'flags', 'ip', /* task registers */ 'gdtr', 'idtr', 'tr', 'ldtr',
		// CSR register 'msw', /* FP core registers */ 'cw', 'sw', 'tw', 'fp_ip', 'fp_dp',
		'fp_cs', 'fp_ds', 'fp_opc']
	32: [
		'eip', /* CSR register */
		'mxcsr' /* 32-bit FP core registers 'fp_dp', 'fp_ip' (TODO: why are there duplicates?) */,
	64: ['rax', 'rbx', 'rcx', 'rdx', 'rbp', 'rsi', 'rdi', 'rsp', 'rflags', 'rip']

#constant x86_with_number_register_list

x86_with_number_register_list = {
	8:   {
		'r#b': 16
	16:  {
		'r#w': 16
	32:  {
		'r#d': 16
	64:  {
		'r#':  16
		'mm#': 16
		'cr#': 16
		'dr#': 16
	80:  {
		'st#': 16
	128: {
		'xmm#': 32
	256: {
		'ymm#': 32
	512: {
		'zmm#': 32

#constant arm_no_number_register_list

arm_no_number_register_list   = ['fp' /* aka r11 */, /* not instruction pointer: */ 'ip' /* aka r12 */,
	'sp' /* aka r13 */, 'lr' /* aka r14 */, /* this is instruction pointer ('program counter'): */
	'pc' /* aka r15 */,
] // 'cpsr' and 'apsr' are special flags registers, but cannot be referred to directly

TODO: saved priviled registers for arm

#constant arm_with_number_register_list

arm_with_number_register_list = {
	'r#': 16

TODO: saved priviled registers for arm

#constant riscv_no_number_register_list

riscv_no_number_register_list   = ['zero', 'ra', 'sp', 'gp', 'tp']

#constant riscv_with_number_register_list

riscv_with_number_register_list = {
	'x#': 32
	't#': 3
	's#': 12
	'a#': 8

#constant native_builtins

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

#constant invalid_type_idx

pub const invalid_type_idx = -1

#constant invalid_type_symbol

pub const invalid_type_symbol = &TypeSymbol{
	idx: invalid_type_idx
	parent_idx: invalid_type_idx
	language: .v
	mod: 'builtin'
	kind: .placeholder
	name: 'InvalidType'
	cname: 'InvalidType'

#constant void_type_idx

void_type_idx          = 1

#constant voidptr_type_idx

voidptr_type_idx       = 2

#constant byteptr_type_idx

byteptr_type_idx       = 3

#constant charptr_type_idx

charptr_type_idx       = 4

#constant i8_type_idx

i8_type_idx            = 5

#constant i16_type_idx

i16_type_idx           = 6

#constant int_type_idx

int_type_idx           = 7

#constant i64_type_idx

i64_type_idx           = 8

#constant isize_type_idx

isize_type_idx         = 9

#constant u8_type_idx

u8_type_idx            = 10

#constant u16_type_idx

u16_type_idx           = 11

#constant u32_type_idx

u32_type_idx           = 12

#constant u64_type_idx

u64_type_idx           = 13

#constant usize_type_idx

usize_type_idx         = 14

#constant f32_type_idx

f32_type_idx           = 15

#constant f64_type_idx

f64_type_idx           = 16

#constant char_type_idx

char_type_idx          = 17

#constant bool_type_idx

bool_type_idx          = 18

#constant none_type_idx

none_type_idx          = 19

#constant string_type_idx

string_type_idx        = 20

#constant rune_type_idx

rune_type_idx          = 21

#constant array_type_idx

array_type_idx         = 22

#constant map_type_idx

map_type_idx           = 23

#constant chan_type_idx

chan_type_idx          = 24

#constant any_type_idx

any_type_idx           = 25

#constant float_literal_type_idx

float_literal_type_idx = 26

#constant int_literal_type_idx

int_literal_type_idx   = 27

#constant thread_type_idx

thread_type_idx        = 28

#constant error_type_idx

error_type_idx         = 29

#constant nil_type_idx

nil_type_idx           = 30

#constant builtin_type_names

pub const builtin_type_names = ['void', 'voidptr', 'byteptr', 'charptr', 'i8', 'i16', 'int', 'i64',
	'isize', 'u8', 'u16', 'u32', 'u64', 'usize', 'f32', 'f64', 'char', 'bool', 'none', 'string',
	'rune', 'array', 'map', 'chan', 'any', 'float_literal', 'int_literal', 'thread', 'Error', 'nil']

Note: builtin_type_names must be in the same order as the idx consts above

#constant builtin_type_names_matcher

pub const builtin_type_names_matcher = token.new_keywords_matcher_from_array_trie(builtin_type_names)

#constant integer_type_idxs

integer_type_idxs          = [i8_type_idx, i16_type_idx, int_type_idx, i64_type_idx, u8_type_idx,
	u16_type_idx, u32_type_idx, u64_type_idx, isize_type_idx, usize_type_idx,
	int_literal_type_idx, rune_type_idx]

#constant signed_integer_type_idxs

signed_integer_type_idxs   = [char_type_idx, i8_type_idx, i16_type_idx, int_type_idx,
	i64_type_idx, isize_type_idx]

#constant unsigned_integer_type_idxs

unsigned_integer_type_idxs = [u8_type_idx, u16_type_idx, u32_type_idx, u64_type_idx,

#constant int_promoted_type_idxs

int_promoted_type_idxs     = [char_type_idx, i8_type_idx, i16_type_idx, u8_type_idx, u16_type_idx]

#constant float_type_idxs

float_type_idxs            = [f32_type_idx, f64_type_idx, float_literal_type_idx]

#constant number_type_idxs

number_type_idxs           = [i8_type_idx, i16_type_idx, int_type_idx, i64_type_idx, u8_type_idx,
	char_type_idx, u16_type_idx, u32_type_idx, u64_type_idx, isize_type_idx, usize_type_idx,
	f32_type_idx, f64_type_idx, int_literal_type_idx, float_literal_type_idx, rune_type_idx]

#constant pointer_type_idxs

pointer_type_idxs          = [voidptr_type_idx, byteptr_type_idx, charptr_type_idx, nil_type_idx]

#constant string_type_idxs

string_type_idxs           = [string_type_idx]

#constant void_type

void_type          = new_type(void_type_idx)

#constant ovoid_type

ovoid_type         = new_type(void_type_idx).set_flag(.option) // the return type of `fn ()?`

#constant rvoid_type

rvoid_type         = new_type(void_type_idx).set_flag(.result) // the return type of `fn () !`

#constant voidptr_type

voidptr_type       = new_type(voidptr_type_idx)

#constant byteptr_type

byteptr_type       = new_type(byteptr_type_idx)

#constant charptr_type

charptr_type       = new_type(charptr_type_idx)

#constant i8_type

i8_type            = new_type(i8_type_idx)

#constant int_type

int_type           = new_type(int_type_idx)

#constant i16_type

i16_type           = new_type(i16_type_idx)

#constant i64_type

i64_type           = new_type(i64_type_idx)

#constant isize_type

isize_type         = new_type(isize_type_idx)

#constant u8_type

u8_type            = new_type(u8_type_idx)

#constant u16_type

u16_type           = new_type(u16_type_idx)

#constant u32_type

u32_type           = new_type(u32_type_idx)

#constant u64_type

u64_type           = new_type(u64_type_idx)

#constant usize_type

usize_type         = new_type(usize_type_idx)

#constant f32_type

f32_type           = new_type(f32_type_idx)

#constant f64_type

f64_type           = new_type(f64_type_idx)

#constant char_type

char_type          = new_type(char_type_idx)

#constant bool_type

bool_type          = new_type(bool_type_idx)

#constant none_type

none_type          = new_type(none_type_idx)

#constant string_type

string_type        = new_type(string_type_idx)

#constant rune_type

rune_type          = new_type(rune_type_idx)

#constant array_type

array_type         = new_type(array_type_idx)

#constant map_type

map_type           = new_type(map_type_idx)

#constant chan_type

chan_type          = new_type(chan_type_idx)

#constant any_type

any_type           = new_type(any_type_idx)

#constant float_literal_type

float_literal_type = new_type(float_literal_type_idx)

#constant int_literal_type

int_literal_type   = new_type(int_literal_type_idx)

#constant thread_type

thread_type        = new_type(thread_type_idx)

#constant error_type

error_type         = new_type(error_type_idx)

#constant charptr_types

charptr_types      = new_charptr_types()

#constant byteptr_types

byteptr_types      = new_byteptr_types()

#constant voidptr_types

voidptr_types      = new_voidptr_types()

#constant cptr_types

cptr_types         = merge_types(voidptr_types, byteptr_types, charptr_types)

#constant nil_type

nil_type           = new_type(nil_type_idx)

Sum types

#type TypeDecl

#type Expr

pub type Expr = AnonFn

#fn (Expr) is_blank_ident

fn (expr Expr) is_blank_ident() bool

#fn (Expr) pos

fn (expr Expr) pos() v.token.Pos

#fn (Expr) is_lvalue

fn (expr Expr) is_lvalue() bool

#fn (Expr) is_expr

fn (expr Expr) is_expr() bool

#fn (Expr) is_pure_literal

fn (expr Expr) is_pure_literal() bool

#fn (Expr) is_auto_deref_var

fn (expr Expr) is_auto_deref_var() bool

#fn (&Expr) is_lockable

fn (e &Expr) is_lockable() bool

returns if an expression can be used in lock x, y.z {

#fn (Expr) is_literal

fn (expr Expr) is_literal() bool

is expr a literal, i.e. it does not depend on any other declarations (C compile time constant)

#fn (Expr) is_nil

fn (e Expr) is_nil() bool

#fn (Expr) str

fn (x Expr) str() string

string representation of expr

#type Stmt

pub type Stmt = AsmStmt

#fn (Stmt) str

fn (node Stmt) str() string

#type ScopeObject

#fn (ScopeObject) is_simple_define_const

fn (obj ScopeObject) is_simple_define_const() bool

#type Node

pub type Node = CallArg

TODO: replace Param

#fn (Node) pos

fn (node Node) pos() v.token.Pos

#fn (Node) children

fn (node Node) children() []Node

#type IdentInfo

pub type IdentInfo = IdentFn | IdentVar

#type AsmArg

pub type AsmArg = AsmAddressing

[eax+5] | j | displacement literal (e.g. 123 in [rax + 123] ) | eax | true | a | 0.594 | 123 | label_name

#type ComptTimeConstValue

fn (val ComptTimeConstValue) voidptr() ?voidptr

fn (val ComptTimeConstValue) string() ?string

#type TypeInfo

pub type TypeInfo = Aggregate


#fn all_registers

fn all_registers(mut t &Table, arch v.pref.Arch) map[string]ScopeObject

return all the registers for the given architecture

#fn args2str

fn args2str(args []CallArg) string

#fn empty_comptime_const_expr

fn empty_comptime_const_expr() ComptTimeConstValue

#fn merge_types

fn merge_types(params [][]Type) []Type

#fn mktyp

fn mktyp(typ Type) Type

#fn new_type

fn new_type(idx int) Type

return new type with TypeSymbol idx set to idx

#fn new_type_ptr

fn new_type_ptr(idx int, nr_muls int) Type

return new type with TypeSymbol idx set to idx & nr_muls set to nr_muls

#fn pref_arch_to_table_language

fn pref_arch_to_table_language(pref_arch v.pref.Arch) Language

#fn set_global_table

fn set_global_table(t &Table)

#fn sharetype_from_flags

fn sharetype_from_flags(is_shared bool, is_atomic bool) ShareType

#fn type_can_start_with_token

fn type_can_start_with_token(tok &v.token.Token) bool

#fn ([]Attr) contains

fn (attrs []Attr) contains(str string) bool

#fn ([]Attr) find_first

fn (attrs []Attr) find_first(aname string) ?Attr

#fn ([]Attr) find_last

fn (attrs []Attr) find_last(aname string) ?Attr

#fn ([]Attr) find_comptime_define

fn (attrs []Attr) find_comptime_define() ?int

#fn ([]Kind) str

fn (kinds []Kind) str() string


#struct TypeNode

pub struct TypeNode {
	pos token.Pos
pub mut:
	typ Type

#struct ComptimeType

pub struct ComptimeType {
	kind ComptimeTypeKind
	pos  token.Pos

fn (cty ComptimeType) str() string

#struct EmptyStmt

pub struct EmptyStmt {
	pos token.Pos

#struct EmptyNode

pub struct EmptyNode {
	pos token.Pos

#struct Block

pub struct Block {
	stmts     []Stmt
	is_unsafe bool
	pos       token.Pos

{stmts} or unsafe {stmts}

#struct ExprStmt

pub struct ExprStmt {
	pos      token.Pos
	comments []Comment
pub mut:
	expr    Expr
	is_expr bool
	typ     Type

| IncDecStmt k Stand-alone expression in a statement list.

#struct IntegerLiteral

pub struct IntegerLiteral {
	val string
	pos token.Pos

#struct FloatLiteral

pub struct FloatLiteral {
	val string
	pos token.Pos

#struct StringLiteral

pub struct StringLiteral {
	val      string
	is_raw   bool
	language Language
	pos      token.Pos

#struct StringInterLiteral

pub struct StringInterLiteral {
	vals       []string
	fwidths    []int
	precisions []int
	pluss      []bool
	fills      []bool
	fmt_poss   []token.Pos
	pos        token.Pos
pub mut:
	exprs      []Expr
	expr_types []Type
	fmts       []u8
	need_fmts  []bool // an explicit non-default fmt required, e.g. `x`

'name: $name'

#fn (&StringInterLiteral) get_fspec_braces

fn (lit &StringInterLiteral) get_fspec_braces(i int) (string, bool)

Expressions in string interpolations may have to be put in braces if they are non-trivial, if they would interfere with the next character or if a format specification is given. In the latter case the format specifier must be appended, separated by a colon:

'$z $z.b $z.c.x ${x[4]} ${z:8.3f} ${a:-20} ${a>b+2}' This method creates the format specifier (including the colon) or an empty string if none is needed and also returns (as bool) if the expression must be enclosed in braces.

#struct CharLiteral

pub struct CharLiteral {
	val string
	pos token.Pos

#struct BoolLiteral

pub struct BoolLiteral {
	val bool
	pos token.Pos

#struct Nil

pub struct Nil {
	pos token.Pos

#struct SelectorExpr

pub struct SelectorExpr {
	pos        token.Pos
	field_name string
	is_mut     bool // is used for the case `if mut ident.selector is MyType {`, it indicates if the root ident is mutable
	mut_pos    token.Pos
	next_token token.Kind
pub mut:
	expr                Expr // expr.field_name
	expr_type           Type // type of `Foo` in ``
	typ                 Type // type of the entire thing (``)
	name_type           Type // T in `` or typeof in `typeof(expr).name`
	or_block            OrExpr
	gkind_field         GenericKindField // `` =>, `T.typ` => ast.GenericKindField.typ, or .unknown
	scope               &Scope = unsafe { nil }
	from_embed_types    []Type // holds the type of the embed that the method is called from
	has_hidden_receiver bool

#fn (&SelectorExpr) root_ident

fn (e &SelectorExpr) root_ident() ?Ident

root_ident returns the origin ident where the selector started.

#struct Module

pub struct Module {
	name       string // encoding.base64
	short_name string // base64
	attrs      []Attr
	pos        token.Pos
	name_pos   token.Pos // `name` in import name
	is_skipped bool      // module main can be skipped in single file programs

module declaration

#struct StructField

pub struct StructField {
	pos              token.Pos
	type_pos         token.Pos
	option_pos       token.Pos
	comments         []Comment
	i                int
	has_default_expr bool
	attrs            []Attr
	is_pub           bool
	default_val      string
	is_mut           bool
	is_global        bool
	is_volatile      bool
	is_deprecated    bool
pub mut:
	is_recursive     bool
	default_expr     Expr
	default_expr_typ Type
	name             string
	typ              Type
	unaliased_typ    Type
	anon_struct_decl StructDecl // only if the field is an anonymous struct

#fn (&StructField) equals

fn (f &StructField) equals(o &StructField) bool

#struct ConstField

pub struct ConstField {
	mod         string
	name        string
	is_pub      bool
	is_markused bool // an explict `[markused]` tag; the const will NOT be removed by `-skip-unused`, no matter what
	pos         token.Pos
pub mut:
	expr         Expr      // the value expr of field; everything after `=`
	typ          Type      // the type of the const field, it can be any type in V
	comments     []Comment // comments before current const field
	end_comments []Comment // comments that after const field
	// the comptime_expr_value field is filled by the checker, when it has enough
	// info to evaluate the constant at compile time
	comptime_expr_value ComptTimeConstValue = empty_comptime_const_expr()

const field in const declaration group

#fn (&ConstField) comptime_expr_value

fn (obj &ConstField) comptime_expr_value() ?ComptTimeConstValue

#fn (&ConstField) is_simple_define_const

fn (obj &ConstField) is_simple_define_const() bool

#struct ConstDecl

pub struct ConstDecl {
	is_pub bool
	pos    token.Pos
	attrs  []Attr // tags like `[markused]`, valid for all the consts in the list
pub mut:
	fields       []ConstField // all the const fields in the `const (...)` block
	end_comments []Comment    // comments that after last const field
	is_block     bool // const() block

const declaration

#struct StructDecl

pub struct StructDecl {
	pos           token.Pos
	name          string
	generic_types []Type
	is_pub        bool
	// _pos fields for vfmt
	mut_pos      int // mut:
	pub_pos      int // pub:
	pub_mut_pos  int // pub mut:
	global_pos   int // __global:
	module_pos   int // module:
	language     Language
	is_union     bool
	attrs        []Attr
	end_comments []Comment
	embeds       []Embed
pub mut:
	fields []StructField

#struct Embed

pub struct Embed {
	typ      Type
	pos      token.Pos
	comments []Comment

#struct InterfaceEmbedding

pub struct InterfaceEmbedding {
	name     string
	typ      Type
	pos      token.Pos
	comments []Comment

#struct InterfaceDecl

pub struct InterfaceDecl {
	name          string
	typ           Type
	name_pos      token.Pos
	language      Language
	field_names   []string
	is_pub        bool
	mut_pos       int // mut:
	pos           token.Pos
	pre_comments  []Comment
	generic_types []Type
	attrs         []Attr
pub mut:
	methods             []FnDecl
	fields              []StructField
	embeds              []InterfaceEmbedding
	are_embeds_expanded bool

#struct StructInitField

pub struct StructInitField {
	pos           token.Pos
	name_pos      token.Pos
	comments      []Comment
	next_comments []Comment
pub mut:
	expr          Expr   // `val1`
	name          string // 'field1'
	typ           Type   // the type of this field
	expected_type Type
	parent_type   Type

field1: val1

#struct StructInitEmbed

pub struct StructInitEmbed {
	pos           token.Pos
	comments      []Comment
	next_comments []Comment
pub mut:
	expr          Expr
	name          string
	typ           Type
	expected_type Type

#struct StructInit

pub struct StructInit {
	pos             token.Pos
	name_pos        token.Pos
	no_keys         bool // `Foo{val1, val2}`
	is_short_syntax bool // `foo(field1: val1, field2: val2)`
	is_anon         bool //  `x: struct{ foo: bar }`
pub mut:
	unresolved           bool
	pre_comments         []Comment
	typ_str              string // 'Foo'
	typ                  Type   // the type of this struct
	update_expr          Expr   // `a` in `...a`
	update_expr_type     Type
	update_expr_pos      token.Pos
	update_expr_comments []Comment
	is_update_embed      bool
	has_update_expr      bool // has `...a`
	fields               []StructInitField
	embeds               []StructInitEmbed
	generic_types        []Type

s := Foo{ ...a field1: 'hello' }

#struct Import

pub struct Import {
	mod       string // the module name of the import
	alias     string // the `x` in `import xxx as x`
	pos       token.Pos
	mod_pos   token.Pos
	alias_pos token.Pos
	syms_pos  token.Pos
pub mut:
	syms          []ImportSymbol // the list of symbols in `import {symbol1, symbol2}`
	comments      []Comment
	next_comments []Comment

import statement

#struct ImportSymbol

pub struct ImportSymbol {
	pos  token.Pos
	name string

import symbol,for import {symbol} syntax

#struct AnonFn

pub struct AnonFn {
pub mut:
	decl           FnDecl
	inherited_vars []Param
	typ            Type // the type of anonymous fn. Both .typ and are auto generated
	has_gen        map[string]bool // has been generated

anonymous function

#fn (&AnonFn) stringify

fn (node &AnonFn) stringify(t &Table, cur_mod string, m2a map[string]string) string

These methods are used only by vfmt, vdoc, and for debugging.

#struct FnDecl

pub struct FnDecl {
	name               string // 'math.bits.normalize'
	short_name         string // 'normalize'
	mod                string // 'math.bits'
	is_deprecated      bool
	is_pub             bool
	is_variadic        bool
	is_anon            bool
	is_noreturn        bool        // true, when [noreturn] is used on a fn
	is_manualfree      bool        // true, when [manualfree] is used on a fn
	is_main            bool        // true for `fn main()`
	is_test            bool        // true for `fn test_abcde() {}`, false for `fn test_abc(x int) {}`, or for fns that do not start with test_
	is_conditional     bool        // true for `[if abc] fn abc(){}`
	is_exported        bool        // true for `[export: 'exact_C_name']`
	is_keep_alive      bool        // passed memory must not be freed (by GC) before function returns
	is_unsafe          bool        // true, when [unsafe] is used on a fn
	is_markused        bool        // true, when an explict `[markused]` tag was put on a fn; `-skip-unused` will not remove that fn
	is_file_translated bool        // true, when the file it resides in is `[translated]`
	receiver           StructField // TODO this is not a struct field
	receiver_pos       token.Pos   // `(u User)` in `fn (u User) name()` position
	is_method          bool
	method_type_pos    token.Pos // `User` in ` fn (u User)` position
	method_idx         int
	rec_mut            bool // is receiver mutable
	rec_share          ShareType
	language           Language  // V, C, JS
	file_mode          Language  // whether *the file*, where a function was a '.c.v', '.js.v' etc.
	no_body            bool      // just a definition `fn C.malloc()`
	is_builtin         bool      // this function is defined in builtin/strconv
	body_pos           token.Pos // function bodys position
	file               string
	generic_names      []string
	is_direct_arr      bool // direct array access
	attrs              []Attr
	ctdefine_idx       int = -1 // the index in fn.attrs of `[if xyz]`, when such attribute exists
pub mut:
	idx               int // index in an external container; can be used to refer to the function in a more efficient way, just by its integer index
	params            []Param
	stmts             []Stmt
	defer_stmts       []DeferStmt
	return_type       Type
	return_type_pos   token.Pos // `string` in `fn (u User) name() string` position
	has_return        bool
	should_be_skipped bool      // true, when -skip-unused could not find any usages of that function, starting from main + other known used functions
	ninstances        int  // 0 for generic functions with no concrete instances
	has_await         bool // 'true' if this function uses JS.await

	comments      []Comment // comments *after* the header, but *before* `{`; used for InterfaceDecl
	end_comments  []Comment // comments *after* header declarations. E.g.: `fn C.C_func(x int) int // Comment`
	next_comments []Comment // comments that are one line after the decl; used for InterfaceDecl

	source_file &File  = unsafe { nil }
	scope       &Scope = unsafe { nil }
	label_names []string
	pos         token.Pos // function declaration position

function or method declaration

#fn (&FnDecl) new_method_with_receiver_type

fn (f &FnDecl) new_method_with_receiver_type(new_type Type) FnDecl

#fn (&FnDecl) modname

fn (node &FnDecl) modname() string

#fn (&FnDecl) fkey

fn (node &FnDecl) fkey() string

fkey returns a unique name of the function/method.

it is used in table.used_fns and v.markused.

#fn (&FnDecl) stringify

fn (node &FnDecl) stringify(t &Table, cur_mod string, m2a map[string]string) string

#struct Fn

pub struct Fn {
	is_variadic        bool
	language           Language
	is_pub             bool
	is_ctor_new        bool // `[use_new] fn JS.Array.prototype.constructor()`
	is_deprecated      bool // `[deprecated] fn abc(){}`
	is_noreturn        bool // `[noreturn] fn abc(){}`
	is_unsafe          bool // `[unsafe] fn abc(){}`
	is_placeholder     bool
	is_main            bool // `fn main(){}`
	is_test            bool // `fn test_abc(){}`
	is_keep_alive      bool // passed memory must not be freed (by GC) before function returns
	is_method          bool // true for `fn (x T) name()`, and for interface declarations (which are also for methods)
	no_body            bool // a pure declaration like `fn abc(x int)`; used in .vh files, C./JS. fns.
	is_file_translated bool // true, when the file it resides in is `[translated]`
	mod                string
	file               string
	file_mode          Language
	pos                token.Pos
	return_type_pos    token.Pos
pub mut:
	return_type    Type
	receiver_type  Type // != 0, when .is_method == true
	name           string
	params         []Param
	source_fn      voidptr // set in the checker, while processing fn declarations // TODO get rid of voidptr
	usages         int
	generic_names  []string
	dep_names      []string // globals or consts dependent names
	attrs          []Attr   // all fn attributes
	is_conditional bool     // true for `[if abc]fn(){}`
	ctdefine_idx   int      // the index of the attribute, containing the compile time define [if mytag]

#fn (&Fn) method_equals

fn (f &Fn) method_equals(o &Fn) bool

#fn (&Fn) new_method_with_receiver_type

fn (f &Fn) new_method_with_receiver_type(new_type Type) Fn

#fn (&Fn) fkey

fn (node &Fn) fkey() string

#struct Param

pub struct Param {
	pos         token.Pos
	name        string
	is_mut      bool
	is_auto_rec bool
	type_pos    token.Pos
	is_hidden   bool // interface first arg
pub mut:
	typ Type

#fn (&Param) equals

fn (p &Param) equals(o &Param) bool

#struct BranchStmt

pub struct BranchStmt {
	kind  token.Kind
	label string
	pos   token.Pos

break, continue

#fn (&BranchStmt) str

fn (node &BranchStmt) str() string

#struct CallExpr

pub struct CallExpr {
	pos      token.Pos
	name_pos token.Pos
	mod      string
pub mut:
	name               string //
	is_method          bool
	is_field           bool // temp hack, remove ASAP when re-impl CallExpr / Selector (joe)
	is_fn_var          bool // fn variable, `a := fn() {}`, then: `a()`
	is_fn_a_const      bool // fn const, `const c = abc`, where `abc` is a function, then: `c()`
	is_keep_alive      bool // GC must not free arguments before fn returns
	is_noreturn        bool // whether the function/method is marked as [noreturn]
	is_ctor_new        bool // if JS ctor calls requires `new` before call, marked as `[use_new]` in V
	is_file_translated bool // true, when the file it resides in is `[translated]`
	args               []CallArg
	expected_arg_types []Type
	comptime_ret_val   bool
	language           Language
	or_block           OrExpr
	left               Expr // `user` in `user.register()`
	left_type          Type // type of `user`
	receiver_type      Type // User
	return_type        Type
	fn_var_type        Type   // the fn type, when `is_fn_a_const` or `is_fn_var` is true
	const_name         string // the fully qualified name of the const, i.e. `main.c`, given `const c = abc`, and callexpr: `c()`
	should_be_skipped  bool   // true for calls to `[if someflag?]` functions, when there is no `-d someflag`
	concrete_types     []Type // concrete types, e.g. 
	concrete_list_pos  token.Pos
	raw_concrete_types []Type
	free_receiver      bool // true if the receiver expression needs to be freed
	scope              &Scope = unsafe { nil }
	from_embed_types   []Type // holds the type of the embed that the method is called from
	comments           []Comment

function or method call expr

#fn (&CallExpr) fkey

fn (node &CallExpr) fkey() string

#struct CallArg

pub struct CallArg {
	is_mut   bool
	share    ShareType
	comments []Comment
pub mut:
	expr            Expr
	typ             Type
	is_tmp_autofree bool // this tells cgen that a tmp variable has to be used for the arg expression in order to free it after the call
	pos             token.Pos
	// tmp_name        string // for autofree

function call argument: f(callarg)

#fn (CallArg) str

fn (a CallArg) str() string

#struct Return

pub struct Return {
	pos      token.Pos
	comments []Comment
pub mut:
	exprs []Expr
	types []Type

function return statement

#struct Var

pub struct Var {
	name            string
	share           ShareType
	is_mut          bool
	is_autofree_tmp bool
	is_arg          bool // fn args should not be autofreed
	is_auto_deref   bool
	is_inherited    bool
	has_inherited   bool
pub mut:
	expr       Expr
	typ        Type
	orig_type  Type   // original sumtype type; 0 if it's not a sumtype
	smartcasts []Type // nested sum types require nested smart casting, for that a list of types is needed
	// TODO: move this to a real docs site later
	// 10 <- original type (orig_type)
	//   [11, 12, 13] <- cast order (smartcasts)
	//        12 <- the current casted type (typ)
	pos         token.Pos
	is_used     bool // whether the local variable was used in other expressions
	is_changed  bool // to detect mutable vars that are never changed
	ct_type_var ComptimeVarKind // comptime variable type
	// (for setting the position after the or block for autofree)
	is_or        bool // `x := foo() or { ... }`
	is_tmp       bool // for tmp for loop vars, so that autofree can skip them
	is_auto_heap bool // value whoes address goes out of scope
	is_stack_obj bool // may be pointer to stack value (`mut` or `&` arg and not [heap] struct)

#struct ScopeStructField

pub struct ScopeStructField {
	struct_type Type // type of struct
	name        string
	pos         token.Pos
	typ         Type
	smartcasts  []Type // nested sum types require nested smart casting, for that a list of types is needed
	orig_type   Type   // original sumtype type; 0 if it's not a sumtype
	// TODO: move this to a real docs site later
	// 10 <- original type (orig_type)
	//   [11, 12, 13] <- cast order (smartcasts)
	//        12 <- the current casted type (typ)

used for smartcasting only struct fields change type in scopes

#struct GlobalField

pub struct GlobalField {
	name        string
	has_expr    bool
	pos         token.Pos
	typ_pos     token.Pos
	is_markused bool // an explict `[markused]` tag; the global will NOT be removed by `-skip-unused`
	is_volatile bool
pub mut:
	expr     Expr
	typ      Type
	comments []Comment

#struct GlobalDecl

pub struct GlobalDecl {
	mod      string
	pos      token.Pos
	is_block bool   // __global() block
	attrs    []Attr // tags like `[markused]`, valid for all the globals in the list
pub mut:
	fields       []GlobalField
	end_comments []Comment

#struct EmbeddedFile

pub struct EmbeddedFile {
	compression_type string
pub mut:
	rpath string // used in the source code, as an ID/key to the embed
	apath string // absolute path during compilation to the resource
	// these are set by gen_embed_file_init in v/gen/c/embed
	is_compressed bool
	bytes         []u8
	len           int

#fn (EmbeddedFile) hash

fn (e EmbeddedFile) hash() u64

#struct File

pub struct File {
	nr_lines      int    // number of source code lines in the file (including newlines and comments)
	nr_bytes      int    // number of processed source code bytes
	mod           Module // the module of the source file (from `module xyz` at the top)
	global_scope  &Scope = unsafe { nil }
	is_test       bool // true for _test.v files
	is_generated  bool // true for `[generated] module xyz` files; turn off notices
	is_translated bool // true for `[translated] module xyz` files; turn off some checks
pub mut:
	idx              int    // index in an external container; can be used to refer to the file in a more efficient way, just by its integer index
	path             string // absolute path of the source file - '/projects/v/file.v'
	path_base        string // file name - 'file.v' (useful for tracing)
	scope            &Scope = unsafe { nil }
	stmts            []Stmt            // all the statements in the source file
	imports          []Import          // all the imports
	auto_imports     []string          // imports that were implicitely added
	embedded_files   []EmbeddedFile    // list of files to embed in the binary
	imported_symbols map[string]string // used for `import {symbol}`, it maps symbol => module.symbol
	errors           []errors.Error    // all the checker errors in the file
	warnings         []errors.Warning  // all the checker warnings in the file
	notices          []errors.Notice   // all the checker notices in the file
	generic_fns      []&FnDecl
	global_labels    []string // from `asm { .globl labelname }`
	template_paths   []string // all the .html/.md files that were processed with $tmpl

Each V source file is represented by one File structure.

When the V compiler runs, the parser will fill an []File.

That array is then passed to V's checker.

#fn (&File) free

fn (f &File) free()

#struct IdentFn

pub struct IdentFn {
pub mut:
	typ Type

#struct IdentVar

pub struct IdentVar {
pub mut:
	typ         Type
	is_mut      bool
	is_static   bool
	is_volatile bool
	is_option   bool
	share       ShareType

TODO: (joe) remove completely, use ident.obj instead which points to the scope object

#struct Ident

pub struct Ident {
	language Language
	tok_kind token.Kind
	pos      token.Pos
	mut_pos  token.Pos
	comptime bool
pub mut:
	scope   &Scope = unsafe { nil }
	obj     ScopeObject
	mod     string
	name    string
	kind    IdentKind
	info    IdentInfo
	is_mut  bool // if mut *token* is before name. Use `is_mut()` to lookup mut variable
	or_expr OrExpr

A single identifier

#fn (&Ident) is_mut

fn (i &Ident) is_mut() bool

#fn (&Ident) var_info

fn (i &Ident) var_info() IdentVar

#struct InfixExpr

pub struct InfixExpr {
	op      token.Kind
	pos     token.Pos
	is_stmt bool
pub mut:
	left          Expr
	right         Expr
	left_type     Type
	right_type    Type
	promoted_type Type = void_type
	auto_locked   string
	or_block      OrExpr

	ct_left_value_evaled  bool
	ct_left_value         ComptTimeConstValue = empty_comptime_const_expr()
	ct_right_value_evaled bool
	ct_right_value        ComptTimeConstValue = empty_comptime_const_expr()

	before_op_comments []Comment
	after_op_comments  []Comment

left op right See: token.Kind.is_infix

#struct PostfixExpr

pub struct PostfixExpr {
	op            token.Kind
	pos           token.Pos
	is_c2v_prefix bool // for `--x` (`x--$`), only for translated code until c2v can handle it
pub mut:
	expr        Expr
	typ         Type
	auto_locked string

++, --

#struct PrefixExpr

pub struct PrefixExpr {
	op  token.Kind
	pos token.Pos
pub mut:
	right_type Type
	right      Expr
	or_block   OrExpr
	is_option  bool // IfGuard

See: token.Kind.is_prefix

#struct IndexExpr

pub struct IndexExpr {
	pos token.Pos
pub mut:
	index     Expr // [0], RangeExpr [start..end] or map[key]
	or_expr   OrExpr
	left      Expr
	left_type Type // array, map, fixed array
	is_setter bool
	is_map    bool
	is_array  bool
	is_farray bool
	is_option bool // IfGuard
	is_direct bool // Set if the underlying memory can be safely accessed
	is_gated  bool // #[] gated array

#fn (&IndexExpr) recursive_mapset_is_setter

fn (mut lx &IndexExpr) recursive_mapset_is_setter(val bool)

helper for dealing with m[k1][k2][k3][k3] = value

#fn (&IndexExpr) recursive_arraymap_set_is_setter

fn (mut lx &IndexExpr) recursive_arraymap_set_is_setter()

#struct IfExpr

pub struct IfExpr {
	is_comptime   bool
	tok_kind      token.Kind
	pos           token.Pos
	post_comments []Comment
pub mut:
	left     Expr       // `a` in `a := if ...`
	branches []IfBranch // includes all `else if` branches
	is_expr  bool
	typ      Type
	has_else bool
	// implements bool // comptime $if implements interface

#struct IfBranch

pub struct IfBranch {
	pos      token.Pos
	body_pos token.Pos
	comments []Comment
pub mut:
	cond      Expr
	pkg_exist bool
	stmts     []Stmt
	scope     &Scope = unsafe { nil }

#struct UnsafeExpr

pub struct UnsafeExpr {
	pos token.Pos
pub mut:
	expr Expr

#struct LockExpr

pub struct LockExpr {
	is_rlock []bool
	pos      token.Pos
pub mut:
	stmts    []Stmt
	lockeds  []Expr // `x`, `y.z` in `lock x, y.z {`
	comments []Comment
	is_expr  bool
	typ      Type
	scope    &Scope = unsafe { nil }

#struct MatchExpr

pub struct MatchExpr {
	tok_kind token.Kind
	pos      token.Pos
	comments []Comment // comments before the first branch
pub mut:
	cond          Expr
	branches      []MatchBranch
	is_expr       bool // returns a value
	return_type   Type
	cond_type     Type // type of `x` in `match x {`
	expected_type Type // for debugging only
	is_sum_type   bool

#struct MatchBranch

pub struct MatchBranch {
	ecmnts        [][]Comment // inline comments for each left side expr
	pos           token.Pos
	is_else       bool
	post_comments []Comment // comments below ´... }´
	branch_pos    token.Pos // for checker errors about invalid branches
pub mut:
	stmts []Stmt // right side
	exprs []Expr // left side
	scope &Scope = unsafe { nil }

#struct SelectExpr

pub struct SelectExpr {
	branches      []SelectBranch
	pos           token.Pos
	has_exception bool
pub mut:
	is_expr       bool // returns a value
	expected_type Type // for debugging only

#struct SelectBranch

pub struct SelectBranch {
	pos           token.Pos
	comment       Comment // comment above `select {`
	is_else       bool
	is_timeout    bool
	post_comments []Comment
pub mut:
	stmt  Stmt   // `a := <-ch` or `ch <- a`
	stmts []Stmt // right side

#struct ComptimeFor

pub struct ComptimeFor {
	val_var string
	stmts   []Stmt
	kind    ComptimeForKind
	pos     token.Pos
	typ_pos token.Pos
pub mut:
	typ Type

#struct ForStmt

pub struct ForStmt {
	is_inf   bool // `for {}`
	pos      token.Pos
	comments []Comment
pub mut:
	cond  Expr
	stmts []Stmt
	label string // `label: for {`
	scope &Scope = unsafe { nil }

#struct ForInStmt

pub struct ForInStmt {
	key_var    string
	val_var    string
	is_range   bool
	high       Expr // `10` in `for i in 0..10 {`
	stmts      []Stmt
	pos        token.Pos
	comments   []Comment
	val_is_mut bool // `for mut val in vals {` means that modifying `val` will modify the array
	// and the array cannot be indexed inside the loop
pub mut:
	val_is_ref bool // `for val in &arr {` means that value of `val` will be the reference of the value in `arr`
	cond       Expr
	key_type   Type
	val_type   Type
	cond_type  Type
	high_type  Type
	kind       Kind   // array/map/string
	label      string // `label: for {`
	scope      &Scope = unsafe { nil }

#struct ForCStmt

pub struct ForCStmt {
	has_init bool
	has_cond bool
	has_inc  bool
	is_multi bool // for a,b := 0,1; a < 10; a,b = a+b, a {...}
	pos      token.Pos
	comments []Comment
pub mut:
	init  Stmt // i := 0;
	cond  Expr // i < 10;
	inc   Stmt // i++; i += 2
	stmts []Stmt
	label string // `label: for {`
	scope &Scope = unsafe { nil }

#struct HashStmt

pub struct HashStmt {
	mod         string
	pos         token.Pos
	source_file string
pub mut:
	val      string // example: 'include  # please install openssl // comment'
	kind     string // : 'include'
	main     string // : ''
	msg      string // : 'please install openssl'
	ct_conds []Expr // *all* comptime conditions, that must be true, for the hash to be processed
	// ct_conds is filled by the checker, based on the current nesting of `$if cond1 {}` blocks

#include, #define etc

#struct AssignStmt

pub struct AssignStmt {
	op           token.Kind // include: =,:=,+=,-=,*=,/= and so on; for a list of all the assign operators, see vlib/token/token.v
	pos          token.Pos
	comments     []Comment
	end_comments []Comment
pub mut:
	right         []Expr
	left          []Expr
	left_types    []Type
	right_types   []Type
	is_static     bool // for translated code only
	is_volatile   bool // for disabling variable access optimisations (needed for hardware drivers)
	is_simple     bool // `x+=2` in `for x:=1; ; x+=2`
	has_cross_var bool

variable assign statement

#struct AsCast

pub struct AsCast {
	typ Type // to type
	pos token.Pos
pub mut:
	expr      Expr // from expr: `expr` in `expr as Ident`
	expr_type Type // from type

expr as Ident

#struct EnumVal

pub struct EnumVal {
	enum_name string
	val       string
	mod       string // for full path `mod_Enum_val`
	pos       token.Pos
pub mut:
	typ Type

An enum value, like OS.macos or .macos

#struct EnumField

pub struct EnumField {
	name          string
	pos           token.Pos
	comments      []Comment // comment after Enumfield in the same line
	next_comments []Comment // comments between current EnumField and next EnumField
	has_expr      bool      // true, when .expr has a value
pub mut:
	expr Expr // the value of current EnumField; 123 in `ename = 123`

enum field in enum declaration

#struct EnumDecl

pub struct EnumDecl {
	name             string
	is_pub           bool
	is_flag          bool        // true when the enum has [flag] tag,for bit field enum
	is_multi_allowed bool        // true when the enum has [_allow_multiple_values] tag
	comments         []Comment   // comments before the first EnumField
	fields           []EnumField // all the enum fields
	attrs            []Attr      // attributes of enum declaration
	typ              Type        // the default is `int`; can be changed by `enum Big as u64 { a = 5 }`
	typ_pos          token.Pos
	pos              token.Pos

enum declaration

#struct AliasTypeDecl

pub struct AliasTypeDecl {
	name        string
	is_pub      bool
	typ         Type
	parent_type Type
	pos         token.Pos
	type_pos    token.Pos
	comments    []Comment

#struct SumTypeDecl

pub struct SumTypeDecl {
	name          string
	is_pub        bool
	pos           token.Pos
	name_pos      token.Pos
	comments      []Comment
	typ           Type
	generic_types []Type
	attrs         []Attr // attributes of type declaration
pub mut:
	variants []TypeNode

SumTypeDecl is the ast node for type MySumType = string | int

#struct FnTypeDecl

pub struct FnTypeDecl {
	name          string
	is_pub        bool
	typ           Type
	pos           token.Pos
	type_pos      token.Pos
	comments      []Comment
	generic_types []Type
	attrs         []Attr // attributes of type declaration

#struct DeferStmt

pub struct DeferStmt {
	stmts []Stmt
	pos   token.Pos
pub mut:
	defer_vars []Ident
	ifdef      string
	idx_in_fn  int = -1 // index in FnDecl.defer_stmts

TODO: handle this differently v1 excludes non current os ifdefs so the defer's never get added in the first place

#struct ParExpr

pub struct ParExpr {
	pos token.Pos
pub mut:
	expr Expr


#struct GoExpr

pub struct GoExpr {
	pos token.Pos
pub mut:
	call_expr CallExpr
	is_expr   bool

#struct GotoLabel

pub struct GotoLabel {
	name string
	pos  token.Pos
pub mut:
	is_used bool

#struct GotoStmt

pub struct GotoStmt {
	name string
	pos  token.Pos

#struct ArrayInit

pub struct ArrayInit {
	pos           token.Pos   // `[]` in []Type{} position
	elem_type_pos token.Pos   // `Type` in []Type{} position
	ecmnts        [][]Comment // optional iembed comments after each expr
	pre_cmnts     []Comment
	is_fixed      bool
	has_val       bool // fixed size literal `[expr, expr]!`
	mod           string
	has_len       bool
	has_cap       bool
	has_default   bool
	has_index     bool // true if temp variable index is used
pub mut:
	exprs        []Expr // `[expr, expr]` or `[expr]Type{}` for fixed array
	len_expr     Expr   // len: expr
	cap_expr     Expr   // cap: expr
	default_expr Expr   // init: expr
	expr_types   []Type // [Dog, Cat] // also used for interface_types
	elem_type    Type   // element type
	default_type Type   // default value type
	typ          Type   // array type

#struct ArrayDecompose

pub struct ArrayDecompose {
	pos token.Pos
pub mut:
	expr      Expr
	expr_type Type
	arg_type  Type

#struct ChanInit

pub struct ChanInit {
	pos           token.Pos
	elem_type_pos token.Pos
	has_cap       bool
pub mut:
	cap_expr  Expr
	typ       Type
	elem_type Type

#struct MapInit

pub struct MapInit {
	pos       token.Pos
	comments  [][]Comment // comments after key-value pairs
	pre_cmnts []Comment   // comments before the first key-value pair
pub mut:
	keys       []Expr
	vals       []Expr
	val_types  []Type
	typ        Type
	key_type   Type
	value_type Type

#struct RangeExpr

pub struct RangeExpr {
	has_high bool
	has_low  bool
	pos      token.Pos
	is_gated bool // #[] gated array
pub mut:
	low  Expr
	high Expr
	typ  Type // filled in by checker; the type of `0...1` is `int` for example, while `a`...`z` is `rune` etc


#struct CastExpr

pub struct CastExpr {
pub mut:
	arg       Expr   // `n` in `string(buf, n)`
	typ       Type   // `string`
	expr      Expr   // `buf` in `string(buf, n)` and `&Type(buf)`
	typname   string // `&Type` in `&Type(buf)`
	expr_type Type   // `byteptr`, the type of the `buf` expression
	has_arg   bool   // true for `string(buf, n)`, false for `&Type(buf)`
	pos       token.Pos

#struct AsmStmt

pub struct AsmStmt {
	arch        pref.Arch
	is_basic    bool
	is_volatile bool
	is_goto     bool
	clobbered   []AsmClobbered
	pos         token.Pos
pub mut:
	templates     []AsmTemplate
	scope         &Scope = unsafe { nil }
	output        []AsmIO
	input         []AsmIO
	global_labels []string // labels defined in assembly block, exported with `.globl`
	local_labels  []string // local to the assembly block

#struct AsmTemplate

pub struct AsmTemplate {
pub mut:
	name         string
	is_label     bool // `example_label:`
	is_directive bool // .globl assembly_function
	args         []AsmArg
	comments     []Comment
	pos          token.Pos

#struct AsmRegister

pub struct AsmRegister {
pub mut:
	name string // eax or r12d etc.
	typ  Type
	size int

#struct AsmDisp

pub struct AsmDisp {
	val string
	pos token.Pos

#struct AsmAlias

pub struct AsmAlias {
	pos token.Pos
pub mut:
	name string // a

#struct AsmAddressing

pub struct AsmAddressing {
	scale int = -1 // 1, 2, 4, or 8 literal
	mode  AddressingMode
	pos   token.Pos
pub mut:
	segment      string // fs:
	displacement AsmArg // 8, 16 or 32 bit literal value
	base         AsmArg // gpr
	index        AsmArg // gpr

#struct AsmClobbered

pub struct AsmClobbered {
pub mut:
	reg      AsmRegister
	comments []Comment

#struct AsmIO

pub struct AsmIO {
	alias      string    // [alias_a]
	constraint string    // '=r' TODO: allow all backends to easily use this with a struct
	expr       Expr      // (a)
	comments   []Comment // // this is a comment
	typ        Type
	pos        token.Pos

: [alias_a] '=r' (a) // this is a comment

#struct AssertStmt

pub struct AssertStmt {
	pos       token.Pos
	extra_pos token.Pos
pub mut:
	expr    Expr // `a == 0`
	extra   Expr // `'a is zero'`
	is_used bool // asserts are used in _test.v files, as well as in non -prod builds of all files

assert a == 0, 'a is zero'

#struct IfGuardVar

pub struct IfGuardVar {
pub mut:
	name   string
	is_mut bool
	pos    token.Pos

#struct IfGuardExpr

pub struct IfGuardExpr {
	vars []IfGuardVar
pub mut:
	expr      Expr // `opt()`
	expr_type Type // type of `opt()`

if x := opt() {

#struct OrExpr

pub struct OrExpr {
	stmts []Stmt
	kind  OrKind
	pos   token.Pos

or { ... }

#struct Assoc

pub struct Assoc {
	var_name string
	fields   []string
	pos      token.Pos
pub mut:
	exprs []Expr
	typ   Type
	scope &Scope = unsafe { nil }


#struct SizeOf

pub struct SizeOf {
	guessed_type bool // a legacy `sizeof( GuessedType )` => a deprecation notice, suggesting `v fmt -w .` => `sizeof[ Type ]()`
	is_type      bool
	pos          token.Pos
pub mut:
	expr Expr // checker uses this to set typ, when !is_type
	typ  Type

#struct IsRefType

pub struct IsRefType {
	guessed_type bool // a legacy `isreftype( GuessedType )` => a deprecation notice, suggesting `v fmt -w .` => `isreftype[ Type ]()`
	is_type      bool
	pos          token.Pos
pub mut:
	expr Expr // checker uses this to set typ, when !is_type
	typ  Type

#struct OffsetOf

pub struct OffsetOf {
	struct_type Type
	field       string
	pos         token.Pos

#struct Likely

pub struct Likely {
	pos       token.Pos
	is_likely bool // false for _unlikely_
pub mut:
	expr Expr

#struct TypeOf

pub struct TypeOf {
	is_type bool
	pos     token.Pos
pub mut:
	expr Expr // checker uses this to set typ, when !is_type
	typ  Type

#struct DumpExpr

pub struct DumpExpr {
	pos token.Pos
pub mut:
	expr      Expr
	expr_type Type
	cname     string // filled in the checker

#struct Comment

pub struct Comment {
	text      string
	is_multi  bool // true only for /* comment */, that use many lines
	is_inline bool // true for all /* comment */ comments
	pos       token.Pos

#struct ConcatExpr

pub struct ConcatExpr {
	vals []Expr
	pos  token.Pos
pub mut:
	return_type Type

#struct AtExpr

pub struct AtExpr {
	name string
	pos  token.Pos
	kind token.AtKind
pub mut:
	val string

@FN, @STRUCT, @MOD etc. See full list in token.valid_at_tokens

#struct ComptimeSelector

pub struct ComptimeSelector {
	has_parens bool // if $() is used, for vfmt
	pos        token.Pos
pub mut:
	left       Expr
	left_type  Type
	field_expr Expr
	typ        Type

#struct ComptimeCall

pub struct ComptimeCall {
	pos          token.Pos
	has_parens   bool // if $() is used, for vfmt
	method_name  string
	method_pos   token.Pos
	scope        &Scope = unsafe { nil }
	left         Expr
	is_vweb      bool
	vweb_tmpl    File
	is_embed     bool
	is_env       bool
	env_pos      token.Pos
	is_pkgconfig bool
pub mut:
	left_type   Type
	result_type Type
	env_value   string
	args_var    string
	args        []CallArg
	embed_file  EmbeddedFile

#struct None

pub struct None {
	pos token.Pos

#struct SqlStmt

pub struct SqlStmt {
	db_expr Expr // `db` in `sql db {`
	or_expr OrExpr
	pos     token.Pos
pub mut:
	lines        []SqlStmtLine
	db_expr_type Type // the type of the `db` in `sql db {`

#struct SqlStmtLine

pub struct SqlStmtLine {
	kind         SqlStmtKind
	pos          token.Pos
	where_expr   Expr
	update_exprs []Expr // for `update`
	// is_generated indicates a statement is generated by ORM for complex queries with related tables.
	is_generated bool
	scope        &Scope = unsafe { nil }
pub mut:
	object_var_name string   // `user`
	updated_columns []string // for `update set x=y`
	table_expr      TypeNode
	fields          []StructField
	sub_structs     map[int]SqlStmtLine

#struct SqlExpr

pub struct SqlExpr {
	is_count   bool
	has_where  bool
	has_order  bool
	has_limit  bool
	has_offset bool
	has_desc   bool
	is_array   bool
	// is_generated indicates a statement is generated by ORM for complex queries with related tables.
	is_generated bool
	or_expr      OrExpr
	pos          token.Pos
pub mut:
	typ         Type
	db_expr     Expr // `db` in `sql db {`
	where_expr  Expr
	order_expr  Expr
	limit_expr  Expr
	offset_expr Expr
	table_expr  TypeNode
	fields      []StructField
	sub_structs map[int]SqlExpr

#struct NodeError

pub struct NodeError {
	idx int // index for referencing the related File error
	pos token.Pos

#struct CTempVar

pub struct CTempVar {
	name   string // the name of the C temporary variable; used by g.expr(x)
	typ    Type   // the type of the original expression
	is_ptr bool   // whether the type is a pointer
pub mut:
	orig Expr // the original expression, which produced the C temp variable; used by x.str()

CTempVar is used in cgen only, to hold nodes for temporary variables

#struct Attr

pub struct Attr {
	name    string // [name]
	has_arg bool
	arg     string // [name: arg]
	kind    AttrKind
	ct_expr Expr // .kind == comptime_define, for [if !name]
	ct_opt  bool // true for [if user_defined_name?]
	pos     token.Pos
pub mut:
	ct_evaled bool // whether ct_skip has been evaluated already
	ct_skip   bool // is the comptime expr *false*, filled by checker

e.g. [unsafe]

#fn (&Attr) debug

fn (a &Attr) debug() string

#fn (&Attr) str

fn (a &Attr) str() string

str returns the string representation without square brackets

#struct Scope

pub struct Scope {
pub mut:
	// mut:
	objects              map[string]ScopeObject
	struct_fields        map[string]ScopeStructField
	parent               &Scope = unsafe { nil }
	detached_from_parent bool
	children             []&Scope
	start_pos            int
	end_pos              int

#fn (&Scope) free

fn (s &Scope) free()

#fn (&Scope) dont_lookup_parent

fn (s &Scope) dont_lookup_parent() bool

#fn (&Scope) find

fn (s &Scope) find(name string) ?ScopeObject

#fn (&Scope) find_struct_field

fn (s &Scope) find_struct_field(name string, struct_type Type, field_name string) ?ScopeStructField

selector_expr: name.field_name

#fn (&Scope) find_var

fn (s &Scope) find_var(name string) ?&Var

#fn (&Scope) find_global

fn (s &Scope) find_global(name string) ?&GlobalField

#fn (&Scope) find_const

fn (s &Scope) find_const(name string) ?&ConstField

#fn (&Scope) known_var

fn (s &Scope) known_var(name string) bool

#fn (&Scope) known_global

fn (s &Scope) known_global(name string) bool

#fn (&Scope) known_const

fn (s &Scope) known_const(name string) bool

#fn (&Scope) update_var_type

fn (mut s &Scope) update_var_type(name string, typ Type)

#fn (&Scope) update_ct_var_kind

fn (mut s &Scope) update_ct_var_kind(name string, kind ComptimeVarKind)

#fn (&Scope) register_struct_field

fn (mut s &Scope) register_struct_field(name string, field ScopeStructField)

selector_expr: name.field_name

#fn (&Scope) register

fn (mut s &Scope) register(obj ScopeObject)

#fn (&Scope) innermost

fn (s &Scope) innermost(pos int) &Scope

returns the innermost scope containing pos pub fn (s &Scope) innermost(pos int) ?&Scope {

#fn (&Scope) contains

fn (s &Scope) contains(pos int) bool

#fn (&Scope) has_inherited_vars

fn (s &Scope) has_inherited_vars() bool

#fn (Scope) show

fn (sc Scope) show(depth int, max_depth int) string

#fn (Scope) str

fn (sc Scope) str() string

#struct Table

pub struct Table {
	parsing_type string // name of the type to enable recursive type parsing
pub mut:
	type_symbols       []&TypeSymbol
	type_idxs          map[string]int
	fns                map[string]Fn
	iface_types        map[string][]Type
	dumps              map[int]string // needed for efficiently generating all _v_dump_expr_TNAME() functions
	imports            []string       // List of all imports
	modules            []string       // Topologically sorted list of all modules registered by the application
	global_scope       &Scope = unsafe { nil }
	cflags             []cflag.CFlag
	redefined_fns      []string
	fn_generic_types   map[string][][]Type // for generic functions
	interfaces         map[int]InterfaceDecl
	cmod_prefix        string // needed for ast.type_to_str(Type) while vfmt; contains `os.`
	is_fmt             bool
	used_fns           map[string]bool // filled in by the checker, when pref.skip_unused = true;
	used_consts        map[string]bool // filled in by the checker, when pref.skip_unused = true;
	used_globals       map[string]bool // filled in by the checker, when pref.skip_unused = true;
	used_vweb_types    []Type // vweb context types, filled in by checker, when pref.skip_unused = true;
	used_maps          int    // how many times maps were used, filled in by checker, when pref.skip_unused = true;
	panic_handler      FnPanicHandler = default_table_panic_handler
	panic_userdata     voidptr        = unsafe { nil } // can be used to pass arbitrary data to panic_handler;
	panic_npanics      int
	cur_fn             &FnDecl = unsafe { nil } // previously stored in Checker.cur_fn and Gen.cur_fn
	cur_concrete_types []Type  // current concrete types, e.g. 
	gostmts            int     // how many `go` statements there were in the parsed files.
	// When table.gostmts > 0, __VTHREADS__ is defined, which can be checked with `$if threads {`
	enum_decls        map[string]EnumDecl
	module_deprecated map[string]bool
	module_attrs      map[string][]Attr // module attributes
	builtin_pub_fns   map[string]bool
	pointer_size      int
	// cache for type_to_str_using_aliases
	cached_type_to_str map[u64]string
	anon_struct_names  map[string]int // anon struct name -> struct sym idx
	// counter for anon struct, avoid name conflicts.
	anon_struct_counter int

#fn new_table

fn new_table() &Table

#fn (&Table) has_cflag

fn (t &Table) has_cflag(flag v.cflag.CFlag) bool

check if cflag is in table

#fn (&Table) parse_cflag

fn (mut t &Table) parse_cflag(cflg string, mod string, ctimedefines []string) !

parse the flags to (ast.cflags) []CFlag Note: clean up big time (joe-c)

#fn (&Table) resolve_init

fn (t &Table) resolve_init(node StructInit, typ Type) Expr

#fn (&Table) free

fn (mut t &Table) free()

used by vls to avoid leaks TODO remove manual memory management

#fn (&Table) panic

fn (t &Table) panic(message string)

#fn (&Table) fn_type_signature

fn (t &Table) fn_type_signature(f &Fn) string

used to compare fn's & for naming anon fn's

#fn (&Table) fn_type_source_signature

fn (t &Table) fn_type_source_signature(f &Fn) string

fn_type_source_signature generates the signature of a function which looks like in the V source

#fn (&Table) is_same_method

fn (t &Table) is_same_method(f &Fn, func &Fn) string

#fn (&Table) find_fn

fn (t &Table) find_fn(name string) ?Fn

#fn (&Table) known_fn

fn (t &Table) known_fn(name string) bool

#fn (&Table) register_fn

fn (mut t &Table) register_fn(new_fn Fn)

#fn (&Table) register_interface

fn (mut t &Table) register_interface(idecl InterfaceDecl)

#fn (&Table) register_aggregate_method

fn (t &Table) register_aggregate_method(mut sym &TypeSymbol, name string) !Fn

#fn (&Table) has_method

fn (t &Table) has_method(s &TypeSymbol, name string) bool

#fn (&Table) find_method

fn (t &Table) find_method(s &TypeSymbol, name string) !Fn

find_method searches from current type up through each parent looking for method

#fn (&Table) get_embeds

fn (t &Table) get_embeds(sym &TypeSymbol, options GetEmbedsOptions) [][]Type

get_embeds returns all nested embedded structs the hierarchy of embeds is returned as a list

#fn (&Table) find_method_from_embeds

fn (t &Table) find_method_from_embeds(sym &TypeSymbol, method_name string) !(Fn, []Type)

#fn (&Table) find_method_with_embeds

fn (t &Table) find_method_with_embeds(sym &TypeSymbol, method_name string) !Fn

find_method_with_embeds searches for a given method, also looking through embedded fields

#fn (&Table) get_embed_methods

fn (t &Table) get_embed_methods(sym &TypeSymbol) []Fn

#fn (&Table) register_aggregate_field

fn (t &Table) register_aggregate_field(mut sym &TypeSymbol, name string) !StructField

#fn (&Table) struct_has_field

fn (t &Table) struct_has_field(struct_ &TypeSymbol, name string) bool

#fn (&Table) struct_fields

fn (t &Table) struct_fields(sym &TypeSymbol) []StructField

struct_fields returns all fields including fields from embeds use this instead to get all fields

#fn (&Table) find_field

fn (t &Table) find_field(s &TypeSymbol, name string) !StructField

search from current type up through each parent looking for field

#fn (&Table) find_field_from_embeds

fn (t &Table) find_field_from_embeds(sym &TypeSymbol, field_name string) !(StructField, []Type)

find_field_from_embeds tries to find a field in the nested embeds

#fn (&Table) find_field_with_embeds

fn (t &Table) find_field_with_embeds(sym &TypeSymbol, field_name string) !StructField

find_field_with_embeds searches for a given field, also looking through embedded fields

#fn (&Table) resolve_common_sumtype_fields

fn (t &Table) resolve_common_sumtype_fields(sym_ &TypeSymbol)

#fn (&Table) find_type_idx

fn (t &Table) find_type_idx(name string) int

#fn (&Table) find_sym

fn (t &Table) find_sym(name string) ?&TypeSymbol

#fn (&Table) find_sym_and_type_idx

fn (t &Table) find_sym_and_type_idx(name string) (&TypeSymbol, int)

#fn (&Table) sym_by_idx

fn (t &Table) sym_by_idx(idx int) &TypeSymbol

#fn (&Table) sym

fn (t &Table) sym(typ Type) &TypeSymbol

#fn (&Table) final_sym

fn (t &Table) final_sym(typ Type) &TypeSymbol

final_sym follows aliases until it gets to a "real" Type

#fn (&Table) get_type_name

fn (t &Table) get_type_name(typ Type) string

#fn (&Table) get_final_type_name

fn (t &Table) get_final_type_name(typ Type) string

#fn (&Table) unalias_num_type

fn (t &Table) unalias_num_type(typ Type) Type

#fn (&Table) unaliased_type

fn (t &Table) unaliased_type(typ Type) Type

#fn (&Table) rewrite_already_registered_symbol

fn (mut t &Table) rewrite_already_registered_symbol(typ TypeSymbol, existing_idx int) int

#fn (&Table) register_sym

fn (mut t &Table) register_sym(sym TypeSymbol) int

#fn (&Table) register_enum_decl

fn (mut t &Table) register_enum_decl(enum_decl EnumDecl)

#fn (&Table) register_anon_struct

fn (mut t &Table) register_anon_struct(name string, sym_idx int)

#fn (&Table) known_type

fn (t &Table) known_type(name string) bool

#fn (&Table) start_parsing_type

fn (mut t &Table) start_parsing_type(type_name string)

start_parsing_type open the scope during the parsing of a type where the type name must include the module prefix

#fn (&Table) reset_parsing_type

fn (mut t &Table) reset_parsing_type()

#fn (&Table) known_type_idx

fn (t &Table) known_type_idx(typ Type) bool

#fn (&Table) array_name

fn (t &Table) array_name(elem_type Type) string

array_source_name generates the original name for the v source.

e. g. []int

#fn (&Table) array_cname

fn (t &Table) array_cname(elem_type Type) string

#fn (&Table) array_fixed_name

fn (t &Table) array_fixed_name(elem_type Type, size int, size_expr Expr) string

array_fixed_source_name generates the original name for the v source.

e. g. [16][8]int

#fn (&Table) array_fixed_cname

fn (t &Table) array_fixed_cname(elem_type Type, size int) string

#fn (&Table) chan_name

fn (t &Table) chan_name(elem_type Type, is_mut bool) string

#fn (&Table) chan_cname

fn (t &Table) chan_cname(elem_type Type, is_mut bool) string

#fn (&Table) promise_name

fn (t &Table) promise_name(return_type Type) string

#fn (&Table) promise_cname

fn (t &Table) promise_cname(return_type Type) string

#fn (&Table) thread_name

fn (t &Table) thread_name(return_type Type) string

#fn (&Table) thread_cname

fn (t &Table) thread_cname(return_type Type) string

#fn (&Table) map_name

fn (t &Table) map_name(key_type Type, value_type Type) string

map_source_name generates the original name for the v source.

e. g. map[string]int

#fn (&Table) map_cname

fn (t &Table) map_cname(key_type Type, value_type Type) string

#fn (&Table) find_or_register_chan

fn (mut t &Table) find_or_register_chan(elem_type Type, is_mut bool) int

#fn (&Table) find_or_register_map

fn (mut t &Table) find_or_register_map(key_type Type, value_type Type) int

#fn (&Table) find_or_register_thread

fn (mut t &Table) find_or_register_thread(return_type Type) int

#fn (&Table) find_or_register_promise

fn (mut t &Table) find_or_register_promise(return_type Type) int

#fn (&Table) find_or_register_array

fn (mut t &Table) find_or_register_array(elem_type Type) int

#fn (&Table) find_or_register_array_with_dims

fn (mut t &Table) find_or_register_array_with_dims(elem_type Type, nr_dims int) int

#fn (&Table) find_or_register_array_fixed

fn (mut t &Table) find_or_register_array_fixed(elem_type Type, size int, size_expr Expr) int

#fn (&Table) find_or_register_multi_return

fn (mut t &Table) find_or_register_multi_return(mr_typs []Type) int

#fn (&Table) find_or_register_fn_type

fn (mut t &Table) find_or_register_fn_type(f Fn, is_anon bool, has_decl bool) int

#fn (&Table) add_placeholder_type

fn (mut t &Table) add_placeholder_type(name string, language Language) int

#fn (&Table) value_type

fn (t &Table) value_type(typ Type) Type

#fn (&Table) register_fn_generic_types

fn (mut t &Table) register_fn_generic_types(fn_name string)

#fn (&Table) register_fn_concrete_types

fn (mut t &Table) register_fn_concrete_types(fn_name string, types []Type) bool

#fn (&Table) sumtype_has_variant

fn (t &Table) sumtype_has_variant(parent Type, variant Type, is_as bool) bool

TODO: there is a bug when casting sumtype the other way if its pointer so until fixed at least show v (not C) error x(variant) = y(SumType*)

#fn (&Table) sumtype_check_function_variant

fn (t &Table) sumtype_check_function_variant(parent_info SumType, variant Type, is_as bool) bool

#fn (&Table) sumtype_check_variant_in_type

fn (t &Table) sumtype_check_variant_in_type(parent_info SumType, variant Type, is_as bool) bool

#fn (&Table) sumtype_check_aggregate_variant

fn (t &Table) sumtype_check_aggregate_variant(parent_type Type, aggregate_type &Type, is_as bool) bool

#fn (&Table) sumtype_check_alias_variant

fn (t &Table) sumtype_check_alias_variant(parent_type Type, alias_type Type, is_as bool) bool

#fn (&Table) is_sumtype_or_in_variant

fn (t &Table) is_sumtype_or_in_variant(parent Type, typ Type) bool

#fn (&Table) known_type_names

fn (t &Table) known_type_names() []string

only used for debugging V compiler type bugs

#fn (&Table) has_deep_child_no_ref

fn (t &Table) has_deep_child_no_ref(ts &TypeSymbol, name string) bool

has_deep_child_no_ref returns true if type is struct and has any child or nested child with the type of the given name the given name consists of module and name (mod.Name) it doesn't care about childs that are references

#fn (&Table) complete_interface_check

fn (mut t &Table) complete_interface_check()

complete_interface_check does a MxN check for all M interfaces vs all N types, to determine what types implement what interfaces.

It short circuits most checks when an interface can not possibly be implemented by a type.

#fn (&Table) bitsize_to_type

fn (mut t &Table) bitsize_to_type(bit_size int) Type

bitsize_to_type returns a type corresponding to the bit_size Examples:

8 > i8

32 > int

123 > panic()

128 > [16]u8

608 > [76]u8

#fn (&Table) does_type_implement_interface

fn (t &Table) does_type_implement_interface(typ Type, inter_typ Type) bool

#fn (&Table) resolve_generic_to_concrete

fn (mut t &Table) resolve_generic_to_concrete(generic_type Type, generic_names []string, concrete_types []Type) ?Type

resolve_generic_to_concrete resolves generics to real types T => int.

Even map[string]map[string]T can be resolved.

This is used for resolving the generic return type of CallExpr white unwrap_generic is used to resolve generic usage in FnDecl.

#fn (&Table) generic_type_names

fn (mut t &Table) generic_type_names(generic_type Type) []string

#fn (&Table) unwrap_generic_type

fn (mut t &Table) unwrap_generic_type(typ Type, generic_names []string, concrete_types []Type) Type

#fn (&Table) generic_insts_to_concrete

fn (mut t &Table) generic_insts_to_concrete()

generic struct instantiations to concrete types

#fn (&Table) get_generic_names

fn (t &Table) get_generic_names(generic_types []Type) []string

Extracts all type names from given types, notice that MultiReturn will be decompose and will not included in returned string

#fn (&Table) is_comptime_type

fn (t &Table) is_comptime_type(x Type, y ComptimeType) bool

#fn (&Table) dependent_names_in_expr

fn (t &Table) dependent_names_in_expr(expr Expr) []string

#fn (&Table) dependent_names_in_stmt

fn (t &Table) dependent_names_in_stmt(stmt Stmt) []string

#fn (&Table) type_str

fn (t &Table) type_str(typ Type) string

#fn (&Table) type_kind

fn (t &Table) type_kind(typ Type) Kind

returns TypeSymbol kind only if there are no type modifiers

#fn (&Table) type_is_for_pointer_arithmetic

fn (t &Table) type_is_for_pointer_arithmetic(typ Type) bool

#fn (&Table) register_builtin_type_symbols

fn (mut t &Table) register_builtin_type_symbols()

#fn (&Table) type_size

fn (t &Table) type_size(typ Type) (int, int)

type_size returns the size and alignment (in bytes) of typ, similarly to C's sizeof() and alignof().

#fn (&Table) type_to_str

fn (t &Table) type_to_str(typ Type) string

human readable type name, also used by vfmt

#fn (&Table) type_to_code

fn (mytable &Table) type_to_code(t Type) string

type name in code (for builtin)

#fn (&Table) clean_generics_type_str

fn (t &Table) clean_generics_type_str(typ Type) string

clean type name from generics form. From Type[int] -> Type

#fn (&Table) type_to_str_using_aliases

fn (t &Table) type_to_str_using_aliases(typ Type, import_aliases map[string]string) string

import_aliases is a map of imported symbol aliases 'module.Type' => 'Type'

#fn (&Table) shorten_user_defined_typenames

fn (t &Table) shorten_user_defined_typenames(originalname string, import_aliases map[string]string) string

#fn (&Table) fn_signature

fn (t &Table) fn_signature(func &Fn, opts FnSignatureOpts) string

#fn (&Table) fn_signature_using_aliases

fn (t &Table) fn_signature_using_aliases(func &Fn, import_aliases map[string]string, opts FnSignatureOpts) string

#struct GetEmbedsOptions

pub struct GetEmbedsOptions {
	preceding []Type

#struct TypeSymbol

pub struct TypeSymbol {
	parent_idx int
pub mut:
	info          TypeInfo
	kind          Kind
	name          string // the internal & source name of the type, i.e. `[5]int`.
	cname         string // the name with no dots for use in the generated C code
	rname         string // the raw name
	methods       []Fn
	generic_types []Type
	mod           string
	is_pub        bool
	language      Language
	idx           int
	size          int = -1
	align         int = -1

Represents a type that only needs an identifier, e.g. int, array_int.

A pointer type &T would have a TypeSymbol T.

Note: For a Type, use:

  • Table.type_to_str(typ) not

  • Table.type_kind(typ) not TypeSymbol.kind.

Each TypeSymbol is entered into Table.types.

See also: Table.sym.

#fn (&TypeSymbol) register_method

fn (mut t &TypeSymbol) register_method(new_fn Fn) int

#fn (&TypeSymbol) debug

fn (ts &TypeSymbol) debug() []string

debug returns a verbose representation of the information in ts, useful for tracing/debugging

#fn (&TypeSymbol) dbg

fn (ts &TypeSymbol) dbg() []string

same as .debug(), but without the verbose .info and .methods fields

#fn (&TypeSymbol) dbg_common

fn (ts &TypeSymbol) dbg_common(mut res &[]string)

#fn (&TypeSymbol) str

fn (t &TypeSymbol) str() string

#fn (&TypeSymbol) no_info_panic

fn (t &TypeSymbol) no_info_panic(fname string)

#fn (&TypeSymbol) enum_info

fn (t &TypeSymbol) enum_info() Enum

#fn (&TypeSymbol) mr_info

fn (t &TypeSymbol) mr_info() MultiReturn

#fn (&TypeSymbol) array_info

fn (t &TypeSymbol) array_info() Array

#fn (&TypeSymbol) array_fixed_info

fn (t &TypeSymbol) array_fixed_info() ArrayFixed

#fn (&TypeSymbol) chan_info

fn (t &TypeSymbol) chan_info() Chan

#fn (&TypeSymbol) thread_info

fn (t &TypeSymbol) thread_info() Thread

#fn (&TypeSymbol) map_info

fn (t &TypeSymbol) map_info() Map

#fn (&TypeSymbol) struct_info

fn (t &TypeSymbol) struct_info() Struct

#fn (&TypeSymbol) sumtype_info

fn (t &TypeSymbol) sumtype_info() SumType

#fn (&TypeSymbol) is_heap

fn (t &TypeSymbol) is_heap() bool

#fn (&TypeSymbol) is_pointer

fn (t &TypeSymbol) is_pointer() bool

#fn (&TypeSymbol) is_int

fn (t &TypeSymbol) is_int() bool

#fn (&TypeSymbol) is_float

fn (t &TypeSymbol) is_float() bool

#fn (&TypeSymbol) is_string

fn (t &TypeSymbol) is_string() bool

#fn (&TypeSymbol) is_number

fn (t &TypeSymbol) is_number() bool

#fn (&TypeSymbol) is_bool

fn (t &TypeSymbol) is_bool() bool

#fn (&TypeSymbol) is_primitive

fn (t &TypeSymbol) is_primitive() bool

#fn (&TypeSymbol) is_builtin

fn (t &TypeSymbol) is_builtin() bool

#fn (&TypeSymbol) symbol_name_except_generic

fn (t &TypeSymbol) symbol_name_except_generic() string

symbol_name_except_generic return the name of the complete qualified name of the type, but without the generic parts. For example, main.Abc[int] -> main.Abc

#fn (&TypeSymbol) embed_name

fn (t &TypeSymbol) embed_name() string

#fn (&TypeSymbol) has_method

fn (t &TypeSymbol) has_method(name string) bool

#fn (&TypeSymbol) has_method_with_generic_parent

fn (t &TypeSymbol) has_method_with_generic_parent(name string) bool

#fn (&TypeSymbol) find_method

fn (t &TypeSymbol) find_method(name string) ?Fn

#fn (&TypeSymbol) find_method_with_generic_parent

fn (t &TypeSymbol) find_method_with_generic_parent(name string) ?Fn

#fn (&TypeSymbol) is_js_compatible

fn (t &TypeSymbol) is_js_compatible() bool

is_js_compatible returns true if type can be converted to JS type and from JS type back to V type

#fn (&TypeSymbol) str_method_info

fn (t &TypeSymbol) str_method_info() (bool, bool, int)

#fn (&TypeSymbol) find_field

fn (t &TypeSymbol) find_field(name string) ?StructField

#fn (&TypeSymbol) has_field

fn (t &TypeSymbol) has_field(name string) bool

#struct MultiReturn

pub struct MultiReturn {
pub mut:
	types []Type

#struct FnType

pub struct FnType {
pub mut:
	is_anon  bool
	has_decl bool
	func     Fn

#struct Struct

pub struct Struct {
	attrs []Attr
pub mut:
	embeds         []Type
	fields         []StructField
	is_typedef     bool // C. [typedef]
	is_union       bool
	is_heap        bool
	is_minify      bool
	is_anon        bool
	is_generic     bool
	generic_types  []Type
	concrete_types []Type
	parent_type    Type

#fn (&Struct) find_field

fn (s &Struct) find_field(name string) ?StructField

#fn (&Struct) get_field

fn (s &Struct) get_field(name string) StructField

#struct GenericInst

pub struct GenericInst {
pub mut:
	parent_idx     int    // idx of the base generic struct
	concrete_types []Type // concrete types, e.g. [int, string]

instantiation of a generic struct

#struct Interface

pub struct Interface {
pub mut:
	types   []Type // all types that implement this interface
	fields  []StructField
	methods []Fn
	embeds  []Type
	// `I1 is I2` conversions
	conversions map[int][]Type
	// generic interface support
	is_generic     bool
	generic_types  []Type
	concrete_types []Type
	parent_type    Type

#fn (&Interface) find_field

fn (i &Interface) find_field(name string) ?StructField

#fn (&Interface) find_method

fn (i &Interface) find_method(name string) ?Fn

#fn (&Interface) has_method

fn (i &Interface) has_method(name string) bool

#fn (&Interface) defines_method

fn (i &Interface) defines_method(name string) bool

#struct Enum

pub struct Enum {
	vals             []string
	is_flag          bool
	is_multi_allowed bool
	uses_exprs       bool
	typ              Type

#struct Alias

pub struct Alias {
	parent_type Type
	language    Language
	is_import   bool

#struct Aggregate

pub struct Aggregate {
	fields []StructField // used for faster lookup inside the module
	sum_type Type
	types    []Type

#fn (&Aggregate) find_field

fn (a &Aggregate) find_field(name string) ?StructField

#struct Array

pub struct Array {
	nr_dims int
pub mut:
	elem_type Type

#struct ArrayFixed

pub struct ArrayFixed {
	size      int
	size_expr Expr // used by fmt for e.g. ´[my_const]u8´
pub mut:
	elem_type Type

#struct Chan

pub struct Chan {
pub mut:
	elem_type Type
	is_mut    bool

#struct Thread

pub struct Thread {
pub mut:
	return_type Type

#struct Map

pub struct Map {
pub mut:
	key_type   Type
	value_type Type

#struct SumType

pub struct SumType {
pub mut:
	fields       []StructField
	found_fields bool
	is_anon      bool
	// generic sumtype support
	is_generic     bool
	variants       []Type
	generic_types  []Type
	concrete_types []Type
	parent_type    Type

#fn (&SumType) find_field

fn (s &SumType) find_field(name string) ?StructField

#struct FnSignatureOpts

pub struct FnSignatureOpts {
	skip_receiver bool
	type_only     bool


This section is empty.


#enum ComptimeTypeKind

pub enum ComptimeTypeKind {

#enum GenericKindField

pub enum GenericKindField {

#enum StructInitKind

pub enum StructInitKind {

#enum ComptimeVarKind

pub enum ComptimeVarKind {
	no_comptime // it is not a comptime var
	key_var // map key from `for k,v in t.$(`
	value_var // map value from `for k,v in t.$(`
	field_var // comptime field var `a := t.$(`
	generic_param // generic fn parameter

#enum IdentKind

pub enum IdentKind {

#enum ComptimeForKind

pub enum ComptimeForKind {

#enum AddressingMode

pub enum AddressingMode {
	displacement // displacement
	base // base
	base_plus_displacement // base + displacement
	index_times_scale_plus_displacement // (index ∗ scale) + displacement
	base_plus_index_plus_displacement // base + (index ∗ scale) + displacement
	base_plus_index_times_scale_plus_displacement // base + index + displacement
	rip_plus_displacement // rip + displacement

adressing modes:

#enum OrKind

pub enum OrKind {

#enum SqlStmtKind

pub enum SqlStmtKind {

#enum AttrKind

pub enum AttrKind {
	plain // [name]
	string // ['name']
	number // [123]
	bool // [true] || [false]
	comptime_define // [if name]

#enum Language

pub enum Language {
	amd64 // aka x86_64
	arm64 // 64-bit arm
	arm32 // 32-bit arm
	rv64 // 64-bit risc-v
	rv32 // 32-bit risc-v

#enum TypeFlag

pub enum TypeFlag {

max of 8

#enum ShareType

pub enum ShareType {

#fn (ShareType) str

fn (t ShareType) str() string

#enum Kind

pub enum Kind {

#fn (Kind) str

fn (k Kind) str() string

for debugging/errors only, perf is not an issue