1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

cgen: call module init function if available

This commit is contained in:
Alexey 2020-04-11 19:38:51 +03:00 committed by GitHub
parent d0ac69d12e
commit 0050c1915b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2132,6 +2132,14 @@ fn (g mut Gen) write_init_function() {
g.writeln('\tbuiltin_init();')
g.writeln('\tvinit_string_literals();')
g.writeln(g.inits.str())
for mod_name in g.table.imports {
init_fn_name := '${mod_name}.init'
if _ := g.table.find_fn(init_fn_name) {
mod_c_name := mod_name.replace('.', '__')
init_fn_c_name := '${mod_c_name}__init'
g.writeln('\t${init_fn_c_name}();')
}
}
g.writeln('}')
if g.autofree {
g.writeln('void _vcleanup() {')