From 653d40bfe8e0133b9415aa8461c3c85f5c7d4353 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Thu, 23 Jul 2020 21:59:34 +0200 Subject: [PATCH] parser: do not duplicate table imports --- vlib/v/builder/cc.v | 13 +++++++------ vlib/v/gen/cgen.v | 5 ++++- vlib/v/parser/parser.v | 6 ++++-- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/vlib/v/builder/cc.v b/vlib/v/builder/cc.v index 0dde6f2e0a..63b5d974cc 100644 --- a/vlib/v/builder/cc.v +++ b/vlib/v/builder/cc.v @@ -289,28 +289,29 @@ fn (mut v Builder) cc() { println('$builtin_o_path not found... building module builtin') os.system('$vexe build module vlib${os.path_separator}builtin') } + */ for imp in v.table.imports { if imp.contains('vweb') { continue - } // not working + } + // not working if imp == 'webview' { continue } + // println('cache: import "$imp"') imp_path := imp.replace('.', os.path_separator) - path := '${pref.default_module_path}${os.path_separator}cache${os.path_separator}vlib${os.path_separator}${imp_path}.o' + path := '$pref.default_module_path${os.path_separator}cache${os.path_separator}vlib$os.path_separator${imp_path}.o' // println('adding ${imp_path}.o') if os.exists(path) { libs += ' ' + path - } - else { + } else { println('$path not found... building module $imp') - os.system('$vexe build module vlib${os.path_separator}$imp_path') + os.system('$vexe build-module vlib$os.path_separator$imp_path') } if path.ends_with('vlib/ui.o') { a << '-framework Cocoa -framework Carbon' } } - */ } if v.pref.sanitize { a << '-fsanitize=leak' diff --git a/vlib/v/gen/cgen.v b/vlib/v/gen/cgen.v index 5ba61ff89e..63d8dfc3d8 100644 --- a/vlib/v/gen/cgen.v +++ b/vlib/v/gen/cgen.v @@ -732,7 +732,10 @@ fn (mut g Gen) stmt(node ast.Stmt) { mut skip := false pos := g.out.buf.len if g.pref.build_mode == .build_module { - if !node.name.starts_with(g.module_built + '.') && node.mod != g.module_built { + // if node.name.contains('parse_text') { + // println('!!! $node.name mod=$node.mod, built=$g.module_built') + // } + if !node.name.starts_with(g.module_built + '.') && node.mod != g.module_built.after('/') { // Skip functions that don't have to be generated // for this module. skip = true diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index 60cc0c86a0..398cf6245e 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -1398,8 +1398,10 @@ fn (mut p Parser) import_stmt() ast.Import { } } p.imports[mod_alias] = mod_name - p.table.imports << mod_name - p.ast_imports << node + if mod_name !in p.table.imports { + p.table.imports << mod_name + p.ast_imports << node + } return node }