next up previous contents
Next: Class and Type Specifiers Up: Programs Previous: Classes and Types

The General Processing Model

  The execution of a program consists of three steps:
  1. Establish types and classes: Collect all the class declarations which are directly or indirectly referred to from the main class K, transform them into classes and create the type dependence graph TDG.
  2. Initialize: Allocate and initialize all shared attributes within those classes, cf. 5.2.
  3. Execute: Call the procedure main in the main class K as K::main.

Hint: Step 1 is usually part of program compilation whereas steps 2 and 3 constitute the program execution proper. tex2html_wrap_inline1707

The required class declarations are given by class specifiers.

Establishing types and classes consists of:

  1. Determining the program text: Starting from a collection of class declarations and a distinguished declaration of the main class K, the transitive closure tex2html_wrap_inline1893 of K is inductively determined:
    1. K belongs to tex2html_wrap_inline1893 .
    2. If a class specifier C or $C with or without arguments occurs in a class declaration belonging to tex2html_wrap_inline1893 then the class declaration for C also belongs to tex2html_wrap_inline1893 . There must be exactly one such class declaration with the appropriated number of parameters in the given collection.

      Hint: Some of the class declarations may be predefined and a priori known to the language processor. There are language constructs which are only meaningful with respect to such predefined classes. tex2html_wrap_inline1707

    The classes belonging to tex2html_wrap_inline1893 together form the text of the program.
  2. Resolution of class parameters: If any of the class declarations in tex2html_wrap_inline1893 is generic, i.e. its heading tex2html_wrap_inline1917 contains class parameters tex2html_wrap_inline1919 with or without type bounds, then it is replaced in tex2html_wrap_inline1893 by a set of class declarations obtained as follows: For each class specifier tex2html_wrap_inline1923 occurring in any class declaration D in tex2html_wrap_inline1893 a copy of C is made in which all parameters tex2html_wrap_inline1919 are consistently replaced by the corresponding tex2html_wrap_inline1933 . $symbols contained in any of the class specifiers tex2html_wrap_inline1933 are retained. The number of parameters in the class declaration and the number of arguments in the class specifier must agree. The replacements are made in textual order, tex2html_wrap_inline1937 is replaced first. If any tex2html_wrap_inline1919 also occurs (as part of) a type bound then it is treated according to the same rules. The feature resolution restrictions given in 7.2 apply.

    If initially a class specifier tex2html_wrap_inline1933 is or contains a specifier which itself is a class parameter of the class declaration D then D must have been processed before C is considered. A program is illegal if it is not possible to find an order of the class declarations satisfying this requirement.

    The identifiers of all the class parameters tex2html_wrap_inline1919 must be pairwise distinct.

    Note: According to these rules class parameters tex2html_wrap_inline1919 are local to the class declaration D and shadow any class identifiers declared globally. tex2html_wrap_inline1707

  3. Resolution of inheritance: The set tex2html_wrap_inline1893 of class declaration is transformed into a set tex2html_wrap_inline1959 of classes as follows:
    1. The class declarations in tex2html_wrap_inline1893 are topologically sorted such that a class D which inherits a class C appears after class C. A program is illegal if such a topogical sort is not possible, i.e. if the inheritance relation tex2html_wrap_inline1969 contains cycles.
    2. Any class declaration in tex2html_wrap_inline1893 which does not contain inheritances belongs to tex2html_wrap_inline1959 .
    3. The remaining classes in tex2html_wrap_inline1893 are considered in an order consistent with the topological sort in step (a). If a class declaration D in tex2html_wrap_inline1893 inherits the classes tex2html_wrap_inline1981 then all the tex2html_wrap_inline1983 must already belong to tex2html_wrap_inline1959 . Then a class D is added to tex2html_wrap_inline1959 which is derived from the class declaration D by textually replacing the inheritance clauses by possibly modified copies of the bodies of their corresponding classes. The potential modifications are described in 4.4.
    4. If in step (c) a class C is inherited as a subtype then the type dependence graph TDG is augmented by a dependence tex2html_wrap_inline1969 .
  4. Checking of type conformance: For every class argument tex2html_wrap_inline1933 which in step 2 replaced a class parameter P and for which P was specified by P<T with a type bound T, it is checked that tex2html_wrap_inline1933 structurally conforms to T as explained in 2.1.5, where T is the type bound of P. A missing type bound means that the minimal constraints for tex2html_wrap_inline1933 are inferred from the body of the generic class and that P must fulfill them all.

    For every dependence tex2html_wrap_inline1969 in the type dependence graph it is checked that D conforms to C as explained in 2.1.5.

Hint: Steps 1-3 are textual substitutions which do not require any semantic processing except for identifying class declarations for a given class name. tex2html_wrap_inline1707


next up previous contents
Next: Class and Type Specifiers Up: Programs Previous: Classes and Types

Martin Trapp
Mon Feb 17 16:49:16 MET 1997