mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: add support for -printfn _vcleanup
and -printfn _vinit
This commit is contained in:
parent
656bc6b6c8
commit
6683f98eba
@ -2475,6 +2475,7 @@ fn (mut g Gen) write_init_function() {
|
|||||||
if g.pref.is_liveshared {
|
if g.pref.is_liveshared {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
fn_vinit_start_pos := g.out.len
|
||||||
g.writeln('void _vinit() {')
|
g.writeln('void _vinit() {')
|
||||||
g.writeln('\tbuiltin_init();')
|
g.writeln('\tbuiltin_init();')
|
||||||
g.writeln('\tvinit_string_literals();')
|
g.writeln('\tvinit_string_literals();')
|
||||||
@ -2488,7 +2489,11 @@ fn (mut g Gen) write_init_function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
g.writeln('}')
|
g.writeln('}')
|
||||||
|
if g.pref.printfn_list.len > 0 && '_vinit' in g.pref.printfn_list {
|
||||||
|
println(g.out.after(fn_vinit_start_pos))
|
||||||
|
}
|
||||||
if g.autofree {
|
if g.autofree {
|
||||||
|
fn_vcleanup_start_pos := g.out.len
|
||||||
g.writeln('void _vcleanup() {')
|
g.writeln('void _vcleanup() {')
|
||||||
// g.writeln('puts("cleaning up...");')
|
// g.writeln('puts("cleaning up...");')
|
||||||
if g.is_importing_os() {
|
if g.is_importing_os() {
|
||||||
@ -2497,6 +2502,9 @@ fn (mut g Gen) write_init_function() {
|
|||||||
}
|
}
|
||||||
g.writeln('array_free(&_const_strconv__ftoa__powers_of_10);')
|
g.writeln('array_free(&_const_strconv__ftoa__powers_of_10);')
|
||||||
g.writeln('}')
|
g.writeln('}')
|
||||||
|
if g.pref.printfn_list.len > 0 && '_vcleanup' in g.pref.printfn_list {
|
||||||
|
println(g.out.after(fn_vcleanup_start_pos))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user