Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
typon-compiler
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
typon
typon-compiler
Commits
b1f44165
Commit
b1f44165
authored
Jul 07, 2023
by
Tom Niget
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add plain block node type
parent
f3a0b3e0
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
0 deletions
+12
-0
trans/transpiler/phases/emit_cpp/function.py
trans/transpiler/phases/emit_cpp/function.py
+3
-0
trans/transpiler/phases/typing/block.py
trans/transpiler/phases/typing/block.py
+6
-0
trans/transpiler/phases/utils.py
trans/transpiler/phases/utils.py
+3
-0
No files found.
trans/transpiler/phases/emit_cpp/function.py
View file @
b1f44165
...
...
@@ -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
:
...
...
trans/transpiler/phases/typing/block.py
View file @
b1f44165
...
...
@@ -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
...
...
trans/transpiler/phases/utils.py
View file @
b1f44165
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment