# operator string
# operand1 ExprNode
# operand2 ExprNode
- # temp_bool ExprNode used internally
- temp_bool = None
-
- subexprs = ['operand1', 'operand2', 'temp_bool']
+ subexprs = ['operand1', 'operand2']
def compile_time_value(self, denv):
if self.operator == 'and':
self.operand2.type.is_pyobject:
self.operand1 = self.operand1.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.gil_check(env)
else:
# be necessary.
self.allocate_temp(env, result_code)
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())
# We haven't called release_temp on either operand,
# because although they are temp nodes, they don't own
def generate_evaluation_code(self, 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':
sense = ""
else:
"if (%s%s) {" % (
sense,
test_result))
+ if uses_temp:
+ code.funcstate.release_temp(test_result)
self.operand1.generate_disposal_code(code)
self.operand2.generate_evaluation_code(code)
code.putln(
def generate_operand1_test(self, code):
# Generate code to test the truth of the first operand.
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(
"%s = __Pyx_PyObject_IsTrue(%s); %s" % (
test_result,
code.error_goto_if_neg(test_result, self.pos)))
else:
test_result = self.operand1.result()
- return test_result
+ return (test_result, self.type.is_pyobject)
class CondExprNode(ExprNode):
# true_val ExprNode
# false_val ExprNode
- temp_bool = None
true_val = None
false_val = None