Commit b1f44165 authored by Tom Niget's avatar Tom Niget

Add plain block node type

parent f3a0b3e0
......@@ -7,6 +7,7 @@ from transpiler.consts import SYMBOLS
from transpiler.phases.emit_cpp import CoroutineMode
from transpiler.phases.emit_cpp.block import BlockVisitor
from transpiler.phases.typing.scope import Scope
from transpiler.phases.utils import PlainBlock
# noinspection PyPep8Naming
......@@ -43,6 +44,8 @@ class FunctionVisitor(BlockVisitor):
yield from self.visit(node.orelse)
else:
yield from self.emit_block(node.orelse.inner_scope, node.orelse)
def visit_PlainBlock(self, node: PlainBlock) -> Iterable[str]:
yield from self.emit_block(node.inner_scope, node.body)
def visit_Return(self, node: ast.Return) -> Iterable[str]:
if CoroutineMode.ASYNC in self.generator:
......
......@@ -148,6 +148,12 @@ class ScoperBlockVisitor(ScoperVisitor):
if node.orelse:
raise NotImplementedError(node.orelse)
def visit_PlainBlock(self, node: PlainBlock):
scope = self.scope.child(ScopeKind.FUNCTION_INNER)
node.inner_scope = scope
body_visitor = ScoperBlockVisitor(scope, self.root_decls)
body_visitor.visit_block(node.body)
def visit_For(self, node: ast.For):
scope = self.scope.child(ScopeKind.FUNCTION_INNER)
node.inner_scope = scope
......
......@@ -16,3 +16,6 @@ class NodeVisitorSeq:
def missing_impl(self, node):
raise UnsupportedNodeError(node)
@dataclass
class PlainBlock(ast.stmt):
body: list[ast.stmt]
\ 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