Oberon || Library || Module Index || Search Engine || Definition || Module

Ulm's Oberon Library:


CompilerSources - reference objects for program text sources


CONST definition = 0;
CONST module = 1;
CONST defmod = 2;
TYPE SourceKind = SHORTINT; (* definition .. defmod *)

TYPE Header = POINTER TO HeaderRec; TYPE HeaderRec = RECORD (PersistentDisciplines.ObjectRec) modname: ConstStrings.String; kind: SourceKind; date: Times.Time; (* date of last modification *) srcid: ConstStrings.String; (* sth unique *) args: Args.Arguments; (* for compilation *) END;

Source = POINTER TO SourceRec; SourceRec = RECORD (PersistentDisciplines.ObjectRec) header: Header; END;

TYPE OpenProc = PROCEDURE (source: Source; VAR s: Streams.Stream) : BOOLEAN; TYPE Interface = POINTER TO InterfaceRec; TYPE InterfaceRec = RECORD (Objects.ObjectRec) open: OpenProc; END;

PROCEDURE Init(source: Source; if: Interface); PROCEDURE CreateHeader(VAR header: Header; modname: ConstStrings.String; kind: SourceKind; date: Times.Time; srcid: ConstStrings.String; args: Args.Arguments); PROCEDURE Open(source: Source; VAR s: Streams.Stream) : BOOLEAN; PROCEDURE GetSource(s: Streams.Stream; VAR source: Source);


CompilerSources provides a storage-independent interface to program text sources. This interface allows compilers to be independent from the choice how program texts are represented and stored, be it in a traditional file system, an object data base, or somewhere across the network.

Sources consist of a byte sequence (accessible as stream) and a header record containing following fields:

Module name of the source file. In traditional file systems this name is usually derived from the base name (the part of the file name before the dot-separated suffix).
Programming languages like Modula-2 and some variants of Oberon have two separate source files per module: one specifying its interface (definition) and the other one giving its implementation (module). Other languages like Java have these parts merged into one source file (defmod).
This time stamp should carry the date of the last modification.
This component should provide an identifying string that must be different for different source texts of the same module. Cryptographic hash sums as those provided by OneWayHashes, MD5, and MD5Names are to be preferred.
Set of compilation options that apply for this source. Usually, Compilers.DefineArgs is used to define the set of valid options accepted by a particular compiler.

Init initializes a source object (that has to be created before) and associates it with if. The open procedure of if is expected to open a source for reading and should return a stream capable of seek operations (important for printing error messages that include source code). Multiple independent stream connections to the same source object must be supported. CreateHeader creates and initializes a persistent header object.

Open opens source for reading. Multiple open operations are permitted. GetSource returns the source object associated with s, if any. Note that GetSource works even for streams imported by RemoteObjects.


Open is free to return FALSE in case of errors and relate its error events to source. Note, however, that CompilerSources does not generate any error events on its own.

GetSource sets source to NIL if it is not associated with a source.


general abstraction for arguments
generation of source ids
operations for persistent objects

Edited by: borchert, last change: 2000/04/28, revision: 1.1, converted to HTML: 2000/04/28

Oberon || Library || Module Index || Search Engine || Definition || Module