v.ast #

Constants #

const (
	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', 'cs', 'ss', 'ds', 'es', 'fs', 'gs',
			'flags', 'ip', 'gdtr', 'idtr', 'tr', 'ldtr', 'fp_cs', 'fp_ds', 'fp_opc']
		32: [
			'eax',
			'ebx',
			'ecx',
			'edx',
			'ebp',
			'esi',
			'edi',
			'esp',
			'eflags',
			'eip',
			'mxcsr',
		]
		64: ['rax', 'rbx', 'rcx', 'rdx', 'rbp', 'rsi', 'rdi', 'rsp', 'rflags', 'rip']
	}

	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
		}
	}
)
const (
	arm_no_number_register_list   = ['fp', 'ip', 'sp', 'lr', 'pc']
	arm_with_number_register_list = {
		'r#': 16
	}
)

TODO: saved priviled registers for arm

const (
	riscv_no_number_register_list   = ['zero', 'ra', 'sp', 'gp', 'tp']
	riscv_with_number_register_list = {
		'x#': 32
		't#': 3
		's#': 12
		'a#': 8
	}
)
const invalid_type_symbol = &TypeSymbol{
	parent_idx: -1
	language: .v
	mod: 'builtin'
	kind: .placeholder
	name: 'InvalidType'
	cname: 'InvalidType'
}
const (
	void_type_idx          = 1
	voidptr_type_idx       = 2
	byteptr_type_idx       = 3
	charptr_type_idx       = 4
	i8_type_idx            = 5
	i16_type_idx           = 6
	int_type_idx           = 7
	i64_type_idx           = 8
	isize_type_idx         = 9
	byte_type_idx          = 10
	u16_type_idx           = 11
	u32_type_idx           = 12
	u64_type_idx           = 13
	usize_type_idx         = 14
	f32_type_idx           = 15
	f64_type_idx           = 16
	char_type_idx          = 17
	bool_type_idx          = 18
	none_type_idx          = 19
	string_type_idx        = 20
	rune_type_idx          = 21
	array_type_idx         = 22
	map_type_idx           = 23
	chan_type_idx          = 24
	any_type_idx           = 25
	float_literal_type_idx = 26
	int_literal_type_idx   = 27
	thread_type_idx        = 28
	error_type_idx         = 29
	u8_type_idx            = 30
)
const (
	integer_type_idxs          = [i8_type_idx, i16_type_idx, int_type_idx, i64_type_idx,
		byte_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]
	signed_integer_type_idxs   = [i8_type_idx, i16_type_idx, int_type_idx, i64_type_idx,
		isize_type_idx]
	unsigned_integer_type_idxs = [byte_type_idx, u16_type_idx, u32_type_idx, u64_type_idx,
		usize_type_idx]
	float_type_idxs            = [f32_type_idx, f64_type_idx, float_literal_type_idx]
	number_type_idxs           = [i8_type_idx, i16_type_idx, int_type_idx, i64_type_idx,
		byte_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]
	pointer_type_idxs          = [voidptr_type_idx, byteptr_type_idx, charptr_type_idx]
	string_type_idxs           = [string_type_idx]
)
const (
	void_type          = new_type(void_type_idx)
	ovoid_type         = new_type(void_type_idx).set_flag(.optional)
	voidptr_type       = new_type(voidptr_type_idx)
	byteptr_type       = new_type(byteptr_type_idx)
	charptr_type       = new_type(charptr_type_idx)
	i8_type            = new_type(i8_type_idx)
	int_type           = new_type(int_type_idx)
	i16_type           = new_type(i16_type_idx)
	i64_type           = new_type(i64_type_idx)
	isize_type         = new_type(isize_type_idx)
	byte_type          = new_type(byte_type_idx)
	u8_type            = new_type(u8_type_idx)
	u16_type           = new_type(u16_type_idx)
	u32_type           = new_type(u32_type_idx)
	u64_type           = new_type(u64_type_idx)
	usize_type         = new_type(usize_type_idx)
	f32_type           = new_type(f32_type_idx)
	f64_type           = new_type(f64_type_idx)
	char_type          = new_type(char_type_idx)
	bool_type          = new_type(bool_type_idx)
	none_type          = new_type(none_type_idx)
	string_type        = new_type(string_type_idx)
	rune_type          = new_type(rune_type_idx)
	array_type         = new_type(array_type_idx)
	map_type           = new_type(map_type_idx)
	chan_type          = new_type(chan_type_idx)
	any_type           = new_type(any_type_idx)
	float_literal_type = new_type(float_literal_type_idx)
	int_literal_type   = new_type(int_literal_type_idx)
	thread_type        = new_type(thread_type_idx)
	error_type         = new_type(error_type_idx)
	charptr_types      = [charptr_type, new_type(char_type_idx).set_nr_muls(1)]
	byteptr_types      = [byteptr_type, new_type(byte_type_idx).set_nr_muls(1)]
	voidptr_types      = [voidptr_type, new_type(voidptr_type_idx).set_nr_muls(1)]
	cptr_types         = merge_types(voidptr_types, byteptr_types, charptr_types)
)
const (
	builtin_type_names = ['void', 'voidptr', 'byteptr', 'charptr', 'i8', 'i16', 'int', 'i64', 'isize',
		'byte', 'u16', 'u32', 'u64', 'usize', 'f32', 'f64', 'char', 'bool', 'none', 'string', 'rune',
		'array', 'map', 'chan', 'any', 'float_literal', 'int_literal', 'thread', 'Error', 'u8']
)

fn all_registers #

fn all_registers(mut t Table, arch 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 empty_expr #

fn empty_expr() Expr

fn empty_node #

fn empty_node() Node

fn empty_stmt #

fn empty_stmt() Stmt

fn merge_types #

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

fn new_table #

fn new_table() &Table

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 pref.Arch) Language

