def analyse_types(self, env):
self.operand1.analyse_types(env)
self.operand2.analyse_types(env)
+ self.analyse_operation(env)
+
+ def analyse_operation(self, env):
if self.is_py_operation():
self.coerce_operands_to_pyobjects(env)
self.type = self.result_type(self.operand1.type,
except Exception, e:
self.compile_time_value_error(e)
- def analyse_types(self, env):
+ def analyse_operation(self, env):
if self.cdivision or env.directives['cdivision']:
self.ctruedivision = False
else:
self.ctruedivision = self.truedivision
- NumBinopNode.analyse_types(self, env)
+ NumBinopNode.analyse_operation(self, env)
if self.is_cpp_operation():
self.cdivision = True
if not self.type.is_pyobject:
# There is code to handle this case.
return node
+ env = self.current_env()
def side_effect_free_reference(node, setting=False):
if isinstance(node, NameNode):
return node, []
lhs, let_ref_nodes = side_effect_free_reference(lhs, setting=True)
except ValueError:
return node
+ lhs.analyse_types(env)
dup = lhs.__class__(**lhs.__dict__)
binop = binop_node(node.pos,
operator = node.operator,
operand1 = dup,
operand2 = rhs,
inplace=True)
- node = SingleAssignmentNode(node.pos, lhs=lhs, rhs=binop)
+ binop.analyse_operation(env)
+ node = SingleAssignmentNode(
+ node.pos,
+ lhs = lhs,
+ rhs=binop.coerce_to(lhs.type, env))
# Use LetRefNode to avoid side effects.
let_ref_nodes.reverse()
for t in let_ref_nodes:
node = LetNode(t, node)
- node.analyse_expressions(self.current_env())
+ # Manually analyse types for new node.
return node
def visit_ExprNode(self, node):