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
33fe1b67
Commit
33fe1b67
authored
Nov 29, 2008
by
Dag Sverre Seljebotn
Browse files
Options
Browse Files
Download
Plain Diff
merge
parents
6ff9d8a5
518b87b5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
10 deletions
+19
-10
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+17
-10
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+2
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
33fe1b67
...
...
@@ -1332,6 +1332,10 @@ class ImportNode(ExprNode):
class
IteratorNode
(
ExprNode
):
# Used as part of for statement implementation.
#
# allocate_counter_temp/release_counter_temp needs to be called
# by parent (ForInStatNode)
#
# Implements result = iter(sequence)
#
# sequence ExprNode
...
...
@@ -1344,16 +1348,19 @@ class IteratorNode(ExprNode):
self
.
type
=
py_object_type
self
.
gil_check
(
env
)
self
.
is_temp
=
1
self
.
counter
=
TempNode
(
self
.
pos
,
PyrexTypes
.
c_py_ssize_t_type
,
env
)
self
.
counter
.
allocate_temp
(
env
)
gil_message
=
"Iterating over Python object"
def
release_temp
(
self
,
env
):
env
.
release_temp
(
self
.
result
())
self
.
counter
.
release_temp
(
env
)
def
allocate_counter_temp
(
self
,
code
):
self
.
counter_cname
=
code
.
funcstate
.
allocate_temp
(
PyrexTypes
.
c_py_ssize_t_type
,
manage_ref
=
False
)
def
release_counter_temp
(
self
,
code
):
code
.
funcstate
.
release_temp
(
self
.
counter_cname
)
def
generate_result_code
(
self
,
code
):
is_builtin_sequence
=
self
.
sequence
.
type
is
list_type
or
\
self
.
sequence
.
type
is
tuple_type
...
...
@@ -1367,7 +1374,7 @@ class IteratorNode(ExprNode):
self
.
sequence
.
py_result
()))
code
.
putln
(
"%s = 0; %s = %s; Py_INCREF(%s);"
%
(
self
.
counter
.
result
()
,
self
.
counter
_cname
,
self
.
result
(),
self
.
sequence
.
py_result
(),
self
.
result
()))
...
...
@@ -1378,7 +1385,7 @@ class IteratorNode(ExprNode):
code
.
error_goto
(
self
.
pos
))
else
:
code
.
putln
(
"%s = -1; %s = PyObject_GetIter(%s); %s"
%
(
self
.
counter
.
result
()
,
self
.
counter
_cname
,
self
.
result
(),
self
.
sequence
.
py_result
(),
code
.
error_goto_if_null
(
self
.
result
(),
self
.
pos
)))
...
...
@@ -1414,7 +1421,7 @@ class NextNode(AtomicExprNode):
prefix
,
self
.
iterator
.
py_result
()))
code
.
putln
(
"if (%s >= Py%s_GET_SIZE(%s)) break;"
%
(
self
.
iterator
.
counter
.
result
()
,
self
.
iterator
.
counter
_cname
,
prefix
,
self
.
iterator
.
py_result
()))
code
.
putln
(
...
...
@@ -1422,9 +1429,9 @@ class NextNode(AtomicExprNode):
self
.
result
(),
prefix
,
self
.
iterator
.
py_result
(),
self
.
iterator
.
counter
.
result
()
,
self
.
iterator
.
counter
_cname
,
self
.
result
(),
self
.
iterator
.
counter
.
result
()
))
self
.
iterator
.
counter
_cname
))
if
len
(
type_checks
)
>
1
:
code
.
put
(
"} else "
)
if
len
(
type_checks
)
==
1
:
...
...
Cython/Compiler/Nodes.py
View file @
33fe1b67
...
...
@@ -3737,6 +3737,7 @@ class ForInStatNode(LoopNode, StatNode):
def
generate_execution_code
(
self
,
code
):
old_loop_labels
=
code
.
new_loop_labels
()
self
.
iterator
.
allocate_counter_temp
(
code
)
self
.
iterator
.
generate_evaluation_code
(
code
)
code
.
putln
(
"for (;;) {"
)
...
...
@@ -3753,6 +3754,7 @@ class ForInStatNode(LoopNode, StatNode):
self
.
else_clause
.
generate_execution_code
(
code
)
code
.
putln
(
"}"
)
code
.
put_label
(
break_label
)
self
.
iterator
.
release_counter_temp
(
code
)
self
.
iterator
.
generate_disposal_code
(
code
)
def
annotate
(
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