Commit 90dce013 authored by Stefan Behnel's avatar Stefan Behnel

make CyFunction work for cpdef methods

parent 66c059d8
......@@ -1877,11 +1877,12 @@ class NameNode(AtomicExprNode):
def analyse_target_types(self, env):
self.analyse_entry(env, is_target=True)
if self.entry.is_cfunction and self.entry.as_variable:
if self.entry.is_overridable or not self.is_lvalue() and self.entry.fused_cfunction:
entry = self.entry
if entry.is_cfunction and entry.as_variable:
if entry.type.is_overridable or not self.is_lvalue() and entry.fused_cfunction:
# We need this for assigning to cpdef names and for the fused 'def' TreeFragment
self.entry = self.entry.as_variable
self.type = self.entry.type
entry = self.entry = entry.as_variable
self.type = entry.type
if self.type.is_const:
error(self.pos, "Assignment to const '%s'" % self.name)
......@@ -1890,10 +1891,10 @@ class NameNode(AtomicExprNode):
if not self.is_lvalue():
error(self.pos, "Assignment to non-lvalue '%s'" % self.name)
self.type = PyrexTypes.error_type
self.entry.used = 1
if self.entry.type.is_buffer:
entry.used = 1
if entry.type.is_buffer:
from . import Buffer
Buffer.used_buffer_aux_vars(self.entry)
Buffer.used_buffer_aux_vars(entry)
return self
def analyse_rvalue_entry(self, env):
......
......@@ -2373,6 +2373,7 @@ class CFuncDefNode(FuncDefNode):
is_wrapper=1)
self.py_func.is_module_scope = env.is_module_scope
self.py_func.analyse_declarations(env)
self.py_func.entry.is_overridable = True
self.py_func_stat = StatListNode(self.pos, stats=[self.py_func])
self.py_func.type = PyrexTypes.py_object_type
self.entry.as_variable = self.py_func.entry
......@@ -2449,7 +2450,10 @@ class CFuncDefNode(FuncDefNode):
def analyse_expressions(self, env):
self.local_scope.directives = env.directives
if self.py_func is not None:
if self.py_func_stat is not None:
# this will also analyse the default values and the function name assignment
self.py_func_stat = self.py_func_stat.analyse_expressions(env)
elif self.py_func is not None:
# this will also analyse the default values
self.py_func = self.py_func.analyse_expressions(env)
else:
......@@ -3035,7 +3039,7 @@ class DefNode(FuncDefNode):
def needs_assignment_synthesis(self, env, code=None):
if self.is_staticmethod:
return True
if self.is_wrapper or self.specialized_cpdefs or self.entry.is_fused_specialized:
if self.specialized_cpdefs or self.entry.is_fused_specialized:
return False
if self.no_assignment_synthesis:
return False
......
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