cgen: minor cleanup in infix_expr() (#9086)

pull/9111/head
yuyi 2021-03-04 18:50:18 +08:00 committed by GitHub
parent 6b2c7fd53e
commit 7c893895d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 12 deletions

View File

@ -3028,16 +3028,13 @@ fn (mut g Gen) enum_expr(node ast.Expr) {
} }
fn (mut g Gen) infix_expr(node ast.InfixExpr) { fn (mut g Gen) infix_expr(node ast.InfixExpr) {
// println('infix_expr() op="$node.op.str()" line_nr=$node.pos.line_nr')
// g.write('/*infix*/')
// if it.left_type == table.string_type_idx {
// g.write('/*$node.left_type str*/')
// }
// string + string, string == string etc
// g.infix_op = node.op
if node.auto_locked != '' { if node.auto_locked != '' {
g.writeln('sync__RwMutex_lock(&$node.auto_locked->mtx);') g.writeln('sync__RwMutex_lock(&$node.auto_locked->mtx);')
} }
if node.op in [.key_is, .not_is] {
g.is_expr(node)
return
}
left_type := g.unwrap_generic(node.left_type) left_type := g.unwrap_generic(node.left_type)
left_sym := g.table.get_type_symbol(left_type) left_sym := g.table.get_type_symbol(left_type)
left_final_sym := g.table.get_final_type_symbol(left_type) left_final_sym := g.table.get_final_type_symbol(left_type)
@ -3046,11 +3043,6 @@ fn (mut g Gen) infix_expr(node ast.InfixExpr) {
} else { } else {
left_type left_type
} }
op_is_key_is_or_not_is := node.op in [.key_is, .not_is]
if op_is_key_is_or_not_is {
g.is_expr(node)
return
}
op_is_key_in_or_not_in := node.op in [.key_in, .not_in] op_is_key_in_or_not_in := node.op in [.key_in, .not_in]
op_is_eq_or_ne := node.op in [.eq, .ne] op_is_eq_or_ne := node.op in [.eq, .ne]
right_sym := g.table.get_type_symbol(node.right_type) right_sym := g.table.get_type_symbol(node.right_type)