From 4b36098e070839ead73ed9676aa4466ffe0af877 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Fri, 20 Mar 2020 20:35:00 +0100 Subject: [PATCH] cgen: 1 error left --- cmd/v/internal/compile/compile_options.v | 8 ++++++-- vlib/compiler/cgen.v | 4 ++-- vlib/compiler/msvc.v | 3 ++- vlib/time/format.v | 6 ++++-- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/cmd/v/internal/compile/compile_options.v b/cmd/v/internal/compile/compile_options.v index 19c553672f..7bde3e87bd 100644 --- a/cmd/v/internal/compile/compile_options.v +++ b/cmd/v/internal/compile/compile_options.v @@ -22,20 +22,24 @@ fn parse_arguments(args []string) (pref.Preferences, []string) { exit(1) } if backend.len == 1 { - p.backend = pref.backend_from_string(backend[0]) or { + +// TODO remove tmp var after cgen optional bug is fixed + x := pref.backend_from_string(backend[0]) or { println('V error: Unknown backend ${backend[0]} provided.') exit(1) } + p.backend = x } else { p.backend = .c } - mut remaining := flag.parse_pref(args, parse_options, p) or { + remaining2 := flag.parse_pref(args, parse_options, p) or { println('V error: Error while parsing flags.') println(err) println('Args:') println(args) exit(1) } + mut remaining := remaining2 // TODO cgen bug match remaining[0] { 'run' { p.is_run = true diff --git a/vlib/compiler/cgen.v b/vlib/compiler/cgen.v index ecbf7facde..335e4b5b8b 100644 --- a/vlib/compiler/cgen.v +++ b/vlib/compiler/cgen.v @@ -49,14 +49,14 @@ pub fn new_cgen(out_name_c string) &CGen { return &CGen{ } } - gen := &CGen{ + return &CGen{ out_path: path out: out // buf: strings.new_builder(10000) lines: make(0, 1000, sizeof(string)) } - return gen + //return gen } fn (g mut CGen) genln(s string) { diff --git a/vlib/compiler/msvc.v b/vlib/compiler/msvc.v index 5b5f9fbac2..ce3f1a5976 100644 --- a/vlib/compiler/msvc.v +++ b/vlib/compiler/msvc.v @@ -133,8 +133,9 @@ fn find_vs(vswhere_dir string, host_arch string) ?VsInstallation { println('Unable to find msvc version') return error('Unable to find vs installation') } + version2 := version // TODO remove. cgen option bug if expr // println('version: $version') - v := if version.ends_with('\n') { version[..version.len - 2] } else { version } + v := if version.ends_with('\n') { version2[..version.len - 2] } else {version2 } lib_path := '$res.output\\VC\\Tools\\MSVC\\$v\\lib\\$host_arch' include_path := '$res.output\\VC\\Tools\\MSVC\\$v\\include' if os.exists('$lib_path\\vcruntime.lib') { diff --git a/vlib/time/format.v b/vlib/time/format.v index 7d44568538..b60bebeae3 100644 --- a/vlib/time/format.v +++ b/vlib/time/format.v @@ -110,7 +110,7 @@ pub fn (t Time) get_fmt_date_str(fmt_dlmtr FormatDelimiter, fmt_date FormatDate) } month := '${t.smonth()}' year := t.year.str()[2..] - return match fmt_date { +mut res := match fmt_date { .ddmmyy{ '${t.day:02d}|${t.month:02d}|$year' } @@ -136,7 +136,8 @@ pub fn (t Time) get_fmt_date_str(fmt_dlmtr FormatDelimiter, fmt_date FormatDate) '${t.year}|${t.month:02d}|${t.day:02d}' } else { - 'unknown enumeration $fmt_date'}}.replace('|', match fmt_dlmtr { + 'unknown enumeration $fmt_date'}} + res = res.replace('|', match fmt_dlmtr { .dot{ '.' } @@ -151,6 +152,7 @@ pub fn (t Time) get_fmt_date_str(fmt_dlmtr FormatDelimiter, fmt_date FormatDate) } else { 'unknown enumeration $fmt_dlmtr'}}) + return res } // get_fmt_str returns a date string with specified FormatDelimiter,