From afeb1525a184ddd5a39916606dd1dbab91865345 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Fri, 10 Sep 2021 03:17:53 +0300 Subject: [PATCH] native: rename cgen to code_gen to avoid confusion with cgen --- examples/dynamic_library_loading/use.v | 3 +-- vlib/v/gen/native/gen.v | 12 ++++++------ vlib/v/gen/native/macho_test.v | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/examples/dynamic_library_loading/use.v b/examples/dynamic_library_loading/use.v index 71a0099f75..38b7122435 100644 --- a/examples/dynamic_library_loading/use.v +++ b/examples/dynamic_library_loading/use.v @@ -9,8 +9,7 @@ fn main() { library_file_path := os.join_path(os.getwd(), dl.get_libname('library')) handle := dl.open_opt(library_file_path, dl.rtld_lazy) ? eprintln('handle: ${ptr_str(handle)}') - mut f := FNAdder(0) - f = dl.sym_opt(handle, 'add_1') ? + f := FNAdder(dl.sym_opt(handle, 'add_1') ?) eprintln('f: ${ptr_str(f)}') res := f(1, 2) eprintln('res: $res') diff --git a/vlib/v/gen/native/gen.v b/vlib/v/gen/native/gen.v index 6df674f017..8859790882 100644 --- a/vlib/v/gen/native/gen.v +++ b/vlib/v/gen/native/gen.v @@ -26,7 +26,7 @@ pub struct Gen { out_name string pref &pref.Preferences // Preferences shared from V struct mut: - cgen CodeGen + code_gen CodeGen table &ast.Table buf []byte sect_header_name_pos int @@ -79,12 +79,12 @@ pub fn gen(files []&ast.File, table &ast.Table, out_name string, pref &pref.Pref out_name: out_name pref: pref // TODO: workaround, needs to support recursive init - cgen: get_backend(pref.arch) or { + code_gen: get_backend(pref.arch) or { eprintln('No available backend for this configuration. Use `-a arm64` or `-a amd64`.') exit(1) } } - g.cgen.g = g + g.code_gen.g = g g.generate_header() for file in files { if file.warnings.len > 0 { @@ -404,8 +404,8 @@ fn (mut g Gen) for_in_stmt(node ast.ForInStmt) { } pub fn (mut g Gen) gen_exit(node ast.Expr) { - // check node type and then call the cgen method - g.cgen.gen_exit(mut g, node) + // check node type and then call the code_gen method + g.code_gen.gen_exit(mut g, node) } fn (mut g Gen) stmt(node ast.Stmt) { @@ -543,7 +543,7 @@ fn (mut g Gen) expr(node ast.Expr) { /* fn (mut g Gen) allocate_var(name string, size int, initial_val int) { - g.cgen.allocate_var(name, size, initial_val) + g.code_gen.allocate_var(name, size, initial_val) } */ diff --git a/vlib/v/gen/native/macho_test.v b/vlib/v/gen/native/macho_test.v index aea9ff4b7f..512ab4e4cc 100644 --- a/vlib/v/gen/native/macho_test.v +++ b/vlib/v/gen/native/macho_test.v @@ -9,7 +9,7 @@ fn test_macho() { pref: &pref.Preferences{} out_name: 'test.bin' table: ast.new_table() - cgen: native.Amd64{ + code_gen: native.Amd64{ g: 0 } }