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
Boxiang Sun
cython
Commits
eb64d91c
Commit
eb64d91c
authored
Jul 29, 2011
by
Mark Florisson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support module level control flow and Entry-level error on uninitialized
parent
9e1e1ffe
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
2 deletions
+13
-2
Cython/Compiler/FlowControl.py
Cython/Compiler/FlowControl.py
+10
-2
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+3
-0
No files found.
Cython/Compiler/FlowControl.py
View file @
eb64d91c
...
...
@@ -145,7 +145,7 @@ class ControlFlow(object):
if
entry
.
type
.
is_array
or
entry
.
type
.
is_struct_or_union
:
return
False
return
(
entry
.
is_local
or
entry
.
is_pyclass_attr
or
entry
.
is_arg
or
entry
.
from_closure
or
entry
.
in_closure
)
entry
.
from_closure
or
entry
.
in_closure
or
entry
.
error_on_uninitialized
)
def
mark_position
(
self
,
node
):
"""Mark position, will be used to draw graph nodes."""
...
...
@@ -479,7 +479,8 @@ def check_definitions(flow, compiler_directives):
if
node
.
allow_null
or
entry
.
from_closure
:
pass
# Can be uninitialized here
elif
node
.
cf_is_null
:
if
entry
.
type
.
is_pyobject
or
entry
.
type
.
is_unspecified
:
if
(
entry
.
type
.
is_pyobject
or
entry
.
type
.
is_unspecified
or
entry
.
error_on_uninitialized
):
messages
.
error
(
node
.
pos
,
"local variable '%s' referenced before assignment"
...
...
@@ -551,15 +552,22 @@ class AssignmentCollector(TreeVisitor):
class
CreateControlFlowGraph
(
CythonTransform
):
"""Create NameNode use and assignment graph."""
in_inplace_assignment
=
False
def
visit_ModuleNode
(
self
,
node
):
self
.
gv_ctx
=
GVContext
()
# Set of NameNode reductions
self
.
reductions
=
cython
.
set
()
self
.
env_stack
=
[]
self
.
env
=
node
.
scope
self
.
stack
=
[]
self
.
flow
=
ControlFlow
()
self
.
visitchildren
(
node
)
check_definitions
(
self
.
flow
,
self
.
current_directives
)
dot_output
=
self
.
current_directives
[
'control_flow.dot_output'
]
if
dot_output
:
annotate_defs
=
self
.
current_directives
[
'control_flow.dot_annotate_defs'
]
...
...
Cython/Compiler/Symtab.py
View file @
eb64d91c
...
...
@@ -125,6 +125,8 @@ class Entry(object):
# utility_code_definition For some Cython builtins, the utility code
# which contains the definition of the entry.
# Currently only supported for CythonScope entries.
# error_on_uninitialized Have Control Flow issue an error when this entry is
# used uninitialized
inline_func_in_pxd = False
borrowed = 0
...
...
@@ -179,6 +181,7 @@ class Entry(object):
utility_code_definition = None
in_with_gil_block = 0
from_cython_utility_code = None
error_on_uninitialized = False
def __init__(self, name, cname, type, pos = None, init = None):
self.name = name
...
...
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