1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

native: rename cgen to code_gen to avoid confusion with cgen

This commit is contained in:
Alexander Medvednikov 2021-09-10 03:17:53 +03:00
parent 0370d4f268
commit afeb1525a1
3 changed files with 8 additions and 9 deletions

View File

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

View File

@ -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)
}
*/

View File

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