cython-devel

changeset 2469:268bd35aa827

Remove TempNode from OverrideCheckNode (fixes #411)
author Dag Sverre Seljebotn <dagss@student.matnat.uio.no>
date Thu Oct 15 12:54:48 2009 +0200 (2 years ago)
parents d91baf68922d
children 421b27846a16
files Cython/Compiler/ExprNodes.py Cython/Compiler/Nodes.py
line diff
1.1 --- a/Cython/Compiler/ExprNodes.py Thu Oct 15 01:42:39 2009 -0700 1.2 +++ b/Cython/Compiler/ExprNodes.py Thu Oct 15 12:54:48 2009 +0200 1.3 @@ -1665,6 +1665,25 @@ 1.4 def __init__(self, pos, env): 1.5 TempNode.__init__(self, pos, PyrexTypes.py_object_type, env) 1.6 1.7 +class RawCNameExprNode(ExprNode): 1.8 + subexprs = [] 1.9 + 1.10 + def __init__(self, pos, type=None): 1.11 + self.pos = pos 1.12 + self.type = type 1.13 + 1.14 + def analyse_types(self, env): 1.15 + return self.type 1.16 + 1.17 + def set_cname(self, cname): 1.18 + self.cname = cname 1.19 + 1.20 + def result(self): 1.21 + return self.cname 1.22 + 1.23 + def generate_result_code(self, code): 1.24 + pass 1.25 + 1.26 1.27 #------------------------------------------------------------------- 1.28 #
2.1 --- a/Cython/Compiler/Nodes.py Thu Oct 15 01:42:39 2009 -0700 2.2 +++ b/Cython/Compiler/Nodes.py Thu Oct 15 12:54:48 2009 +0200 2.3 @@ -2458,7 +2458,7 @@ 2.4 else: 2.5 first_arg = 1 2.6 import ExprNodes 2.7 - self.func_node = ExprNodes.PyTempNode(self.pos, env) 2.8 + self.func_node = ExprNodes.RawCNameExprNode(self.pos, py_object_type) 2.9 call_tuple = ExprNodes.TupleNode(self.pos, args=[ExprNodes.NameNode(self.pos, name=arg.name) for arg in self.args[first_arg:]]) 2.10 call_node = ExprNodes.SimpleCallNode(self.pos, 2.11 function=self.func_node, 2.12 @@ -2480,20 +2480,21 @@ 2.13 code.putln("else {") 2.14 else: 2.15 code.putln("else if (unlikely(Py_TYPE(%s)->tp_dictoffset != 0)) {" % self_arg) 2.16 - self.func_node.allocate(code) 2.17 - err = code.error_goto_if_null(self.func_node.result(), self.pos) 2.18 + func_node_temp = code.funcstate.allocate_temp(py_object_type, manage_ref=True) 2.19 + self.func_node.set_cname(func_node_temp) 2.20 # need to get attribute manually--scope would return cdef method 2.21 + err = code.error_goto_if_null(func_node_temp, self.pos) 2.22 code.putln("%s = PyObject_GetAttr(%s, %s); %s" % ( 2.23 - self.func_node.result(), self_arg, interned_attr_cname, err)) 2.24 - code.put_gotref(self.func_node.py_result()) 2.25 - is_builtin_function_or_method = "PyCFunction_Check(%s)" % self.func_node.result() 2.26 + func_node_temp, self_arg, interned_attr_cname, err)) 2.27 + code.put_gotref(func_node_temp) 2.28 + is_builtin_function_or_method = "PyCFunction_Check(%s)" % func_node_temp 2.29 is_overridden = "(PyCFunction_GET_FUNCTION(%s) != (void *)&%s)" % ( 2.30 - self.func_node.result(), self.py_func.entry.func_cname) 2.31 + func_node_temp, self.py_func.entry.func_cname) 2.32 code.putln("if (!%s || %s) {" % (is_builtin_function_or_method, is_overridden)) 2.33 self.body.generate_execution_code(code) 2.34 code.putln("}") 2.35 - code.put_decref_clear(self.func_node.result(), PyrexTypes.py_object_type) 2.36 - self.func_node.release(code) 2.37 + code.put_decref_clear(func_node_temp, PyrexTypes.py_object_type) 2.38 + code.funcstate.release_temp(func_node_temp) 2.39 code.putln("}") 2.40 2.41 class ClassDefNode(StatNode, BlockNode):