diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 02441a86ee..cc281518f2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -155,6 +155,8 @@ jobs: ../../vprod -backend x64 -o 1m 1m.v echo "Running it..." ls + - name: V self compilation with -autofree + run: ./v -o v2 -autofree cmd/v && ./v2 -o v3 -autofree cmd/v && ./v3 -o v4 -autofree cmd/v # - name: SDL examples # run: git clone --depth 1 https://github.com/vlang/sdl && cd sdl diff --git a/vlib/v/builder/c.v b/vlib/v/builder/c.v index 252e63b5ca..8e9d0e2651 100644 --- a/vlib/v/builder/c.v +++ b/vlib/v/builder/c.v @@ -33,11 +33,11 @@ pub fn (mut b Builder) gen_c(v_files []string) string { pub fn (mut b Builder) build_c(v_files []string, out_file string) { b.out_name_c = out_file b.info('build_c($out_file)') - output := b.gen_c(v_files) + output2 := b.gen_c(v_files) mut f := os.create(out_file) or { panic(err) } - f.writeln(output) + f.writeln(output2) f.close() // os.write_file(out_file, b.gen_c(v_files)) } diff --git a/vlib/v/builder/compile.v b/vlib/v/builder/compile.v index df7f85a599..c08c7c5fda 100644 --- a/vlib/v/builder/compile.v +++ b/vlib/v/builder/compile.v @@ -43,7 +43,14 @@ pub fn compile(command string, pref &pref.Preferences) { if pref.is_test || pref.is_run { b.run_compiled_executable_and_exit() } - // v.finalize_compilation() + b.myfree() +} + +// Temporary, will be done by -autofree +fn (mut b Builder) myfree() { + // for file in b.parsed_files { + // } + b.parsed_files.free() } fn (mut b Builder) run_compiled_executable_and_exit() { @@ -152,7 +159,7 @@ pub fn (v Builder) get_user_files() []string { preludes_path := os.join_path(vroot, 'cmd', 'tools', 'preludes') if v.pref.is_livemain || v.pref.is_liveshared { user_files << os.join_path(preludes_path, 'live.v') - } + } if v.pref.is_livemain { user_files << os.join_path(preludes_path, 'live_main.v') } diff --git a/vlib/v/gen/cgen.v b/vlib/v/gen/cgen.v index 3beb5d5725..940da36aa3 100644 --- a/vlib/v/gen/cgen.v +++ b/vlib/v/gen/cgen.v @@ -1053,7 +1053,9 @@ fn (mut g Gen) autofree_scope_vars(pos int) string { fn (g &Gen) autofree_variable(v ast.Var) string { sym := g.table.get_type_symbol(v.typ) - // eprintln(' > var name: ${v.name:-20s} | is_arg: ${v.is_arg.str():6} | var type: ${int(v.typ):8} | type_name: ${sym.name:-33s}') + // if v.name.contains('output2') { + eprintln(' > var name: ${v.name:-20s} | is_arg: ${v.is_arg.str():6} | var type: ${int(v.typ):8} | type_name: ${sym.name:-33s}') + // } if sym.kind == .array { return g.autofree_var_call('array_free', v) }