compiler: checks if variables are unused on scripts main function
parent
165dfe5fe0
commit
d8caa6431f
|
@ -403,7 +403,14 @@ pthread_create(&_thread_so , NULL, &reload_so, NULL); ')
|
|||
p.fgenln('\n')
|
||||
return
|
||||
}
|
||||
for var in f.local_vars {
|
||||
p.check_unused_variables()
|
||||
p.cur_fn = EmptyFn
|
||||
p.fgenln('\n')
|
||||
p.genln('}')
|
||||
}
|
||||
|
||||
fn (p mut Parser) check_unused_variables() {
|
||||
for var in p.cur_fn.local_vars {
|
||||
if var.name == '' {
|
||||
break
|
||||
}
|
||||
|
@ -419,11 +426,6 @@ pthread_create(&_thread_so , NULL, &reload_so, NULL); ')
|
|||
// p.genln('free(${var.name}.data); // !!!! XAXA')
|
||||
}
|
||||
}
|
||||
// println('end of func decl')
|
||||
// p.print_tok()
|
||||
p.cur_fn = EmptyFn
|
||||
p.fgenln('\n')
|
||||
p.genln('}')
|
||||
}
|
||||
|
||||
// Important function with 5 args.
|
||||
|
|
|
@ -230,6 +230,10 @@ fn (p mut Parser) parse() {
|
|||
p.cgen.consts << g
|
||||
case EOF:
|
||||
p.log('end of parse()')
|
||||
if p.is_script && !p.is_test {
|
||||
p.cur_fn = MainFn
|
||||
p.check_unused_variables()
|
||||
}
|
||||
if true && !p.first_run() && p.fileis('test') {
|
||||
out := os.create('/var/tmp/fmt.v')
|
||||
out.appendln(p.scanner.fmt_out.str())
|
||||
|
|
Loading…
Reference in New Issue