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
Gwenaël Samain
cython
Commits
62068b7b
Commit
62068b7b
authored
Apr 02, 2011
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Trac 676 - arithmetic is always at least an int
parent
6100f407
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
4 deletions
+13
-4
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+13
-4
No files found.
Cython/Compiler/ExprNodes.py
View file @
62068b7b
...
@@ -5295,7 +5295,8 @@ class UnaryPlusNode(UnopNode):
...
@@ -5295,7 +5295,8 @@ class UnaryPlusNode(UnopNode):
operator
=
'+'
operator
=
'+'
def
analyse_c_operation
(
self
,
env
):
def
analyse_c_operation
(
self
,
env
):
self
.
type
=
self
.
operand
.
type
self
.
type
=
PyrexTypes
.
widest_numeic_type
(
self
.
operand
.
type
,
PyreXTypes
.
c_int_type
)
def
py_operation_function
(
self
):
def
py_operation_function
(
self
):
return
"PyNumber_Positive"
return
"PyNumber_Positive"
...
@@ -5314,7 +5315,8 @@ class UnaryMinusNode(UnopNode):
...
@@ -5314,7 +5315,8 @@ class UnaryMinusNode(UnopNode):
def
analyse_c_operation
(
self
,
env
):
def
analyse_c_operation
(
self
,
env
):
if
self
.
operand
.
type
.
is_numeric
:
if
self
.
operand
.
type
.
is_numeric
:
self
.
type
=
self
.
operand
.
type
self
.
type
=
PyrexTypes
.
widest_numeric_type
(
self
.
operand
.
type
,
PyrexTypes
.
c_int_type
)
else
:
else
:
self
.
type_error
()
self
.
type_error
()
if
self
.
type
.
is_complex
:
if
self
.
type
.
is_complex
:
...
@@ -5339,7 +5341,8 @@ class TildeNode(UnopNode):
...
@@ -5339,7 +5341,8 @@ class TildeNode(UnopNode):
def
analyse_c_operation
(
self
,
env
):
def
analyse_c_operation
(
self
,
env
):
if
self
.
operand
.
type
.
is_int
:
if
self
.
operand
.
type
.
is_int
:
self
.
type
=
self
.
operand
.
type
self
.
type
=
PyrexTypes
.
widest_numeric_type
(
self
.
operand
.
type
,
PyrexTypes
.
c_int_type
)
else
:
else
:
self
.
type_error
()
self
.
type_error
()
...
@@ -5374,7 +5377,10 @@ class DecrementIncrementNode(CUnopNode):
...
@@ -5374,7 +5377,10 @@ class DecrementIncrementNode(CUnopNode):
# unary ++/-- operator
# unary ++/-- operator
def
analyse_c_operation
(
self
,
env
):
def
analyse_c_operation
(
self
,
env
):
if
self
.
operand
.
type
.
is_ptr
or
self
.
operand
.
type
.
is_numeric
:
if
self
.
operand
.
type
.
is_numeric
:
self
.
type
=
PyrexTypes
.
widest_numeric_type
(
self
.
operand
.
type
,
PyrexTypes
.
c_int_type
)
elif
self
.
operand
.
type
.
is_ptr
:
self
.
type
=
self
.
operand
.
type
self
.
type
=
self
.
operand
.
type
else
:
else
:
self
.
type_error
()
self
.
type_error
()
...
@@ -5913,6 +5919,9 @@ class NumBinopNode(BinopNode):
...
@@ -5913,6 +5919,9 @@ class NumBinopNode(BinopNode):
if
self
.
operator
not
in
'|^&'
:
if
self
.
operator
not
in
'|^&'
:
# False + False == 0 # not False!
# False + False == 0 # not False!
widest_type
=
PyrexTypes
.
c_int_type
widest_type
=
PyrexTypes
.
c_int_type
else
:
widest_type
=
PyrexTypes
.
widest_numeric_type
(
widest_type
,
PyrexTypes
.
c_int_type
)
return
widest_type
return
widest_type
else
:
else
:
return
None
return
None
...
...
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