Pattern 19 | Symbol Table for Classes |
Purpose
This pattern tracks symbols and builds a scope tree for non-nested classes with single inheritance.
Discussion
Classes are data aggregates that allow method members and that can inherit members from superclasses. Methods within classes can see global variables in the object-oriented version of our Cymbol language (since Cymbol is a subset of C++). To support these language semantics, we need to tweak the scope trees we used for structs in Pattern 18, Symbol Table for Data Aggregates. We’ll replace StructSymbol nodes with ClassSymbol nodes and have them point at their superclasses as well as their enclosing scopes (recall Figure 17, Scope tree for classes A and B). All the symbol table objects this ...
Get Language Implementation Patterns now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.