CarlManning, caroma@ai.mit.edu
Copyright (c) 1997, 1998, 1999 Massachusetts Institute of Technology
Verifying/evaluating compilation units with multiple types (and which
may refer to external types) requires 3 passes. Consider classes in two
compilation units which refer to each other; for example:
unit1.class1 has field1 withType class2
unit2.class2 has field2 withType class1
Do all three passes on compilation unit, do pass 1&2 on other units as
needed.
1. Scan unit and make interpreted classes for all type definitions in
unit. Add to package in env the top-level class and interface names
bound to each class or interface. Scan classes and interfaces
nested at class level and add them to their enclosing class, but
not classes inside (method or constructor) bodies or (field or
static/object) initializers.
2. Compute field & method signature for each unit class, using that env.
This requires knowing that each type name in signature names a valid
type, represented by its IClass. For forward references to an
unknown type, attempt to find type by scanning or loading its
compilation unit:
a. if java file exists and is newer than class file, do scan pass on
java file to make interpreted classes for its type names.
b. if class file exists and newer than java file (or no java file)
load class file, then make wrapped class for type name.
c. else error, no such class found
3. (optional?) verify types in bodies and initializers of unit classes.
Requires knowing field and method signatures. For external types,
use reflection methods:
a. If external type was loaded from java file, it should trigger
step 2 on itself as needed to lazily compute field and method
signatures.
b. If external type was loaded from class file, field and method
signatures will be precomputed.
If a declaration node is verified by itself (not as part of compilation
unit), then it should trigger step 1 and 2 on itself as needed to compute
signatures. (In this case, any forward references to other declarations
will be looked up in the classpath as if they were in another compilation
unit, producing IllegalNameExceptions if not found.)