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
e77db9c9
Commit
e77db9c9
authored
Jul 14, 2015
by
Ian Henriksen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow Cython-style cascaded assignment to use overloaded assignment
operators declared for C++ classes.
parent
2bb76871
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
5 deletions
+22
-5
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+22
-5
No files found.
Cython/Compiler/Nodes.py
View file @
e77db9c9
...
...
@@ -5064,12 +5064,14 @@ class CascadedAssignmentNode(AssignmentNode):
#
# Used internally:
#
# coerced_values [ExprNode] RHS coerced to all distinct LHS types
# cloned_values [ExprNode] cloned RHS value for each LHS
# coerced_values [ExprNode] RHS coerced to all distinct LHS types
# cloned_values [ExprNode] cloned RHS value for each LHS
# assignment_overloads [Bool] If each assignment uses a C++ operator=
child_attrs
=
[
"lhs_list"
,
"rhs"
,
"coerced_values"
,
"cloned_values"
]
cloned_values
=
None
coerced_values
=
None
assignment_overloads
=
None
def
analyse_declarations
(
self
,
env
):
for
lhs
in
self
.
lhs_list
:
...
...
@@ -5100,11 +5102,26 @@ class CascadedAssignmentNode(AssignmentNode):
# clone RHS and coerce it to all distinct LHS types
self
.
coerced_values
=
[]
coerced_values
=
{}
self
.
assignment_overloads
=
[]
for
lhs
in
self
.
lhs_list
:
overloaded
=
False
if
lhs
.
type
.
is_cpp_class
:
op
=
env
.
lookup_operator
(
'='
,
[
lhs
,
self
.
rhs
])
if
op
:
rhs
=
self
.
rhs
self
.
assignment_overloads
.
append
(
True
)
overloaded
=
True
else
:
self
.
assignment_overloads
.
append
(
False
)
else
:
self
.
assignment_overloads
.
append
(
False
)
if
lhs
.
type
not
in
coerced_values
and
lhs
.
type
!=
rhs
.
type
:
rhs
=
CloneNode
(
self
.
rhs
).
coerce_to
(
lhs
.
type
,
env
)
if
not
overloaded
:
rhs
=
CloneNode
(
self
.
rhs
).
coerce_to
(
lhs
.
type
,
env
)
self
.
coerced_values
.
append
(
rhs
)
coerced_values
[
lhs
.
type
]
=
rhs
else
:
self
.
assignment_overloads
.
append
(
False
)
# clone coerced values for all LHS assignments
self
.
cloned_values
=
[]
...
...
@@ -5121,9 +5138,9 @@ class CascadedAssignmentNode(AssignmentNode):
for
rhs
in
self
.
coerced_values
:
rhs
.
generate_evaluation_code
(
code
)
# assign clones to LHS
for
lhs
,
rhs
in
zip
(
self
.
lhs_list
,
self
.
cloned_value
s
):
for
lhs
,
rhs
,
overload
in
zip
(
self
.
lhs_list
,
self
.
cloned_values
,
self
.
assignment_overload
s
):
rhs
.
generate_evaluation_code
(
code
)
lhs
.
generate_assignment_code
(
rhs
,
code
)
lhs
.
generate_assignment_code
(
rhs
,
code
,
overloaded_assignment
=
overload
)
# dispose of coerced values and original RHS
for
rhs_value
in
self
.
coerced_values
:
rhs_value
.
generate_disposal_code
(
code
)
...
...
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