Remove println2

pull/402/head
Alexander Medvednikov 2019-06-23 10:01:55 +02:00
parent ee5d6f1e7f
commit 20b5c4b88b
10 changed files with 26 additions and 30 deletions

View File

@ -8,7 +8,7 @@ pub fn exit(reason string) {
if reason == '' { if reason == '' {
panic('exit empty reason') panic('exit empty reason')
} }
println2('exit(): $reason') println('exit(): $reason')
C.exit(0) C.exit(0)
} }
@ -31,7 +31,7 @@ pub fn print_backtrace() {
} }
pub fn panic(s string) { pub fn panic(s string) {
println2('V panic: $s') println('V panic: $s')
print_backtrace() print_backtrace()
C.exit(1) C.exit(1)
} }
@ -53,7 +53,7 @@ pub fn eprintln(s string) {
} }
// TODO issues with stderr and cross compiling for Linux // TODO issues with stderr and cross compiling for Linux
$else { $else {
println2(s) println(s)
} }
} }
@ -61,10 +61,6 @@ pub fn print(s string) {
C.printf('%.*s', s.len, s.str) C.printf('%.*s', s.len, s.str)
} }
fn println2(s string) {
C.printf('%.*s\n', s.len, s.str)
}
pub fn malloc(n int) byteptr { pub fn malloc(n int) byteptr {
if n < 0 { if n < 0 {
panic('malloc(<0)') panic('malloc(<0)')
@ -78,7 +74,7 @@ pub fn malloc(n int) byteptr {
total := i64(0) total := i64(0)
# total_m += n; # total_m += n;
# total = total_m; # total = total_m;
println2('\n\n\nmalloc($n) total=$total') println('\n\n\nmalloc($n) total=$total')
print_backtrace() print_backtrace()
#endif #endif
ptr := C.malloc(n) ptr := C.malloc(n)

View File

@ -228,7 +228,7 @@ pub fn (s string) split(delim string) []string {
} }
if delim.len == 1 { if delim.len == 1 {
return s.split_single(delim[0]) return s.split_single(delim[0])
// println2('split 1 only') // println('split 1 only')
// os.exit() // os.exit()
} }
mut i := 0 mut i := 0

View File

@ -201,7 +201,7 @@ fn (s string) is_utf8() int {
return -1 return -1
} }
if !ok { if !ok {
println2('utf is bad dalen=$len KEK $s sdf') println('utf is bad dalen=$len KEK $s sdf')
// s = s.left(i) // s = s.left(i)
} }
return i return i
@ -215,7 +215,7 @@ fn (s string) runes() []string {
res := []string{} res := []string{}
if !s.is_utf8() { if !s.is_utf8() {
mys := s mys := s
println2('string.me runes bad utf $mys HAHA') println('string.me runes bad utf $mys HAHA')
return res return res
} }
for i := 0; i < s.len; i++ { for i := 0; i < s.len; i++ {

View File

@ -91,7 +91,7 @@ fn main() {
args := os.args args := os.args
// Print the version and exit. // Print the version and exit.
if 'version' in args { if 'version' in args {
println2('V $Version') println('V $Version')
return return
} }
if '-h' in args || '--help' in args || 'help' in args { if '-h' in args || '--help' in args || 'help' in args {
@ -120,7 +120,7 @@ fn main() {
if !file.ends_with('.v') { if !file.ends_with('.v') {
os.exit1('v fmt can only be used on .v files') os.exit1('v fmt can only be used on .v files')
} }
println2('vfmt is temporarily disabled') println('vfmt is temporarily disabled')
return return
} }
// V with no args? REPL // V with no args? REPL
@ -379,7 +379,7 @@ string _STR_TMP(const char *fmt, ...) {
ret := os.system2(cmd) ret := os.system2(cmd)
if ret != 0 { if ret != 0 {
s := os.system(cmd) s := os.system(cmd)
println2(s) println(s)
os.exit1('ret not 0, exiting') os.exit1('ret not 0, exiting')
} }
} }
@ -413,7 +413,7 @@ fn (c mut V) cc() {
else if c.build_mode == DEFAULT_MODE { else if c.build_mode == DEFAULT_MODE {
libs = '$TmpPath/vlib/builtin.o' libs = '$TmpPath/vlib/builtin.o'
if !os.file_exists(libs) { if !os.file_exists(libs) {
println2('`builtin.o` not found') println('`builtin.o` not found')
exit('') exit('')
} }
for imp in c.table.imports { for imp in c.table.imports {
@ -485,7 +485,7 @@ mut args := ''
res := os.system(cmd) res := os.system(cmd)
// println('C OUTPUT:') // println('C OUTPUT:')
if res.contains('error: ') { if res.contains('error: ') {
println2(res) println(res)
panic('clang error') panic('clang error')
} }
// Link it if we are cross compiling and need an executable // Link it if we are cross compiling and need an executable
@ -791,9 +791,9 @@ fn new_v(args[]string) *V {
} }
fn run_repl() []string { fn run_repl() []string {
println2('V $Version') println('V $Version')
println2('Use Ctrl-D to exit') println('Use Ctrl-D to exit')
println2('For now you have to use println() to print values, this will be fixed soon\n') println('For now you have to use println() to print values, this will be fixed soon\n')
file := TmpPath + '/vrepl.v' file := TmpPath + '/vrepl.v'
mut lines := []string mut lines := []string
for { for {
@ -812,7 +812,7 @@ fn run_repl() []string {
mut v := new_v( ['v', '-repl', file]) mut v := new_v( ['v', '-repl', file])
v.compile() v.compile()
s := os.system(TmpPath + '/vrepl') s := os.system(TmpPath + '/vrepl')
println2(s) println(s)
} }
else { else {
lines << line lines << line

View File

@ -450,7 +450,7 @@ fn (s mut Scanner) scan() ScanRes {
} }
return scan_res(DIV, '') return scan_res(DIV, '')
} }
println2('(char code=$c) pos=$s.pos len=$s.text.len') println('(char code=$c) pos=$s.pos len=$s.text.len')
s.error('invalid character `${c.str()}`') s.error('invalid character `${c.str()}`')
return scan_res(EOF, '') return scan_res(EOF, '')
} }
@ -458,15 +458,15 @@ fn (s mut Scanner) scan() ScanRes {
fn (s &Scanner) error(msg string) { fn (s &Scanner) error(msg string) {
// println('!! SCANNER ERROR: $msg') // println('!! SCANNER ERROR: $msg')
file := s.file_path.all_after('/') file := s.file_path.all_after('/')
println2('panic: $file:${s.line_nr + 1}') println('panic: $file:${s.line_nr + 1}')
println2(msg) println(msg)
// os.print_backtrace() // os.print_backtrace()
// println(file) // println(file)
// println(s.file_path) // println(s.file_path)
os.exit1(' ') os.exit1(' ')
} }
// println2('array out of bounds $idx len=$a.len') // println('array out of bounds $idx len=$a.len')
// This is really bad. It needs a major clean up // This is really bad. It needs a major clean up
fn (s mut Scanner) ident_string() string { fn (s mut Scanner) ident_string() string {
// println("\nidentString() at char=", string(s.text[s.pos]), // println("\nidentString() at char=", string(s.text[s.pos]),

View File

@ -615,7 +615,7 @@ fn (table mut Table) cgen_name(f &Fn) string {
} }
old := name old := name
name = 'f_$idx' name = 'f_$idx'
println2('$old ==> $name') println('$old ==> $name')
} }
return name return name
} }

View File

@ -344,7 +344,7 @@ fn new_context_text(cfg Cfg, scale int) *GG {
font_path = '/var/tmp/RobotoMono-Regular.ttf' font_path = '/var/tmp/RobotoMono-Regular.ttf'
} }
if !os.file_exists(font_path) { if !os.file_exists(font_path) {
println2('failed to load RobotoMono-Regular.ttf') println('failed to load RobotoMono-Regular.ttf')
exit('') exit('')
} }
# FT_Face face; # FT_Face face;

View File

@ -30,7 +30,7 @@ pub:
// embed 'http' // embed 'http'
fn get(url string) string { fn get(url string) string {
if url == '' { if url == '' {
println2('http: empty get url') println('http: empty get url')
return '' return ''
} }
mut req := new_request('GET', url, '') mut req := new_request('GET', url, '')

View File

@ -98,7 +98,7 @@ fn (req &Request) do() Response {
// init curl // init curl
curl := C.curl_easy_init() curl := C.curl_easy_init()
if isnil(curl) { if isnil(curl) {
println2('curl init failed') println('curl init failed')
return Response{} return Response{}
} }
// options // options

View File

@ -316,13 +316,13 @@ pub fn getenv(key string) string {
} }
fn exit(reason string) { fn exit(reason string) {
println2('exit(): $reason') println('exit(): $reason')
log(reason) log(reason)
C.exit(0) C.exit(0)
} }
fn exit1(reason string) { fn exit1(reason string) {
println2('exit(): $reason') println('exit(): $reason')
C.exit(1) C.exit(1)
} }