mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: minor cleanup in return_stmt() (#15854)
This commit is contained in:
parent
41fd02496a
commit
c811b5343a
@ -4324,32 +4324,26 @@ fn (mut g Gen) return_stmt(node ast.Return) {
|
|||||||
for i, expr in node.exprs {
|
for i, expr in node.exprs {
|
||||||
// Check if we are dealing with a multi return and handle it seperately
|
// Check if we are dealing with a multi return and handle it seperately
|
||||||
if g.expr_is_multi_return_call(expr) {
|
if g.expr_is_multi_return_call(expr) {
|
||||||
c := expr as ast.CallExpr
|
call_expr := expr as ast.CallExpr
|
||||||
expr_sym := g.table.sym(c.return_type)
|
expr_sym := g.table.sym(call_expr.return_type)
|
||||||
// Create a tmp for this call
|
|
||||||
mut tmp := g.new_tmp_var()
|
mut tmp := g.new_tmp_var()
|
||||||
if !c.return_type.has_flag(.optional) {
|
if !call_expr.return_type.has_flag(.optional)
|
||||||
s := g.go_before_stmt(0)
|
&& !call_expr.return_type.has_flag(.result) {
|
||||||
expr_styp := g.typ(c.return_type)
|
line := g.go_before_stmt(0)
|
||||||
|
expr_styp := g.typ(call_expr.return_type)
|
||||||
g.write('$expr_styp $tmp=')
|
g.write('$expr_styp $tmp=')
|
||||||
g.expr(expr)
|
g.expr(expr)
|
||||||
g.writeln(';')
|
g.writeln(';')
|
||||||
multi_unpack += g.go_before_stmt(0)
|
multi_unpack += g.go_before_stmt(0)
|
||||||
g.write(s)
|
g.write(line)
|
||||||
} else {
|
} else {
|
||||||
s := g.go_before_stmt(0)
|
line := g.go_before_stmt(0)
|
||||||
// TODO
|
|
||||||
// I (emily) am sorry for doing this
|
|
||||||
// I cant find another way to do this so right now
|
|
||||||
// this will have to do.
|
|
||||||
g.tmp_count--
|
g.tmp_count--
|
||||||
g.expr(expr)
|
g.expr(expr)
|
||||||
multi_unpack += g.go_before_stmt(0)
|
multi_unpack += g.go_before_stmt(0)
|
||||||
g.write(s)
|
g.write(line)
|
||||||
// modify tmp so that it is the opt deref
|
expr_styp := g.base_type(call_expr.return_type)
|
||||||
// TODO copy-paste from cgen.v:2397
|
tmp = ('(*($expr_styp*)${tmp}.data)')
|
||||||
expr_styp := g.base_type(c.return_type)
|
|
||||||
tmp = ('/*opt*/(*($expr_styp*)${tmp}.data)')
|
|
||||||
}
|
}
|
||||||
expr_types := expr_sym.mr_info().types
|
expr_types := expr_sym.mr_info().types
|
||||||
for j, _ in expr_types {
|
for j, _ in expr_types {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user