Dealing with Inheritance
- When one class inherits a declaration from another, we won't make a new declaration
descriptor. We will just make a new binding to the existing declaration descriptor and
place this binding in the current scope.
- This means that when semantic processing is done, all references in the syntax
tree to the same declaration will refer to the same descriptor regardless of
which subclass the reference involved.
- In Woolite, to make things a bit simpler, only method names are inherited (variable and
class declarations are considered private). Also, to simplify handling inheritance,
forward references are not allowed in extends clauses.
- As a result of Woolite's design, when we process a class, the declaration descriptor
of any superclass will already contain:
- a pointer to a list of all methods defined within the body of the superclass definitions, and
- a pointer to any superclasses of the superclass.
- Your compiler will run up the chain of superclasses and through each superclass' list of
methods creating bindings and adding them to the new class' scope.
Computer Science 434
Department of Computer Science
Williams College