Commit 29c7169e authored by Stefan Behnel's avatar Stefan Behnel

clean up overloaded C++ assignment analysis code

parent 7c3ca028
...@@ -4912,7 +4912,7 @@ class SingleAssignmentNode(AssignmentNode): ...@@ -4912,7 +4912,7 @@ class SingleAssignmentNode(AssignmentNode):
op = env.lookup_operator_for_types(self.pos, '=', [self.lhs.type, self.rhs.type]) op = env.lookup_operator_for_types(self.pos, '=', [self.lhs.type, self.rhs.type])
if op: if op:
rhs = self.rhs rhs = self.rhs
self.is_overloaded_assignment = 1 self.is_overloaded_assignment = True
else: else:
rhs = self.rhs.coerce_to(dtype, env) rhs = self.rhs.coerce_to(dtype, env)
else: else:
...@@ -5064,11 +5064,8 @@ class SingleAssignmentNode(AssignmentNode): ...@@ -5064,11 +5064,8 @@ class SingleAssignmentNode(AssignmentNode):
self.rhs.generate_evaluation_code(code) self.rhs.generate_evaluation_code(code)
def generate_assignment_code(self, code): def generate_assignment_code(self, code):
if self.is_overloaded_assignment: self.lhs.generate_assignment_code(
self.lhs.generate_assignment_code(self.rhs, code, overloaded_assignment=True) self.rhs, code, overloaded_assignment=self.is_overloaded_assignment)
else:
self.lhs.generate_assignment_code(self.rhs, code)
def generate_function_definitions(self, env, code): def generate_function_definitions(self, env, code):
self.rhs.generate_function_definitions(env, code) self.rhs.generate_function_definitions(env, code)
...@@ -5134,24 +5131,14 @@ class CascadedAssignmentNode(AssignmentNode): ...@@ -5134,24 +5131,14 @@ class CascadedAssignmentNode(AssignmentNode):
coerced_values = {} coerced_values = {}
self.assignment_overloads = [] self.assignment_overloads = []
for lhs in self.lhs_list: for lhs in self.lhs_list:
overloaded = False overloaded = lhs.type.is_cpp_class and env.lookup_operator('=', [lhs, self.rhs])
if lhs.type.is_cpp_class: self.assignment_overloads.append(overloaded)
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: if lhs.type not in coerced_values and lhs.type != rhs.type:
rhs = CloneNode(self.rhs)
if not overloaded: if not overloaded:
rhs = CloneNode(self.rhs).coerce_to(lhs.type, env) rhs = rhs.coerce_to(lhs.type, env)
self.coerced_values.append(rhs) self.coerced_values.append(rhs)
coerced_values[lhs.type] = rhs coerced_values[lhs.type] = rhs
else:
self.assignment_overloads.append(False)
# clone coerced values for all LHS assignments # clone coerced values for all LHS assignments
self.cloned_values = [] self.cloned_values = []
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment