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
d8fa1dba
Commit
d8fa1dba
authored
Jan 12, 2012
by
Vitja Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ControlFlowState object instead of set() for convinience
parent
e82a3a33
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
5 deletions
+30
-5
Cython/Compiler/FlowControl.py
Cython/Compiler/FlowControl.py
+28
-3
Cython/Compiler/Optimize.py
Cython/Compiler/Optimize.py
+2
-2
No files found.
Cython/Compiler/FlowControl.py
View file @
d8fa1dba
...
...
@@ -327,6 +327,32 @@ class NameReference(object):
return
'%s(entry=%r)'
%
(
self
.
__class__
.
__name__
,
self
.
entry
)
class
ControlFlowState
(
list
):
# Keeps track of Node's entry assignments
#
# cf_is_null [boolean] It is uninitialized
# cf_maybe_null [boolean] May be uninitialized
# is_single [boolean] Has only one assignment at this point
cf_maybe_null
=
False
cf_is_null
=
False
is_single
=
False
def
__init__
(
self
,
state
):
if
Uninitialized
in
state
:
state
.
discard
(
Uninitialized
)
self
.
cf_maybe_null
=
True
if
not
state
:
self
.
cf_is_null
=
True
else
:
if
len
(
state
)
==
1
:
self
.
is_single
=
True
super
(
ControlFlowState
,
self
).
__init__
(
state
)
def
one
(
self
):
return
self
[
0
]
class
GVContext
(
object
):
"""Graphviz subgraph object."""
...
...
@@ -530,11 +556,10 @@ def check_definitions(flow, compiler_directives):
messages
.
report
()
# Remove Uninitialized from cf_state
for
node
in
assmt_nodes
:
node
.
cf_state
.
discard
(
Uninitialized
)
node
.
cf_state
=
ControlFlowState
(
node
.
cf_state
)
for
node
in
references
:
node
.
cf_state
.
discard
(
Uninitialized
)
node
.
cf_state
=
ControlFlowState
(
node
.
cf_state
)
class
AssignmentCollector
(
TreeVisitor
):
...
...
Cython/Compiler/Optimize.py
View file @
d8fa1dba
...
...
@@ -1653,9 +1653,9 @@ class InlineDefNodeCalls(Visitor.CythonTransform):
function_name
=
node
.
function
if
not
function_name
.
is_name
:
return
node
if
len
(
function_name
.
cf_state
)
!=
1
:
if
not
function_name
.
cf_state
.
is_single
:
return
node
function
=
list
(
function_name
.
cf_state
)[
0
]
.
rhs
function
=
function_name
.
cf_state
.
one
()
.
rhs
if
not
isinstance
(
function
,
ExprNodes
.
PyCFunctionNode
):
return
node
inlined
=
ExprNodes
.
InlinedDefNodeCallNode
(
...
...
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