Commit ba105125 authored by Dag Sverre Seljebotn's avatar Dag Sverre Seljebotn

Remove TempNode from OverrideCheckNode (fixes #411)

parent 4d4d29d8
...@@ -1665,6 +1665,25 @@ class PyTempNode(TempNode): ...@@ -1665,6 +1665,25 @@ class PyTempNode(TempNode):
def __init__(self, pos, env): def __init__(self, pos, env):
TempNode.__init__(self, pos, PyrexTypes.py_object_type, 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
#------------------------------------------------------------------- #-------------------------------------------------------------------
# #
......
...@@ -2458,7 +2458,7 @@ class OverrideCheckNode(StatNode): ...@@ -2458,7 +2458,7 @@ class OverrideCheckNode(StatNode):
else: else:
first_arg = 1 first_arg = 1
import ExprNodes 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_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, call_node = ExprNodes.SimpleCallNode(self.pos,
function=self.func_node, function=self.func_node,
...@@ -2480,20 +2480,21 @@ class OverrideCheckNode(StatNode): ...@@ -2480,20 +2480,21 @@ class OverrideCheckNode(StatNode):
code.putln("else {") code.putln("else {")
else: else:
code.putln("else if (unlikely(Py_TYPE(%s)->tp_dictoffset != 0)) {" % self_arg) code.putln("else if (unlikely(Py_TYPE(%s)->tp_dictoffset != 0)) {" % self_arg)
self.func_node.allocate(code) func_node_temp = code.funcstate.allocate_temp(py_object_type, manage_ref=True)
err = code.error_goto_if_null(self.func_node.result(), self.pos) self.func_node.set_cname(func_node_temp)
# need to get attribute manually--scope would return cdef method # 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" % ( code.putln("%s = PyObject_GetAttr(%s, %s); %s" % (
self.func_node.result(), self_arg, interned_attr_cname, err)) func_node_temp, self_arg, interned_attr_cname, err))
code.put_gotref(self.func_node.py_result()) code.put_gotref(func_node_temp)
is_builtin_function_or_method = "PyCFunction_Check(%s)" % self.func_node.result() is_builtin_function_or_method = "PyCFunction_Check(%s)" % func_node_temp
is_overridden = "(PyCFunction_GET_FUNCTION(%s) != (void *)&%s)" % ( 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)) code.putln("if (!%s || %s) {" % (is_builtin_function_or_method, is_overridden))
self.body.generate_execution_code(code) self.body.generate_execution_code(code)
code.putln("}") code.putln("}")
code.put_decref_clear(self.func_node.result(), PyrexTypes.py_object_type) code.put_decref_clear(func_node_temp, PyrexTypes.py_object_type)
self.func_node.release(code) code.funcstate.release_temp(func_node_temp)
code.putln("}") code.putln("}")
class ClassDefNode(StatNode, BlockNode): class ClassDefNode(StatNode, BlockNode):
......
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