fn resolve_init #

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

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 ([]Attr) contains #

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

fn ([]Attr) find_comptime_define #

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

fn ([]Kind) str #

fn (kinds []Kind) str() string

type AsmArg #

type AsmArg = AsmAddressing
	| AsmAlias
	| AsmDisp
	| AsmRegister
	| BoolLiteral
	| CharLiteral
	| FloatLiteral
	| IntegerLiteral
	| string

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

type ComptTimeConstValue #

type ComptTimeConstValue = EmptyExpr
	| byte
	| f32
	| f64
	| i16
	| i64
	| i8
	| int
	| rune
	| string
	| u16
	| u32
	| u64

fn (ComptTimeConstValue) i8 #

fn (val ComptTimeConstValue) i8() ?i8

fn (ComptTimeConstValue) i16 #

fn (val ComptTimeConstValue) i16() ?i16

fn (ComptTimeConstValue) int #

fn (val ComptTimeConstValue) int() ?int

fn (ComptTimeConstValue) i64 #

fn (val ComptTimeConstValue) i64() ?i64

fn (ComptTimeConstValue) byte #

fn (val ComptTimeConstValue) byte() ?byte

fn (ComptTimeConstValue) u16 #

fn (val ComptTimeConstValue) u16() ?u16

fn (ComptTimeConstValue) u32 #

fn (val ComptTimeConstValue) u32() ?u32

fn (ComptTimeConstValue) u64 #

fn (val ComptTimeConstValue) u64() ?u64

fn (ComptTimeConstValue) f32 #

fn (val ComptTimeConstValue) f32() ?f32

fn (ComptTimeConstValue) f64 #

fn (val ComptTimeConstValue) f64() ?f64

fn (ComptTimeConstValue) string #

fn (val ComptTimeConstValue) string() ?string

type Expr #

type Expr = AnonFn
	| ArrayDecompose
	| ArrayInit
	| AsCast
	| Assoc
	| AtExpr
	| BoolLiteral
	| CTempVar
	| CallExpr
	| CastExpr
	| ChanInit
	| CharLiteral
	| Comment
	| ComptimeCall
	| ComptimeSelector
	| ConcatExpr
	| DumpExpr
	| EmptyExpr
	| EnumVal
	| FloatLiteral
	| GoExpr
	| Ident
	| IfExpr
	| IfGuardExpr
	| IndexExpr
	| InfixExpr
	| IntegerLiteral
	| IsRefType
	| Likely
	| LockExpr
	| MapInit
	| MatchExpr
	| NodeError
	| None
	| OffsetOf
	| OrExpr
	| ParExpr
	| PostfixExpr
	| PrefixExpr
	| RangeExpr
	| SelectExpr
	| SelectorExpr
	| SizeOf
	| SqlExpr
	| StringInterLiteral
	| StringLiteral
	| StructInit
	| TypeNode
	| TypeOf
	| UnsafeExpr

fn (Expr) is_auto_deref_var #

fn (expr Expr) is_auto_deref_var() bool

fn (Expr) is_blank_ident #

fn (expr Expr) is_blank_ident() bool

fn (Expr) is_expr #

fn (expr Expr) is_expr() bool

fn (Expr) is_lit #

fn (expr Expr) is_lit() bool

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_lockable #

fn (e &Expr) is_lockable() bool

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

fn (Expr) is_lvalue #

fn (expr Expr) is_lvalue() bool

fn (Expr) position #

fn (expr Expr) position() token.Position

fn (Expr) str #

fn (x Expr) str() string

string representation of expr

type FnPanicHandler #

type FnPanicHandler = fn (&Table, string)

type IdentInfo #

type IdentInfo = IdentFn | IdentVar

type Node #

type Node = CallArg
	| ConstField
	| EmptyNode
	| EnumField
	| Expr
	| File
	| GlobalField
	| IfBranch
	| MatchBranch
	| NodeError
	| Param
	| ScopeObject
	| SelectBranch
	| Stmt
	| StructField
	| StructInitField

TODO: replace Param

fn (Node) position #

fn (node Node) position() token.Position

fn (Node) children #

fn (node Node) children() []Node

type ScopeObject #

type ScopeObject = AsmRegister | ConstField | GlobalField | Var

fn (ScopeObject) is_simple_define_const #

fn (obj ScopeObject) is_simple_define_const() bool

type Stmt #

type Stmt = AsmStmt
	| AssertStmt
	| AssignStmt
	| Block
	| BranchStmt
	| CompFor
	| ConstDecl
	| DeferStmt
	| EmptyStmt
	| EnumDecl
	| ExprStmt
	| FnDecl
	| ForCStmt
	| ForInStmt
	| ForStmt
	| GlobalDecl
	| GotoLabel
	| GotoStmt
	| HashStmt
	| Import
	| InterfaceDecl
	| Module
	| NodeError
	| Return
	| SqlStmt
	| StructDecl
	| TypeDecl

fn (Stmt) check_c_expr #

fn (stmt Stmt) check_c_expr() ?

check if stmt can be an expression in C

fn (Stmt) str #

fn (node Stmt) str() string

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() Type

clear all 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_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) 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

type TypeDecl #

type TypeDecl = AliasTypeDecl | FnTypeDecl | SumTypeDecl

type TypeInfo #

type TypeInfo = Aggregate
	| Alias
	| Array
	| ArrayFixed
	| Chan
	| Enum
	| FnType
	| GenericInst
	| Interface
	| Map
	| MultiReturn
	| Struct
	| SumType
	| Thread

enum AddressingMode #

