PipalIO.mesa
Copyright Ó 1988 by Xerox Corporation. All rights reversed.
Created by Bertrand Serlet, May 2, 1988 6:06:45 pm PDT
Bertrand Serlet, May 9, 1988 11:58:01 pm PDT
DIRECTORY
BasicTime, IO,
Pipal, PipalInt, PipalReal,
SymTab;
PipalIO: CEDAR DEFINITIONS ~ BEGIN
Framework
ClassReadProc: TYPE = PROC [stream: IO.STREAM] RETURNS [object: Pipal.Object];
ClassWriteProc: TYPE = PROC [stream: IO.STREAM, object: Pipal.Object];
RegisterClass: PROC [class: Pipal.Class, read: ClassReadProc, write: ClassWriteProc];
ReadObject: PROC [stream: IO.STREAM] RETURNS [object: Pipal.Object];
WriteObject: PROC [stream: IO.STREAM, object: Pipal.Object];
PipalInt Data Types
ReadIntVector: PROC [stream: IO.STREAM] RETURNS [vector: PipalInt.Vector];
WriteIntVector: PROC [stream: IO.STREAM, vector: PipalInt.Vector];
ReadIntRectangle: PROC [stream: IO.STREAM] RETURNS [rectangle: PipalInt.Rectangle];
WriteIntRectangle: PROC [stream: IO.STREAM, rectangle: PipalInt.Rectangle];
ReadOrientation: PROC [stream: IO.STREAM] RETURNS [orientation: PipalInt.Orientation];
WriteOrientation: PROC [stream: IO.STREAM, orientation: PipalInt.Orientation];
ReadIntTransformation: PROC [stream: IO.STREAM] RETURNS [transformation: PipalInt.Transformation];
WriteIntTransformation: PROC [stream: IO.STREAM, transformation: PipalInt.Transformation];
PipalReal Data Types
ReadRealVector: PROC [stream: IO.STREAM] RETURNS [vector: PipalReal.Vector];
WriteRealVector: PROC [stream: IO.STREAM, vector: PipalReal.Vector];
ReadRealRectangle: PROC [stream: IO.STREAM] RETURNS [rectangle: PipalReal.Rectangle];
WriteRealRectangle: PROC [stream: IO.STREAM, rectangle: PipalReal.Rectangle];
ReadRealTransformation: PROC [stream: IO.STREAM] RETURNS [transformation: PipalReal.Transformation];
WriteRealTransformation: PROC [stream: IO.STREAM, transformation: PipalReal.Transformation];
Pipal Files
For all the following operations, the suffix ".pipal" is added to the file name.
FileInfo: PROC [fileName: Pipal.ROPE, wantedCreatedTime: BasicTime.GMT ← BasicTime.nullGMT] RETURNS [creationTime: BasicTime.GMT ← BasicTime.nullGMT];
Returns nullGMT iff not found.
RestoreObject: PROC [fileName: Pipal.ROPE, wantedCreatedTime: BasicTime.GMT ← BasicTime.nullGMT] RETURNS [object: Pipal.Object];
SaveObject: PROC [fileName: Pipal.ROPE, object: Pipal.Object] RETURNS [creationTime: BasicTime.GMT];
Directory
Allows packing of several objects into a single one. Also provides some kind of hierarchical naming (enforced by the user interface).
directoryClass: Pipal.Class;
Directory: TYPE = REF DirectoryRec;
DirectoryRec: TYPE = RECORD [
name: Pipal.ROPE,
short name of the design (such as "Logic")
table: SymTab.Ref
maps short names to objects (such as "nand.sch")
];
CreateDirectory: PROC [name: Pipal.ROPE, table: SymTab.Ref] RETURNS [directory: Directory];
name is the short name of the design (such as "Logic").
FetchInDirectory: PROC [directory: Directory, name: Pipal.ROPE] RETURNS [object: Pipal.Object ← NIL];
name is the short name of the object (such as "Nand.sch").
DirectoryAndShortName: PROC [name: Pipal.ROPE] RETURNS [directory, shortName: Pipal.ROPENIL];
Breaks a full name into the directory name and the shortName. Directory part ends at the first ".". For example DirectoryAndShortName["Logic.nand.sch"] -> ["Logic", "nand.sch"].
directory is NIL if breaking is not possible.
Imports
Allows explicit sharing and lazy read.
importClass: Pipal.Class;
Import: TYPE = REF ImportRec;
ImportRec: TYPE = RECORD [
name: Pipal.ROPE,
full name of the object (such as "Logic.or.sch")
isDirectory: BOOLFALSE,
private field reserved for the implementation
referee: Pipal.Object ← NIL,
creationTime: BasicTime.GMT ← BasicTime.nullGMT
creation time of the underlying file (such as "Logic.or.sch.pipal")
];
Only three of these states are valid:
creationTime#nullGMT AND referee#NIL => the underlying file and the VM are consistent.
creationTime=nullGMT  => the VM is the truth.
referee=NIL   => the underlying file has not been read yet.
When isDirectory is TRUE, referee is the whole directory, and creationTime is the directory creation time.
CreateTimedImport: PROC [name: Pipal.ROPE, isDirectory: BOOLFALSE, creationTime: BasicTime.GMT] RETURNS [import: Import];
CreateRefereedImport: PROC [name: Pipal.ROPE, isDirectory: BOOLFALSE, referee: Pipal.Object] RETURNS [import: Import];
EachImportProc: TYPE = PROC [import: Import] RETURNS [quit: BOOLFALSE];
EnumerateObjectImports: PROC [object: Pipal.Object, each: EachImportProc] RETURNS [quit: BOOLFALSE];
Imports + Directories
Fetch: PROC [name: Pipal.ROPE] RETURNS [object: Pipal.Object ← NIL];
If there is a file named <name>, an import of this file is made.
If not, a directory file is searched. When such a directory file exists a directory import is made, otherwise NIL is returned.
Utilities
ReadObjects: PROC [stream: IO.STREAM] RETURNS [objects: Pipal.Objects ← NIL];
END.