Next: Member declarations
Up: Scope of a simple
Previous: Imported types
The scope of a type introduced by a class type declaration or interface
type declaration is the declarations of all class and interface types in
all the compilation units of the package in which it is declared.
Class and interface declarations are children of the TypeDeclarationsOpt
child of the CompilationUnit node.
Thus each TypeDeclarationsOpt node provides the appropriate scope for
these declarations.
TypIdDefScope computations normally create a new definition table key
to be bound to the identifier.
In this case, however, we want to bind the key for the fully-qualified type
identifier to the simple type name being defined.
Therefore we need to override the normal binding computation:
ATTR IsLocalClass: int;
TREE SYMBOL Goal COMPUTE SYNT.IsLocalClass=0; END;
CLASS SYMBOL LocalTypeRange INHERITS TypExportRange COMPUTE
SYNT.TypScopeKey=NoKey;
SYNT.IsLocalClass=1;
END;
TREE SYMBOL MethodDeclaration INHERITS LocalTypeRange END;
TREE SYMBOL Block INHERITS LocalTypeRange END;
TREE SYMBOL SwitchBlockStatement INHERITS LocalTypeRange END;
TREE SYMBOL TypeIdDef INHERITS IdentOcc, TypIdDefScope, MultDefChk END;
RULE: TypeDeclaration ::=
Modifiers 'class' TypeIdDef Super Interfaces ClassBody COMPUTE
TypeDeclaration.Ids=
ConsintList(TypeIdDef.Sym,INCLUDING CompilationUnit.Ids);
END;
RULE: TypeDeclaration ::=
Modifiers 'interface' TypeIdDef Interfaces InterfaceBody COMPUTE
TypeDeclaration.Ids=
ConsintList(TypeIdDef.Sym,INCLUDING CompilationUnit.Ids);
END;
RULE: CompilationUnit ::=
PackageDeclarationOpt
ImportJavaLang ImportDeclarationsOpt TypeDeclarationsOpt
COMPUTE
CompilationUnit.Ids=PackageDeclarationOpt.Ids;
END;
RULE: PackageDeclarationOpt ::= 'package' PackageName ';' COMPUTE
PackageDeclarationOpt.Ids=PackageName.Ids;
END;
RULE: PackageDeclarationOpt ::= COMPUTE
PackageDeclarationOpt.Ids=SingleintList(0);
END;
This macro is defined in definitions 11, 12, 14, 15, 16, 17, 18, 19, and 20.
This macro is invoked in definition 2.
Next: Member declarations
Up: Scope of a simple
Previous: Imported types
2008-09-11