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
8151c0ef
Commit
8151c0ef
authored
Dec 06, 2009
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix declaration analysis (and type inference) for comprehensions
parent
ea3d3f55
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
8 deletions
+11
-8
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+5
-6
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+6
-1
Cython/Compiler/TypeInference.py
Cython/Compiler/TypeInference.py
+0
-1
No files found.
Cython/Compiler/ExprNodes.py
View file @
8151c0ef
...
@@ -3631,14 +3631,13 @@ class ComprehensionNode(ExprNode):
...
@@ -3631,14 +3631,13 @@ class ComprehensionNode(ExprNode):
def
infer_type
(
self
,
env
):
def
infer_type
(
self
,
env
):
return
self
.
target
.
infer_type
(
env
)
return
self
.
target
.
infer_type
(
env
)
def
analyse_declarations
(
self
,
env
):
self
.
append
.
target
=
self
# this is used in the PyList_Append of the inner loop
self
.
loop
.
analyse_declarations
(
env
)
def
analyse_types
(
self
,
env
):
def
analyse_types
(
self
,
env
):
self
.
target
.
analyse_expressions
(
env
)
self
.
target
.
analyse_expressions
(
env
)
self
.
type
=
self
.
target
.
type
self
.
type
=
self
.
target
.
type
self
.
append
.
target
=
self
# this is a CloneNode used in the PyList_Append in the inner loop
# We are analysing declarations to late.
self
.
loop
.
target
.
analyse_target_declaration
(
env
)
env
.
infer_types
()
self
.
loop
.
analyse_declarations
(
env
)
self
.
loop
.
analyse_expressions
(
env
)
self
.
loop
.
analyse_expressions
(
env
)
def
calculate_result_code
(
self
):
def
calculate_result_code
(
self
):
...
...
Cython/Compiler/ParseTreeTransforms.py
View file @
8151c0ef
...
@@ -725,6 +725,11 @@ property NAME:
...
@@ -725,6 +725,11 @@ property NAME:
self
.
seen_vars_stack
.
pop
()
self
.
seen_vars_stack
.
pop
()
return
node
return
node
def
visit_ComprehensionNode
(
self
,
node
):
self
.
visitchildren
(
node
)
node
.
analyse_declarations
(
self
.
env_stack
[
-
1
])
return
node
# Some nodes are no longer needed after declaration
# Some nodes are no longer needed after declaration
# analysis and can be dropped. The analysis was performed
# analysis and can be dropped. The analysis was performed
# on these nodes in a seperate recursive process from the
# on these nodes in a seperate recursive process from the
...
...
Cython/Compiler/TypeInference.py
View file @
8151c0ef
...
@@ -25,7 +25,6 @@ class MarkAssignments(CythonTransform):
...
@@ -25,7 +25,6 @@ class MarkAssignments(CythonTransform):
if
isinstance
(
lhs
,
(
ExprNodes
.
NameNode
,
Nodes
.
PyArgDeclNode
)):
if
isinstance
(
lhs
,
(
ExprNodes
.
NameNode
,
Nodes
.
PyArgDeclNode
)):
if
lhs
.
entry
is
None
:
if
lhs
.
entry
is
None
:
# TODO: This shouldn't happen...
# TODO: This shouldn't happen...
# It looks like comprehension loop targets are not declared soon enough.
return
return
lhs
.
entry
.
assignments
.
append
(
rhs
)
lhs
.
entry
.
assignments
.
append
(
rhs
)
elif
isinstance
(
lhs
,
ExprNodes
.
SequenceNode
):
elif
isinstance
(
lhs
,
ExprNodes
.
SequenceNode
):
...
...
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