- Up - | Next >> |
The Mozart Compiler is, in principle, only a special kind of evaluator. In general, an evaluator implements the mapping:
source_text × environment -> value
Compiling Programs
Performing evaluation of Oz programs with a compiler has some advantages:
Programs with statically discoverable errors are rejected. Apart from syntax errors and undeclared variables, this also includes discouraged uses of the language that are not - strictly speaking - necessarily errors. For instance, applying a procedure with the wrong number of arguments does raise a catchable exception, but may be reported as an error.
Programs may be translated into a more efficient representation. In the case of the Mozart Compiler, this consists of bytecode for the Mozart VM.
For correct programs, both these steps are transparent to the user, but due to them the transformation has actually more parameters and output than the general evaluator illustrated above.
The Manual's Structure
The remainder of this chapter will describe what the state of the Mozart Compiler consists of, and what additional parameters compilation takes into account. Chapter 2 describes what programs the compiler accepts as input. Chapter 3 describes two applications of the compiler, namely the batch compiler, which is invoked from the command line, and the compiler panel, which is a graphical interface to the compiler's state. Both of these are implemented using the compiler's Application Programmer's Interface, which is described in detail in Chapter 4.
Note that there is another widely used application of the compiler, namely the Oz Programming Interface. See Section 4.6 of ``The Oz Programming Interface'' for a description.
This section describes the components of the compiler's internal state as well as their initial values.
Macro Definitions
The compiler stores a set of so-called macro names, used to control conditional compilation via macro directives such as \ifdef
(see Section 2.2).
Initially, the set of macro names consists of entries describing the system's version number, for instance, when running Mozart 1.1.0, all of Mozart_1
, Mozart_1_1
, and Mozart_1_1_0
are macro names.
Switches and Options
The compiler's behaviour is influenced by a number of boolean switches and non-boolean options. While the switch settings can conveniently be changed by several methods as described later, the options are only accessible to users of the application programmer's interface.
The active switch settings are given by a mapping from switch names to boolean values. The compiler manages a stack of switch states, the top element of which is taken as the active state. This allows to temporarily escape into a different mode of compiler operation.
The available switches, their initial settings and their effects on the compilation process are described in detail in Appendix A.
The Environment
The Oz compiler does not take the environment as input for each evaluation as was illustrated above, but stores its active environment. This may be extended as a side-effect of the compilation, and it may be replaced by other environments at will.
An environment is a mapping from variable print names to arbitrary Oz values. Initially, the environment consists of the variables defined by the Oz Base Environment ``The Oz Base Environment''.
The Query Queue
Since the Oz compiler has internal state, it is not implemented as a function as described above, but as an active object that sequentializes all requests made to it via a query queue.
- Up - | Next >> |