Next: , Up: Procedures


4.1 Defining a procedure or array

The Expression module exports computational roles to support procedure and array definition:

ProcedureDenotation
The computational role inherited by a grammar symbol that represents a subtree denoting a procedure or array signature. Its Oper attribute is a new, unique, definition table key.
ParameterListRoot
The computational role inherited by a grammar symbol that represents a subtree defining the parameter list of a procedure or subscript types of an array. Its ParameterTypeList attribute is set by a module computation to a DefTableKeyList value containing the ParameterListElem.Type attribute values (in reverse order).
ParameterListElem
The computational role inherited by a grammar symbol that represents a definition of a single procedure parameter or array subscript. It must be a descendant of a ParameterListRoot. Its Type attribute must be set by user computation to the definition table key representing the type of the parameter.

The same grammar symbol may inherit both the ProcedureDenotation role and the ParameterListRoot role.

Information characterizing a procedure is often stored as properties of the definition table key that is the value of ProcedureDenotation.Oper. The post-condition ProcedureDenotation.GotProp establishes the fact that such properties have been set, but it can only be used for computations that are themselves independent of all aspects of type analysis (see Dependence on the operator database).

Information characterizing an array is usually stored as properties of the typed entity that names the array (see Establishing the type of an entity), or as properties of the array type (see User-Defined Types). Only information specifically related to the array access operation should be stored as properties of the definition table key that is the value of ProcedureDenotation.Oper.

Here is the specification for Mystery procedure and array denotations:

     SYMBOL ArrayTy   INHERITS ProcedureDenotation END;
     SYMBOL Procedure INHERITS ProcedureDenotation END;
     SYMBOL Formals   INHERITS ParameterListRoot   END;
     SYMBOL Formal    INHERITS ParameterListElem   END;
     
     RULE: Formal ::= VarIdDef ':' Type
     COMPUTE Formal.Type=Type.Type;
     END;