Skip to content

Commit de5ad45

Browse files
authored
handle more CallExpr variations (#146)
1 parent 561b6fa commit de5ad45

File tree

11 files changed

+256
-219
lines changed

11 files changed

+256
-219
lines changed

assign_stmt.v

+19-18
Original file line numberDiff line numberDiff line change
@@ -69,34 +69,35 @@ fn (mut app App) assign_stmt(assign AssignStmt, no_mut bool) {
6969
app.expr(lhs_expr)
7070
}
7171
}
72+
7273
// Special case for 'append()' => '<<'
7374
if app.check_and_handle_append(assign) {
7475
return
7576
}
76-
//
77+
7778
app.gen(assign.tok)
78-
// app.gen('/*F*/')
79+
7980
for r_idx, rhs_expr in assign.rhs {
80-
// app.genln('/* ${rhs_expr} */')
81-
// app.gen('ridx=${r_idx}')
8281
mut needs_close_paren := false
83-
if r_idx == 0 {
84-
rhs := rhs_expr
85-
match rhs {
86-
BasicLit {
87-
if rhs.kind.is_upper() {
88-
v_kind := go2v_type(rhs.kind.to_lower())
89-
if v_kind != 'int' && v_kind != 'string' {
90-
app.gen('${v_kind}(')
91-
needs_close_paren = true
92-
}
82+
if r_idx > 0 {
83+
app.gen(', ')
84+
}
85+
match rhs_expr {
86+
BasicLit {
87+
v_kind := rhs_expr.kind.to_lower()
88+
if v_kind != 'int' && v_kind != 'string' {
89+
app.gen('${go2v_type(v_kind)}(')
90+
needs_close_paren = true
91+
} else {
92+
v_type := go2v_type(v_kind)
93+
if v_type != v_kind {
94+
app.gen(go2v_type(v_kind))
95+
app.gen('(')
96+
needs_close_paren = true
9397
}
9498
}
95-
else {}
9699
}
97-
}
98-
if r_idx > 0 {
99-
app.gen(', ')
100+
else {}
100101
}
101102
app.expr(rhs_expr)
102103
if needs_close_paren {

0 commit comments

Comments
 (0)