From 1abb40dc46b80f6f134f8094e479606a37dee4a1 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Tue, 8 Dec 2020 19:52:29 +0100 Subject: [PATCH] cgen: use `cur_mode ast.Module` instead of a string --- vlib/os/file.v | 1 - vlib/v/gen/cgen.v | 9 ++++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/vlib/os/file.v b/vlib/os/file.v index 2317424ff3..5691ac644e 100644 --- a/vlib/os/file.v +++ b/vlib/os/file.v @@ -77,7 +77,6 @@ pub fn (mut f File) write_string(s string) ?int { return written } - // write_to implements the RandomWriter interface pub fn (mut f File) write_to(pos int, buf []byte) ?int { C.fseek(f.cfile, pos, C.SEEK_SET) diff --git a/vlib/v/gen/cgen.v b/vlib/v/gen/cgen.v index cfa70b8707..5c8e5b3656 100644 --- a/vlib/v/gen/cgen.v +++ b/vlib/v/gen/cgen.v @@ -114,8 +114,7 @@ mut: // autofree_pregen_buf strings.Builder // autofree_tmp_vars []string // to avoid redefining the same tmp vars in a single function called_fn_name string - cur_mod string // TODO remove - cur_mod_node ast.Module + cur_mod ast.Module is_js_call bool // for handling a special type arg #1 `json.decode(User, ...)` // nr_vars_to_free int // doing_autofree_tmp bool @@ -1090,8 +1089,8 @@ fn (mut g Gen) stmt(node ast.Stmt) { ast.Module { // g.is_builtin_mod = node.name == 'builtin' g.is_builtin_mod = node.name in ['builtin', 'os', 'strconv', 'strings', 'gg'] - g.cur_mod = node.name - g.cur_mod_node = node + // g.cur_mod = node.name + g.cur_mod = node } ast.Return { g.write_defer_stmts_when_needed() @@ -2212,7 +2211,7 @@ fn (mut g Gen) autofree_var_call(free_fn_name string, v ast.Var) { if v.typ.is_ptr() { g.writeln('\t${free_fn_name}(${c_name(v.name)}); // autofreed ptr var') } else { - g.writeln('\t${free_fn_name}(&${c_name(v.name)}); // autofreed var $g.cur_mod $g.is_builtin_mod') + g.writeln('\t${free_fn_name}(&${c_name(v.name)}); // autofreed var $g.cur_mod.name $g.is_builtin_mod') } }