enum AddressingMode {
	invalid
	displacement
	base
	base_plus_displacement
	index_times_scale_plus_displacement
	base_plus_index_plus_displacement
	base_plus_index_times_scale_plus_displacement
	rip_plus_displacement
}

adressing modes:

enum AttrKind #

enum AttrKind {
	plain
	string
	number
	comptime_define
}

enum CompForKind #

enum CompForKind {
	methods
	fields
	attributes
}

fn (CompForKind) str #

fn (e CompForKind) str() string

enum GenericKindField #

enum GenericKindField {
	unknown
	name
	typ
}

enum IdentKind #

enum IdentKind {
	unresolved
	blank_ident
	variable
	constant
	global
	function
}

enum Kind #

enum Kind {
	placeholder
	void
	voidptr
	byteptr
	charptr
	i8
	i16
	int
	i64
	isize
	byte
	u8
	u16
	u32
	u64
	usize
	f32
	f64
	char
	rune
	bool
	none_
	string
	array
	array_fixed
	map
	chan
	any
	struct_
	generic_inst
	multi_return
	sum_type
	alias
	enum_
	function
	interface_
	float_literal
	int_literal
	aggregate
	thread
}

fn (Kind) str #

fn (k Kind) str() string

for debugging/errors only, perf is not an issue

enum Language #

enum Language {
	v
	c
	js
	amd64
	i386
	arm64
	arm32
	rv64
	rv32
}

enum OrKind #

enum OrKind {
	absent
	block
	propagate
}

enum ShareType #

enum ShareType {
	mut_t
	shared_t
	atomic_t
}

fn (ShareType) str #

fn (t ShareType) str() string

enum SqlStmtKind #

enum SqlStmtKind {
	insert
	update
	delete
	create
	drop
}

enum TypeFlag #

enum TypeFlag {
	optional
	variadic
	generic
	shared_f
	atomic_f
}

max of 8

struct Aggregate #

struct Aggregate {
mut:
	fields []StructField
pub:
	types []Type
}

struct Alias #

struct Alias {
pub:
	parent_type Type
	language    Language
	is_import   bool
}

struct AliasTypeDecl #

struct AliasTypeDecl {
pub:
	name        string
	is_pub      bool
	parent_type Type
	pos         token.Position
	type_pos    token.Position
	comments    []Comment
}

struct AnonFn #

struct AnonFn {
pub mut:
	decl           FnDecl
	inherited_vars []Param
	typ            Type
	has_gen        bool
}

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 Array #

struct Array {
pub:
	nr_dims int
pub mut:
	elem_type Type
}

struct ArrayDecompose #

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

struct ArrayFixed #

struct ArrayFixed {
pub:
	size      int
	size_expr Expr
pub mut:
	elem_type Type
}

struct ArrayInit #

struct ArrayInit {
pub:
	pos           token.Position
	elem_type_pos token.Position
	exprs         []Expr
	ecmnts        [][]Comment
	pre_cmnts     []Comment
	is_fixed      bool
	has_val       bool
	mod           string
	len_expr      Expr
	cap_expr      Expr
	default_expr  Expr
	has_len       bool
	has_cap       bool
	has_default   bool
	has_it        bool
pub mut:
	expr_types []Type
	elem_type  Type
	typ        Type
}

struct AsCast #

struct AsCast {
pub:
	expr Expr
	typ  Type
	pos  token.Position
pub mut:
	expr_type Type
}

expr as Ident

struct AsmAddressing #

struct AsmAddressing {
pub:
	scale int = -1
	mode  AddressingMode
	pos   token.Position
pub mut:
	segment      string
	displacement AsmArg
	base         AsmArg
	index        AsmArg
}

struct AsmAlias #

struct AsmAlias {
pub:
	pos token.Position
pub mut:
	name string
}

struct AsmClobbered #

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

struct AsmDisp #

struct AsmDisp {
pub:
	val string
	pos token.Position
}

struct AsmIO #

struct AsmIO {
pub:
	alias      string
	constraint string
	expr       Expr
	comments   []Comment
	typ        Type
	pos        token.Position
}

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

struct AsmRegister #

struct AsmRegister {
pub mut:
	name string
	typ  Type
	size int
}

struct AsmStmt #

struct AsmStmt {
pub:
	arch        pref.Arch
	is_basic    bool
	is_volatile bool
	is_goto     bool
	clobbered   []AsmClobbered
	pos         token.Position
pub mut:
	templates     []AsmTemplate
	scope         &Scope
	output        []AsmIO
	input         []AsmIO
	global_labels []string
	local_labels  []string
}

struct AsmTemplate #

struct AsmTemplate {
pub mut:
	name         string
	is_label     bool
	is_directive bool
	args         []AsmArg
	comments     []Comment
	pos          token.Position
}

struct AssertStmt #

struct AssertStmt {
pub:
	pos token.Position
pub mut:
	expr    Expr
	is_used bool
}

struct AssignStmt #

struct AssignStmt {
pub:
	op           token.Kind
	pos          token.Position
	comments     []Comment
	end_comments []Comment
pub mut:
	right         []Expr
	left          []Expr
	left_types    []Type
	right_types   []Type
	is_static     bool
	is_volatile   bool
	is_simple     bool
	has_cross_var bool
}

variable assign statement

struct Assoc #

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

deprecated

struct AtExpr #

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

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

struct Attr #

struct Attr {
pub:
	name    string
	has_arg bool
	arg     string
	kind    AttrKind
	ct_expr Expr
	ct_opt  bool
	pos     token.Position
pub mut:
	ct_evaled bool
	ct_skip   bool
}

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 Block #

struct Block {
pub:
	stmts     []Stmt
	is_unsafe bool
	pos       token.Position
}

{stmts} or unsafe {stmts}

struct BoolLiteral #

struct BoolLiteral {
pub:
	val bool
	pos token.Position
}

