Oberon [option|file]…You can specify one or more filenames. Each source file is compiled separately-compiling the file Module.mod creates object file Module.mod.o. By convention, Oberon source filenames end in a .mod suffix. Options and filenames may be written in any order on the command line.
Compiler errors and warnings are written to diagnostic output which can be written to another file or redirected. Progress and summary information is also written to diagnostic output, if requested.
Note: Writing error messages and warning may sometimes confuse
the MPW Shell-it will break into Macsbug. We were unable so far to resolve
that problem. It seems to be somewhere in the MPW environment and not in
MPW Oberon.
Compiler options
The MPW Oberon compiler options are symbols in the command line sending
instructions to the compiler. The following table contains all options supported
by MPW Oberon in alphabetical order.
| SADE | SADE information is enabled |
| MC68040 | Use MC68040 instruction set |
| MC68881 | Use MC68881 instruction set |
| MAIN | Module is main-module |
| INITDATA | Local-Data will be initialized |
| ULM | Ulmer Oberon is enabled |
| noreg | Do not use register variables. |
| noreload | Do not optimize reloads. |
| nosbra | Do not generate short branches. |
| noexpr | Do not optimize expressions. |
| nolines | Do not include information about statement positions. |
| notypes | Do not include information about the structure of data types. |
| novars | Do not include information about global and local variables. |
The MPW Oberon compiler directives are listed alphabetically in the followingtable with the default conditions marked by asteriks. The individual directives are discussed in the following sections.
Note: Compiler directives must start immediately after the comment is opened. If there are any characters between the opening (*-symbol and the $-sign, the compiler directive will not be recognized.
(*$C+*)A CASE statement in Oberon generates an exception if a selector was supplied not explicitly listed. The effect of the directive may be simulated by using an empty ELSE within the CASE statement.
(*$C-*)
(*$CALLING PASCAL*)High-level languages on the Macintosh (M68000 systems) use different methods for passing parameters to procedures. MPW Oberon supports two so-called calling conventions: Oberon and Pascal. By default the Oberon convention is normally used for procedures calls (see "Oberon calling convention" for a detailed description). The operating system uses the Pascal calling convention. Both conventions are similar but not equivalent.
(*$CALLING OBERON*)
You must specify which calling convention to use when passing procedures to the operating system that will be called later on by the system. Typical examples for such procedures are filter routines for events or handlers for Apple events. Such routines must use the Pascal calling convention. Note that to both procedures and procedure types a calling convention is attached.
The MPW Oberon interface files contain definitions of procedure types used by the Macintosh ROMs. All these types use the Pascal convention. If you try to pass a procedure with the same parameters but a different calling convention, MPW Oberon will report an error. For example, if you want to write a filter for the Dialog Manager's routine ModalDialog, you must use the $CALLING directive:
(*$CALLING PASCAL*)
PROCEDURE Filter(dialog: Dialogs.DialogPtr;
VAR event: Events.EventRecord;
VAR item: INTEGER): BOOLEAN;
BEGIN
(*your code here*)
END Filter;
(*$CALLING OBERON*)
(*$J+*)The directive $J+ allows global data declared in a module to be defined in another file, the connections being made be the linker. Such connections are case sensitive. The default directive $J- requires all definitions to be in the Oberon source file.
(*$J-*)
(*$OV+*)The default condition $OV- prevents the compiler from generating code to detect arithmetic overflow during expression evaluation. The directive $OV+ causes it to produce such code.
(*$OV-*)
(*$R+*)The $R+ directive instructs the compiler to generate code to perform range checking of array bounds and arguments to the CHR standard function. The default, $R-, is to suppress the generation of such code.
(*$R-*)
(*$PARAMETER ProcName([register[,register]+])[:register] *)The $PARAMETER directive allows to assign registers for the parameters of the procedure ProcName. This directive must be given immediately before the declaration of the corresponding procedure. Otherwise it will be ignored. Currently MPW Oberon restricts use of the $PARAMETER directive to inline procedures.
The name given in the $PARAMETER directive is case sensitive and must
match the name of the following procedure. For every parameter of the procedure
a register must be given. MPW Oberon supports the registers D0-D7, A0-A7,
and FP0-FP7 for parameters. FP0-FP7 may be used only when the code for the
MC68881 is generated. See "Passing parameters in
registers" for an example and further details.
The $REGVAR directive
(*$REGVAR+*)MPW Compiler uses some registers for storing values of local variables (see "Oberon calling convention" for further details). The $REGVAR- directive instruct the compiler to place all local variables in memory. The default, $REGVAR+, instructs the compiler to use registers for variables.
(*$REGVAR-*)
Note: Sometimes you should switch off register variables to improve
speed. MPW Oberon can't perform detailed analysis of the source code due
to the lack of an intermediate representation, so loading and restoring registers
may take longer than directly using the variables on the stack. This applies
especially to very short procedures.
The $S directive
(*$S segmentName*)By default the compiler instructs the linker to place all routines of a module within a single segment. The module's name is used as the case-sensitive identifier for the segment. The $S directive allows to specify that subsequent routines be directed to the specified segment. The $S directive can only appear between global routines. See "Segmentation control" for further details about segmenting your program.
Note: You may use at most 20 different segments in one source
file.
The $TYPECHECK directive
(*$TYPECHECK+*)Type tags are used in Oberon to keep the type of a variable allocated on the heap. If an operation tries to modify a variable with a type not allowed, a run-time exception is generated. The command $TYPECHECK- instructs the compiler to suppress such type checks. The default, $TYPECHECK+, is produce such tests. See "Passing dynamic structures to the operating system" for further information about type tags.
(*$TYPECHECK-*)
Compile-time expressions may be formed out of compile-time variables, Boolean constants, and the Boolean operators ~, OR, and &. You may use the alternate notations ¬ and AND for the operators ~ and & respectively. Compile-time expressions are always of type BOOLEAN. The grammar governing the structure of compile-time expression is:
Expression ::= Term ["OR" Term].Identifiers start with a letter and may contain letters, digits, and underscores and denote compile-time variables. If a compile-time variable was not assigned a value prior to its first usage, MPW Oberon defines it with a value of FALSE. Variables may be defined by using the -d option or the $SET directive.
Term ::= Factor [("AND"|"&") Factor].
Factor ::= identifier | "TRUE" | "FALSE" | ("~"|"¬") Factor
Note: Conditional compilation was added to MPW Oberon mainly for porting the universal interface files. Using the facilities provided for conditional compilation so far, transforming the interface files for use with Oberon is relatively easy but tedious.
(*$IF compExpr*)The $IF directive causes the compiler to compile subsequent source text until the next $ELSIF, $ELSE, or $END directive, only if the value of the compile-time expression compExpr is TRUE.
(*$ELSE*)The $ELSE directive marks the beginning of source text that is compiled only if all compExprs in the corresponding $IF and $ELSIF directives evaluated to FALSE.
(*$ELSIF compExpr*)The $ELSIF directive causes the compiler to compile subsequent source text until the next $ELSIF, $ELSE, or $END directive, only if the value of the compile-time expression compExpr is TRUE.
(*$END*)The $END directive marks the end of a section of conditionally compiled source text, matching a $IF directive.
(*$SET varName compExpr*)The $SET directive assigns the compile-time variable varName the value of the compile-time expression compExpr. If a compile-time variable with the given name does not exist, it will be defined.
Note: You may use at most 20 different compile-time variables
in one source file.
Other directives
(*$MAIN*)The $MAIN directive instructs the compiler to identify the module body of the current module as the main entry point. Only one module linked into a program may be marked as the main module. This option is needed because Oberon does not have a main program.
(*$PUSH*)The $PUSH directive allows to save the current option settings. You may nest $PUSH directive five times. The $POP directive restores the options saved by the most recent $PUSH. It is an error to have more $POPs than $PUSHs. Use $PUSH and $POP to modify an option without changing its original value.
(*$POP*)
(*$TAGS+*)The $TAGS- directive instructs the compiler to mark subsequently declared types as "untagged". Dynamic variables of an untagged types do not have a type tag, so type check and type guard may not be performed. Untagged variables are used when allocating structures passed to the system. The default, $TAGS+, is to not mark types as untagged. See "Type tags in MPW Oberon" for further information about type tags.
(*$TAGS-*)