Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
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
Kirill Smelkov
cython
Commits
749fe583
Commit
749fe583
authored
Dec 26, 2021
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up individual child traversals in transforms using the new visitchild() method.
parent
84ed66f4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
14 deletions
+13
-14
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+13
-14
No files found.
Cython/Compiler/ParseTreeTransforms.py
View file @
749fe583
...
@@ -914,7 +914,7 @@ class InterpretCompilerDirectives(CythonTransform):
...
@@ -914,7 +914,7 @@ class InterpretCompilerDirectives(CythonTransform):
def
visit_NameNode
(
self
,
node
):
def
visit_NameNode
(
self
,
node
):
if
node
.
annotation
:
if
node
.
annotation
:
self
.
visit
(
node
.
annotation
)
self
.
visit
child
(
node
,
'annotation'
)
if
node
.
name
in
self
.
cython_module_names
:
if
node
.
name
in
self
.
cython_module_names
:
node
.
is_cython_module
=
True
node
.
is_cython_module
=
True
else
:
else
:
...
@@ -941,7 +941,7 @@ class InterpretCompilerDirectives(CythonTransform):
...
@@ -941,7 +941,7 @@ class InterpretCompilerDirectives(CythonTransform):
return
node
return
node
def
visit_NewExprNode
(
self
,
node
):
def
visit_NewExprNode
(
self
,
node
):
self
.
visit
(
node
.
cppclass
)
self
.
visit
child
(
node
,
'cppclass'
)
self
.
visitchildren
(
node
)
self
.
visitchildren
(
node
)
return
node
return
node
...
@@ -950,7 +950,7 @@ class InterpretCompilerDirectives(CythonTransform):
...
@@ -950,7 +950,7 @@ class InterpretCompilerDirectives(CythonTransform):
# decorator), returns a list of (directivename, value) pairs.
# decorator), returns a list of (directivename, value) pairs.
# Otherwise, returns None
# Otherwise, returns None
if
isinstance
(
node
,
ExprNodes
.
CallNode
):
if
isinstance
(
node
,
ExprNodes
.
CallNode
):
self
.
visit
(
node
.
function
)
self
.
visit
child
(
node
,
'function'
)
optname
=
node
.
function
.
as_cython_attribute
()
optname
=
node
.
function
.
as_cython_attribute
()
if
optname
:
if
optname
:
directivetype
=
Options
.
directive_types
.
get
(
optname
)
directivetype
=
Options
.
directive_types
.
get
(
optname
)
...
@@ -1253,7 +1253,7 @@ class ParallelRangeTransform(CythonTransform, SkipDeclarations):
...
@@ -1253,7 +1253,7 @@ class ParallelRangeTransform(CythonTransform, SkipDeclarations):
return
node
return
node
def
visit_CallNode
(
self
,
node
):
def
visit_CallNode
(
self
,
node
):
self
.
visit
(
node
.
function
)
self
.
visit
child
(
node
,
'function'
)
if
not
self
.
parallel_directive
:
if
not
self
.
parallel_directive
:
self
.
visitchildren
(
node
,
exclude
=
(
'function'
,))
self
.
visitchildren
(
node
,
exclude
=
(
'function'
,))
return
node
return
node
...
@@ -1286,7 +1286,7 @@ class ParallelRangeTransform(CythonTransform, SkipDeclarations):
...
@@ -1286,7 +1286,7 @@ class ParallelRangeTransform(CythonTransform, SkipDeclarations):
"Nested parallel with blocks are disallowed"
)
"Nested parallel with blocks are disallowed"
)
self
.
state
=
'parallel with'
self
.
state
=
'parallel with'
body
=
self
.
visit
(
node
.
body
)
body
=
self
.
visit
child
(
node
,
'body'
)
self
.
state
=
None
self
.
state
=
None
newnode
.
body
=
body
newnode
.
body
=
body
...
@@ -1302,13 +1302,13 @@ class ParallelRangeTransform(CythonTransform, SkipDeclarations):
...
@@ -1302,13 +1302,13 @@ class ParallelRangeTransform(CythonTransform, SkipDeclarations):
error
(
node
.
pos
,
"The parallel directive must be called"
)
error
(
node
.
pos
,
"The parallel directive must be called"
)
return
None
return
None
node
.
body
=
self
.
visit
(
node
.
body
)
self
.
visitchild
(
node
,
'body'
)
return
node
return
node
def
visit_ForInStatNode
(
self
,
node
):
def
visit_ForInStatNode
(
self
,
node
):
"Rewrite 'for i in cython.parallel.prange(...):'"
"Rewrite 'for i in cython.parallel.prange(...):'"
self
.
visit
(
node
.
iterator
)
self
.
visit
child
(
node
,
'iterator'
)
self
.
visit
(
node
.
target
)
self
.
visit
child
(
node
,
'target'
)
in_prange
=
isinstance
(
node
.
iterator
.
sequence
,
in_prange
=
isinstance
(
node
.
iterator
.
sequence
,
Nodes
.
ParallelRangeNode
)
Nodes
.
ParallelRangeNode
)
...
@@ -1331,9 +1331,9 @@ class ParallelRangeTransform(CythonTransform, SkipDeclarations):
...
@@ -1331,9 +1331,9 @@ class ParallelRangeTransform(CythonTransform, SkipDeclarations):
self
.
state
=
'prange'
self
.
state
=
'prange'
self
.
visit
(
node
.
body
)
self
.
visit
child
(
node
,
'body'
)
self
.
state
=
previous_state
self
.
state
=
previous_state
self
.
visit
(
node
.
else_clause
)
self
.
visit
child
(
node
,
'else_clause'
)
return
node
return
node
def
visit
(
self
,
node
):
def
visit
(
self
,
node
):
...
@@ -1960,7 +1960,7 @@ if VALUE is not None:
...
@@ -1960,7 +1960,7 @@ if VALUE is not None:
"Handle def or cpdef fused functions"
"Handle def or cpdef fused functions"
# Create PyCFunction nodes for each specialization
# Create PyCFunction nodes for each specialization
node
.
stats
.
insert
(
0
,
node
.
py_func
)
node
.
stats
.
insert
(
0
,
node
.
py_func
)
node
.
py_func
=
self
.
visit
(
node
.
py_func
)
self
.
visitchild
(
node
,
'py_func'
)
node
.
update_fused_defnode_entry
(
env
)
node
.
update_fused_defnode_entry
(
env
)
# For the moment, fused functions do not support METH_FASTCALL
# For the moment, fused functions do not support METH_FASTCALL
node
.
py_func
.
entry
.
signature
.
use_fastcall
=
False
node
.
py_func
.
entry
.
signature
.
use_fastcall
=
False
...
@@ -2242,13 +2242,12 @@ if VALUE is not None:
...
@@ -2242,13 +2242,12 @@ if VALUE is not None:
return
None
return
None
def
visit_CnameDecoratorNode
(
self
,
node
):
def
visit_CnameDecoratorNode
(
self
,
node
):
child_node
=
self
.
visit
(
node
.
node
)
child_node
=
self
.
visit
child
(
node
,
'node'
)
if
not
child_node
:
if
not
child_node
:
return
None
return
None
if
type
(
child_node
)
is
list
:
# Assignment synthesized
if
type
(
child_node
)
is
list
:
# Assignment synthesized
node
.
child_
node
=
child_node
[
0
]
node
.
node
=
child_node
[
0
]
return
[
node
]
+
child_node
[
1
:]
return
[
node
]
+
child_node
[
1
:]
node
.
node
=
child_node
return
node
return
node
def
create_Property
(
self
,
entry
):
def
create_Property
(
self
,
entry
):
...
...
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