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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
deec7f35
Commit
deec7f35
authored
Sep 18, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix cpp iteration over attributes that depend on temporary results
parent
0d241078
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
2 deletions
+19
-2
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+19
-2
No files found.
Cython/Compiler/ExprNodes.py
View file @
deec7f35
...
@@ -2965,6 +2965,20 @@ class CppIteratorNode(ExprNode):
...
@@ -2965,6 +2965,20 @@ class CppIteratorNode(ExprNode):
self
.
result
()))
self
.
result
()))
code
.
putln
(
"++%s;"
%
self
.
result
())
code
.
putln
(
"++%s;"
%
self
.
result
())
def
generate_subexpr_disposal_code
(
self
,
code
):
if
self
.
sequence
.
is_simple
():
# the sequence is accessed directly so any temporary result in its
# subexpressions must remain available until the iterator is not needed
return
ExprNode
.
generate_subexpr_disposal_code
(
self
,
code
)
def
free_subexpr_temps
(
self
,
code
):
if
self
.
sequence
.
is_simple
():
# the sequence is accessed directly so any temporary result in its
# subexpressions must remain available until the iterator is not needed
return
ExprNode
.
free_subexpr_temps
(
self
,
code
)
def
generate_disposal_code
(
self
,
code
):
def
generate_disposal_code
(
self
,
code
):
# clean-up the iterator by assigning end to it
# clean-up the iterator by assigning end to it
# this is only required if the iterator holds resources that must be released once iteration is complete
# this is only required if the iterator holds resources that must be released once iteration is complete
...
@@ -2974,12 +2988,15 @@ class CppIteratorNode(ExprNode):
...
@@ -2974,12 +2988,15 @@ class CppIteratorNode(ExprNode):
self
.
cpp_attribute_op
))
self
.
cpp_attribute_op
))
if
self
.
cpp_sequence_cname
and
self
.
sequence
.
type
.
is_cyp_class
:
if
self
.
cpp_sequence_cname
and
self
.
sequence
.
type
.
is_cyp_class
:
code
.
put_decref
(
self
.
cpp_sequence_cname
,
self
.
sequence
.
type
)
code
.
put_decref
(
self
.
cpp_sequence_cname
,
self
.
sequence
.
type
)
super
(
CppIteratorNode
,
self
).
generate_disposal_code
(
code
)
if
self
.
sequence
.
is_simple
():
# postponed from CppIteratorNode.generate_subexpr_disposal_code
# and CppIteratorNode.free_subexpr_temps
ExprNode
.
generate_subexpr_disposal_code
(
self
,
code
)
ExprNode
.
free_subexpr_temps
(
self
,
code
)
def
free_temps
(
self
,
code
):
def
free_temps
(
self
,
code
):
if
self
.
cpp_sequence_cname
:
if
self
.
cpp_sequence_cname
:
code
.
funcstate
.
release_temp
(
self
.
cpp_sequence_cname
)
code
.
funcstate
.
release_temp
(
self
.
cpp_sequence_cname
)
# skip over IteratorNode since we don't use any of the temps it does
ExprNode
.
free_temps
(
self
,
code
)
ExprNode
.
free_temps
(
self
,
code
)
...
...
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