Commit 9cefcb88 authored by Stefan Behnel's avatar Stefan Behnel

minor code cleanup

parent 7f36b856
...@@ -9641,22 +9641,20 @@ class BoolBinopNode(ExprNode): ...@@ -9641,22 +9641,20 @@ class BoolBinopNode(ExprNode):
return self.operand1.may_be_none() or self.operand2.may_be_none() return self.operand1.may_be_none() or self.operand2.may_be_none()
def calculate_constant_result(self): def calculate_constant_result(self):
operand1 = self.operand1.constant_result
operand2 = self.operand2.constant_result
if self.operator == 'and': if self.operator == 'and':
self.constant_result = \ self.constant_result = operand1 and operand2
self.operand1.constant_result and \
self.operand2.constant_result
else: else:
self.constant_result = \ self.constant_result = operand1 or operand2
self.operand1.constant_result or \
self.operand2.constant_result
def compile_time_value(self, denv): def compile_time_value(self, denv):
operand1 = self.operand1.compile_time_value(denv)
operand2 = self.operand2.compile_time_value(denv)
if self.operator == 'and': if self.operator == 'and':
return self.operand1.compile_time_value(denv) \ return operand1 and operand2
and self.operand2.compile_time_value(denv)
else: else:
return self.operand1.compile_time_value(denv) \ return operand1 or operand2
or self.operand2.compile_time_value(denv)
def coerce_to_boolean(self, env): def coerce_to_boolean(self, env):
return BoolBinopNode.from_node( return BoolBinopNode.from_node(
......
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