Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
typon
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tom Niget
typon
Commits
d258d294
Commit
d258d294
authored
Jul 07, 2023
by
Tom Niget
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add plain block node type
parent
e816c5ac
Changes
3
Hide 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 @
d258d294
...
@@ -7,6 +7,7 @@ from transpiler.consts import SYMBOLS
...
@@ -7,6 +7,7 @@ from transpiler.consts import SYMBOLS
from
transpiler.phases.emit_cpp
import
CoroutineMode
from
transpiler.phases.emit_cpp
import
CoroutineMode
from
transpiler.phases.emit_cpp.block
import
BlockVisitor
from
transpiler.phases.emit_cpp.block
import
BlockVisitor
from
transpiler.phases.typing.scope
import
Scope
from
transpiler.phases.typing.scope
import
Scope
from
transpiler.phases.utils
import
PlainBlock
# noinspection PyPep8Naming
# noinspection PyPep8Naming
...
@@ -43,6 +44,8 @@ class FunctionVisitor(BlockVisitor):
...
@@ -43,6 +44,8 @@ class FunctionVisitor(BlockVisitor):
yield
from
self
.
visit
(
node
.
orelse
)
yield
from
self
.
visit
(
node
.
orelse
)
else
:
else
:
yield
from
self
.
emit_block
(
node
.
orelse
.
inner_scope
,
node
.
orelse
)
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
]:
def
visit_Return
(
self
,
node
:
ast
.
Return
)
->
Iterable
[
str
]:
if
CoroutineMode
.
ASYNC
in
self
.
generator
:
if
CoroutineMode
.
ASYNC
in
self
.
generator
:
...
...
trans/transpiler/phases/typing/block.py
View file @
d258d294
...
@@ -148,6 +148,12 @@ class ScoperBlockVisitor(ScoperVisitor):
...
@@ -148,6 +148,12 @@ class ScoperBlockVisitor(ScoperVisitor):
if
node
.
orelse
:
if
node
.
orelse
:
raise
NotImplementedError
(
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
):
def
visit_For
(
self
,
node
:
ast
.
For
):
scope
=
self
.
scope
.
child
(
ScopeKind
.
FUNCTION_INNER
)
scope
=
self
.
scope
.
child
(
ScopeKind
.
FUNCTION_INNER
)
node
.
inner_scope
=
scope
node
.
inner_scope
=
scope
...
...
trans/transpiler/phases/utils.py
View file @
d258d294
...
@@ -16,3 +16,6 @@ class NodeVisitorSeq:
...
@@ -16,3 +16,6 @@ class NodeVisitorSeq:
def
missing_impl
(
self
,
node
):
def
missing_impl
(
self
,
node
):
raise
UnsupportedNodeError
(
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