From c5ce74b878c3a84417d168d73b9e9fb30e4c3ddd Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Tue, 18 Sep 2007 18:56:46 -0700 Subject: [PATCH] Finish class members --- Cython/Compiler/Nodes.py | 6 +++++- Cython/Compiler/Symtab.py | 12 ++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index 0aa2aa74..2c0cebc7 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -1371,7 +1371,11 @@ class CClassDefNode(StatNode): def analyse_expressions(self, env): if self.body: - self.body.analyse_expressions(env) + scope = self.entry.type.scope + print "env", env + print "scope", scope + print scope.outer_scope + self.body.analyse_expressions(scope) def generate_function_definitions(self, env, code): if self.body: diff --git a/Cython/Compiler/Symtab.py b/Cython/Compiler/Symtab.py index 29e6f69e..b25b9154 100644 --- a/Cython/Compiler/Symtab.py +++ b/Cython/Compiler/Symtab.py @@ -342,6 +342,7 @@ class Scope: error(pos, "'%s' is not declared" % name) def lookup(self, name): + print "looking up", name, "in", self # Look up name in this scope or an enclosing one. # Return None if not found. return (self.lookup_here(name) @@ -977,6 +978,13 @@ class ClassScope(Scope): def add_string_const(self, value): return self.outer_scope.add_string_const(value) + def lookup(self, name): + print "*** Looking for", name, "in ClassScope", self + print self.entries + res = Scope.lookup(self, name) + print "got", res, res.type + return res + class PyClassScope(ClassScope): # Namespace of a Python class. @@ -1099,7 +1107,7 @@ class CClassScope(ClassScope): if name in ('__eq__', '__ne__', '__lt__', '__gt__', '__le__', '__ge__'): error(pos, "Special method %s must be implemented via __richcmp__" % name) - entry = self.declare(name, name, py_object_type, pos) + entry = self.declare_var(name, py_object_type, pos) special_sig = get_special_method_signature(name) if special_sig: # Special methods get put in the method table with a particular @@ -1177,7 +1185,7 @@ class CClassScope(ClassScope): entry = self.add_cfunction(base_entry.name, base_entry.type, None, adapt(base_entry.cname), base_entry.visibility) entry.is_inherited = 1 - + class PropertyScope(Scope): # Scope holding the __get__, __set__ and __del__ methods for -- 2.26.2