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
397ce8a2
Commit
397ce8a2
authored
Nov 22, 2014
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
constant-fold expressions generated for type inference during control flow analysis
parent
d7453bd0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
7 deletions
+9
-7
Cython/Compiler/FlowControl.pxd
Cython/Compiler/FlowControl.pxd
+1
-0
Cython/Compiler/FlowControl.py
Cython/Compiler/FlowControl.py
+8
-7
No files found.
Cython/Compiler/FlowControl.pxd
View file @
397ce8a2
...
...
@@ -96,6 +96,7 @@ cdef check_definitions(ControlFlow flow, dict compiler_directives)
@
cython
.
final
cdef
class
ControlFlowAnalysis
(
CythonTransform
):
cdef
object
gv_ctx
cdef
object
constant_folder
cdef
set
reductions
cdef
list
env_stack
cdef
list
stack
...
...
Cython/Compiler/FlowControl.py
View file @
397ce8a2
...
...
@@ -16,6 +16,8 @@ from . import PyrexTypes
from
.Visitor
import
TreeVisitor
,
CythonTransform
from
.Errors
import
error
,
warning
,
InternalError
from
.Optimize
import
ConstantFolding
class
TypedExprNode
(
ExprNodes
.
ExprNode
):
# Used for declaring assignments of a specified type without a known entry.
...
...
@@ -674,6 +676,7 @@ class ControlFlowAnalysis(CythonTransform):
def
visit_ModuleNode
(
self
,
node
):
self
.
gv_ctx
=
GVContext
()
self
.
constant_folder
=
ConstantFolding
()
# Set of NameNode reductions
self
.
reductions
=
set
()
...
...
@@ -830,7 +833,7 @@ class ControlFlowAnalysis(CythonTransform):
self
.
in_inplace_assignment
=
True
self
.
visitchildren
(
node
)
self
.
in_inplace_assignment
=
False
self
.
mark_assignment
(
node
.
lhs
,
node
.
create_binop_node
(
))
self
.
mark_assignment
(
node
.
lhs
,
self
.
constant_folder
(
node
.
create_binop_node
()
))
return
node
def
visit_DelStatNode
(
self
,
node
):
...
...
@@ -973,12 +976,11 @@ class ControlFlowAnalysis(CythonTransform):
for
arg
in
sequence
.
args
[:
2
]:
self
.
mark_assignment
(
target
,
arg
)
if
len
(
sequence
.
args
)
>
2
:
self
.
mark_assignment
(
target
,
self
.
mark_assignment
(
target
,
self
.
constant_folder
(
ExprNodes
.
binop_node
(
node
.
pos
,
'+'
,
sequence
.
args
[
0
],
sequence
.
args
[
2
]))
sequence
.
args
[
2
]))
)
if
not
is_special
:
# A for-loop basically translates to subsequent calls to
...
...
@@ -1077,9 +1079,8 @@ class ControlFlowAnalysis(CythonTransform):
self
.
flow
.
nextblock
()
self
.
mark_assignment
(
node
.
target
,
node
.
bound1
)
if
node
.
step
is
not
None
:
self
.
mark_assignment
(
node
.
target
,
ExprNodes
.
binop_node
(
node
.
pos
,
'+'
,
node
.
bound1
,
node
.
step
))
self
.
mark_assignment
(
node
.
target
,
self
.
constant_folder
(
ExprNodes
.
binop_node
(
node
.
pos
,
'+'
,
node
.
bound1
,
node
.
step
)))
# Body block
self
.
flow
.
nextblock
()
self
.
_visit
(
node
.
body
)
...
...
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