cgen: fix eq generation for translated code
parent
5ada79c629
commit
f66e514430
|
@ -116,6 +116,10 @@ fn (mut g Gen) infix_expr_eq_op(node ast.InfixExpr) {
|
||||||
g.write(')')
|
g.write(')')
|
||||||
} else if left.typ.idx() == right.typ.idx()
|
} else if left.typ.idx() == right.typ.idx()
|
||||||
&& left.sym.kind in [.array, .array_fixed, .alias, .map, .struct_, .sum_type, .interface_] {
|
&& 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 {
|
match left.sym.kind {
|
||||||
.alias {
|
.alias {
|
||||||
ptr_typ := g.equality_fn(left.typ)
|
ptr_typ := g.equality_fn(left.typ)
|
||||||
|
@ -201,25 +205,25 @@ fn (mut g Gen) infix_expr_eq_op(node ast.InfixExpr) {
|
||||||
g.write(')')
|
g.write(')')
|
||||||
}
|
}
|
||||||
.struct_ {
|
.struct_ {
|
||||||
if g.pref.translated {
|
// if g.pref.translated {
|
||||||
g.gen_plain_infix_expr(node)
|
// g.gen_plain_infix_expr(node)
|
||||||
} else {
|
//} else {
|
||||||
ptr_typ := g.equality_fn(left.unaliased)
|
ptr_typ := g.equality_fn(left.unaliased)
|
||||||
if node.op == .ne {
|
if node.op == .ne {
|
||||||
g.write('!')
|
g.write('!')
|
||||||
}
|
|
||||||
g.write('${ptr_typ}_struct_eq(')
|
|
||||||
if left.typ.is_ptr() {
|
|
||||||
g.write('*')
|
|
||||||
}
|
|
||||||
g.expr(node.left)
|
|
||||||
g.write(', ')
|
|
||||||
if right.typ.is_ptr() {
|
|
||||||
g.write('*')
|
|
||||||
}
|
|
||||||
g.expr(node.right)
|
|
||||||
g.write(')')
|
|
||||||
}
|
}
|
||||||
|
g.write('${ptr_typ}_struct_eq(')
|
||||||
|
if left.typ.is_ptr() {
|
||||||
|
g.write('*')
|
||||||
|
}
|
||||||
|
g.expr(node.left)
|
||||||
|
g.write(', ')
|
||||||
|
if right.typ.is_ptr() {
|
||||||
|
g.write('*')
|
||||||
|
}
|
||||||
|
g.expr(node.right)
|
||||||
|
g.write(')')
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
.sum_type {
|
.sum_type {
|
||||||
ptr_typ := g.equality_fn(left.unaliased)
|
ptr_typ := g.equality_fn(left.unaliased)
|
||||||
|
|
Loading…
Reference in New Issue