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)
}
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

View File

@ -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) {

View File

@ -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') {

View File

@ -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,