Oberon || Library || Module Index || Search Engine || Definition || Module
TYPE Result = POINTER TO ResultRec; TYPE ResultRec = RECORD (Disciplines.ObjectRec) header: CompilerObjects.Header; object: CompilerObjects.Object; END;
TYPE Compiler = POINTER TO CompilerRec; TYPE CompilerRec = RECORD (Services.ObjectRec) END;
TYPE Context = POINTER TO ContextRec; TYPE ContextRec = RECORD (Disciplines.ObjectRec) keys: CompilerKeys.Set; mtab: CompilerObjects.ModuleTable; tab: ModularizedStructures.ObjectTable; db: CompilerDatabases.Database; cachemode: CompilerObjects.CacheMode; log: CompilerLogs.Log; END;
TYPE Pass1Proc = PROCEDURE (compiler: Compiler; context: Context; source: CompilerSources.Source; VAR definition, module: Result) : BOOLEAN; TYPE Pass2Proc = PROCEDURE (compiler: Compiler; context: Context; definition, module: CompilerObjects.Object; arch: Architectures.Architecture; updatesPermitted: BOOLEAN; VAR archdef, code: Result; errors: RelatedEvents.Object) : BOOLEAN; TYPE DefineArgsProc = PROCEDURE (compiler: Compiler; args: Args.Arguments); TYPE Pass1Interface = POINTER TO Pass1InterfaceRec; TYPE Pass1InterfaceRec = RECORD (Objects.ObjectRec) pass1: Pass1Proc; defineArgs: DefineArgsProc; (* may be NIL *) END; TYPE Pass2Interface = POINTER TO Pass2InterfaceRec; TYPE Pass2InterfaceRec = RECORD (Objects.ObjectRec) pass2: Pass2Proc; defineArgs: DefineArgsProc; (* may be NIL *) END;
PROCEDURE Init(compiler: Compiler; if: Pass1Interface); PROCEDURE Register(compiler: Compiler; arch: Architectures.Architecture; if: Pass2Interface);
PROCEDURE DefineArgs(compiler: Compiler; args: Args.Arguments);
PROCEDURE CreateCopyOfContext(VAR newcontext: Context; orig: Context); PROCEDURE SynchronizeContext(context, ext: Context);
PROCEDURE Pass1(compiler: Compiler; context: Context; source: CompilerSources.Source; VAR definition, module: Result) : BOOLEAN;
PROCEDURE Pass2(compiler: Compiler; context: Context; definition, module: CompilerObjects.Object; arch: Architectures.Architecture; updatesPermitted: BOOLEAN; VAR archdef, code: Result; errors: RelatedEvents.Object) : BOOLEAN;
PROCEDURE Supported(compiler: Compiler; arch: Architectures.Architecture) : BOOLEAN;
PROCEDURE GetSupportedArchitectures(compiler: Compiler; VAR it: Iterators.Iterator);
This interface supports the separation of interface descriptions (called definitions) from module implementations (called modules) as known by Modula-2 and classic Oberon. Variants where both, the interface and its implementation, are derived from one source (as in newer variants of Oberon) are supported as well.
Program texts are represented by CompilerSources. Note that source objects have already their compilation options associated with. Modules that create source objects for a particular compiler are obliged to include all possible compilation options into their set of options using DefineArgs.
A compilation process is set into a context that consists of
Contexts can be cloned using CreateCopyOfContext and a branch can be synchronized back using SynchronizeContext. Note, however, that synchronization requires both contexts to be compatible to each other. Otherwise an assertion will fail. Cloning and resynchronization is useful if an attempt is to be made to load an imported module and where in case of failures the original context should remain unchanged.
Compilation results are of type Result and consist of a header object (CompilerObjects.Header) and an object that represents the entire result (CompilerObjects.Object).
Pass2 generates, if successful, compilation results for the architecture arch. If just an architecture-dependent definition object is to be generated, an architecture-independent definition is to be given and module is to be set to NIL. For the generation of machine code (represented by the code result object) definition and module must be non-NIL where definition may be either architecture-independent, or, if it already available for arch, architecture-dependent. Pass2 is allowed to update a architecture-dependent definition if updatesPermitted is TRUE. However, if updates are permitted, definition must neither be a member of context.mtab and its key must not be a member of context.keys. Note that updatesPermitted must be set to TRUE if definition is architecture-independent.
Supported return TRUE if arch is supported by compiler. The list of supported architectures by a compiler can be retrieved using GetSupportedArchitectures.
Oberon || Library || Module Index || Search Engine || Definition || Module