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 a39e418d32
commit 520a438c42
7 changed files with 61 additions and 21 deletions

View File

@@ -265,12 +265,17 @@ class InstDocumenter(sphinx.ext.autodoc.Documenter):
def format_signature(self):
inst = self.object
sig = self.format_name()
sig = inst.name
if len(inst.outs) > 0:
sig = ', '.join([op.name for op in inst.outs]) + ' = ' + sig
if len(inst.ins) > 0:
sig = sig + ' ' + inst.ins[0].name
op = inst.ins[0]
sig += ' ' + op.name
# If the first input is variable-args, this is 'return'. No parens.
if op.typ.operand_kind().name == 'variable_args':
sig += '...'.format(op.name)
for op in inst.ins[1:]:
# This is a call or branch with args in (...).
if op.typ.operand_kind().name == 'variable_args':
sig += '({}...)'.format(op.name)
else: