From c54c9b817c2f1777624f88c3c0936fa78758ddd9 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Wed, 1 Jun 2022 06:14:28 +0300 Subject: [PATCH] cgen: c2v infix fix --- vlib/v/gen/c/cgen.v | 2 +- vlib/v/gen/c/infix.v | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/vlib/v/gen/c/cgen.v b/vlib/v/gen/c/cgen.v index a7a0176ff3..ef472526fc 100644 --- a/vlib/v/gen/c/cgen.v +++ b/vlib/v/gen/c/cgen.v @@ -1825,7 +1825,7 @@ fn (mut g Gen) stmt(node ast.Stmt) { g.global_decl(node) } ast.GotoLabel { - g.writeln('${c_name(node.name)}: {}') + g.writeln('${c_name(node.name)}: ') } ast.GotoStmt { g.write_v_source_line_info(node.pos) diff --git a/vlib/v/gen/c/infix.v b/vlib/v/gen/c/infix.v index 782dd332a5..8bd7dfd0f8 100644 --- a/vlib/v/gen/c/infix.v +++ b/vlib/v/gen/c/infix.v @@ -87,6 +87,10 @@ fn (mut g Gen) infix_expr_eq_op(node ast.InfixExpr) { right := g.unwrap(node.right_type) has_defined_eq_operator := g.table.has_method(left.sym, '==') has_alias_eq_op_overload := left.sym.info is ast.Alias && left.sym.has_method('==') + if g.pref.translated && !g.is_builtin_mod { + g.gen_plain_infix_expr(node) + return + } if (left.typ.is_ptr() && right.typ.is_int()) || (right.typ.is_ptr() && left.typ.is_int()) { g.gen_plain_infix_expr(node) } else if (left.typ.idx() == ast.string_type_idx || (!has_defined_eq_operator @@ -291,6 +295,10 @@ fn (mut g Gen) infix_expr_cmp_op(node ast.InfixExpr) { left := g.unwrap(node.left_type) right := g.unwrap(node.right_type) has_operator_overloading := g.table.has_method(left.sym, '<') + if g.pref.translated && !g.is_builtin_mod { + g.gen_plain_infix_expr(node) + return + } if left.sym.kind == .struct_ && (left.sym.info as ast.Struct).generic_types.len > 0 { if node.op in [.le, .ge] { g.write('!')