Commit 0556c173 authored by Dag Sverre Seljebotn's avatar Dag Sverre Seljebotn

BoolBinopNode cleanup due to new temps

parent 63968d47
...@@ -3914,11 +3914,8 @@ class BoolBinopNode(ExprNode): ...@@ -3914,11 +3914,8 @@ class BoolBinopNode(ExprNode):
# operator string # operator string
# operand1 ExprNode # operand1 ExprNode
# operand2 ExprNode # operand2 ExprNode
# temp_bool ExprNode used internally
temp_bool = None subexprs = ['operand1', 'operand2']
subexprs = ['operand1', 'operand2', 'temp_bool']
def compile_time_value(self, denv): def compile_time_value(self, denv):
if self.operator == 'and': if self.operator == 'and':
...@@ -3941,7 +3938,6 @@ class BoolBinopNode(ExprNode): ...@@ -3941,7 +3938,6 @@ class BoolBinopNode(ExprNode):
self.operand2.type.is_pyobject: self.operand2.type.is_pyobject:
self.operand1 = self.operand1.coerce_to_pyobject(env) self.operand1 = self.operand1.coerce_to_pyobject(env)
self.operand2 = self.operand2.coerce_to_pyobject(env) self.operand2 = self.operand2.coerce_to_pyobject(env)
self.temp_bool = TempNode(self.pos, PyrexTypes.c_bint_type, env)
self.type = py_object_type self.type = py_object_type
self.gil_check(env) self.gil_check(env)
else: else:
...@@ -3966,9 +3962,6 @@ class BoolBinopNode(ExprNode): ...@@ -3966,9 +3962,6 @@ class BoolBinopNode(ExprNode):
# be necessary. # be necessary.
self.allocate_temp(env, result_code) self.allocate_temp(env, result_code)
self.operand1.allocate_temps(env, self.result()) self.operand1.allocate_temps(env, self.result())
if self.temp_bool:
self.temp_bool.allocate_temp(env)
self.temp_bool.release_temp(env)
self.operand2.allocate_temps(env, self.result()) self.operand2.allocate_temps(env, self.result())
# We haven't called release_temp on either operand, # We haven't called release_temp on either operand,
# because although they are temp nodes, they don't own # because although they are temp nodes, they don't own
...@@ -3992,7 +3985,7 @@ class BoolBinopNode(ExprNode): ...@@ -3992,7 +3985,7 @@ class BoolBinopNode(ExprNode):
def generate_evaluation_code(self, code): def generate_evaluation_code(self, code):
self.operand1.generate_evaluation_code(code) self.operand1.generate_evaluation_code(code)
test_result = self.generate_operand1_test(code) test_result, uses_temp = self.generate_operand1_test(code)
if self.operator == 'and': if self.operator == 'and':
sense = "" sense = ""
else: else:
...@@ -4001,6 +3994,8 @@ class BoolBinopNode(ExprNode): ...@@ -4001,6 +3994,8 @@ class BoolBinopNode(ExprNode):
"if (%s%s) {" % ( "if (%s%s) {" % (
sense, sense,
test_result)) test_result))
if uses_temp:
code.funcstate.release_temp(test_result)
self.operand1.generate_disposal_code(code) self.operand1.generate_disposal_code(code)
self.operand2.generate_evaluation_code(code) self.operand2.generate_evaluation_code(code)
code.putln( code.putln(
...@@ -4009,7 +4004,8 @@ class BoolBinopNode(ExprNode): ...@@ -4009,7 +4004,8 @@ class BoolBinopNode(ExprNode):
def generate_operand1_test(self, code): def generate_operand1_test(self, code):
# Generate code to test the truth of the first operand. # Generate code to test the truth of the first operand.
if self.type.is_pyobject: if self.type.is_pyobject:
test_result = self.temp_bool.result() test_result = code.funcstate.allocate_temp(PyrexTypes.c_bint_type,
manage_ref=False)
code.putln( code.putln(
"%s = __Pyx_PyObject_IsTrue(%s); %s" % ( "%s = __Pyx_PyObject_IsTrue(%s); %s" % (
test_result, test_result,
...@@ -4017,7 +4013,7 @@ class BoolBinopNode(ExprNode): ...@@ -4017,7 +4013,7 @@ class BoolBinopNode(ExprNode):
code.error_goto_if_neg(test_result, self.pos))) code.error_goto_if_neg(test_result, self.pos)))
else: else:
test_result = self.operand1.result() test_result = self.operand1.result()
return test_result return (test_result, self.type.is_pyobject)
class CondExprNode(ExprNode): class CondExprNode(ExprNode):
...@@ -4027,7 +4023,6 @@ class CondExprNode(ExprNode): ...@@ -4027,7 +4023,6 @@ class CondExprNode(ExprNode):
# true_val ExprNode # true_val ExprNode
# false_val ExprNode # false_val ExprNode
temp_bool = None
true_val = None true_val = None
false_val = None false_val = None
......
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