cgen: 1 error left

pull/4084/head
Alexander Medvednikov 2020-03-20 20:35:00 +01:00
parent 8077a7534e
commit 4b36098e07
4 changed files with 14 additions and 7 deletions

View File

@ -22,20 +22,24 @@ fn parse_arguments(args []string) (pref.Preferences, []string) {
exit(1) exit(1)
} }
if backend.len == 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.') println('V error: Unknown backend ${backend[0]} provided.')
exit(1) exit(1)
} }
p.backend = x
} else { } else {
p.backend = .c 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('V error: Error while parsing flags.')
println(err) println(err)
println('Args:') println('Args:')
println(args) println(args)
exit(1) exit(1)
} }
mut remaining := remaining2 // TODO cgen bug
match remaining[0] { match remaining[0] {
'run' { 'run' {
p.is_run = true p.is_run = true

View File

@ -49,14 +49,14 @@ pub fn new_cgen(out_name_c string) &CGen {
return &CGen{ return &CGen{
} }
} }
gen := &CGen{ return &CGen{
out_path: path out_path: path
out: out out: out
// buf: strings.new_builder(10000) // buf: strings.new_builder(10000)
lines: make(0, 1000, sizeof(string)) lines: make(0, 1000, sizeof(string))
} }
return gen //return gen
} }
fn (g mut CGen) genln(s string) { fn (g mut CGen) genln(s string) {

View File

@ -133,8 +133,9 @@ fn find_vs(vswhere_dir string, host_arch string) ?VsInstallation {
println('Unable to find msvc version') println('Unable to find msvc version')
return error('Unable to find vs installation') return error('Unable to find vs installation')
} }
version2 := version // TODO remove. cgen option bug if expr
// println('version: $version') // 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' lib_path := '$res.output\\VC\\Tools\\MSVC\\$v\\lib\\$host_arch'
include_path := '$res.output\\VC\\Tools\\MSVC\\$v\\include' include_path := '$res.output\\VC\\Tools\\MSVC\\$v\\include'
if os.exists('$lib_path\\vcruntime.lib') { if os.exists('$lib_path\\vcruntime.lib') {

View File

@ -110,7 +110,7 @@ pub fn (t Time) get_fmt_date_str(fmt_dlmtr FormatDelimiter, fmt_date FormatDate)
} }
month := '${t.smonth()}' month := '${t.smonth()}'
year := t.year.str()[2..] year := t.year.str()[2..]
return match fmt_date { mut res := match fmt_date {
.ddmmyy{ .ddmmyy{
'${t.day:02d}|${t.month:02d}|$year' '${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}' '${t.year}|${t.month:02d}|${t.day:02d}'
} }
else { else {
'unknown enumeration $fmt_date'}}.replace('|', match fmt_dlmtr { 'unknown enumeration $fmt_date'}}
res = res.replace('|', match fmt_dlmtr {
.dot{ .dot{
'.' '.'
} }
@ -151,6 +152,7 @@ pub fn (t Time) get_fmt_date_str(fmt_dlmtr FormatDelimiter, fmt_date FormatDate)
} }
else { else {
'unknown enumeration $fmt_dlmtr'}}) 'unknown enumeration $fmt_dlmtr'}})
return res
} }
// get_fmt_str returns a date string with specified FormatDelimiter, // get_fmt_str returns a date string with specified FormatDelimiter,