1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

run vfmt on array.v

This commit is contained in:
Alexander Medvednikov
2019-12-18 20:07:32 +03:00
parent 9e11de4a8c
commit 1cef83aea4
5 changed files with 46 additions and 43 deletions

View File

@@ -15,7 +15,7 @@ fn todo() {
}
fn (v &V) no_cc_installed() bool {
$if windows {
$if windows {
os.exec('$v.pref.ccompiler -v') or {
if v.pref.is_verbose {
println('C compiler not found, trying to build with msvc...')
@@ -27,6 +27,9 @@ fn (v &V) no_cc_installed() bool {
}
fn (v mut V) cc() {
if os.executable().contains('vfmt') {
return
}
v.build_thirdparty_obj_files()
vexe := vexe_path()
vdir := os.dir(vexe)

View File

@@ -221,7 +221,7 @@ fn (p mut Parser) fn_decl() {
mut f := Fn{
mod: p.mod
is_public: is_pub || p.is_vh // functions defined in .vh are always public
is_unsafe: p.attr == 'unsafe_fn'
is_deprecated: p.attr == 'deprecated'
comptime_define: if p.attr.starts_with('if ') {p.attr[3..]}else {''}
@@ -454,7 +454,7 @@ fn (p mut Parser) fn_decl() {
p.genln('; // $f.name')
}
// Generic functions are inserted as needed from the call site
if f.is_generic {
if f.is_generic && !p.scanner.is_fmt {
if p.first_pass() {
if !p.scanner.is_vh {
gpidx := p.v.get_file_parser_index(p.file_path) or {
@@ -885,7 +885,7 @@ fn (p mut Parser) fn_args(f mut Fn) {
typ: typ
is_arg: true
// is_mut: is_mut
line_nr: p.scanner.line_nr
token_idx: p.cur_tok_index()
}
@@ -1271,7 +1271,7 @@ fn (p mut Parser) fn_call_args(f mut Fn) {
p.error('wrong number of arguments in call to `${f.str_for_error()}`')
}
p.check(.rpar)
if f.is_generic {
if f.is_generic && !p.scanner.is_fmt {
type_map := p.extract_type_inst(f, saved_args)
p.dispatch_generic_fn_instance(mut f, &type_map)
}

View File

@@ -124,7 +124,7 @@ pub mut:
comptime_define string // -D vfmt for `if $vfmt {`
fast bool // use tcc/x64 codegen
enable_globals bool // allow __global for low level code
is_fmt bool
//is_fmt bool
is_bare bool
user_mod_path string // `v -user_mod_path /Users/user/modules` adds a new lookup path for imported modules
@@ -1093,7 +1093,7 @@ pub fn new_v(args[]string) &V {
ccompiler: find_c_compiler()
building_v: !is_repl && (rdir_name == 'compiler' || rdir_name == 'v.v' || dir.contains('vlib'))
comptime_define: comptime_define
is_fmt: comptime_define == 'vfmt'
//is_fmt: comptime_define == 'vfmt'
user_mod_path: user_mod_path
vlib_path: vlib_path
vpath: vpath

View File

@@ -130,11 +130,11 @@ fn (p mut Parser) fmt_dec() {
}
[if vfmt]
fn (p mut Scanner) init_fmt() {
fn (s mut Scanner) init_fmt() {
// Right now we can't do `$if vfmt {`, so I'm using
// a conditional function init_fmt to set this flag.
// This function will only be called if `-d vfmt` is passed.
p.is_fmt = true
s.is_fmt = true
}
[if vfmt]
@@ -243,7 +243,7 @@ fn (p &Parser) gen_fmt() {
if s == '' {
return
}
if !p.file_name.contains('fn.v') {return}
if !p.file_name.contains('parser.v') {return}
path := os.tmpdir() + '/' + p.file_name
println('generating ${path}')
mut out := os.create(path) or {