mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
builder: move warning/error printing into print_warnings_and_errors
This commit is contained in:
parent
1e910c6afe
commit
3d8853af2b
@ -267,23 +267,24 @@ pub fn (b Builder) find_module_path(mod, fpath string) ?string {
|
||||
return error('module "$mod" not found in:\n$smodule_lookup_paths')
|
||||
}
|
||||
|
||||
fn (b &Builder) print_errors(errors []errors.Error) {
|
||||
for err in errors {
|
||||
kind := if b.pref.is_verbose { '$err.reporter error #$b.checker.nr_errors:' } else { 'error:' }
|
||||
ferror := util.formatted_error(kind, err.message, err.file_path, err.pos)
|
||||
eprintln(ferror)
|
||||
fn (b &Builder) print_warnings_and_errors(){
|
||||
if b.checker.nr_warnings > 0 {
|
||||
for err in b.checker.warnings {
|
||||
kind := if b.pref.is_verbose { '$err.reporter warning #$b.checker.nr_warnings:' } else { 'warning:' }
|
||||
ferror := util.formatted_error(kind, err.message, err.file_path, err.pos)
|
||||
eprintln(ferror)
|
||||
}
|
||||
}
|
||||
if b.checker.nr_errors > 0 {
|
||||
for err in b.checker.errors {
|
||||
kind := if b.pref.is_verbose { '$err.reporter error #$b.checker.nr_errors:' } else { 'error:' }
|
||||
ferror := util.formatted_error(kind, err.message, err.file_path, err.pos)
|
||||
eprintln(ferror)
|
||||
}
|
||||
exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
fn (b &Builder) print_warnings(warnings []errors.Warning) {
|
||||
for err in warnings {
|
||||
kind := if b.pref.is_verbose { '$err.reporter warning #$b.checker.nr_errors:' } else { 'warning:' }
|
||||
ferror := util.formatted_error(kind, err.message, err.file_path, err.pos)
|
||||
eprintln(ferror)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fn verror(s string) {
|
||||
util.verror('builder error', s)
|
||||
}
|
||||
|
@ -18,13 +18,7 @@ pub fn (mut b Builder) gen_c(v_files []string) string {
|
||||
t2 := time.ticks()
|
||||
check_time := t2 - t1
|
||||
b.info('CHECK: ${check_time}ms')
|
||||
if b.checker.nr_warnings > 0 {
|
||||
b.print_warnings(b.checker.warnings)
|
||||
}
|
||||
if b.checker.nr_errors > 0 {
|
||||
b.print_errors(b.checker.errors)
|
||||
exit(1)
|
||||
}
|
||||
b.print_warnings_and_errors()
|
||||
// println('starting cgen...')
|
||||
// TODO: move gen.cgen() to c.gen()
|
||||
res := gen.cgen(b.parsed_files, b.table, b.pref)
|
||||
|
@ -18,9 +18,7 @@ pub fn (mut b Builder) gen_js(v_files []string) string {
|
||||
t2 := time.ticks()
|
||||
check_time := t2 - t1
|
||||
b.info('CHECK: ${check_time}ms')
|
||||
if b.checker.nr_errors > 0 {
|
||||
exit(1)
|
||||
}
|
||||
b.print_warnings_and_errors()
|
||||
res := js.gen(b.parsed_files, b.table, b.pref)
|
||||
t3 := time.ticks()
|
||||
gen_time := t3 - t2
|
||||
|
Loading…
Reference in New Issue
Block a user