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
2601dc12
Commit
2601dc12
authored
Nov 24, 2013
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor safety fixes in constant folding
parent
92e16f1e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
2 deletions
+4
-2
Cython/Compiler/Optimize.py
Cython/Compiler/Optimize.py
+4
-2
No files found.
Cython/Compiler/Optimize.py
View file @
2601dc12
...
...
@@ -3171,11 +3171,12 @@ class ConstantFolding(Visitor.VisitorTransform, SkipDeclarations):
value
=
'-'
+
value
return
value
node_type
=
node
.
operand
.
type
if
isinstance
(
node
.
operand
,
ExprNodes
.
FloatNode
):
# this is a safe operation
return
ExprNodes
.
FloatNode
(
node
.
pos
,
value
=
_negate
(
node
.
operand
.
value
),
type
=
node_type
,
constant_result
=
node
.
constant_result
)
node_type
=
node
.
operand
.
type
if
node_type
.
is_int
and
node_type
.
signed
or
\
isinstance
(
node
.
operand
,
ExprNodes
.
IntNode
)
and
node_type
.
is_pyobject
:
return
ExprNodes
.
IntNode
(
node
.
pos
,
value
=
_negate
(
node
.
operand
.
value
),
...
...
@@ -3185,7 +3186,8 @@ class ConstantFolding(Visitor.VisitorTransform, SkipDeclarations):
return
node
def
_handle_UnaryPlusNode
(
self
,
node
):
if
node
.
constant_result
==
node
.
operand
.
constant_result
:
if
(
node
.
operand
.
has_constant_result
()
and
node
.
constant_result
==
node
.
operand
.
constant_result
):
return
node
.
operand
return
node
...
...
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