Skip to content

Commit

Permalink
Remove incompatible visit_unsupported_body
Browse files Browse the repository at this point in the history
The subclasses had a different signature, and
returned a list instead of a string.
  • Loading branch information
jayvdb committed Jul 7, 2021
1 parent da403fe commit 4ed1af0
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 46 deletions.
6 changes: 0 additions & 6 deletions pydart/transpiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,12 +443,6 @@ def visit_Tuple(self, node):
return elts
return "({0})".format(elts)

def visit_unsupported_body(self, name, body):
buf = ["let {0} = {{ //unsupported".format(name)]
buf += [self.visit(n) for n in body]
buf.append("};")
return buf

def visit_Raise(self, node):
if node.exc is not None:
return "throw new {};".format(self.visit(node.exc))
Expand Down
12 changes: 3 additions & 9 deletions pygo/transpiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,21 +563,15 @@ def visit_Tuple(self, node):
return elts
return "{0}".format(elts)

def visit_unsupported_body(self, name, body):
buf = ["let {0} = {{ //unsupported".format(name)]
buf += [self.visit(n) for n in body]
buf.append("};")
return buf

def visit_Try(self, node, finallybody=None):
buf = self.visit_unsupported_body("try_dummy", node.body)
buf = self.visit_unsupported_body(node, "try_dummy", node.body)

for handler in node.handlers:
buf += self.visit(handler)
# buf.append("\n".join(excepts));

if finallybody:
buf += self.visit_unsupported_body("finally_dummy", finallybody)
buf += self.visit_unsupported_body(node, "finally_dummy", finallybody)

return "\n".join(buf)

Expand All @@ -586,7 +580,7 @@ def visit_ExceptHandler(self, node):
if node.type:
exception_type = self.visit(node.type)
name = "except!({0})".format(exception_type)
body = self.visit_unsupported_body(name, node.body)
body = self.visit_unsupported_body(node, name, node.body)
return body

def visit_Assert(self, node):
Expand Down
12 changes: 3 additions & 9 deletions pyjl/transpiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,21 +459,15 @@ def visit_Tuple(self, node):
return elts
return "({0})".format(elts)

def visit_unsupported_body(self, name, body):
buf = ["let {0} = {{ //unsupported".format(name)]
buf += [self.visit(n) for n in body]
buf.append("}")
return buf

def visit_Try(self, node, finallybody=None):
buf = self.visit_unsupported_body("try_dummy", node.body)
buf = self.visit_unsupported_body(node, "try_dummy", node.body)

for handler in node.handlers:
buf += self.visit(handler)
# buf.append("\n".join(excepts));

if finallybody:
buf += self.visit_unsupported_body("finally_dummy", finallybody)
buf += self.visit_unsupported_body(node, "finally_dummy", finallybody)

return "\n".join(buf)

Expand All @@ -482,7 +476,7 @@ def visit_ExceptHandler(self, node):
if node.type:
exception_type = self.visit(node.type)
name = "except!({0})".format(exception_type)
body = self.visit_unsupported_body(name, node.body)
body = self.visit_unsupported_body(node, name, node.body)
return body

def visit_Assert(self, node):
Expand Down
12 changes: 3 additions & 9 deletions pykt/transpiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,21 +442,15 @@ def visit_Tuple(self, node):
return elts
return "({0})".format(elts)

def visit_unsupported_body(self, name, body):
buf = ["let {0} = {{ //unsupported".format(name)]
buf += [self.visit(n) for n in body]
buf.append("};")
return buf

def visit_Try(self, node, finallybody=None):
buf = self.visit_unsupported_body("try_dummy", node.body)
buf = self.visit_unsupported_body(node, "try_dummy", node.body)

for handler in node.handlers:
buf += self.visit(handler)
# buf.append("\n".join(excepts));

if finallybody:
buf += self.visit_unsupported_body("finally_dummy", finallybody)
buf += self.visit_unsupported_body(node, "finally_dummy", finallybody)

return "\n".join(buf)

Expand All @@ -465,7 +459,7 @@ def visit_ExceptHandler(self, node):
if node.type:
exception_type = self.visit(node.type)
name = "except!({0})".format(exception_type)
body = self.visit_unsupported_body(name, node.body)
body = self.visit_unsupported_body(node, name, node.body)
return body

def visit_Assert(self, node):
Expand Down
12 changes: 3 additions & 9 deletions pynim/transpiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,21 +435,15 @@ def visit_Tuple(self, node):
return elts
return "({0})".format(elts)

def visit_unsupported_body(self, name, body):
buf = ["let {0} = {{ //unsupported".format(name)]
buf += [self.visit(n) for n in body]
buf.append("};")
return buf

def visit_Try(self, node, finallybody=None):
buf = self.visit_unsupported_body("try_dummy", node.body)
buf = self.visit_unsupported_body(node, "try_dummy", node.body)

for handler in node.handlers:
buf += self.visit(handler)
# buf.append("\n".join(excepts));

if finallybody:
buf += self.visit_unsupported_body("finally_dummy", finallybody)
buf += self.visit_unsupported_body(node, "finally_dummy", finallybody)

return "\n".join(buf)

Expand All @@ -458,7 +452,7 @@ def visit_ExceptHandler(self, node):
if node.type:
exception_type = self.visit(node.type)
name = "except!({0})".format(exception_type)
body = self.visit_unsupported_body(name, node.body)
body = self.visit_unsupported_body(node, name, node.body)
return body

def visit_Assert(self, node):
Expand Down
8 changes: 4 additions & 4 deletions pyrs/transpiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -721,14 +721,14 @@ def visit_Tuple(self, node):
return elts
return "({0})".format(elts)

def visit_unsupported_body(self, name, body):
def grrvisit_unsupported_body(self, node, name, body):
buf = ["let {0} = {{ //unsupported".format(name)]
buf += [self.visit(n) for n in body]
buf.append("};")
return buf
return "\n".join(buf)

def visit_Try(self, node, finallybody=None):
# buf = self.visit_unsupported_body("try_dummy", node.body)
# buf = self.visit_unsupported_body(node, "try_dummy", node.body)
buf = ["if true {"]
buf += [self.visit(n) for n in node.body]

Expand All @@ -747,7 +747,7 @@ def visit_ExceptHandler(self, node):
if node.type:
exception_type = self.visit(node.type)
name = "// except!({0})".format(exception_type)
body = self.visit_unsupported_body(name, node.body)
body = self.visit_unsupported_body(node, name, node.body)
body = [self.comment(b) for b in body]
return body

Expand Down

0 comments on commit 4ed1af0

Please sign in to comment.