cgen: fix eq generation for translated code

Alexander Medvednikov 2022-05-17 15:29:52 +03:00 committed by Jef Roosens
parent 5ada79c629
commit f66e514430
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
1 changed files with 22 additions and 18 deletions

View File

@ -116,6 +116,10 @@ fn (mut g Gen) infix_expr_eq_op(node ast.InfixExpr) {
g.write(')')
} else if left.typ.idx() == right.typ.idx()
&& left.sym.kind in [.array, .array_fixed, .alias, .map, .struct_, .sum_type, .interface_] {
if g.pref.translated && !g.is_builtin_mod {
g.gen_plain_infix_expr(node)
return
}
match left.sym.kind {
.alias {
ptr_typ := g.equality_fn(left.typ)
@ -201,9 +205,9 @@ fn (mut g Gen) infix_expr_eq_op(node ast.InfixExpr) {
g.write(')')
}
.struct_ {
if g.pref.translated {
g.gen_plain_infix_expr(node)
} else {
// if g.pref.translated {
// g.gen_plain_infix_expr(node)
//} else {
ptr_typ := g.equality_fn(left.unaliased)
if node.op == .ne {
g.write('!')
@ -219,7 +223,7 @@ fn (mut g Gen) infix_expr_eq_op(node ast.InfixExpr) {
}
g.expr(node.right)
g.write(')')
}
//}
}
.sum_type {
ptr_typ := g.equality_fn(left.unaliased)