table: .is_used => .usages (a counter, instead of a boolean flag)
parent
231182c3ff
commit
80697ec7f3
|
@ -1799,7 +1799,7 @@ pub fn (mut c Checker) call_fn(mut call_expr ast.CallExpr) table.Type {
|
||||||
call_expr.name = name_prefixed
|
call_expr.name = name_prefixed
|
||||||
found = true
|
found = true
|
||||||
f = f1
|
f = f1
|
||||||
c.table.fns[name_prefixed].is_used = true
|
c.table.fns[name_prefixed].usages++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !found && call_expr.left is ast.IndexExpr {
|
if !found && call_expr.left is ast.IndexExpr {
|
||||||
|
@ -1833,7 +1833,7 @@ pub fn (mut c Checker) call_fn(mut call_expr ast.CallExpr) table.Type {
|
||||||
if f1 := c.table.find_fn(fn_name) {
|
if f1 := c.table.find_fn(fn_name) {
|
||||||
found = true
|
found = true
|
||||||
f = f1
|
f = f1
|
||||||
c.table.fns[fn_name].is_used = true
|
c.table.fns[fn_name].usages++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if c.pref.is_script && !found {
|
if c.pref.is_script && !found {
|
||||||
|
@ -1845,7 +1845,7 @@ pub fn (mut c Checker) call_fn(mut call_expr ast.CallExpr) table.Type {
|
||||||
call_expr.name = os_name
|
call_expr.name = os_name
|
||||||
found = true
|
found = true
|
||||||
f = f1
|
f = f1
|
||||||
c.table.fns[os_name].is_used = true
|
c.table.fns[os_name].usages++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// check for arg (var) of fn type
|
// check for arg (var) of fn type
|
||||||
|
|
|
@ -26,13 +26,16 @@ fn (mut g Gen) gen_fn_decl(node ast.FnDecl, skip bool) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if f := g.table.find_fn(node.name) {
|
|
||||||
if !f.is_used {
|
|
||||||
g.writeln('// fn $node.name UNUSED')
|
|
||||||
// return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
*/
|
||||||
|
if g.pref.experimental {
|
||||||
|
if f := g.table.find_fn(node.name) {
|
||||||
|
println('> usages: ${f.usages:-10} | node.name: $node.name')
|
||||||
|
if f.usages == 0 {
|
||||||
|
g.writeln('// fn $node.name UNUSED')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
g.returned_var_name = ''
|
g.returned_var_name = ''
|
||||||
//
|
//
|
||||||
|
|
|
@ -39,7 +39,7 @@ pub:
|
||||||
pub mut:
|
pub mut:
|
||||||
name string
|
name string
|
||||||
source_fn voidptr // set in the checker, while processing fn declarations
|
source_fn voidptr // set in the checker, while processing fn declarations
|
||||||
is_used bool
|
usages int
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (f &Fn) method_equals(o &Fn) bool {
|
fn (f &Fn) method_equals(o &Fn) bool {
|
||||||
|
|
Loading…
Reference in New Issue