Commit 77130f16 authored by Tom Niget's avatar Tom Niget

Add placeholder implementation for `try` block

parent b23ce6e3
......@@ -81,3 +81,14 @@ class FunctionVisitor(BlockVisitor):
def visit_Break(self, node: ast.Break) -> Iterable[str]:
yield "break;"
def visit_Try(self, node: ast.Try) -> Iterable[str]:
yield from self.emit_block(node.inner_scope, node.body)
if node.orelse:
raise NotImplementedError(node, "orelse")
if node.finalbody:
raise NotImplementedError(node, "finalbody")
for handler in node.handlers:
#yield from self.visit(handler)
pass
# todo
......@@ -199,3 +199,21 @@ class ScoperBlockVisitor(ScoperVisitor):
def visit_Break(self, node: ast.Break):
pass # TODO: check in loop
def visit_Try(self, node: ast.Try):
scope = self.scope.child(ScopeKind.FUNCTION_INNER)
node.inner_scope = scope
body_scope = scope.child(ScopeKind.FUNCTION_INNER)
body_visitor = ScoperBlockVisitor(body_scope, self.root_decls)
body_visitor.visit_block(node.body)
# todo
for handler in node.handlers:
handler_scope = scope.child(ScopeKind.FUNCTION_INNER)
handler_visitor = ScoperBlockVisitor(handler_scope, self.root_decls)
handler_visitor.visit_block(handler.body)
if node.orelse:
else_scope = scope.child(ScopeKind.FUNCTION_INNER)
else_visitor = ScoperBlockVisitor(else_scope, self.root_decls)
else_visitor.visit_block(node.orelse)
if node.finalbody:
raise NotImplementedError(node.finalbody)
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment