From 0c78422989aaf19c0693c07505e08f2630b27272 Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Mon, 16 Dec 2024 18:55:55 -0300 Subject: [PATCH] fix --- vlib/v/gen/c/assign.v | 4 ++-- vlib/v/gen/c/dumpexpr.v | 5 ++--- vlib/v/gen/c/for.v | 12 ++++++------ 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/vlib/v/gen/c/assign.v b/vlib/v/gen/c/assign.v index b2df3b9daf5d7c..2b03545b63006b 100644 --- a/vlib/v/gen/c/assign.v +++ b/vlib/v/gen/c/assign.v @@ -1014,8 +1014,8 @@ fn (mut g Gen) gen_cross_var_assign(node &ast.AssignStmt) { } } } - if left_sym.kind == .function { - g.write_fn_ptr_decl(left_sym.info as ast.FnType, '_var_${left.pos.pos}') + if left_sym.info is ast.FnType { + g.write_fn_ptr_decl(&left_sym.info, '_var_${left.pos.pos}') g.writeln(' = ${anon_ctx}${c_name(left.name)};') } else if left_is_auto_deref_var { styp := g.styp(left_typ).trim('*') diff --git a/vlib/v/gen/c/dumpexpr.v b/vlib/v/gen/c/dumpexpr.v index 246a07388280af..216ed85dba43df 100644 --- a/vlib/v/gen/c/dumpexpr.v +++ b/vlib/v/gen/c/dumpexpr.v @@ -129,11 +129,10 @@ fn (mut g Gen) dump_expr_definitions() { str_dumparg_type += g.cc_type(typ, true) + ptr_asterisk } mut is_fixed_arr_ret := false - if dump_sym.kind == .function && !is_option { - fninfo := dump_sym.info as ast.FnType + if dump_sym.info is ast.FnType && !is_option { str_dumparg_type = 'DumpFNType_${name}' tdef_pos := g.out.len - g.write_fn_ptr_decl(&fninfo, str_dumparg_type) + g.write_fn_ptr_decl(&dump_sym.info, str_dumparg_type) str_tdef := g.out.after(tdef_pos) g.go_back(str_tdef.len) dump_typedefs['typedef ${str_tdef};'] = true diff --git a/vlib/v/gen/c/for.v b/vlib/v/gen/c/for.v index 944a3a76c84faa..dd49db94bc3730 100644 --- a/vlib/v/gen/c/for.v +++ b/vlib/v/gen/c/for.v @@ -258,9 +258,9 @@ fn (mut g Gen) for_in_stmt(node_ ast.ForInStmt) { } g.writeln('for (int ${i} = 0; ${i} < ${cond_expr}; ++${i}) {') if node.val_var != '_' { - if val_sym.kind == .function { + if mut val_sym.info is ast.FnType { g.write('\t') - g.write_fn_ptr_decl(val_sym.info as ast.FnType, c_name(node.val_var)) + g.write_fn_ptr_decl(&val_sym.info, c_name(node.val_var)) g.writeln(' = ((voidptr*)${cond_var}${op_field}data)[${i}];') } else if val_sym.kind == .array_fixed && !node.val_is_mut { right := '((${styp}*)${cond_var}${op_field}data)[${i}]' @@ -320,9 +320,9 @@ fn (mut g Gen) for_in_stmt(node_ ast.ForInStmt) { if node.val_var != '_' { val_sym := g.table.sym(node.val_type) is_fixed_array := val_sym.kind == .array_fixed && !node.val_is_mut - if val_sym.kind == .function { + if val_sym.info is ast.FnType { g.write('\t') - g.write_fn_ptr_decl(val_sym.info as ast.FnType, c_name(node.val_var)) + g.write_fn_ptr_decl(&val_sym.info, c_name(node.val_var)) } else if is_fixed_array { styp := g.styp(node.val_type) g.writeln('\t${styp} ${c_name(node.val_var)};') @@ -387,8 +387,8 @@ fn (mut g Gen) for_in_stmt(node_ ast.ForInStmt) { } if node.val_var != '_' { val_sym := g.table.sym(node.val_type) - if val_sym.kind == .function { - g.write_fn_ptr_decl(val_sym.info as ast.FnType, c_name(node.val_var)) + if val_sym.info is ast.FnType { + g.write_fn_ptr_decl(&val_sym.info, c_name(node.val_var)) g.write(' = (*(voidptr*)') g.writeln('DenseArray_value(&${cond_var}${dot_or_ptr}key_values, ${idx}));') } else if val_sym.kind == .array_fixed && !node.val_is_mut {