next up previous
Next: Statements Up: Indications Previous: Language-defined indications


Method declaration

Each Java method declaration defines one operator in the method indication's set. Name analysis (Chapter 4) associates a definition table key with the method name, and that key is used as the indication. Each use of the method name is an instance of the MethodName node.

Method declaration[39]:
RULE: MethodHeader ::= Modifiers Type MethodDeclarator Throws COMPUTE
  MethodHeader.Type=Type.Type;
END;

TREE SYMBOL MethodDeclarator COMPUTE
  SYNT.Type=INCLUDING MethodHeader.Type;
END;

RULE: MethodDeclarator ::= MethodIdDef '(' FormalParameters ')' COMPUTE
  MethodDeclarator.GotOper=
    ListOperator(
      MethodIdDef.Key,
      NoOprName,
      FormalParameters.OpndTypeList,
      MethodDeclarator.Type);
END;
This macro is defined in definitions 39, 40, and 41.
This macro is invoked in definition 2.

The roundabout mechanism for transmitting the return type of the method is due to the obsolete requirement for allowing dimensions to follow the parameter list when the method's return type is an array Section 5.2.3 contains additional computations associated with MethodDeclarator in this case.

Computational roles provide all of the necessary computations for gathering up the formal parameter types and computing the OpndTypeList attribute:

Method declaration[40]:
SYMBOL FormalParameters INHERITS OpndTypeListRoot END;
SYMBOL FormalParameter  INHERITS OpndTypeListElem END;
This macro is defined in definitions 39, 40, and 41.
This macro is invoked in definition 2.

A constructor declaration is very similar to a method declaration, except that the type name serves as the method name:

Method declaration[41]:
SYMBOL ConstructorDeclaration INHERITS OperatorDefs END;

RULE: ConstructorDeclaration ::=
        Modifiers TypeName '(' FormalParameters ')' Throws
        '{' Statements '}' COMPUTE
  ConstructorDeclaration.GotOper=
    ListOperator(
      TypeName.TypeKey,
      NoOprName,
      FormalParameters.OpndTypeList,
      TypeName.TypeKey);
END;
This macro is defined in definitions 39, 40, and 41.
This macro is invoked in definition 2.


next up previous
Next: Statements Up: Indications Previous: Language-defined indications
2008-09-11