# 3 Standard Applications

This chapter defines the standard applications of the compiler available with the Mozart system: the batch compiler, the compiler panel, and its relation to the OPI.

## 3.1 The Batch Compiler

The batch compiler `ozc` provides a command line interface to the compiler for batch compilation. Batch compilation means that expressions (typically functor definitions) are compiled and evaluated, and the resulting value is pickled.

Parameterization

The command line options of `ozc` allow to customize the state of the compiler to use for compilation. Options allow for configuration of the set of defined macro names, to set all compiler switches, and to configure the compilation environment. Pickling can be parameterized to using compression or headers that make the resulting pickle executable. Further options influence the compilation mode: The default, evaluating an expression and pickling the result, can be replaced by evaluation of a statement, or intermediate results of compilation can be dumped. Finally, a special mode allows to compute dependencies (in the form of included source files).

Reference

The exact specification of command line options can be found in Chapter 2 of ``Oz Shell Utilities''.

## 3.2 The Compiler Panel

The Compiler Panel is another application of the compiler. The compiler defines the notion of a compiler interface to communicate with the outside world. The compiler panel is one such interface.

Interfaces

A compiler interface received notification about the state of the compiler. This includes its compilation state, but also its state of execution (how it manages its query queue, what errors it reports, and whether a compilation succeeds). Chapter 4 describes how the API allows to define interfaces.

The Panel

The compiler panel is a compiler interface that provides a graphical display of the compiler's state. Its toplevel window has a menu that allows to enqueue further compilation tasks and to configure how the the compiler's state is displayed. Furthermore, it features a set of notebook tabs for the different parts of its state.

Tabs

The `Messages` tab provides access to a text display of compilation phase tracking, and the warnings and errors reported. The `Environment` tab displays all variables in the compilation environment. Each identifier can be clicked to execute an action on its value; for instance, values can be shown or inspected. The set of actions is configurable. The `Switches` tab displays the settings of every compiler switch and option. Finally, the `Query Queue` tab displays the list of queries the compiler currently executes.

### The Compiler Panel API

Like all tools, the compiler panel has an API to enable applications to control it. The module `CompilerPanel`, located at `x-oz://system/CompilerPanel`, exports a class `CompilerPanel.'class'` implementing the `Listener` interface, with the following methods.

`init`

  > `init(``+CompilerObject``` `+IconifiedB``<= false)`

  initializes a new instance of a compiler panel, associated with the compiler `CompilerObject`. If `IconifiedB` is `true`, it is started with its toplevel window retracted.

`close`

  > `close()`

  closes a compiler panel instance, also closing its window.

`enqueue`

  > `enqueue(``+Message``)`

  enqueues a query to the compiler associated with the compiler panel instance. See Chapter 4 for a specification of the values `Message` can take.

`addAction`

  > `addAction(``+NameV``` `+ActionP``)`

  adds an action to the menu of actions that can be performed on values in the environment. `NameV` is the name of the action as displayed in the menu while `ActionP` is a unary procedure which will be passed the value when invoked.

## 3.3 The Oz Programming Interface

The OPI (see ``The Oz Programming Interface'') runs a dedicated compiler instance which receives all queries generated by feeding code in the OPI by default. It is available as `OPI.compiler`.