Module v.gen.golang 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.


Imported by


This section is empty.


This section is empty.

Sum types

This section is empty.


#fn gen

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


#struct AttrsOptions

pub struct AttrsOptions {
	inline bool

#struct Gen

pub struct Gen {
pub mut:
	table &ast.Table        = unsafe { nil }
	pref  &pref.Preferences = unsafe { nil }
	// is_debug           bool
	out                strings.Builder
	out_imports        strings.Builder
	indent             int
	empty_line         bool
	line_len           int  // the current line length, Note: it counts \t as 4 spaces, and starts at 0 after f.writeln
	buffering          bool // disables line wrapping for exprs that will be analyzed later
	par_level          int  // how many parentheses are put around the current expression
	single_line_if     bool
	cur_mod            string
	did_imports        bool
	is_assign          bool
	is_struct_init     bool
	auto_imports       []string          // automatically inserted imports that the user forgot to specify
	import_pos         int               // position of the imports in the resulting string for later autoimports insertion
	used_imports       []string          // to remove unused imports
	import_syms_used   map[string]bool   // to remove unused import symbols.
	mod2alias          map[string]string // for `import time as t`, will contain: 'time'=>'t'
	mod2syms           map[string]string // import time { now } ''=>'now'
	use_short_fn_args  bool
	single_line_fields bool   // should struct fields be on a single line
	it_name            string // the name to replace `it` with
	in_lambda_depth    int
	inside_const       bool
	is_mbranch_expr    bool // match a { x...y { } }
	fn_scope           &ast.Scope = unsafe { nil }
	wsinfix_depth      int
	nlines             int

#fn (&Gen) attrs

fn (mut f &Gen) attrs(attrs []v.ast.Attr)

#fn (&Gen) single_line_attrs

fn (mut f &Gen) single_line_attrs(attrs []v.ast.Attr, options AttrsOptions)

#fn (&Gen) process_file_imports

fn (mut f &Gen) process_file_imports(file &v.ast.File)

#fn (&Gen) write

fn (mut f &Gen) write(s string)

#fn (&Gen) writeln

fn (mut f &Gen) writeln(s string)

#fn (&Gen) write_indent

fn (mut f &Gen) write_indent()

#fn (&Gen) wrap_long_line

fn (mut f &Gen) wrap_long_line(penalty_idx int, add_indent bool) bool

#fn (&Gen) remove_new_line

fn (mut f &Gen) remove_new_line(cfg RemoveNewLineConfig)

#fn (&Gen) write_language_prefix

fn (mut f &Gen) write_language_prefix(lang v.ast.Language)

#fn (&Gen) write_generic_types

fn (mut f &Gen) write_generic_types(gtypes []v.ast.Type)

#fn (&Gen) set_current_module_name

fn (mut f &Gen) set_current_module_name(cmodname string)

#fn (&Gen) get_modname_prefix

fn (f &Gen) get_modname_prefix(mname string) (string, string)

#fn (&Gen) is_external_name

fn (mut f &Gen) is_external_name(name string) bool

#fn (&Gen) no_cur_mod

fn (mut f &Gen) no_cur_mod(typename string) string

#fn (&Gen) short_module

fn (mut f &Gen) short_module(name string) string => bar.fn()

#fn (&Gen) mark_types_import_as_used

fn (mut f &Gen) mark_types_import_as_used(typ v.ast.Type)

#fn (&Gen) mark_import_as_used

fn (mut f &Gen) mark_import_as_used(name string)

name is a function ( or type (foo.Bar{})

#fn (&Gen) imports

fn (mut f &Gen) imports(imports []v.ast.Import)

#fn (&Gen) imp_stmt_str

fn (f &Gen) imp_stmt_str(imp v.ast.Import) string

#fn (&Gen) should_insert_newline_before_node

fn (f &Gen) should_insert_newline_before_node(node v.ast.Node, prev_node v.ast.Node) bool

#fn (&Gen) node_str

fn (mut f &Gen) node_str(node v.ast.Node) string

#fn (&Gen) stmts

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

#fn (&Gen) stmt

fn (mut f &Gen) stmt(node v.ast.Stmt)

#fn (&Gen) expr

fn (mut f &Gen) expr(node_ v.ast.Expr)

#fn (&Gen) assert_stmt

fn (mut f &Gen) assert_stmt(node v.ast.AssertStmt)

#fn (&Gen) assign_stmt

fn (mut f &Gen) assign_stmt(node v.ast.AssignStmt)

#fn (&Gen) block

fn (mut f &Gen) block(node v.ast.Block)

#fn (&Gen) branch_stmt

fn (mut f &Gen) branch_stmt(node v.ast.BranchStmt)

#fn (&Gen) comptime_for

fn (mut f &Gen) comptime_for(node v.ast.ComptimeFor)

#fn (&Gen) const_decl

fn (mut f &Gen) const_decl(node v.ast.ConstDecl)

#fn (&Gen) defer_stmt

fn (mut f &Gen) defer_stmt(node v.ast.DeferStmt)

#fn (&Gen) expr_stmt

fn (mut f &Gen) expr_stmt(node v.ast.ExprStmt)

#fn (&Gen) enum_decl

fn (mut f &Gen) enum_decl(node v.ast.EnumDecl)

#fn (&Gen) fn_decl

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

#fn (&Gen) anon_fn

fn (mut f &Gen) anon_fn(node v.ast.AnonFn)

#fn (&Gen) fn_body

fn (mut f &Gen) fn_body(node v.ast.FnDecl)

#fn (&Gen) for_c_stmt

fn (mut f &Gen) for_c_stmt(node v.ast.ForCStmt)

#fn (&Gen) for_in_stmt

fn (mut f &Gen) for_in_stmt(node v.ast.ForInStmt)

#fn (&Gen) for_stmt

fn (mut f &Gen) for_stmt(node v.ast.ForStmt)

#fn (&Gen) global_decl

fn (mut f &Gen) global_decl(node v.ast.GlobalDecl)

#fn (&Gen) go_expr

fn (mut f &Gen) go_expr(node v.ast.GoExpr)

#fn (&Gen) goto_label

fn (mut f &Gen) goto_label(node v.ast.GotoLabel)

#fn (&Gen) goto_stmt

fn (mut f &Gen) goto_stmt(node v.ast.GotoStmt)

#fn (&Gen) hash_stmt

fn (mut f &Gen) hash_stmt(node v.ast.HashStmt)

#fn (&Gen) interface_decl

fn (mut f &Gen) interface_decl(node v.ast.InterfaceDecl)

#fn (&Gen) interface_field

fn (mut f &Gen) interface_field(field v.ast.StructField)

#fn (&Gen) interface_method

fn (mut f &Gen) interface_method(method v.ast.FnDecl)

#fn (&Gen) module_stmt

fn (mut f &Gen) module_stmt(mod v.ast.Module)

#fn (&Gen) return_stmt

fn (mut f &Gen) return_stmt(node v.ast.Return)

#fn (&Gen) sql_stmt

fn (mut f &Gen) sql_stmt(node v.ast.SqlStmt)

#fn (&Gen) sql_stmt_line

fn (mut f &Gen) sql_stmt_line(node v.ast.SqlStmtLine)

#fn (&Gen) type_decl

fn (mut f &Gen) type_decl(node v.ast.TypeDecl)

#fn (&Gen) alias_type_decl

fn (mut f &Gen) alias_type_decl(node v.ast.AliasTypeDecl)

#fn (&Gen) fn_type_decl

fn (mut f &Gen) fn_type_decl(node v.ast.FnTypeDecl)

#fn (&Gen) sum_type_decl

fn (mut f &Gen) sum_type_decl(node v.ast.SumTypeDecl)

#fn (&Gen) array_decompose

fn (mut f &Gen) array_decompose(node v.ast.ArrayDecompose)

#fn (&Gen) array_init

fn (mut f &Gen) array_init(node v.ast.ArrayInit)

#fn (&Gen) as_cast

fn (mut f &Gen) as_cast(node v.ast.AsCast)

#fn (&Gen) assoc

fn (mut f &Gen) assoc(node v.ast.Assoc)

#fn (&Gen) at_expr

fn (mut f &Gen) at_expr(node v.ast.AtExpr)

#fn (&Gen) call_expr

fn (mut f &Gen) call_expr(node v.ast.CallExpr)

#fn (&Gen) write_generic_call_if_require

fn (mut f &Gen) write_generic_call_if_require(node v.ast.CallExpr)

#fn (&Gen) call_args

fn (mut f &Gen) call_args(args []v.ast.CallArg)

#fn (&Gen) cast_expr

fn (mut f &Gen) cast_expr(node v.ast.CastExpr)

#fn (&Gen) chan_init

fn (mut f &Gen) chan_init(mut node &v.ast.ChanInit)

#fn (&Gen) comptime_call

fn (mut f &Gen) comptime_call(node v.ast.ComptimeCall)

#fn (&Gen) comptime_selector

fn (mut f &Gen) comptime_selector(node v.ast.ComptimeSelector)

#fn (&Gen) concat_expr

fn (mut f &Gen) concat_expr(node v.ast.ConcatExpr)

#fn (&Gen) dump_expr

fn (mut f &Gen) dump_expr(node v.ast.DumpExpr)

#fn (&Gen) enum_val

fn (mut f &Gen) enum_val(node v.ast.EnumVal)

#fn (&Gen) ident

fn (mut f &Gen) ident(node v.ast.Ident)

#fn (&Gen) if_expr

fn (mut f &Gen) if_expr(node v.ast.IfExpr)

#fn (&Gen) if_guard_expr

fn (mut f &Gen) if_guard_expr(node v.ast.IfGuardExpr)

#fn (&Gen) index_expr

fn (mut f &Gen) index_expr(node v.ast.IndexExpr)

#fn (&Gen) infix_expr

fn (mut f &Gen) infix_expr(node v.ast.InfixExpr)

#fn (&Gen) wrap_infix

fn (mut f &Gen) wrap_infix(start_pos int, start_len int, is_cond bool)

#fn (&Gen) write_splitted_infix

fn (mut f &Gen) write_splitted_infix(conditions []string, penalties []int, ignore_paren bool, is_cond bool)

#fn (&Gen) likely

fn (mut f &Gen) likely(node v.ast.Likely)

#fn (&Gen) lock_expr

fn (mut f &Gen) lock_expr(node v.ast.LockExpr)

#fn (&Gen) map_init

fn (mut f &Gen) map_init(node v.ast.MapInit)

#fn (&Gen) match_branch

fn (mut f &Gen) match_branch(branch v.ast.MatchBranch, single_line bool)

#fn (&Gen) match_expr

fn (mut f &Gen) match_expr(node v.ast.MatchExpr)

#fn (&Gen) offset_of

fn (mut f &Gen) offset_of(node v.ast.OffsetOf)

#fn (&Gen) or_expr

fn (mut f &Gen) or_expr(node v.ast.OrExpr)

#fn (&Gen) par_expr

fn (mut f &Gen) par_expr(node v.ast.ParExpr)

#fn (&Gen) postfix_expr

fn (mut f &Gen) postfix_expr(node v.ast.PostfixExpr)

#fn (&Gen) prefix_expr

fn (mut f &Gen) prefix_expr(node v.ast.PrefixExpr)

#fn (&Gen) range_expr

fn (mut f &Gen) range_expr(node v.ast.RangeExpr)

#fn (&Gen) select_expr

fn (mut f &Gen) select_expr(node v.ast.SelectExpr)

#fn (&Gen) selector_expr

fn (mut f &Gen) selector_expr(node v.ast.SelectorExpr)

#fn (&Gen) size_of

fn (mut f &Gen) size_of(node v.ast.SizeOf)

#fn (&Gen) is_ref_type

fn (mut f &Gen) is_ref_type(node v.ast.IsRefType)

#fn (&Gen) sql_expr

fn (mut f &Gen) sql_expr(node v.ast.SqlExpr)

#fn (&Gen) char_literal

fn (mut f &Gen) char_literal(node v.ast.CharLiteral)

#fn (&Gen) string_literal

fn (mut f &Gen) string_literal(node v.ast.StringLiteral)

#fn (&Gen) string_inter_literal

fn (mut f &Gen) string_inter_literal(node v.ast.StringInterLiteral)

#fn (&Gen) type_expr

fn (mut f &Gen) type_expr(node v.ast.TypeNode)

#fn (&Gen) type_of

fn (mut f &Gen) type_of(node v.ast.TypeOf)

#fn (&Gen) unsafe_expr

fn (mut f &Gen) unsafe_expr(node v.ast.UnsafeExpr)

#fn (&Gen) trace

fn (mut f &Gen) trace(fbase string, message string)

#fn (&Gen) error

fn (mut g &Gen) error(s string)

#fn (&Gen) struct_decl

fn (mut f &Gen) struct_decl(node v.ast.StructDecl)

#fn (&Gen) struct_init

fn (mut f &Gen) struct_init(node v.ast.StructInit)

#struct RemoveNewLineConfig

pub struct RemoveNewLineConfig {
	imports_buffer bool // Work on f.out_imports instead of f.out


This section is empty.


This section is empty.