Define a return instruction.

It is possible to return multiple values from a function, so ReturnData contains
a VariableArgs instance.

We don't want return instructions to appear as 'return (v1)', so tweak the
printing of VariableArgs so the parantheses are added externally.
This commit is contained in:
Jakob Stoklund Olesen
2016-07-08 16:19:26 -07:00
parent 6587784d7d
commit 3839281414
7 changed files with 61 additions and 21 deletions

View File

@@ -203,6 +203,13 @@ pub fn write_instruction(w: &mut Write, func: &Function, inst: Inst) -> Result {
Branch { ref data, .. } => writeln!(w, " {}", data),
BranchTable { arg, table, .. } => writeln!(w, " {}, {}", arg, table),
Call { ref data, .. } => writeln!(w, " {}", data),
Return { ref data, .. } => {
if data.args.is_empty() {
writeln!(w, "")
} else {
writeln!(w, " {}", data.args)
}
}
}
}