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
47aeb5aa
Commit
47aeb5aa
authored
May 08, 2010
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support type analysis in TempResultFromStatNode
parent
23ce7f96
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
9 deletions
+24
-9
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+5
-0
Cython/Compiler/UtilNodes.py
Cython/Compiler/UtilNodes.py
+19
-9
No files found.
Cython/Compiler/ParseTreeTransforms.py
View file @
47aeb5aa
...
@@ -1035,6 +1035,11 @@ property NAME:
...
@@ -1035,6 +1035,11 @@ property NAME:
node
.
analyse_declarations
(
self
.
env_stack
[
-
1
])
node
.
analyse_declarations
(
self
.
env_stack
[
-
1
])
return
node
return
node
def
visit_TempResultFromStatNode
(
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/UtilNodes.py
View file @
47aeb5aa
...
@@ -119,17 +119,24 @@ class ResultRefNode(AtomicExprNode):
...
@@ -119,17 +119,24 @@ class ResultRefNode(AtomicExprNode):
subexprs
=
[]
subexprs
=
[]
lhs_of_first_assignment
=
False
lhs_of_first_assignment
=
False
def
__init__
(
self
,
expression
):
def
__init__
(
self
,
expression
=
None
,
pos
=
None
):
self
.
pos
=
expression
.
pos
self
.
expression
=
expression
self
.
expression
=
expression
if
hasattr
(
expression
,
"type"
):
self
.
pos
=
None
self
.
type
=
expression
.
type
if
expression
is
not
None
:
self
.
pos
=
expression
.
pos
if
hasattr
(
expression
,
"type"
):
self
.
type
=
expression
.
type
if
pos
is
not
None
:
self
.
pos
=
pos
assert
self
.
pos
is
not
None
def
analyse_types
(
self
,
env
):
def
analyse_types
(
self
,
env
):
self
.
type
=
self
.
expression
.
type
if
self
.
expression
is
not
None
:
self
.
type
=
self
.
expression
.
type
def
infer_type
(
self
,
env
):
def
infer_type
(
self
,
env
):
return
self
.
expression
.
infer_type
(
env
)
if
self
.
expression
is
not
None
:
return
self
.
expression
.
infer_type
(
env
)
def
is_simple
(
self
):
def
is_simple
(
self
):
return
True
return
True
...
@@ -258,9 +265,6 @@ class TempResultFromStatNode(ExprNodes.ExprNode):
...
@@ -258,9 +265,6 @@ class TempResultFromStatNode(ExprNodes.ExprNode):
# body. Requires a ResultRefNode that it sets up to refer to its
# body. Requires a ResultRefNode that it sets up to refer to its
# own temp result. The StatNode must assign a value to the result
# own temp result. The StatNode must assign a value to the result
# node, which then becomes the result of this node.
# node, which then becomes the result of this node.
#
# This can only be used in/after type analysis.
#
subexprs
=
[]
subexprs
=
[]
child_attrs
=
[
'body'
]
child_attrs
=
[
'body'
]
...
@@ -272,6 +276,12 @@ class TempResultFromStatNode(ExprNodes.ExprNode):
...
@@ -272,6 +276,12 @@ class TempResultFromStatNode(ExprNodes.ExprNode):
self
.
type
=
result_ref
.
type
self
.
type
=
result_ref
.
type
self
.
is_temp
=
1
self
.
is_temp
=
1
def
analyse_declarations
(
self
,
env
):
self
.
body
.
analyse_declarations
(
env
)
def
analyse_types
(
self
,
env
):
self
.
body
.
analyse_expressions
(
env
)
def
generate_result_code
(
self
,
code
):
def
generate_result_code
(
self
,
code
):
self
.
result_ref
.
result_code
=
self
.
result
()
self
.
result_ref
.
result_code
=
self
.
result
()
self
.
body
.
generate_execution_code
(
code
)
self
.
body
.
generate_execution_code
(
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