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
9ca148be
Commit
9ca148be
authored
Nov 12, 2010
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup, support UnaryPlusNode in constant folding
parent
9dd0e113
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
Cython/Compiler/Optimize.py
Cython/Compiler/Optimize.py
+9
-9
No files found.
Cython/Compiler/Optimize.py
View file @
9ca148be
...
...
@@ -2940,17 +2940,23 @@ class ConstantFolding(Visitor.VisitorTransform, SkipDeclarations):
isinstance
(
node
.
operand
,
ExprNodes
.
IntNode
)
and
node_type
.
is_pyobject
:
return
ExprNodes
.
IntNode
(
node
.
pos
,
value
=
'-'
+
node
.
operand
.
value
,
type
=
node_type
,
longness
=
node
.
operand
.
longness
,
constant_result
=
node
.
constant_result
)
return
node
def
visit_UnaryPlusNode
(
self
,
node
):
self
.
_calculate_const
(
node
)
if
node
.
constant_result
is
ExprNodes
.
not_a_constant
:
return
node
if
node
.
constant_result
==
node
.
operand
.
constant_result
:
return
node
.
operand
return
node
def
visit_BoolBinopNode
(
self
,
node
):
self
.
_calculate_const
(
node
)
if
node
.
constant_result
is
ExprNodes
.
not_a_constant
:
return
node
if
not
node
.
operand1
.
is_literal
or
not
node
.
operand2
.
is_literal
:
# We calculate other constants to make them available to
# the compiler, but we only aggregate constant nodes
# recursively, so non-const nodes are straight out.
return
node
if
node
.
constant_result
==
node
.
operand1
.
constant_result
and
node
.
operand1
.
is_literal
:
...
...
@@ -2966,14 +2972,8 @@ class ConstantFolding(Visitor.VisitorTransform, SkipDeclarations):
if
node
.
constant_result
is
ExprNodes
.
not_a_constant
:
return
node
if
isinstance
(
node
.
constant_result
,
float
):
# We calculate float constants to make them available to
# the compiler, but we do not aggregate them into a
# constant node to prevent any loss of precision.
return
node
if
not
node
.
operand1
.
is_literal
or
not
node
.
operand2
.
is_literal
:
# We calculate other constants to make them available to
# the compiler, but we only aggregate constant nodes
# recursively, so non-const nodes are straight out.
return
node
# now inject a new constant node with the calculated value
...
...
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