Commit c5ce74b8 authored by Robert Bradshaw's avatar Robert Bradshaw

Finish class members

parent 598b2537
...@@ -1371,7 +1371,11 @@ class CClassDefNode(StatNode): ...@@ -1371,7 +1371,11 @@ class CClassDefNode(StatNode):
def analyse_expressions(self, env): def analyse_expressions(self, env):
if self.body: 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): def generate_function_definitions(self, env, code):
if self.body: if self.body:
......
...@@ -342,6 +342,7 @@ class Scope: ...@@ -342,6 +342,7 @@ class Scope:
error(pos, "'%s' is not declared" % name) error(pos, "'%s' is not declared" % name)
def lookup(self, name): def lookup(self, name):
print "looking up", name, "in", self
# Look up name in this scope or an enclosing one. # Look up name in this scope or an enclosing one.
# Return None if not found. # Return None if not found.
return (self.lookup_here(name) return (self.lookup_here(name)
...@@ -977,6 +978,13 @@ class ClassScope(Scope): ...@@ -977,6 +978,13 @@ class ClassScope(Scope):
def add_string_const(self, value): def add_string_const(self, value):
return self.outer_scope.add_string_const(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): class PyClassScope(ClassScope):
# Namespace of a Python class. # Namespace of a Python class.
...@@ -1099,7 +1107,7 @@ class CClassScope(ClassScope): ...@@ -1099,7 +1107,7 @@ class CClassScope(ClassScope):
if name in ('__eq__', '__ne__', '__lt__', '__gt__', '__le__', '__ge__'): if name in ('__eq__', '__ne__', '__lt__', '__gt__', '__le__', '__ge__'):
error(pos, "Special method %s must be implemented via __richcmp__" error(pos, "Special method %s must be implemented via __richcmp__"
% name) % 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) special_sig = get_special_method_signature(name)
if special_sig: if special_sig:
# Special methods get put in the method table with a particular # Special methods get put in the method table with a particular
......
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