The C-compiler is set through the C Compiler/Flags setting of the Options; for example:
gcc -gwould 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 Translator provides for an implementation of the formal machine parameters. Linking information is generated from this 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 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.
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 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 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.
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.