All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class epp.TypeChecker

java.lang.Object
   |
   +----epp.Macro
           |
           +----epp.TypeChecker

public abstract class TypeChecker
extends Macro
The TypeChecker class is the super class of all TypeChecker object classes.

Within the type checking pass, each node of an abstract syntax tree are type checked with the call method of the corresponding TypeChecker object, and are converted to abstract syntax trees with type information. Type information of a Trees with type information can be retrieved using the method type.

The type checking pass can execute not only type checking but also "macro expansion using type information." Plug-in programmers may introduce a non-Java standard node and define a corresponding TypeChecker object. In this case, the TypeChecker object type checks the subtree as required, expand macros using these type information, and returns the result.

The TypeChecker object the plug-in programmer defined must be registered to the TypeChecker.macroTable using the definedTypeChecker method of epp.

The TypeChecker object can be extended by difference using the decorator pattern. In order to do so, you use the extendTypeChecker method of Epp. You can call the original TypeChecker. If not extended with extendTypeChecker, the value of variable orig will be null.

The recursive type checking of a Treeis done by the typeCheckTree method. The behaviour of the typeCheckTree method is actually defined as follows.

      Symbol lastTag = null;
      while(true) {
	if (tree.isTyped()) break;
	Symbol tag = tree.tag();
	if (tag == lastTag) break;
	lastTag = tag;
	TypeChecker func = (TypeChecker)typeCheckerTable.get(tag);
	if (func != null) {
	  tree = func.call(tree);
	} else {
	  throw error("TypeCheker for "+ tag+ " is not defined.");
	}
      }
      return tree;
That is, it calls method call of the TypeChecker object corresponding to the tree and tag, and if the returned tag and the tag prior to calling match, exits the loop and returns the return value. Otherwise, continues converting with TypeChecker until the tag does not change.

See Also:
TypeCheck, initTypeCheckerTable, defineTypeChecker, extendTypeChecker, Macro, TypeNameChecker

Constructor Index

 o TypeChecker()

Method Index

 o call(Tree)
Defines within a subclass, a method that type checks a tree.
 o checkArgsLength(Tree, int)
Checks the number of arguments of the node.
 o checkVariableDeclaratorId(Type, Tree, Tree[])
Delegated to checkVariableDeclaratorId of the EPP preprocessor.
 o resolveAmbiguousName(Tree)
Determines the meaning of an "ambiguous name" that may be a type name or field access, and converts it into an unambiguous Tree.
 o typeCheck1(Tree)
Type checks only once.
 o typeCheckArgs(Tree)
Type checks all args of a tree and returns an array of the resulting tree.
 o typeCheckTree(Tree)
Type checks a tree recursively, and converts it into a tree with type information.
 o typeNameCheckTree(Tree)
Delegated to TypeNameChecker.typeNameCheckTree.
 o unaryNumericPromotion(Tree)
Executes an unary numeric promotion.

Constructors

 o TypeChecker
 public TypeChecker()

Methods

 o call
 public abstract Tree call(Tree tree)
Defines within a subclass, a method that type checks a tree. This method must do one of the following. Standard Java language nodes normally behave as shown in the first alternative. On the other hand, the TypeChecker of the non-standard node introduced by a plug-in must normally behave as shown in the secode arlternative.

Overrides:
call in class Macro
 o typeCheckTree
 public static Tree typeCheckTree(Tree tree)
Type checks a tree recursively, and converts it into a tree with type information. If the node already has type information, returns the tree itself without doing any type checking.

 o typeCheck1
 public static Tree typeCheck1(Tree tree)
Type checks only once.

 o typeCheckArgs
 public static Tree[] typeCheckArgs(Tree tree)
Type checks all args of a tree and returns an array of the resulting tree.

 o typeNameCheckTree
 public static Tree typeNameCheckTree(Tree tree)
Delegated to TypeNameChecker.typeNameCheckTree.

See Also:
typeNameCheckTree
 o checkArgsLength
 public static void checkArgsLength(Tree tree,
                                    int argc)
Checks the number of arguments of the node. If the length of args of the tree does not match argc, the error method is called.

 o checkVariableDeclaratorId
 public static Tree checkVariableDeclaratorId(Type type,
                                              Tree tree,
                                              Tree declaredVars[])
Delegated to checkVariableDeclaratorId of the EPP preprocessor.

See Also:
checkVariableDeclaratorId
 o resolveAmbiguousName
 public static Tree resolveAmbiguousName(Tree tree)
Determines the meaning of an "ambiguous name" that may be a type name or field access, and converts it into an unambiguous Tree. For information regarding the rules of resolving ambiguity, please refer to JLS1.0 Section 6.5.2. This method receives a Tree in the form of (name ...) and converts into one of the Tree of type id, name, fieldStatic, or fieldExp. If the Tree cannot be interpreted, this method returns null.

 o unaryNumericPromotion
 public static Tree unaryNumericPromotion(Tree tree)
Executes an unary numeric promotion. Please refer to JLS1.0 5.6.1.


All Packages  Class Hierarchy  This Package  Previous  Next  Index