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
e5a59ad5
Commit
e5a59ad5
authored
Jul 08, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix unary operators '+' '-' and '~' for cypclasses
parent
aa76c850
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
3 deletions
+11
-3
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+11
-3
No files found.
Cython/Compiler/ExprNodes.py
View file @
e5a59ad5
...
...
@@ -10551,6 +10551,12 @@ class UnopNode(ExprNode):
return
self
.
type
=
cpp_type
def
calculate_operation_result_code
(
self
,
operator
):
op
=
self
.
operand
.
result
()
if
self
.
operand
.
type
.
is_cyp_class
:
op
=
"(*%s)"
%
op
return
"(%s%s)"
%
(
operator
,
op
)
class
NotNode
(
UnopNode
):
# 'not' operator
...
...
@@ -10600,7 +10606,7 @@ class UnaryPlusNode(UnopNode):
def
calculate_result_code
(
self
):
if
self
.
is_cpp_operation
():
return
"(+%s)"
%
self
.
operand
.
result
(
)
return
self
.
calculate_operation_result_code
(
self
.
operator
)
else
:
return
self
.
operand
.
result
()
...
...
@@ -10626,7 +10632,7 @@ class UnaryMinusNode(UnopNode):
def
calculate_result_code
(
self
):
if
self
.
infix
:
return
"(-%s)"
%
self
.
operand
.
result
(
)
return
self
.
calculate_operation_result_code
(
self
.
operator
)
else
:
return
"%s(%s)"
%
(
self
.
operand
.
type
.
unary_op
(
'-'
),
self
.
operand
.
result
())
...
...
@@ -10651,7 +10657,7 @@ class TildeNode(UnopNode):
return
"PyNumber_Invert"
def
calculate_result_code
(
self
):
return
"(~%s)"
%
self
.
operand
.
result
(
)
return
self
.
calculate_operation_result_code
(
'~'
)
class
CUnopNode
(
UnopNode
):
...
...
@@ -10718,6 +10724,8 @@ class AmpersandNode(CUnopNode):
self
.
operand
=
self
.
operand
.
analyse_types
(
env
)
argtype
=
self
.
operand
.
type
if
argtype
.
is_cpp_class
:
if
argtype
.
is_cyp_class
:
self
.
error
(
"Cannot take address of cypclass"
)
self
.
analyse_cpp_operation
(
env
,
overload_check
=
False
)
if
not
(
argtype
.
is_cfunction
or
argtype
.
is_reference
or
self
.
operand
.
is_addressable
()):
if
argtype
.
is_memoryviewslice
:
...
...
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