edu.mit.ai.psg.jeva
Interface IDeclarationNode

All Known Implementing Classes:
JNDClassDeclaration, JNDImportDeclaration, JNDPackageDeclaration

public interface IDeclarationNode
extends IStatementNode

Declaration nodes are top level declarations that appear in a compilation unit, e.g., package, import, interface, class.

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.)


Method Summary
 void computeTypeSignatures(IEnv env)
           
 IEnv scanDeclarations(IEnv env)
           
 IEnv verifyTypes(IEnv env)
          Verify types within this statement; don't call this directly, use EvalMethods.verifyTypes(IStatementNode, IEnv).
 
Methods inherited from interface edu.mit.ai.psg.jeva.IStatementNode
eval
 
Methods inherited from interface edu.mit.ai.psg.jeva.IJevaNode
getBeginToken, getEndToken, insertNewChildAfter, insertNewChildAt, insertNewChildBefore, jjtAccept, jnGetChild, jnGetParent, print, print, printToString, printToString, removeChild, replaceChild, replaceChild, setBeginToken, setEndToken
 
Methods inherited from interface edu.mit.ai.psg.jeva.Node
jjtAddChild, jjtClose, jjtGetChild, jjtGetNumChildren, jjtGetParent, jjtOpen, jjtSetParent
 

Method Detail

scanDeclarations

public IEnv scanDeclarations(IEnv env)
                      throws VerifyingException

computeTypeSignatures

public void computeTypeSignatures(IEnv env)
                           throws VerifyingException

verifyTypes

public IEnv verifyTypes(IEnv env)
                 throws VerifyingException
Description copied from interface: IStatementNode
Verify types within this statement; don't call this directly, use EvalMethods.verifyTypes(IStatementNode, IEnv). Builds env without evaluating anything with side effects, for the purpose of verifying types of later statements. May be used by preprocessors which must find the type of an expression in order to assign it to a new variable.
Specified by:
verifyTypes in interface IStatementNode
Tags copied from interface: IStatementNode
Parameters:
env - environment of names bindings.
Returns:
env or possibly extended env
Throws:
VerifyingException - if statement is illegal
See Also:
EvalMethods.verifyTypes(IStatementNode, IEnv)

Copyright (c) 1996-1999
Massachusetts Institute of Technology

Feedback: jeva-feedback@ai.mit.edu