fmt: fix array receivers; cmd/v: -showcc
parent
d7ae9d7279
commit
f3c917e0aa
|
@ -7,7 +7,6 @@ import v.pref
|
||||||
const (
|
const (
|
||||||
skip_test_files = [
|
skip_test_files = [
|
||||||
'vlib/arrays/arrays_test.v',
|
'vlib/arrays/arrays_test.v',
|
||||||
'vlib/builtin/map_test.v',
|
|
||||||
'vlib/cli/command_test.v',
|
'vlib/cli/command_test.v',
|
||||||
'vlib/cli/flag_test.v',
|
'vlib/cli/flag_test.v',
|
||||||
'vlib/clipboard/clipboard_test.v', // Linux only
|
'vlib/clipboard/clipboard_test.v', // Linux only
|
||||||
|
|
|
@ -129,6 +129,7 @@ fn parse_args(args []string) (&pref.Preferences, string) {
|
||||||
'-stats' { res.is_stats = true }
|
'-stats' { res.is_stats = true }
|
||||||
'-obfuscate' { res.obfuscate = true }
|
'-obfuscate' { res.obfuscate = true }
|
||||||
'-translated' { res.translated = true }
|
'-translated' { res.translated = true }
|
||||||
|
'-showcc' { res.show_cc = true }
|
||||||
//'-x64' { res.translated = true }
|
//'-x64' { res.translated = true }
|
||||||
'-os' {
|
'-os' {
|
||||||
//TODO Remove `tmp` variable when it doesn't error out in C.
|
//TODO Remove `tmp` variable when it doesn't error out in C.
|
||||||
|
|
|
@ -16,6 +16,13 @@ pub fn (node &FnDecl) str(t &table.Table) string {
|
||||||
}
|
}
|
||||||
mut receiver := ''
|
mut receiver := ''
|
||||||
if node.is_method {
|
if node.is_method {
|
||||||
|
mut styp := t.type_to_str(node.receiver.typ)
|
||||||
|
mut m := if node.rec_mut { 'mut ' } else { '' }
|
||||||
|
if node.rec_mut {
|
||||||
|
styp = styp[1..] // remove &
|
||||||
|
}
|
||||||
|
receiver = '($node.receiver.name $m$styp) '
|
||||||
|
/*
|
||||||
sym := t.get_type_symbol(node.receiver.typ)
|
sym := t.get_type_symbol(node.receiver.typ)
|
||||||
name := sym.name.after('.')
|
name := sym.name.after('.')
|
||||||
mut m := if node.rec_mut { 'mut ' } else { '' }
|
mut m := if node.rec_mut { 'mut ' } else { '' }
|
||||||
|
@ -23,6 +30,7 @@ pub fn (node &FnDecl) str(t &table.Table) string {
|
||||||
m = '&'
|
m = '&'
|
||||||
}
|
}
|
||||||
receiver = '($node.receiver.name $m$name) '
|
receiver = '($node.receiver.name $m$name) '
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
name := node.name.after('.')
|
name := node.name.after('.')
|
||||||
if node.is_c {
|
if node.is_c {
|
||||||
|
@ -35,8 +43,8 @@ pub fn (node &FnDecl) str(t &table.Table) string {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
is_last_arg := i == node.args.len - 1
|
is_last_arg := i == node.args.len - 1
|
||||||
should_add_type := is_last_arg || node.args[i + 1].typ != arg.typ || (node.is_variadic && i ==
|
should_add_type := is_last_arg || node.args[i + 1].typ != arg.typ || (node.is_variadic &&
|
||||||
node.args.len - 2)
|
i == node.args.len - 2)
|
||||||
f.write(arg.name)
|
f.write(arg.name)
|
||||||
mut s := t.type_to_str(arg.typ)
|
mut s := t.type_to_str(arg.typ)
|
||||||
if arg.is_mut {
|
if arg.is_mut {
|
||||||
|
|
|
@ -323,7 +323,7 @@ start:
|
||||||
// TODO remove
|
// TODO remove
|
||||||
cmd := '${v.pref.ccompiler} $args'
|
cmd := '${v.pref.ccompiler} $args'
|
||||||
// Run
|
// Run
|
||||||
if v.pref.is_verbose {
|
if v.pref.is_verbose || v.pref.show_cc {
|
||||||
println('\n==========')
|
println('\n==========')
|
||||||
println(cmd)
|
println(cmd)
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
module builder
|
module builder
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
// parsed cflag
|
// parsed cflag
|
||||||
struct CFlag {
|
struct CFlag {
|
||||||
mod string // the module in which the flag was given
|
mod string // the module in which the flag was given
|
||||||
|
@ -23,9 +24,8 @@ fn (v &Builder) get_os_cflags() []CFlag {
|
||||||
if v.pref.compile_defines.len > 0 {
|
if v.pref.compile_defines.len > 0 {
|
||||||
ctimedefines << v.pref.compile_defines
|
ctimedefines << v.pref.compile_defines
|
||||||
}
|
}
|
||||||
|
// QTODO
|
||||||
// QTODO
|
/*
|
||||||
/*
|
|
||||||
for flag in v.table.cflags {
|
for flag in v.table.cflags {
|
||||||
if flag.os == '' || (flag.os == 'linux' && v.pref.os == .linux) || (flag.os == 'darwin' && v.pref.os == .mac) || (flag.os == 'freebsd' && v.pref.os == .freebsd) || (flag.os == 'windows' && v.pref.os == .windows) || (flag.os == 'mingw' && v.pref.os == .windows && v.pref.ccompiler != 'msvc') || (flag.os == 'solaris' && v.pref.os == .solaris) {
|
if flag.os == '' || (flag.os == 'linux' && v.pref.os == .linux) || (flag.os == 'darwin' && v.pref.os == .mac) || (flag.os == 'freebsd' && v.pref.os == .freebsd) || (flag.os == 'windows' && v.pref.os == .windows) || (flag.os == 'mingw' && v.pref.os == .windows && v.pref.ccompiler != 'msvc') || (flag.os == 'solaris' && v.pref.os == .solaris) {
|
||||||
flags << flag
|
flags << flag
|
||||||
|
@ -34,7 +34,7 @@ fn (v &Builder) get_os_cflags() []CFlag {
|
||||||
flags << flag
|
flags << flag
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
return flags
|
return flags
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,7 +152,6 @@ fn (table mut Table) parse_cflag(cflag string, mod string, ctimedefines []string
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// TODO: implement msvc specific c_options_before_target and c_options_after_target ...
|
// TODO: implement msvc specific c_options_before_target and c_options_after_target ...
|
||||||
fn (cflags []CFlag) c_options_before_target_msvc() string {
|
fn (cflags []CFlag) c_options_before_target_msvc() string {
|
||||||
return ''
|
return ''
|
||||||
|
@ -204,4 +203,3 @@ fn (cflags []CFlag) c_options_only_object_files() string {
|
||||||
}
|
}
|
||||||
return args.join(' ')
|
return args.join(' ')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -327,8 +327,7 @@ pub fn (p mut Parser) top_stmt() ast.Stmt {
|
||||||
p.next()
|
p.next()
|
||||||
p.next()
|
p.next()
|
||||||
return p.top_stmt()
|
return p.top_stmt()
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
p.error('bad top level statement ' + p.tok.str())
|
p.error('bad top level statement ' + p.tok.str())
|
||||||
return ast.Stmt{}
|
return ast.Stmt{}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ pub mut:
|
||||||
is_debug bool // false by default, turned on by -g or -cg, it tells v to pass -g to the C backend compiler.
|
is_debug bool // false by default, turned on by -g or -cg, it tells v to pass -g to the C backend compiler.
|
||||||
is_vlines bool // turned on by -g, false by default (it slows down .tmp.c generation slightly).
|
is_vlines bool // turned on by -g, false by default (it slows down .tmp.c generation slightly).
|
||||||
is_keep_c bool // -keep_c , tell v to leave the generated .tmp.c alone (since by default v will delete them after c backend finishes)
|
is_keep_c bool // -keep_c , tell v to leave the generated .tmp.c alone (since by default v will delete them after c backend finishes)
|
||||||
|
show_cc bool // -showcc, print cc command
|
||||||
// NB: passing -cg instead of -g will set is_vlines to false and is_g to true, thus making v generate cleaner C files,
|
// NB: passing -cg instead of -g will set is_vlines to false and is_g to true, thus making v generate cleaner C files,
|
||||||
// which are sometimes easier to debug / inspect manually than the .tmp.c files by plain -g (when/if v line number generation breaks).
|
// which are sometimes easier to debug / inspect manually than the .tmp.c files by plain -g (when/if v line number generation breaks).
|
||||||
is_cache bool // turns on v usage of the module cache to speed up compilation.
|
is_cache bool // turns on v usage of the module cache to speed up compilation.
|
||||||
|
|
Loading…
Reference in New Issue