Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Dec 16, 2024
1 parent 679a6f6 commit d054883
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions vlib/v/gen/c/assign.v
Original file line number Diff line number Diff line change
Expand Up @@ -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('*')
Expand Down
5 changes: 2 additions & 3 deletions vlib/v/gen/c/dumpexpr.v
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions vlib/v/gen/c/for.v
Original file line number Diff line number Diff line change
Expand Up @@ -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}]'
Expand Down Expand Up @@ -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)};')
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit d054883

Please sign in to comment.