Skip to content

v.markused #

fn mark_used #

fn mark_used(mut table ast.Table, mut pref_ pref.Preferences, ast_files []&ast.File)

mark_used walks the AST, starting at main() and marks all used fns transitively.

fn Walker.new #

fn Walker.new(params Walker) &Walker

struct Walker #

struct Walker {
pub mut:
	table           &ast.Table        = unsafe { nil }
	features        &ast.UsedFeatures = unsafe { nil }
	used_fns        map[string]bool // used_fns['println'] == true
	trace_enabled   bool
	used_consts     map[string]bool // used_consts['os.args'] == true
	used_globals    map[string]bool
	used_fields     map[string]bool
	used_structs    map[string]bool
	used_types      map[ast.Type]bool
	used_syms       map[int]bool
	used_arr_method map[string]bool
	used_map_method map[string]bool
	used_none       int // _option_none
	used_option     int // _option_ok
	used_result     int // _result_ok
	used_panic      int // option/result propagation
	used_closures   int // fn [x] (){}, and `instance.method` used in an expression
	pref            &pref.Preferences = unsafe { nil }
mut:
	all_fns       map[string]ast.FnDecl
	all_consts    map[string]ast.ConstField
	all_globals   map[string]ast.GlobalField
	all_fields    map[string]ast.StructField
	all_decltypes map[string]ast.TypeDecl
	all_structs   map[string]ast.StructDecl

	level                  int
	is_builtin_mod         bool
	is_direct_array_access bool

	// dependencies finding flags
	uses_atomic                bool // has atomic
	uses_array                 bool // has array
	uses_channel               bool // has chan dep
	uses_lock                  bool // has mutex dep
	uses_ct_fields             bool // $for .fields
	uses_ct_methods            bool // $for .methods
	uses_ct_params             bool // $for .params
	uses_ct_values             bool // $for .values
	uses_ct_variants           bool // $for .variants
	uses_ct_attribute          bool // $for .attributes
	uses_external_type         bool
	uses_err                   bool // err var
	uses_asserts               bool // assert
	uses_map_update            bool // has {...expr}
	uses_debugger              bool // has debugger;
	uses_mem_align             bool // @[aligned:N] for structs
	uses_eq                    bool // has == op
	uses_interp                bool // string interpolation
	uses_guard                 bool
	uses_orm                   bool
	uses_str                   map[ast.Type]bool // has .str() calls, and for which types
	uses_free                  map[ast.Type]bool // has .free() calls, and for which types
	uses_spawn                 bool
	uses_dump                  bool
	uses_memdup                bool // sumtype cast and &Struct{}
	uses_arr_void              bool // auto arr methods
	uses_index                 bool // var[k]
	uses_index_check           bool // var[k] or { }
	uses_arr_range_index       bool // arr[i..j]
	uses_str_range_index       bool // str[i..j]
	uses_range_index_check     bool // var[i..j] or { }
	uses_arr_range_index_gated bool
	uses_str_range_index_gated bool
	uses_str_index             bool // string[k]
	uses_str_index_check       bool // string[k] or { }
	uses_str_range             bool // string[a..b]
	uses_fixed_arr_int         bool // fixed_arr[k]
	uses_append                bool // var << item
	uses_map_setter            bool
	uses_map_getter            bool
	uses_arr_setter            bool
	uses_arr_getter            bool
	uses_arr_clone             bool
	uses_arr_sorted            bool
}

fn (Walker) mark_builtin_array_method_as_used #

fn (mut w Walker) mark_builtin_array_method_as_used(method_name string)

fn (Walker) mark_builtin_map_method_as_used #

fn (mut w Walker) mark_builtin_map_method_as_used(method_name string)

fn (Walker) mark_builtin_type_method_as_used #

fn (mut w Walker) mark_builtin_type_method_as_used(k string, rk string)

fn (Walker) mark_const_as_used #

fn (mut w Walker) mark_const_as_used(ckey string)

fn (Walker) mark_global_as_used #

fn (mut w Walker) mark_global_as_used(ckey string)

fn (Walker) mark_struct_field_default_expr_as_used #

fn (mut w Walker) mark_struct_field_default_expr_as_used(sfkey string)

fn (Walker) mark_markused_fns #

fn (mut w Walker) mark_markused_fns()

fn (Walker) mark_root_fns #

fn (mut w Walker) mark_root_fns(all_fn_root_names []string)

fn (Walker) mark_markused_consts #

fn (mut w Walker) mark_markused_consts()

fn (Walker) mark_markused_globals #

fn (mut w Walker) mark_markused_globals()

fn (Walker) mark_markused_syms #

fn (mut w Walker) mark_markused_syms()

fn (Walker) mark_markused_decltypes #

fn (mut w Walker) mark_markused_decltypes()

fn (Walker) stmt #

fn (mut w Walker) stmt(node_ ast.Stmt)

fn (Walker) fn_decl #

fn (mut w Walker) fn_decl(mut node ast.FnDecl)

fn (Walker) call_expr #

fn (mut w Walker) call_expr(mut node ast.CallExpr)

fn (Walker) fn_by_name #

fn (mut w Walker) fn_by_name(fn_name string)

fn (Walker) struct_fields #

fn (mut w Walker) struct_fields(sfields []ast.StructField)

fn (Walker) const_fields #

fn (mut w Walker) const_fields(cfields []ast.ConstField)

fn (Walker) or_block #

fn (mut w Walker) or_block(node ast.OrExpr)

fn (Walker) mark_fn_ret_and_params #

fn (mut w Walker) mark_fn_ret_and_params(return_type ast.Type, params []ast.Param)

fn (Walker) mark_by_sym_name #

fn (mut w Walker) mark_by_sym_name(name string)

fn (Walker) mark_by_type #

fn (mut w Walker) mark_by_type(typ ast.Type)

fn (Walker) mark_by_sym #

fn (mut w Walker) mark_by_sym(isym ast.TypeSymbol)

fn (Walker) finalize #

fn (mut w Walker) finalize(include_panic_deps bool)

fn (Walker) mark_generic_types #

fn (mut w Walker) mark_generic_types()