From b69ebd73b214078eb06b0759e875541e958d09f2 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Sun, 22 Mar 2020 16:55:42 +0100 Subject: [PATCH] cgen: minor fixes. v2 can now compile itself! --- vlib/os/os_nix.v | 2 +- vlib/v/gen/cgen.v | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/vlib/os/os_nix.v b/vlib/os/os_nix.v index 6c57dff35f..1d0915829d 100644 --- a/vlib/os/os_nix.v +++ b/vlib/os/os_nix.v @@ -210,7 +210,7 @@ pub fn exec(cmd string) ?Result { res.write_bytes( buf, vstrlen(buf) ) } soutput := res.str().trim_space() - res.free() + //res.free() exit_code := vpclose(f) // if exit_code != 0 { // return error(res) diff --git a/vlib/v/gen/cgen.v b/vlib/v/gen/cgen.v index f9102d4e53..bed48132c6 100644 --- a/vlib/v/gen/cgen.v +++ b/vlib/v/gen/cgen.v @@ -54,7 +54,9 @@ pub fn cgen(files []ast.File, table &table.Table) string { for file in files { g.file = file // println('\ncgen "$g.file.path" nr_stmts=$file.stmts.len') - if g.file.path == '' || g.file.path.ends_with('.vv') || g.file.path.contains('/vlib/') { + building_v := g.file.path.contains('/vlib/') || g.file.path.contains('cmd/v') + is_test := g.file.path.ends_with('.vv') + if g.file.path == '' || is_test || building_v { // cgen test or building V // println('autofree=false') g.autofree = false @@ -100,7 +102,7 @@ pub fn (g mut Gen) typ(t table.Type) string { if styp.starts_with('C__') { styp = styp[3..] } - if styp in ['stat', 'dirent*', 'tm', 'tm*', 'winsize', 'sigaction'] { + if styp in ['stat', 'dirent*', 'tm', 'tm*', 'winsize', 'sigaction', 'timeval'] { // TODO perf and other C structs styp = 'struct $styp' }