all: more cached moduels fixes

pull/5874/head
Alexander Medvednikov 2020-07-18 13:49:00 +02:00
parent 3a4f2dfe8b
commit 74d70b8719
3 changed files with 15 additions and 8 deletions

View File

@ -4,8 +4,8 @@
module builtin
import strings
import hash.wyhash as hash
//import hash
//import hash.wyhash as hash
import hash
/*
This is a highly optimized hashmap implementation. It has several traits that

View File

@ -220,8 +220,10 @@ pub fn cgen(files []ast.File, table &table.Table, pref &pref.Preferences) string
b.write(g.stringliterals.str())
}
if g.auto_str_funcs.len > 0 {
b.writeln('\n// V auto str functions:')
b.write(g.auto_str_funcs.str())
if g.pref.build_mode != .build_module {
b.writeln('\n// V auto str functions:')
b.write(g.auto_str_funcs.str())
}
}
b.writeln('\n// V out')
b.write(g.out.str())
@ -733,6 +735,11 @@ fn (mut g Gen) stmt(node ast.Stmt) {
println('build module `$g.module_built` fn `$node.name`')
}
}
if g.pref.use_cache {
if node.mod != 'main' {
skip = true
}
}
keep_fn_decl := g.fn_decl
g.fn_decl = node
if node.name == 'main.main' {
@ -4164,6 +4171,9 @@ fn styp_to_str_fn_name(styp string) string {
[inline]
fn (mut g Gen) gen_str_for_type(typ table.Type) string {
if g.pref.build_mode == .build_module {
return ''
}
styp := g.typ(typ)
return g.gen_str_for_type_with_styp(typ, styp)
}

View File

@ -15,9 +15,6 @@ fn (mut g Gen) gen_fn_decl(it ast.FnDecl, skip bool) {
// if g.fileis('vweb.v') {
// println('\ngen_fn_decl() $it.name $it.is_generic $g.cur_generic_type')
// }
if g.pref.use_cache && skip {
return
}
if it.is_generic && g.cur_generic_type == 0 { // need the cur_generic_type check to avoid inf. recursion
// loop thru each generic type and generate a function
for gen_type in g.table.fn_gen_types[it.name] {
@ -108,7 +105,7 @@ fn (mut g Gen) gen_fn_decl(it ast.FnDecl, skip bool) {
g.write(fn_header)
}
fargs, fargtypes := g.fn_args(it.args, it.is_variadic)
if it.no_body || (g.pref.use_cache && it.is_builtin) {
if it.no_body || (g.pref.use_cache && it.is_builtin) || skip {
// Just a function header. Builtin function bodies are defined in builtin.o
g.definitions.writeln('); // NO BODY')
g.writeln(');')