Next: Indications
Up: Type Analysis
Previous: Array types
Typed identifiers
Fields, local variables, and formal parameters are the only typed
identifiers in Java.
Formal parameters are considered to be variables, and their defining
occurrences are represented by the nonterminal VariableDeclaratorId.
TREE SYMBOL FieldDeclarators INHERITS TypedDefinition END;
TREE SYMBOL VariableDeclarators INHERITS TypedDefinition END;
TREE SYMBOL FormalParameter INHERITS TypedDefinition END;
TREE SYMBOL FieldIdDef INHERITS TypedDefId END;
TREE SYMBOL VariableIdDef INHERITS TypedDefId END;
This macro is defined in definitions 34, 35, and 36.
This macro is invoked in definition 2.
All of the typed definitions get their type information from their
context, and the simple identifier definitions reach up to those typed
definitions.
RULE: FieldDeclaration ::= Modifiers Type FieldDeclarators ';' COMPUTE
FieldDeclarators.Type=Type.Type;
END;
RULE: LocalVariableDeclaration ::= 'final' Type VariableDeclarators COMPUTE
VariableDeclarators.Type=Type.Type;
END;
RULE: LocalVariableDeclaration ::= Type VariableDeclarators COMPUTE
VariableDeclarators.Type=Type.Type;
END;
RULE: FormalParameter ::= 'final' Type VariableDeclaratorId COMPUTE
FormalParameter.Type=Type.Type;
END;
RULE: FormalParameter ::= Type VariableDeclaratorId COMPUTE
FormalParameter.Type=Type.Type;
END;
This macro is defined in definitions 34, 35, and 36.
This macro is invoked in definition 2.
Java also allows a C-like declaration in which the dimensions follow the
identifier.
In fact, it is legal to mix the two.
We implement this requirement by using the VariableDeclaratorId as a
mechanism to provide the necessary type denotations
(see Section 5.2.3 for the necessary definitions).
If no dimension is attached to the variable, then the type is passed
through unmodified:
TREE SYMBOL VariableDeclaratorId COMPUTE
SYNT.Type=INCLUDING TypedDefinition.Type;
END;
RULE: VariableDeclaratorId ::= VariableIdDef COMPUTE
VariableIdDef.Type=VariableDeclaratorId.Type;
END;
This macro is defined in definitions 34, 35, and 36.
This macro is invoked in definition 2.
Next: Indications
Up: Type Analysis
Previous: Array types
2008-09-11