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