The Translator (trl)
The Translator (trl) is invoked from the
Translators Environment
and
is applicable to all
implementations
which are currently
analysed,
but not translated.
The C-compiler is set through the
C Compiler/Flags
setting of the
Options;
for example:
gcc -g
would result in code produced by the gcc compiler with the debugging
option set.
The setting of the
Programming Language Option
determines whether (currently) C or ANSI-C is produced as the
intermediate language.
The Translator translates an
IMPLEMENTATION
into an executable code
module; a prerequisite for translation is that the implementation and
all subordinate implementations are
analysed;
the C Compiler is used
to generate the executable binary for the machine on which the
B-Toolkit is running. Subordinate implementations that are analysed but
not yet translated are translated first.
If the specification `spec.mch' is implemented by `prog.imp', then
translation of the latter will produce the files `spec.g',`spec.h',
`spec.c' and `spec.o' all written to the
CDE/C
directory.`spec.o' is
the binary linkable code module, `spec.h' contains header information
for an
IMPLEMENTATION
which
IMPORTS
or
SEES
`spec.mch', and `spec.g'
contains module parameterisation information to be used at
link-time
when the values of module parameters are known.
Note that, an
IMPLEMENTATION
has no variables of its own which are
global to all operations (e.g. the VARIABLES clause is not allowed).
All static data (information global to the module) or persistent data
(information which survives from one invocation of the module to the
next) must be held within other machines which the implementation
IMPORTS.
In the B-Toolkit environment there is a selection of such
pre-defined machines.
The pre-defined machines are held in the
System Library
and can be
introduced into a development by using the
`Introduce construct from SLIB'
facility.
The `main' Implementation:
The machine/implementation which contains the single operation
`main' will be the main module of the development. This module
will be the top node when all executable object modules are
linked,
and the main operation will be the entry when the linked
code is invoked.
The Translation Process
The Translator translates the following clauses of an IMPLEMENTATION:
- The MACHINE header clause:
The Translator provides for an implementation of the formal
machine parameters.
Linking information is generated from this clause.
- The IMPORTS clause:
The Translator provides for an implementation which makes
instances of the imported MACHINEs known to this implementation;
an imported MACHINE must be a library (SLIB machine,
a generated machine (with code module, for example generated
through the Enumerator) or a MACHINE which already has been
provided with an IMPLEMENTATION within the development.
Linking information is generated from this clause.
- The SEES clause:
The Translator provides for an implementation which makes seen
MACHINEs known to the implementation. A seen MACHINE must be a
committed construct which is imported elsewhere, in which
case its state is shared between the machine which imports it
and the machine which sees it.
- The CONSTANTS and PROPERTIES clauses:
All constants must be given an exact value in the PROPERTIES clause.
The constants and its values are known to all implementation which
SEES or IMPORTS the MACHINE for which we are providing an
implementation.
Header information is generated from this clause.
- The SETS and PROPERTIES clauses:
The Translator provides for an implementation of enumerated sets and
deferred sets. The deferred sets must be given an exact value within
the latter clause; however the value is normally a deferred set from
an imported machine.
Header information is generated from this clause.
- The INITIALISATION clause:
The Translator provides for a C implementation of the initialisation
which is executed at run-time on invocation. Note that the INITIALISATION
clauses of all imported MACHINES are automatically invoked before any
statements present in this clause.
- The OPERATIONS clause:
Each of the operations is translated into code. Note that for imported
SLIB MACHINES,
operations are translated into parameterised macros and others
into C functions or procedures.
Note:
-
The `file_dump' machine must always be imported into the development
when the development uses a state machine from the System Library,
even if the dump facilities SAVE and RESTORE from the state machine
are not actually used.
A full on-line help listing is available
in the Contents Page
Also available in the form of a complete
Index.
© B-Core
(UK) Limited, Last updated: 25/08/99