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
8d4c8f4d
Commit
8d4c8f4d
authored
Jul 31, 2011
by
Vitja Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code cleanup
parent
480798a6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
11 deletions
+19
-11
Cython/Compiler/FlowControl.py
Cython/Compiler/FlowControl.py
+19
-11
No files found.
Cython/Compiler/FlowControl.py
View file @
8d4c8f4d
import
cython
import
cython
cython
.
declare
(
PyrexTypes
=
object
,
Naming
=
object
,
ExprNodes
=
object
,
Nodes
=
object
,
cython
.
declare
(
PyrexTypes
=
object
,
Naming
=
object
,
ExprNodes
=
object
,
Nodes
=
object
,
Options
=
object
,
UtilNodes
=
object
,
ModuleNode
=
object
,
Options
=
object
,
UtilNodes
=
object
,
ModuleNode
=
object
,
...
@@ -145,7 +144,8 @@ class ControlFlow(object):
...
@@ -145,7 +144,8 @@ class ControlFlow(object):
if
entry
.
type
.
is_array
or
entry
.
type
.
is_struct_or_union
:
if
entry
.
type
.
is_array
or
entry
.
type
.
is_struct_or_union
:
return
False
return
False
return
(
entry
.
is_local
or
entry
.
is_pyclass_attr
or
entry
.
is_arg
or
return
(
entry
.
is_local
or
entry
.
is_pyclass_attr
or
entry
.
is_arg
or
entry
.
from_closure
or
entry
.
in_closure
or
entry
.
error_on_uninitialized
)
entry
.
from_closure
or
entry
.
in_closure
or
entry
.
error_on_uninitialized
)
def
mark_position
(
self
,
node
):
def
mark_position
(
self
,
node
):
"""Mark position, will be used to draw graph nodes."""
"""Mark position, will be used to draw graph nodes."""
...
@@ -501,18 +501,21 @@ def check_definitions(flow, compiler_directives):
...
@@ -501,18 +501,21 @@ def check_definitions(flow, compiler_directives):
# Unused result
# Unused result
for
assmt
in
assignments
:
for
assmt
in
assignments
:
if
not
assmt
.
refs
and
not
assmt
.
entry
.
is_pyclass_attr
\
if
(
not
assmt
.
refs
and
not
assmt
.
entry
.
is_pyclass_attr
and
not
assmt
.
entry
.
in_closure
:
and
not
assmt
.
entry
.
in_closure
)
:
if
assmt
.
entry
.
cf_references
and
warn_unused_result
:
if
assmt
.
entry
.
cf_references
and
warn_unused_result
:
if
assmt
.
is_arg
:
if
assmt
.
is_arg
:
messages
.
warning
(
assmt
.
pos
,
"Unused argument value '%s'"
%
assmt
.
entry
.
name
)
messages
.
warning
(
assmt
.
pos
,
"Unused argument value '%s'"
%
assmt
.
entry
.
name
)
else
:
else
:
messages
.
warning
(
assmt
.
pos
,
"Unused result in '%s'"
%
assmt
.
entry
.
name
)
messages
.
warning
(
assmt
.
pos
,
"Unused result in '%s'"
%
assmt
.
entry
.
name
)
assmt
.
lhs
.
cf_used
=
False
assmt
.
lhs
.
cf_used
=
False
# Unused entries
# Unused entries
for
entry
in
flow
.
entries
:
for
entry
in
flow
.
entries
:
if
not
entry
.
cf_references
and
not
entry
.
is_pyclass_attr
and
not
entry
.
in_closure
:
if
(
not
entry
.
cf_references
and
not
entry
.
is_pyclass_attr
and
not
entry
.
in_closure
):
# TODO: starred args entries are not marked with is_arg flag
# TODO: starred args entries are not marked with is_arg flag
for
assmt
in
entry
.
cf_assignments
:
for
assmt
in
entry
.
cf_assignments
:
if
assmt
.
is_arg
:
if
assmt
.
is_arg
:
...
@@ -522,10 +525,12 @@ def check_definitions(flow, compiler_directives):
...
@@ -522,10 +525,12 @@ def check_definitions(flow, compiler_directives):
is_arg
=
False
is_arg
=
False
if
is_arg
:
if
is_arg
:
if
warn_unused_arg
:
if
warn_unused_arg
:
messages
.
warning
(
entry
.
pos
,
"Unused argument '%s'"
%
entry
.
name
)
messages
.
warning
(
entry
.
pos
,
"Unused argument '%s'"
%
entry
.
name
)
else
:
else
:
if
warn_unused
:
if
warn_unused
:
messages
.
warning
(
entry
.
pos
,
"Unused entry '%s'"
%
entry
.
name
)
messages
.
warning
(
entry
.
pos
,
"Unused entry '%s'"
%
entry
.
name
)
entry
.
cf_used
=
False
entry
.
cf_used
=
False
messages
.
report
()
messages
.
report
()
...
@@ -709,7 +714,9 @@ class CreateControlFlowGraph(CythonTransform):
...
@@ -709,7 +714,9 @@ class CreateControlFlowGraph(CythonTransform):
if
arg
.
is_name
:
if
arg
.
is_name
:
entry
=
arg
.
entry
or
self
.
env
.
lookup
(
arg
.
name
)
entry
=
arg
.
entry
or
self
.
env
.
lookup
(
arg
.
name
)
if
entry
.
in_closure
or
entry
.
from_closure
:
if
entry
.
in_closure
or
entry
.
from_closure
:
error
(
arg
.
pos
,
"can not delete variable '%s' referenced in nested scope"
%
entry
.
name
)
error
(
arg
.
pos
,
"can not delete variable '%s' "
"referenced in nested scope"
%
entry
.
name
)
# Mark reference
# Mark reference
self
.
visit
(
arg
)
self
.
visit
(
arg
)
self
.
flow
.
mark_deletion
(
arg
,
entry
)
self
.
flow
.
mark_deletion
(
arg
,
entry
)
...
@@ -1094,7 +1101,8 @@ class CreateControlFlowGraph(CythonTransform):
...
@@ -1094,7 +1101,8 @@ class CreateControlFlowGraph(CythonTransform):
self
.
flow
.
mark_assignment
(
node
.
target
,
self
.
flow
.
mark_assignment
(
node
.
target
,
object_expr
,
self
.
env
.
lookup
(
node
.
name
))
object_expr
,
self
.
env
.
lookup
(
node
.
name
))
# TODO: add negative attribute list to "visitchildren"?
# TODO: add negative attribute list to "visitchildren"?
self
.
visitchildren
(
node
,
attrs
=
[
'dict'
,
'metaclass'
,
'mkw'
,
'bases'
,
'classobj'
])
self
.
visitchildren
(
node
,
attrs
=
[
'dict'
,
'metaclass'
,
'mkw'
,
'bases'
,
'classobj'
])
self
.
env_stack
.
append
(
self
.
env
)
self
.
env_stack
.
append
(
self
.
env
)
self
.
env
=
node
.
scope
self
.
env
=
node
.
scope
self
.
flow
.
nextblock
()
self
.
flow
.
nextblock
()
...
...
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