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
Gwenaël Samain
cython
Commits
aa2cc986
Commit
aa2cc986
authored
Dec 18, 2008
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
for-from-loop: remember loopvar node instead of its name which may not be known at analysis phase
parent
d5f88aac
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
9 deletions
+10
-9
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+9
-8
Cython/Compiler/Optimize.py
Cython/Compiler/Optimize.py
+1
-1
No files found.
Cython/Compiler/Nodes.py
View file @
aa2cc986
...
...
@@ -3798,12 +3798,12 @@ class ForFromStatNode(LoopNode, StatNode):
# Used internally:
#
# is_py_target bool
# loopvar_n
ame string
# loopvar_n
ode ExprNode (usually a NameNode or temp node)
# py_loopvar_node PyTempNode or None
child_attrs
=
[
"target"
,
"bound1"
,
"bound2"
,
"step"
,
"body"
,
"else_clause"
]
is_py_target
=
False
loopvar_n
am
e
=
None
loopvar_n
od
e
=
None
py_loopvar_node
=
None
def
analyse_declarations
(
self
,
env
):
...
...
@@ -3811,7 +3811,7 @@ class ForFromStatNode(LoopNode, StatNode):
self
.
body
.
analyse_declarations
(
env
)
if
self
.
else_clause
:
self
.
else_clause
.
analyse_declarations
(
env
)
def
analyse_expressions
(
self
,
env
):
import
ExprNodes
self
.
target
.
analyse_target_types
(
env
)
...
...
@@ -3842,14 +3842,14 @@ class ForFromStatNode(LoopNode, StatNode):
self
.
is_py_target
=
0
if
isinstance
(
self
.
target
,
ExprNodes
.
IndexNode
)
and
self
.
target
.
is_buffer_access
:
raise
error
(
self
.
pos
,
"Buffer indexing not allowed as for loop target."
)
self
.
loopvar_n
ame
=
self
.
target
.
entry
.
cname
self
.
loopvar_n
ode
=
self
.
target
self
.
py_loopvar_node
=
None
else
:
self
.
is_py_target
=
1
c_loopvar_node
=
ExprNodes
.
TempNode
(
self
.
pos
,
PyrexTypes
.
c_long_type
,
env
)
c_loopvar_node
.
allocate_temps
(
env
)
self
.
loopvar_n
ame
=
c_loopvar_node
.
result
()
self
.
loopvar_n
ode
=
c_loopvar_node
self
.
py_loopvar_node
=
\
ExprNodes
.
CloneNode
(
c_loopvar_node
).
coerce_to_pyobject
(
env
)
self
.
bound1
.
allocate_temps
(
env
)
...
...
@@ -3879,12 +3879,13 @@ class ForFromStatNode(LoopNode, StatNode):
if
self
.
step
is
not
None
:
self
.
step
.
generate_evaluation_code
(
code
)
incop
=
"%s=%s"
%
(
incop
[
0
],
self
.
step
.
result
())
loopvar_name
=
self
.
loopvar_node
.
result
()
code
.
putln
(
"for (%s = %s%s; %s %s %s; %s%s) {"
%
(
self
.
loopvar_name
,
loopvar_name
,
self
.
bound1
.
result
(),
offset
,
self
.
loopvar_name
,
self
.
relation2
,
self
.
bound2
.
result
(),
self
.
loopvar_name
,
incop
))
loopvar_name
,
self
.
relation2
,
self
.
bound2
.
result
(),
loopvar_name
,
incop
))
if
self
.
py_loopvar_node
:
self
.
py_loopvar_node
.
generate_evaluation_code
(
code
)
self
.
target
.
generate_assignment_code
(
self
.
py_loopvar_node
,
code
)
...
...
Cython/Compiler/Optimize.py
View file @
aa2cc986
...
...
@@ -148,7 +148,7 @@ class IterationTransform(Visitor.VisitorTransform):
relation2
=
relation2
,
bound2
=
bound2
,
step
=
step
,
body
=
node
.
body
,
else_clause
=
node
.
else_clause
,
loopvar_n
ame
=
node
.
target
.
entry
.
cname
)
loopvar_n
ode
=
node
.
target
)
return
for_node
def
_transform_dict_iteration
(
self
,
node
,
dict_obj
,
keys
,
values
):
...
...
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