v: show the number of processed bytes and lines for V source code with -stats
parent
fef4e1e700
commit
de5cf4ac5e
|
@ -543,6 +543,8 @@ pub struct File {
|
||||||
pub:
|
pub:
|
||||||
path string // absolute path of the source file - '/projects/v/file.v'
|
path string // absolute path of the source file - '/projects/v/file.v'
|
||||||
path_base string // file name - 'file.v' (useful for tracing)
|
path_base string // file name - 'file.v' (useful for tracing)
|
||||||
|
lines int // number of source code lines in the file (including newlines and comments)
|
||||||
|
bytes int // number of processed source code bytes
|
||||||
mod Module // the module of the source file (from `module xyz` at the top)
|
mod Module // the module of the source file (from `module xyz` at the top)
|
||||||
global_scope &Scope
|
global_scope &Scope
|
||||||
pub mut:
|
pub mut:
|
||||||
|
|
|
@ -48,6 +48,12 @@ pub fn (mut b Builder) build_c(v_files []string, out_file string) {
|
||||||
if b.pref.is_stats {
|
if b.pref.is_stats {
|
||||||
slines := util.bold((output2.count('\n') + 1).str())
|
slines := util.bold((output2.count('\n') + 1).str())
|
||||||
sbytes := util.bold(output2.len.str())
|
sbytes := util.bold(output2.len.str())
|
||||||
|
mut all_v_source_lines, mut all_v_source_bytes := 0, 0
|
||||||
|
for mut pf in b.parsed_files {
|
||||||
|
all_v_source_lines += pf.lines
|
||||||
|
all_v_source_bytes += pf.bytes
|
||||||
|
}
|
||||||
|
println(' V source code size: ${util.bold(all_v_source_lines.str())} lines, ${util.bold(all_v_source_bytes.str())} bytes')
|
||||||
println('generated C source code size: $slines lines, $sbytes bytes')
|
println('generated C source code size: $slines lines, $sbytes bytes')
|
||||||
}
|
}
|
||||||
// os.write_file(out_file, b.gen_c(v_files))
|
// os.write_file(out_file, b.gen_c(v_files))
|
||||||
|
|
|
@ -272,6 +272,8 @@ pub fn (mut p Parser) parse() ast.File {
|
||||||
return ast.File{
|
return ast.File{
|
||||||
path: p.file_name
|
path: p.file_name
|
||||||
path_base: p.file_base
|
path_base: p.file_base
|
||||||
|
lines: p.scanner.line_nr
|
||||||
|
bytes: p.scanner.text.len
|
||||||
mod: module_decl
|
mod: module_decl
|
||||||
imports: p.ast_imports
|
imports: p.ast_imports
|
||||||
imported_symbols: p.imported_symbols
|
imported_symbols: p.imported_symbols
|
||||||
|
|
Loading…
Reference in New Issue