![]() |
Section 6.1:
|
![]() |
A Sather program has one distinguished program class and, in that class, one method is the program method. The means by which this particular class and method are distinguished is not defined by the language (see, however, Section 4.5 for implementation requirements of the translator).
The entire program consists, in addition to the distinguished program class itself, of those classes which are used directly by it and, recursively, all of those other classes in turn which they use.
Five kinds of class are specified by the above rule -
NOTE | An implementation of Sather may permit this source text to be arranged in separate text files. The source text which defines a single class or partial class must not, however, be divided among multiple files. This requirement ensures that type safety can be determined statically. |
A complete program consists of the definition of the distinguished class which contains the method to be invoked by the external environment when executing the program, together with all of those classes on which it (recursively) depends.
Program :: program_class : Class_Def dependent_classes : set of Class_Def inv mk_Program(dist,depc) == dist.kind in set {Immutable, Reference} and dist not in set depc and let names : set of token = {forall feat in dist.features & feat.name} in Distinguished_Method in set names ;
For a particular program there shall be only one distinguished program class. The identifier of this class shall not identify any other class in the set of dependent classes. The program class shall be either a reference class or an immutable class. The program class shall have a feature which has the name of the distinguished method known to the translation mechanism.
In addition to the above, which are expressed by the invariant of the abstract type, each class shall itself be well-formed and the set of classes which make up the program shall have a conforming type graph (see section 6.5.2), thus
wf_program : Program -> bool wf_program(mk_Program(dist,others)) == wf_class_def(dist.program_class) and forall cl in set others & wf_class_def(cl)
The program state shall first be initialized from the external state as it exists before the execution of the program. Initial protection from interrupts shall be implementation-defined.
The outermost environment for program execution shall be constructed from the environments defined by those classes which form part of the program - in particular constants and all initialised shared objects are to be initialised. This shall be combined with the environment defined by the pervasive classes forming part of the program. These actions are specified as the initialisation of the environment component of the program state (see Auxiliary vdm-sl in Section 6.9 of this specification).
Execution of the program shall then start with the distinguished method in the distinguished program class.
m_program : External_program_state * Program -> External_program_state m_program(env,mk_Program(dist,_)) == let prog : Feature be st (prog = iota dist.features & prog.name=Distinguished_Method) in m_feature(env,prog)
![]() |
Specification Index | ![]() |
Language Index | ![]() |
Program examples | ![]() |
Section 6 Index |
Comments
or enquiries should be made to Keith Hopper. Page last modified: Thursday, 26 April 2001. |
![]() |