vfmt: ran `v vet vlib/v/` and fix spaces

pull/5656/head
Delyan Angelov 2020-07-04 16:19:54 +03:00
parent d2a2db7bff
commit fe50bdc164
7 changed files with 56 additions and 72 deletions

View File

@ -36,7 +36,6 @@ pub fn (mut o OrderedDepMap) add(name string, deps []string) {
if dep !in d { if dep !in d {
d << dep d << dep
} }
//
else{} else{}
} }
o.set(name, d) o.set(name, d)

View File

@ -1,6 +1,6 @@
import v.table //import v.table
import v.doc //import v.doc
import v.pref //import v.pref
// fn test_vdoc() { // fn test_vdoc() {
// mut prefs := &pref.Preferences{} // mut prefs := &pref.Preferences{}

View File

@ -9,8 +9,7 @@ import os
pub enum BuildMode { pub enum BuildMode {
// `v program.v' // `v program.v'
// Build user code only, and add pre-compiled vlib (`cc program.o builtin.o os.o...`) // Build user code only, and add pre-compiled vlib (`cc program.o builtin.o os.o...`)
default_mode default_mode // `v -lib ~/v/os`
// `v -lib ~/v/os`
// build any module (generate os.o + os.vh) // build any module (generate os.o + os.vh)
build_module build_module
} }
@ -41,10 +40,8 @@ pub enum CompilerType {
} }
const ( const (
list_of_flags_with_param = [ list_of_flags_with_param = ['o', 'output', 'd', 'define', 'b', 'backend', 'cc', 'os', 'target-os',
'o' 'arch', 'csource', 'cf', 'cflags', 'path']
'output', 'd', 'define', 'b', 'backend', 'cc', 'os', 'target-os', 'arch', 'csource'
'cf', 'cflags', 'path']
) )
pub struct Preferences { pub struct Preferences {
@ -53,7 +50,7 @@ pub mut:
backend Backend backend Backend
build_mode BuildMode build_mode BuildMode
output_mode OutputMode = .stdout output_mode OutputMode = .stdout
//verbosity VerboseLevel // verbosity VerboseLevel
is_verbose bool is_verbose bool
// nofmt bool // disable vfmt // nofmt bool // disable vfmt
is_test bool // `v test string_test.v` is_test bool // `v test string_test.v`
@ -107,11 +104,9 @@ pub mut:
vroot string vroot string
out_name string out_name string
path string // Path to file/folder to compile path string // Path to file/folder to compile
// -d vfmt and -d another=0 for `$if vfmt { will execute }` and `$if another { will NOT get here }` // -d vfmt and -d another=0 for `$if vfmt { will execute }` and `$if another { will NOT get here }`
compile_defines []string // just ['vfmt'] compile_defines []string // just ['vfmt']
compile_defines_all []string // contains both: ['vfmt','another'] compile_defines_all []string // contains both: ['vfmt','another']
run_args []string // `v run x.v 1 2 3` => `1 2 3` run_args []string // `v run x.v 1 2 3` => `1 2 3`
printfn_list []string // a list of generated function names, whose source should be shown, for debugging printfn_list []string // a list of generated function names, whose source should be shown, for debugging
print_v_files bool // when true, just print the list of all parsed .v files then stop. print_v_files bool // when true, just print the list of all parsed .v files then stop.
@ -124,7 +119,7 @@ pub mut:
} }
pub fn parse_args(args []string) (&Preferences, string) { pub fn parse_args(args []string) (&Preferences, string) {
mut res := &pref.Preferences{} mut res := &Preferences{}
mut command := '' mut command := ''
mut command_pos := 0 mut command_pos := 0
// for i, arg in args { // for i, arg in args {
@ -222,7 +217,7 @@ pub fn parse_args(args []string) (&Preferences, string) {
'-os' { '-os' {
target_os := cmdline.option(current_args, '-os', '') target_os := cmdline.option(current_args, '-os', '')
i++ i++
target_os_kind := pref.os_from_string(target_os) or { target_os_kind := os_from_string(target_os) or {
if target_os == 'cross' { if target_os == 'cross' {
res.output_cross_c = true res.output_cross_c = true
continue continue
@ -256,7 +251,7 @@ pub fn parse_args(args []string) (&Preferences, string) {
i++ i++
} }
'-b' { '-b' {
b := pref.backend_from_string(cmdline.option(current_args, '-b', 'c')) or { b := backend_from_string(cmdline.option(current_args, '-b', 'c')) or {
continue continue
} }
res.backend = b res.backend = b
@ -318,21 +313,12 @@ pub fn parse_args(args []string) (&Preferences, string) {
return res, command return res, command
} }
pub fn backend_from_string(s string) ?Backend { pub fn backend_from_string(s string) ?Backend {
match s { match s {
'c' { 'c' { return .c }
return .c 'js' { return .js }
} 'x64' { return .x64 }
'js' { else { return error('Unknown backend type $s') }
return .js
}
'x64' {
return .x64
}
else {
return error('Unknown backend type $s')
}
} }
} }

View File

@ -227,7 +227,6 @@ pub fn (mut t Table) register_builtin_type_symbol(typ TypeSymbol) int {
kind: existing_type.kind kind: existing_type.kind
} }
} }
//
else { else {
t.types[existing_idx] = typ t.types[existing_idx] = typ
} }