Skip to content

Commit

Permalink
Add Recv attribute to FuncDecl and fix the generator method for Inter…
Browse files Browse the repository at this point in the history
…faceType
  • Loading branch information
M. Mert Yildiran committed Feb 22, 2021
1 parent 483fddc commit 4a9d9eb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion gopygo/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
7 changes: 5 additions & 2 deletions gopygo/unparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 4a9d9eb

Please sign in to comment.