This assignment regards the building of internal compiler structures for the class hierarchy and the checking of well-formedness of the class hierarchy. It encompasses the three compiler phases Nameresolving, Environments and Hierarchy. You must hand in three files nameresolving.ml, environment.ml and hierarchy.ml that extend the skeleton. You must also post an entry in your group blog that explains how your code works and which problems you have encountered and solved in the process.

Nameresolving

The Nameresolving phase resolves all syntactically recognizable uses of named types (class and interface types) to their canonical names (implemented by the CanonicalNames module found in canonicalNames.ml).

Transformations

The Nameresolving phase transforms an AST of type Weedingast (or WAst for short) defined in weedingast.ml into Nameresolvingast (or NAst for short) defined in nameresolvingast.ml. The changes on the AST include:

Implementations

Checks

Environment

The Environment phase builds a type environment for all types used in the program.

Type specifications and the type environment are defined by the module Types in the file types.ml. A type environment is a mapping from canonical names to named-type specifications (i.e., classes and interfaces). The type environment has type Types.type_env.

Transformations

Checks

Implementations

Hierarchy

The Hierarchy phase resolves all inheritance relationships for classes, interfaces, methods and fields.

The rules governing this phase are described in chapters 8 and 9 of the JLS. In particular, inheritance and hiding of fields is described in 8.3, and inheritance, overriding and hiding of methods is described in 8.4.6 and 9.4.1.

Note that the work done in this phase follows the structure of the class hierarchy, rather than the structure of the AST. For the purposes of inheritance, not only the classes and interfaces in the program but also those in the class library will have to be handled. The checks need only be performed on the classes (Joos 2: and interfaces) declared in the program itself.

Implementations

Checks

The checks to be performed by the Hierarchy phase correspond to the constraints mentioned in the slides, plus some additional checks for Joos 2.