From: Dag Sverre Seljebotn Date: Thu, 15 Oct 2009 10:54:48 +0000 (+0200) Subject: Remove TempNode from OverrideCheckNode (fixes #411) X-Git-Tag: 0.13.beta0~2^2~121^2~51 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=ba105125ed8cc998a0640cef56ebc991d5921b6e;p=cython.git Remove TempNode from OverrideCheckNode (fixes #411) --- diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index b16c9e8d..4f0c8daa 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -1665,6 +1665,25 @@ class PyTempNode(TempNode): def __init__(self, pos, env): TempNode.__init__(self, pos, PyrexTypes.py_object_type, env) +class RawCNameExprNode(ExprNode): + subexprs = [] + + def __init__(self, pos, type=None): + self.pos = pos + self.type = type + + def analyse_types(self, env): + return self.type + + def set_cname(self, cname): + self.cname = cname + + def result(self): + return self.cname + + def generate_result_code(self, code): + pass + #------------------------------------------------------------------- # diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index 0daf2bd3..613c7e6d 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -2458,7 +2458,7 @@ class OverrideCheckNode(StatNode): else: first_arg = 1 import ExprNodes - self.func_node = ExprNodes.PyTempNode(self.pos, env) + self.func_node = ExprNodes.RawCNameExprNode(self.pos, py_object_type) call_tuple = ExprNodes.TupleNode(self.pos, args=[ExprNodes.NameNode(self.pos, name=arg.name) for arg in self.args[first_arg:]]) call_node = ExprNodes.SimpleCallNode(self.pos, function=self.func_node, @@ -2480,20 +2480,21 @@ class OverrideCheckNode(StatNode): code.putln("else {") else: code.putln("else if (unlikely(Py_TYPE(%s)->tp_dictoffset != 0)) {" % self_arg) - self.func_node.allocate(code) - err = code.error_goto_if_null(self.func_node.result(), self.pos) + func_node_temp = code.funcstate.allocate_temp(py_object_type, manage_ref=True) + self.func_node.set_cname(func_node_temp) # need to get attribute manually--scope would return cdef method + err = code.error_goto_if_null(func_node_temp, self.pos) code.putln("%s = PyObject_GetAttr(%s, %s); %s" % ( - self.func_node.result(), self_arg, interned_attr_cname, err)) - code.put_gotref(self.func_node.py_result()) - is_builtin_function_or_method = "PyCFunction_Check(%s)" % self.func_node.result() + func_node_temp, self_arg, interned_attr_cname, err)) + code.put_gotref(func_node_temp) + is_builtin_function_or_method = "PyCFunction_Check(%s)" % func_node_temp is_overridden = "(PyCFunction_GET_FUNCTION(%s) != (void *)&%s)" % ( - self.func_node.result(), self.py_func.entry.func_cname) + func_node_temp, self.py_func.entry.func_cname) code.putln("if (!%s || %s) {" % (is_builtin_function_or_method, is_overridden)) self.body.generate_execution_code(code) code.putln("}") - code.put_decref_clear(self.func_node.result(), PyrexTypes.py_object_type) - self.func_node.release(code) + code.put_decref_clear(func_node_temp, PyrexTypes.py_object_type) + code.funcstate.release_temp(func_node_temp) code.putln("}") class ClassDefNode(StatNode, BlockNode):