diff --git a/gopygo/ast.py b/gopygo/ast.py index a214f54..47401d5 100644 --- a/gopygo/ast.py +++ b/gopygo/ast.py @@ -79,10 +79,11 @@ def __init__(self, _list: list): class FuncDecl(): - def __init__(self, name: str, _type: FuncType, body: BlockStmt): + def __init__(self, name: str, _type: FuncType, body: BlockStmt, recv=None): self.name = name self.type = _type self.body = body + self.recv = recv class SelectorExpr(): diff --git a/gopygo/unparser.py b/gopygo/unparser.py index 0feb5e3..51056a9 100644 --- a/gopygo/unparser.py +++ b/gopygo/unparser.py @@ -49,7 +49,10 @@ def import_spec(self, node): return text def func_decl(self, node): - text = 'func %s' % node.name + text = 'func %s%s' % ( + ('(%s) ' % getattr(self, _get_node_type(node.recv))(node.recv)) if node.recv is not None else '', + node.name + ) text += getattr(self, _get_node_type(node.type))(node.type) text += ' ' text += getattr(self, _get_node_type(node.body))(node.body) @@ -429,7 +432,7 @@ def struct_type(self, node): def interface_type(self, node): text = 'interface' if node.methods.list: - text += ' {\n%s\n}' % getattr(self, _get_node_type(node.methods))( + text += ' {\n%s\n}\n' % getattr(self, _get_node_type(node.methods))( node.methods, separator='\n', indent=((self.indent + 1) * INDENT)