Commit 0f465ef8 authored by Stefan Behnel's avatar Stefan Behnel

fix up more places where new "overloaded_assignment" argument was missing...

fix up more places where new "overloaded_assignment" argument was missing (there has to be a better way than passing this flag around...)
parent abad1a01
...@@ -2096,11 +2096,8 @@ class NameNode(AtomicExprNode): ...@@ -2096,11 +2096,8 @@ class NameNode(AtomicExprNode):
code.put_giveref(rhs.py_result()) code.put_giveref(rhs.py_result())
if not self.type.is_memoryviewslice: if not self.type.is_memoryviewslice:
if not assigned: if not assigned:
if overloaded_assignment: result = rhs.result() if overloaded_assignment else rhs.result_as(self.ctype())
code.putln('%s = %s;' % (self.result(), rhs.result())) code.putln('%s = %s;' % (self.result(), result))
else:
code.putln('%s = %s;' % (
self.result(), rhs.result_as(self.ctype())))
if debug_disposal_code: if debug_disposal_code:
print("NameNode.generate_assignment_code:") print("NameNode.generate_assignment_code:")
print("...generating post-assignment code for %s" % rhs) print("...generating post-assignment code for %s" % rhs)
......
...@@ -901,7 +901,7 @@ class CArgDeclNode(Node): ...@@ -901,7 +901,7 @@ class CArgDeclNode(Node):
if self.default: if self.default:
self.default.annotate(code) self.default.annotate(code)
def generate_assignment_code(self, code, target=None): def generate_assignment_code(self, code, target=None, overloaded_assignment=False):
default = self.default default = self.default
if default is None or default.is_literal: if default is None or default.is_literal:
return return
...@@ -909,7 +909,7 @@ class CArgDeclNode(Node): ...@@ -909,7 +909,7 @@ class CArgDeclNode(Node):
target = self.calculate_default_value_code(code) target = self.calculate_default_value_code(code)
default.generate_evaluation_code(code) default.generate_evaluation_code(code)
default.make_owned_reference(code) default.make_owned_reference(code)
result = default.result_as(self.type) result = default.result() if overloaded_assignment else default.result_as(self.type)
code.putln("%s = %s;" % (target, result)) code.putln("%s = %s;" % (target, result))
if self.type.is_pyobject: if self.type.is_pyobject:
code.put_giveref(default.result()) code.put_giveref(default.result())
...@@ -5071,7 +5071,7 @@ class SingleAssignmentNode(AssignmentNode): ...@@ -5071,7 +5071,7 @@ class SingleAssignmentNode(AssignmentNode):
def generate_rhs_evaluation_code(self, code): def generate_rhs_evaluation_code(self, code):
self.rhs.generate_evaluation_code(code) self.rhs.generate_evaluation_code(code)
def generate_assignment_code(self, code): def generate_assignment_code(self, code, overloaded_assignment=False):
self.lhs.generate_assignment_code( self.lhs.generate_assignment_code(
self.rhs, code, overloaded_assignment=self.is_overloaded_assignment) self.rhs, code, overloaded_assignment=self.is_overloaded_assignment)
...@@ -5158,7 +5158,7 @@ class CascadedAssignmentNode(AssignmentNode): ...@@ -5158,7 +5158,7 @@ class CascadedAssignmentNode(AssignmentNode):
def generate_rhs_evaluation_code(self, code): def generate_rhs_evaluation_code(self, code):
self.rhs.generate_evaluation_code(code) self.rhs.generate_evaluation_code(code)
def generate_assignment_code(self, code): def generate_assignment_code(self, code, overloaded_assignment=False):
# prepare all coercions # prepare all coercions
for rhs in self.coerced_values: for rhs in self.coerced_values:
rhs.generate_evaluation_code(code) rhs.generate_evaluation_code(code)
......
...@@ -53,12 +53,15 @@ class TempRefNode(AtomicExprNode): ...@@ -53,12 +53,15 @@ class TempRefNode(AtomicExprNode):
def generate_result_code(self, code): def generate_result_code(self, code):
pass pass
def generate_assignment_code(self, rhs, code): def generate_assignment_code(self, rhs, code, overloaded_assignment=False):
if self.type.is_pyobject: if self.type.is_pyobject:
rhs.make_owned_reference(code) rhs.make_owned_reference(code)
# TODO: analyse control flow to see if this is necessary # TODO: analyse control flow to see if this is necessary
code.put_xdecref(self.result(), self.ctype()) code.put_xdecref(self.result(), self.ctype())
code.putln('%s = %s;' % (self.result(), rhs.result_as(self.ctype()))) code.putln('%s = %s;' % (
self.result(),
rhs.result() if overloaded_assignment else rhs.result_as(self.ctype()),
))
rhs.generate_post_assignment_code(code) rhs.generate_post_assignment_code(code)
rhs.free_temps(code) rhs.free_temps(code)
...@@ -66,7 +69,7 @@ class CleanupTempRefNode(TempRefNode): ...@@ -66,7 +69,7 @@ class CleanupTempRefNode(TempRefNode):
# THIS IS DEPRECATED, USE LetRefNode instead # THIS IS DEPRECATED, USE LetRefNode instead
# handle TempHandle # handle TempHandle
def generate_assignment_code(self, rhs, code): def generate_assignment_code(self, rhs, code, overloaded_assignment=False):
pass pass
def generate_execution_code(self, code): def generate_execution_code(self, code):
...@@ -200,12 +203,15 @@ class ResultRefNode(AtomicExprNode): ...@@ -200,12 +203,15 @@ class ResultRefNode(AtomicExprNode):
def generate_disposal_code(self, code): def generate_disposal_code(self, code):
pass pass
def generate_assignment_code(self, rhs, code): def generate_assignment_code(self, rhs, code, overloaded_assignment=False):
if self.type.is_pyobject: if self.type.is_pyobject:
rhs.make_owned_reference(code) rhs.make_owned_reference(code)
if not self.lhs_of_first_assignment: if not self.lhs_of_first_assignment:
code.put_decref(self.result(), self.ctype()) code.put_decref(self.result(), self.ctype())
code.putln('%s = %s;' % (self.result(), rhs.result_as(self.ctype()))) code.putln('%s = %s;' % (
self.result(),
rhs.result() if overloaded_assignment else rhs.result_as(self.ctype()),
))
rhs.generate_post_assignment_code(code) rhs.generate_post_assignment_code(code)
rhs.free_temps(code) rhs.free_temps(code)
......
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