struct BranchStmt #

struct BranchStmt {
pub:
	kind  token.Kind
	label string
	pos   token.Position
}

break, continue

fn (BranchStmt) str #

fn (node &BranchStmt) str() string

struct CallArg #

struct CallArg {
pub:
	is_mut   bool
	share    ShareType
	comments []Comment
pub mut:
	expr            Expr
	typ             Type
	is_tmp_autofree bool
	pos             token.Position
}

function call argument: f(callarg)

fn (CallArg) str #

fn (a CallArg) str() string

struct CallExpr #

struct CallExpr {
pub:
	pos      token.Position
	name_pos token.Position
	mod      string
pub mut:
	name               string
	is_method          bool
	is_field           bool
	is_keep_alive      bool
	is_noreturn        bool
	args               []CallArg
	expected_arg_types []Type
	language           Language
	or_block           OrExpr
	left               Expr
	left_type          Type
	receiver_type      Type
	return_type        Type
	should_be_skipped  bool
	concrete_types     []Type
	concrete_list_pos  token.Position
	free_receiver      bool
	scope              &Scope
	from_embed_type    Type
	comments           []Comment
}

function or method call expr

fn (CallExpr) fkey #

fn (node &CallExpr) fkey() string

struct CastExpr #

struct CastExpr {
pub:
	arg Expr
pub mut:
	typ       Type
	expr      Expr
	typname   string
	expr_type Type
	has_arg   bool
	pos       token.Position
}

struct Chan #

struct Chan {
pub mut:
	elem_type Type
	is_mut    bool
}

struct ChanInit #

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

struct CharLiteral #

struct CharLiteral {
pub:
	val string
	pos token.Position
}

struct Comment #

struct Comment {
pub:
	text      string
	is_multi  bool
	is_inline bool
	pos       token.Position
}

struct CompFor #

struct CompFor {
pub:
	val_var string
	stmts   []Stmt
	kind    CompForKind
	pos     token.Position
	typ_pos token.Position
pub mut:
	typ Type
}

struct ComptimeCall #

struct ComptimeCall {
pub:
	pos         token.Position
	has_parens  bool
	method_name string
	method_pos  token.Position
	scope       &Scope
	left        Expr
	args_var    string

	is_vweb   bool
	vweb_tmpl File

	is_embed   bool
	embed_file EmbeddedFile

	is_env  bool
	env_pos token.Position

	is_pkgconfig bool
pub mut:
	sym         TypeSymbol
	result_type Type
	env_value   string
	args        []CallArg
}

struct ComptimeSelector #

struct ComptimeSelector {
pub:
	has_parens bool
	left       Expr
	field_expr Expr
	pos        token.Position
pub mut:
	left_type Type
	typ       Type
}

struct ConcatExpr #

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

struct ConstDecl #

struct ConstDecl {
pub:
	is_pub bool
	pos    token.Position
pub mut:
	fields       []ConstField
	end_comments []Comment
	is_block     bool
}

const declaration

struct ConstField #

struct ConstField {
pub:
	mod    string
	name   string
	expr   Expr
	is_pub bool
	pos    token.Position
pub mut:
	typ      Type
	comments []Comment

	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 CTempVar #

struct CTempVar {
pub:
	name   string
	orig   Expr
	typ    Type
	is_ptr bool
}

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

struct DeferStmt #

struct DeferStmt {
pub:
	stmts []Stmt
	pos   token.Position
pub mut:
	defer_vars []Ident
	ifdef      string
	idx_in_fn  int = -1
}

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

struct DumpExpr #

struct DumpExpr {
pub:
	expr Expr
	pos  token.Position
pub mut:
	expr_type Type
	cname     string
}

struct Embed #

struct Embed {
pub:
	typ      Type
	pos      token.Position
	comments []Comment
}

struct EmbeddedFile #

struct EmbeddedFile {
pub:
	rpath string
	apath string
}

struct EmptyExpr #

struct EmptyExpr {
	x int
}

struct EmptyNode #

struct EmptyNode {
	x int
}

struct EmptyStmt #

struct EmptyStmt {
pub:
	pos token.Position
}

struct Enum #

struct Enum {
pub:
	vals             []string
	is_flag          bool
	is_multi_allowed bool
}

struct EnumDecl #

struct EnumDecl {
pub:
	name             string
	is_pub           bool
	is_flag          bool
	is_multi_allowed bool
	comments         []Comment
	fields           []EnumField
	attrs            []Attr
	pos              token.Position
}

enum declaration

struct EnumField #

struct EnumField {
pub:
	name          string
	pos           token.Position
	comments      []Comment
	next_comments []Comment
	expr          Expr
	has_expr      bool
}

enum field in enum declaration

struct EnumVal #

struct EnumVal {
pub:
	enum_name string
	val       string
	mod       string
	pos       token.Position
pub mut:
	typ Type
}

an enum value, like OS.macos or .macos

struct ExprStmt #

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

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

struct File #

struct File {
pub:
	nr_lines     int
	nr_bytes     int
	mod          Module
	global_scope &Scope
	is_test      bool
pub mut:
	path             string
	path_base        string
	scope            &Scope
	stmts            []Stmt
	imports          []Import
	auto_imports     []string
	embedded_files   []EmbeddedFile
	imported_symbols map[string]string
	errors           []errors.Error
	warnings         []errors.Warning
	notices          []errors.Notice
	generic_fns      []&FnDecl
	global_labels    []string
}

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 #

unsafe
fn (f &File) free()

struct FloatLiteral #

struct FloatLiteral {
pub:
	val string
	pos token.Position
}

struct Fn #

struct Fn {
pub:
	is_variadic     bool
	language        Language
	is_pub          bool
	is_deprecated   bool
	is_noreturn     bool
	is_unsafe       bool
	is_placeholder  bool
	is_main         bool
	is_test         bool
	is_keep_alive   bool
	no_body         bool
	mod             string
	file_mode       Language
	pos             token.Position
	return_type_pos token.Position
pub mut:
	return_type Type
	name        string
	params      []Param
	source_fn   voidptr
	usages      int

	generic_names  []string
	attrs          []Attr
	is_conditional bool
	ctdefine_idx   int
}

fn (Fn) new_method_with_receiver_type #

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

struct FnDecl #

struct FnDecl {
pub:
	name            string
	mod             string
	is_deprecated   bool
	is_pub          bool
	is_variadic     bool
	is_anon         bool
	is_noreturn     bool
	is_manualfree   bool
	is_main         bool
	is_test         bool
	is_conditional  bool
	is_exported     bool
	is_keep_alive   bool
	is_unsafe       bool
	receiver        StructField
	receiver_pos    token.Position
	is_method       bool
	method_type_pos token.Position
	method_idx      int
	rec_mut         bool
	rec_share       ShareType
	language        Language
	file_mode       Language
	no_body         bool
	is_builtin      bool
	body_pos        token.Position
	file            string
	generic_names   []string
	is_direct_arr   bool
	attrs           []Attr
	ctdefine_idx    int = -1
pub mut:
	params            []Param
	stmts             []Stmt
	defer_stmts       []DeferStmt
	return_type       Type
	return_type_pos   token.Position
	has_return        bool
	should_be_skipped bool

	comments      []Comment
	next_comments []Comment

	source_file &File = 0
	scope       &Scope
	label_names []string
	pos         token.Position
}

function or method declaration

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

fn (node &FnDecl) modname() string

fn (FnDecl) new_method_with_receiver_type #

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

fn (FnDecl) stringify #

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

struct FnSignatureOpts #

struct FnSignatureOpts {
	skip_receiver bool
	type_only     bool
}

struct FnType #

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

struct FnTypeDecl #

struct FnTypeDecl {
pub:
	name     string
	is_pub   bool
	typ      Type
	pos      token.Position
	type_pos token.Position
	comments []Comment
}

struct ForCStmt #

struct ForCStmt {
pub:
	init     Stmt
	has_init bool
	cond     Expr
	has_cond bool
	inc      Stmt
	has_inc  bool
	is_multi bool
	stmts    []Stmt
	pos      token.Position
pub mut:
	label string
	scope &Scope
}

struct ForInStmt #

struct ForInStmt {
pub:
	key_var    string
	val_var    string
	cond       Expr
	is_range   bool
	high       Expr
	stmts      []Stmt
	pos        token.Position
	val_is_mut bool
pub mut:
	key_type  Type
	val_type  Type
	cond_type Type
	kind      Kind
	label     string
	scope     &Scope
}

struct ForStmt #

struct ForStmt {
pub:
	cond   Expr
	stmts  []Stmt
	is_inf bool
	pos    token.Position
pub mut:
	label string
	scope &Scope
}

struct GenericInst #

struct GenericInst {
pub mut:
	parent_idx     int
	concrete_types []Type
}

instantiation of a generic struct

struct GetEmbedsOptions #

struct GetEmbedsOptions {
	preceding []Type
}

struct GlobalDecl #

struct GlobalDecl {
pub:
	mod      string
	pos      token.Position
	is_block bool
pub mut:
	fields       []GlobalField
	end_comments []Comment
}

struct GlobalField #

struct GlobalField {
pub:
	name     string
	has_expr bool
	pos      token.Position
	typ_pos  token.Position
pub mut:
	expr     Expr
	typ      Type
	comments []Comment
}

struct GoExpr #

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

struct GotoLabel #

struct GotoLabel {
pub:
	name string
	pos  token.Position
}

struct GotoStmt #

struct GotoStmt {
pub:
	name string
	pos  token.Position
}

struct HashStmt #

struct HashStmt {
pub:
	mod         string
	pos         token.Position
	source_file string
pub mut:
	val      string
	kind     string
	main     string
	msg      string
	ct_conds []Expr
}

#include, #define etc

struct Ident #

struct Ident {
pub:
	language Language
	tok_kind token.Kind
	pos      token.Position
	mut_pos  token.Position
	comptime bool
pub mut:
	scope  &Scope
	obj    ScopeObject
	mod    string
	name   string
	kind   IdentKind
	info   IdentInfo
	is_mut bool
}

A single identifier

fn (Ident) var_info #

fn (i &Ident) var_info() IdentVar

struct IdentFn #

struct IdentFn {
pub mut:
	typ Type
}

struct IdentVar #

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

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

struct IfBranch #

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

struct IfExpr #

struct IfExpr {
pub:
	is_comptime   bool
	tok_kind      token.Kind
	left          Expr
	pos           token.Position
	post_comments []Comment
pub mut:
	branches []IfBranch
	is_expr  bool
	typ      Type
	has_else bool
}

struct IfGuardExpr #

struct IfGuardExpr {
pub:
	var_name string
	pos      token.Position
pub mut:
	expr      Expr
	expr_type Type
}

if [x := opt()] {

struct Import #

struct Import {
pub:
	mod       string
	alias     string
	pos       token.Position
	mod_pos   token.Position
	alias_pos token.Position
	syms_pos  token.Position
pub mut:
	syms          []ImportSymbol
	comments      []Comment
	next_comments []Comment
}

import statement

struct ImportSymbol #

struct ImportSymbol {
pub:
	pos  token.Position
	name string
}

import symbol,for import {symbol} syntax

struct IndexExpr #

struct IndexExpr {
pub:
	pos     token.Position
	index   Expr
	or_expr OrExpr
pub mut:
	left      Expr
	left_type Type
	is_setter bool
	is_map    bool
	is_array  bool
	is_farray bool
	is_option bool
}

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

struct InfixExpr #

struct InfixExpr {
pub:
	op      token.Kind
	pos     token.Position
	is_stmt bool
pub mut:
	left        Expr
	right       Expr
	left_type   Type
	right_type  Type
	auto_locked string
	or_block    OrExpr
}

left op right See: token.Kind.is_infix

struct IntegerLiteral #

struct IntegerLiteral {
pub:
	val string
	pos token.Position
}

struct Interface #

struct Interface {
pub mut:
	types   []Type
	fields  []StructField
	methods []Fn
	ifaces  []Type

	conversions map[int][]Type

	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 InterfaceDecl #

struct InterfaceDecl {
pub:
	name          string
	typ           Type
	name_pos      token.Position
	language      Language
	field_names   []string
	is_pub        bool
	mut_pos       int
	pos           token.Position
	pre_comments  []Comment
	generic_types []Type
pub mut:
	methods []FnDecl
	fields  []StructField

	ifaces              []InterfaceEmbedding
	are_ifaces_expanded bool
}

struct InterfaceEmbedding #

struct InterfaceEmbedding {
pub:
	name     string
	typ      Type
	pos      token.Position
	comments []Comment
}

struct IsRefType #

struct IsRefType {
pub:
	is_type bool
	expr    Expr
	pos     token.Position
pub mut:
	typ Type
}

struct Likely #

struct Likely {
pub:
	expr      Expr
	pos       token.Position
	is_likely bool
}

struct LockExpr #

struct LockExpr {
pub:
	stmts    []Stmt
	is_rlock []bool
	pos      token.Position
pub mut:
	lockeds  []Expr
	comments []Comment
	is_expr  bool
	typ      Type
	scope    &Scope
}

struct Map #

struct Map {
pub mut:
	key_type   Type
	value_type Type
}

struct MapInit #

struct MapInit {
pub:
	pos       token.Position
	keys      []Expr
	vals      []Expr
	comments  [][]Comment
	pre_cmnts []Comment
pub mut:
	typ        Type
	key_type   Type
	value_type Type
}

struct MatchBranch #

struct MatchBranch {
pub:
	ecmnts        [][]Comment
	pos           token.Position
	is_else       bool
	post_comments []Comment
	branch_pos    token.Position
pub mut:
	stmts []Stmt
	exprs []Expr
	scope &Scope
}

struct MatchExpr #

struct MatchExpr {
pub:
	tok_kind token.Kind
	cond     Expr
	branches []MatchBranch
	pos      token.Position
	comments []Comment
pub mut:
	is_expr       bool
	return_type   Type
	cond_type     Type
	expected_type Type
	is_sum_type   bool
}

struct Module #

struct Module {
pub:
	name       string
	short_name string
	attrs      []Attr
	pos        token.Position
	name_pos   token.Position
	is_skipped bool
}

module declaration

struct MultiReturn #

struct MultiReturn {
pub mut:
	types []Type
}

struct NodeError #

struct NodeError {
pub:
	idx int
	pos token.Position
}

struct None #

struct None {
pub:
	pos token.Position
}

struct OffsetOf #

struct OffsetOf {
pub:
	struct_type Type
	field       string
	pos         token.Position
}

struct OrExpr #

struct OrExpr {
pub:
	stmts []Stmt
	kind  OrKind
	pos   token.Position
}

or { ... }

struct Param #

struct Param {
pub:
	pos         token.Position
	name        string
	is_mut      bool
	is_auto_rec bool
	type_pos    token.Position
	is_hidden   bool
pub mut:
	typ Type
}

struct ParExpr #

struct ParExpr {
pub:
	expr Expr
	pos  token.Position
}

(3+4)

struct PostfixExpr #

struct PostfixExpr {
pub:
	op   token.Kind
	expr Expr
	pos  token.Position
pub mut:
	auto_locked string
}

++, --

struct PrefixExpr #

struct PrefixExpr {
pub:
	op  token.Kind
	pos token.Position
pub mut:
	right_type Type
	right      Expr
	or_block   OrExpr
	is_option  bool
}

See: token.Kind.is_prefix

struct RangeExpr #

struct RangeExpr {
pub:
	low      Expr
	high     Expr
	has_high bool
	has_low  bool
	pos      token.Position
}

s[10..20]

struct Return #

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

function return statement

struct Scope #

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

fn (Scope) free #

unsafe
fn (s &Scope) free()

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

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

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 ScopeStructField #

struct ScopeStructField {
pub:
	struct_type Type
	name        string
	pos         token.Position
	typ         Type
	smartcasts  []Type
	orig_type   Type
}

used for smartcasting only struct fields change type in scopes

struct SelectBranch #

struct SelectBranch {
pub:
	stmt          Stmt
	stmts         []Stmt
	pos           token.Position
	comment       Comment
	is_else       bool
	is_timeout    bool
	post_comments []Comment
}

struct SelectExpr #

struct SelectExpr {
pub:
	branches      []SelectBranch
	pos           token.Position
	has_exception bool
pub mut:
	is_expr       bool
	expected_type Type
}

struct SelectorExpr #

struct SelectorExpr {
pub:
	pos        token.Position
	field_name string
	is_mut     bool
	mut_pos    token.Position
	next_token token.Kind
pub mut:
	expr            Expr
	expr_type       Type
	typ             Type
	name_type       Type
	gkind_field     GenericKindField
	scope           &Scope
	from_embed_type Type
}

foo.bar

fn (SelectorExpr) root_ident #

fn (e &SelectorExpr) root_ident() ?Ident

root_ident returns the origin ident where the selector started.

struct SizeOf #

struct SizeOf {
pub:
	is_type bool
	expr    Expr
	pos     token.Position
pub mut:
	typ Type
}

struct SqlExpr #

struct SqlExpr {
pub:
	typ         Type
	is_count    bool
	db_expr     Expr
	has_where   bool
	has_offset  bool
	offset_expr Expr
	has_order   bool
	order_expr  Expr
	has_desc    bool
	is_array    bool
	pos         token.Position
	has_limit   bool
	limit_expr  Expr
pub mut:
	where_expr  Expr
	table_expr  TypeNode
	fields      []StructField
	sub_structs map[int]SqlExpr
}

struct SqlStmt #

struct SqlStmt {
pub:
	pos     token.Position
	db_expr Expr
pub mut:
	lines []SqlStmtLine
}

struct SqlStmtLine #

struct SqlStmtLine {
pub:
	kind         SqlStmtKind
	pos          token.Position
	where_expr   Expr
	update_exprs []Expr
pub mut:
	object_var_name string
	updated_columns []string
	table_expr      TypeNode
	fields          []StructField
	sub_structs     map[int]SqlStmtLine
}

struct StringInterLiteral #

struct StringInterLiteral {
pub:
	vals       []string
	exprs      []Expr
	fwidths    []int
	precisions []int
	pluss      []bool
	fills      []bool
	fmt_poss   []token.Position
	pos        token.Position
pub mut:
	expr_types []Type
	fmts       []byte
	need_fmts  []bool
}

'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 StringLiteral #

struct StringLiteral {
pub:
	val      string
	is_raw   bool
	language Language
	pos      token.Position
}

struct Struct #

struct Struct {
pub:
	attrs []Attr
pub mut:
	embeds         []Type
	fields         []StructField
	is_typedef     bool
	is_union       bool
	is_heap        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 StructDecl #

struct StructDecl {
pub:
	pos           token.Position
	name          string
	generic_types []Type
	is_pub        bool

	mut_pos      int
	pub_pos      int
	pub_mut_pos  int
	global_pos   int
	module_pos   int
	language     Language
	is_union     bool
	attrs        []Attr
	end_comments []Comment
	embeds       []Embed
pub mut:
	fields []StructField
}

struct StructField #

struct StructField {
pub:
	pos              token.Position
	type_pos         token.Position
	comments         []Comment
	has_default_expr bool
	attrs            []Attr
	is_pub           bool
	default_val      string
	is_mut           bool
	is_global        bool
pub mut:
	default_expr     Expr
	default_expr_typ Type
	name             string
	typ              Type
}

fn (StructField) equals #

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

struct StructInit #

struct StructInit {
pub:
	pos      token.Position
	name_pos token.Position
	is_short bool
pub mut:
	unresolved           bool
	pre_comments         []Comment
	typ                  Type
	update_expr          Expr
	update_expr_type     Type
	update_expr_comments []Comment
	has_update_expr      bool
	fields               []StructInitField
	embeds               []StructInitEmbed
}

struct StructInitEmbed #

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

struct StructInitField #

struct StructInitField {
pub:
	pos           token.Position
	name_pos      token.Position
	comments      []Comment
	next_comments []Comment
pub mut:
	expr          Expr
	name          string
	typ           Type
	expected_type Type
	parent_type   Type
}

struct SumType #

struct SumType {
pub:
	variants []Type
pub mut:
	fields       []StructField
	found_fields bool

	is_generic     bool
	generic_types  []Type
	concrete_types []Type
	parent_type    Type
}

fn (SumType) find_field #

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

struct SumTypeDecl #

struct SumTypeDecl {
pub:
	name          string
	is_pub        bool
	pos           token.Position
	comments      []Comment
	typ           Type
	generic_types []Type
pub mut:
	variants []TypeNode
}

New implementation of sum types

struct Table #

struct Table {
pub mut:
	type_symbols       []TypeSymbol
	type_idxs          map[string]int
	fns                map[string]Fn
	iface_types        map[string][]Type
	dumps              map[int]string
	imports            []string
	modules            []string
	global_scope       &Scope
	cflags             []cflag.CFlag
	redefined_fns      []string
	fn_generic_types   map[string][][]Type
	interfaces         map[int]InterfaceDecl
	cmod_prefix        string
	is_fmt             bool
	used_fns           map[string]bool
	used_consts        map[string]bool
	used_globals       map[string]bool
	used_vweb_types    []Type
	used_maps          int
	panic_handler      FnPanicHandler = default_table_panic_handler
	panic_userdata     voidptr        = voidptr(0)
	panic_npanics      int
	cur_fn             &FnDecl = 0
	cur_concrete_types []Type
	gostmts            int
	enum_decls         map[string]EnumDecl
}

fn (Table) add_placeholder_type #

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

fn (Table) array_cname #

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

fn (Table) array_fixed_cname #

fn (t &Table) array_fixed_cname(elem_type Type, size int) 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_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) 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]byte

608 > [76]byte

fn (Table) chan_cname #

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

fn (Table) chan_name #

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

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

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

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 finds and returns a field in the embeddings of a struct and the embedding type

fn (Table) find_field_from_embeds_recursive #

fn (t &Table) find_field_from_embeds_recursive(sym &TypeSymbol, field_name string) ?(StructField, []Type)

find_field_from_embeds is the same as find_field_from_embeds but also looks into 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) find_fn #

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

fn (Table) find_or_register_array #

fn (mut t Table) find_or_register_array(elem_type Type) 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_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_chan #

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

fn (Table) find_or_register_fn_type #

fn (mut t Table) find_or_register_fn_type(mod string, f Fn, is_anon bool, has_decl 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_multi_return #

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

fn (Table) find_or_register_thread #

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

fn (Table) find_type #

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

fn (Table) find_type_idx #

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

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

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

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

fn (Table) free #

unsafe
fn (t &Table) free()

used by vls to avoid leaks TODO remove manual memory management

fn (Table) generic_insts_to_concrete #

fn (mut t Table) generic_insts_to_concrete()

generic struct instantiations to concrete types

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

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

get_final_type_symbol 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_type_symbol #

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

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

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

fn (Table) known_fn #

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

fn (Table) known_type #

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

fn (Table) known_type_idx #

fn (t &Table) known_type_idx(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) map_cname #

fn (t &Table) map_cname(key_type Type, value_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) mktyp #

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

fn (Table) panic #

fn (t &Table) panic(message string)

fn (Table) parse_cflag #

fn (mut t Table) parse_cflag(cflg string, mod string, ctimedefines []string) ?bool

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

fn (Table) register_aggregate_method #

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

fn (Table) register_builtin_type_symbols #

fn (mut t Table) register_builtin_type_symbols()

fn (Table) register_enum_decl #

fn (mut t Table) register_enum_decl(enum_decl EnumDecl)

fn (Table) register_fn #

fn (mut t Table) register_fn(new_fn Fn)

fn (Table) register_fn_concrete_types #

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

fn (Table) register_interface #

fn (mut t Table) register_interface(idecl InterfaceDecl)

fn (Table) register_type_symbol #

fn (mut t Table) register_type_symbol(sym TypeSymbol) int

fn (Table) resolve_common_sumtype_fields #

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

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

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

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

fn (Table) struct_has_field #

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

fn (Table) sumtype_has_variant #

fn (t &Table) sumtype_has_variant(parent Type, variant Type) 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) thread_cname #

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

fn (Table) thread_name #

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

fn (Table) type_find_method #

fn (t &Table) type_find_method(s &TypeSymbol, name string) ?Fn

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

fn (Table) type_find_method_from_embeds #

fn (t &Table) type_find_method_from_embeds(sym &TypeSymbol, method_name string) ?(Fn, Type)

fn (Table) type_has_method #

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

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_str #

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

fn (Table) type_to_code #

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

type name in code (for builtin)

fn (Table) type_to_str #

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

human readable type name

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

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

fn (Table) unwrap_generic_type #

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

fn (Table) value_type #

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

struct Thread #

struct Thread {
pub mut:
	return_type Type
}

struct TypeNode #

struct TypeNode {
pub:
	typ Type
	pos token.Position
}

struct TypeOf #

struct TypeOf {
pub:
	expr Expr
	pos  token.Position
pub mut:
	expr_type Type
}

struct TypeSymbol #

struct TypeSymbol {
pub:
	parent_idx int
pub mut:
	info      TypeInfo
	kind      Kind
	name      string
	cname     string
	methods   []Fn
	mod       string
	is_public bool
	language  Language
	idx       int
}

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 TypeSymbol.name.
  • Table.type_kind(typ) not TypeSymbol.kind.
    Each TypeSymbol is entered into Table.types.
    See also: Table.get_type_symbol.

fn (TypeSymbol) array_fixed_info #

fn (t &TypeSymbol) array_fixed_info() ArrayFixed

fn (TypeSymbol) array_info #

fn (t &TypeSymbol) array_info() Array

fn (TypeSymbol) chan_info #

fn (t &TypeSymbol) chan_info() Chan

fn (TypeSymbol) dbg #

fn (ts TypeSymbol) dbg() []string

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

fn (TypeSymbol) debug #

fn (ts TypeSymbol) debug() []string

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

fn (TypeSymbol) embed_name #

fn (t &TypeSymbol) embed_name() string

fn (TypeSymbol) enum_info #

fn (t &TypeSymbol) enum_info() Enum

fn (TypeSymbol) find_field #

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

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

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

fn (TypeSymbol) is_builtin #

fn (t &TypeSymbol) is_builtin() bool

fn (TypeSymbol) is_float #

fn (t &TypeSymbol) is_float() bool

fn (TypeSymbol) is_heap #

fn (t &TypeSymbol) is_heap() bool

fn (TypeSymbol) is_int #

fn (t &TypeSymbol) is_int() bool

fn (TypeSymbol) is_number #

fn (t &TypeSymbol) is_number() bool

fn (TypeSymbol) is_pointer #

fn (t &TypeSymbol) is_pointer() bool

fn (TypeSymbol) is_primitive #

fn (t &TypeSymbol) is_primitive() bool

fn (TypeSymbol) is_string #

fn (t &TypeSymbol) is_string() bool

fn (TypeSymbol) map_info #

fn (t &TypeSymbol) map_info() Map

fn (TypeSymbol) mr_info #

fn (t &TypeSymbol) mr_info() MultiReturn

fn (TypeSymbol) register_method #

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

fn (TypeSymbol) str #

fn (t TypeSymbol) str() string

fn (TypeSymbol) str_method_info #

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

fn (TypeSymbol) struct_info #

fn (t &TypeSymbol) struct_info() Struct

fn (TypeSymbol) sumtype_info #

fn (t &TypeSymbol) sumtype_info() SumType

fn (TypeSymbol) thread_info #

fn (t &TypeSymbol) thread_info() Thread

struct UnsafeExpr #

struct UnsafeExpr {
pub:
	expr Expr
	pos  token.Position
}

struct Var #

struct Var {
pub:
	name            string
	expr            Expr
	share           ShareType
	is_mut          bool
	is_autofree_tmp bool
	is_arg          bool
	is_auto_deref   bool
	is_inherited    bool
pub mut:
	typ        Type
	orig_type  Type
	smartcasts []Type

	pos        token.Position
	is_used    bool
	is_changed bool

	is_or        bool
	is_tmp       bool
	is_auto_heap bool
	is_stack_obj bool
}