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
a686f030
Commit
a686f030
authored
Feb 08, 2009
by
Magnus Lie Hetland
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added if around for loop (for issue 208)
parent
6e54e1e6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
1 deletion
+10
-1
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+10
-1
No files found.
Cython/Compiler/Nodes.py
View file @
a686f030
...
@@ -3951,6 +3951,7 @@ class ForFromStatNode(LoopNode, StatNode):
...
@@ -3951,6 +3951,7 @@ class ForFromStatNode(LoopNode, StatNode):
def
generate_execution_code
(
self
,
code
):
def
generate_execution_code
(
self
,
code
):
old_loop_labels
=
code
.
new_loop_labels
()
old_loop_labels
=
code
.
new_loop_labels
()
from_range
=
getattr
(
self
,
"from_range"
,
False
)
self
.
bound1
.
generate_evaluation_code
(
code
)
self
.
bound1
.
generate_evaluation_code
(
code
)
self
.
bound2
.
generate_evaluation_code
(
code
)
self
.
bound2
.
generate_evaluation_code
(
code
)
offset
,
incop
=
self
.
relation_table
[
self
.
relation1
]
offset
,
incop
=
self
.
relation_table
[
self
.
relation1
]
...
@@ -3964,6 +3965,12 @@ class ForFromStatNode(LoopNode, StatNode):
...
@@ -3964,6 +3965,12 @@ class ForFromStatNode(LoopNode, StatNode):
incop
=
"%s=%s"
%
(
incop
[
0
],
step
)
incop
=
"%s=%s"
%
(
incop
[
0
],
step
)
decop
=
"%s=%s"
%
(
decop
[
0
],
step
)
decop
=
"%s=%s"
%
(
decop
[
0
],
step
)
loopvar_name
=
self
.
loopvar_node
.
result
()
loopvar_name
=
self
.
loopvar_node
.
result
()
if
from_range
:
# Skip the loop entirely (and avoid assigning to the loopvar) if
# the loop is empty:
code
.
putln
(
"if (%s%s %s %s) {"
%
(
self
.
bound1
.
result
(),
offset
,
self
.
relation2
,
self
.
bound2
.
result
()
))
code
.
putln
(
code
.
putln
(
"for (%s = %s%s; %s %s %s; %s%s) {"
%
(
"for (%s = %s%s; %s %s %s; %s%s) {"
%
(
loopvar_name
,
loopvar_name
,
...
@@ -3975,9 +3982,11 @@ class ForFromStatNode(LoopNode, StatNode):
...
@@ -3975,9 +3982,11 @@ class ForFromStatNode(LoopNode, StatNode):
self
.
target
.
generate_assignment_code
(
self
.
py_loopvar_node
,
code
)
self
.
target
.
generate_assignment_code
(
self
.
py_loopvar_node
,
code
)
self
.
body
.
generate_execution_code
(
code
)
self
.
body
.
generate_execution_code
(
code
)
code
.
put_label
(
code
.
continue_label
)
code
.
put_label
(
code
.
continue_label
)
if
getattr
(
self
,
"from_range"
,
False
)
:
if
from_range
:
# Undo last increment to maintain Python semantics:
# Undo last increment to maintain Python semantics:
code
.
putln
(
"} %s%s;"
%
(
loopvar_name
,
decop
))
code
.
putln
(
"} %s%s;"
%
(
loopvar_name
,
decop
))
# End the outer if statement:
code
.
putln
(
"} /* end if */"
)
else
:
else
:
code
.
putln
(
"}"
)
code
.
putln
(
"}"
)
break_label
=
code
.
break_label
break_label
=
code
.
break_label
...
...
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