From 50143ad9bfb32f65fc58e580a01e29c4e9790b82 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Tue, 31 Mar 2020 20:58:44 +0300 Subject: [PATCH] v2: be silent by default --- vlib/compiler/main.v | 2 +- vlib/v/builder/builder.v | 22 ++++++++++++++-------- vlib/v/gen/cgen.v | 4 +++- vlib/v/parser/parser.v | 8 ++++++-- 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/vlib/compiler/main.v b/vlib/compiler/main.v index d5c9af182b..7eff425214 100644 --- a/vlib/compiler/main.v +++ b/vlib/compiler/main.v @@ -322,7 +322,7 @@ pub fn (v mut V) compile2() { verror('Cannot build with msvc on ${os.user_os()}') } //cgen.genln('// Generated by V') - println('compile2()') + //println('compile2()') if v.pref.verbosity.is_higher_or_equal(.level_three) { println('all .v files before:') println(v.files) diff --git a/vlib/v/builder/builder.v b/vlib/v/builder/builder.v index 234a89598a..14f5986b05 100644 --- a/vlib/v/builder/builder.v +++ b/vlib/v/builder/builder.v @@ -40,12 +40,12 @@ pub fn (b mut Builder) gen_c(v_files []string) string { b.parse_imports() t1 := time.ticks() parse_time := t1 - t0 - println('PARSE: ${parse_time}ms') + b.info('PARSE: ${parse_time}ms') // b.checker.check_files(b.parsed_files) t2 := time.ticks() check_time := t2 - t1 - println('CHECK: ${check_time}ms') + b.info('CHECK: ${check_time}ms') if b.checker.nr_errors > 0 { exit(1) } @@ -53,14 +53,14 @@ pub fn (b mut Builder) gen_c(v_files []string) string { res := gen.cgen(b.parsed_files, b.table, b.pref) t3 := time.ticks() gen_time := t3 - t2 - println('C GEN: ${gen_time}ms') - println('cgen done') + b.info('C GEN: ${gen_time}ms') + // println('cgen done') // println(res) return res } pub fn (b mut Builder) build_c(v_files []string, out_file string) { - println('build_c($out_file)') + b.info('build_c($out_file)') mut f := os.create(out_file) or { panic(err) } @@ -75,15 +75,15 @@ pub fn (b mut Builder) build_x64(v_files []string, out_file string) { b.parse_imports() t1 := time.ticks() parse_time := t1 - t0 - println('PARSE: ${parse_time}ms') + b.info('PARSE: ${parse_time}ms') b.checker.check_files(b.parsed_files) t2 := time.ticks() check_time := t2 - t1 - println('CHECK: ${check_time}ms') + b.info('CHECK: ${check_time}ms') x64.gen(b.parsed_files, out_file) t3 := time.ticks() gen_time := t3 - t2 - println('x64 GEN: ${gen_time}ms') + b.info('x64 GEN: ${gen_time}ms') } // parse all deps from already parsed files @@ -197,6 +197,12 @@ pub fn (b &Builder) log(s string) { } } +pub fn (b &Builder) info(s string) { + if b.pref.verbosity.is_higher_or_equal(.level_one) { + println(s) + } +} + [inline] fn module_path(mod string) string { // submodule support diff --git a/vlib/v/gen/cgen.v b/vlib/v/gen/cgen.v index a481d3ac1c..c546fa4ca4 100644 --- a/vlib/v/gen/cgen.v +++ b/vlib/v/gen/cgen.v @@ -1974,7 +1974,7 @@ fn (g mut Gen) write_init_function() { g.writeln('}') if g.autofree { g.writeln('void _vcleanup() {') - g.writeln('puts("cleaning up...");') + //g.writeln('puts("cleaning up...");') if g.is_importing_os() { g.writeln('free(_const_os__args.data);') g.writeln('string_free(_const_os__wd_at_startup);') @@ -2612,6 +2612,7 @@ pub fn (g mut Gen) write_tests_main() { g.writeln('\tBenchedTests bt = start_testing(${all_tfuncs.len}, tos3("$g.pref.path"));') } for t in all_tfuncs { + g.writeln('') if g.pref.is_stats { g.writeln('\tBenchedTests_testing_step_start(&bt, tos3("$t"));') } @@ -2620,6 +2621,7 @@ pub fn (g mut Gen) write_tests_main() { g.writeln('\tBenchedTests_testing_step_end(&bt);') } } + g.writeln('') if g.pref.is_stats { g.writeln('\tBenchedTests_end_testing(&bt);') } diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index 30a3d55fb3..5755ec2f35 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -1095,7 +1095,7 @@ fn (p mut Parser) for_statement() ast.Stmt { // for i := 0; i < 10; i++ { else if p.peek_tok.kind in [.decl_assign, .assign, .semicolon] || p.tok.kind == .semicolon { mut init := ast.Stmt{} - mut cond := ast.Expr{} + mut cond := p.new_true_expr() // mut inc := ast.Stmt{} mut inc := ast.Expr{} mut has_init := false @@ -1702,7 +1702,7 @@ fn (p mut Parser) global_decl() ast.GlobalDecl { } p.next() name := p.check_name() - println(name) + // println(name) typ := p.parse_type() if p.tok.kind == .assign { p.next() @@ -1904,3 +1904,7 @@ fn verror(s string) { println(s) exit(1) } + +fn (p &Parser) new_true_expr() ast.Expr { + return ast.BoolLiteral{ val: true } +}