CoreIO.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Barth, December 4, 1986 4:59:34 pm PST
Bertrand Serlet July 7, 1986 5:01:01 pm PDT
DIRECTORY
Core, CoreClasses, HashTable;
CoreIO: CEDAR DEFINITIONS = BEGIN
ROPE: TYPE = Core.ROPE;
Theory
Do not put source information in .core files! They are caches which may be flushed at any time!
CoreIO is just a speed up for saving the result of some computation and reading it later without paying all of the cost of the computation again.
Cell Type IO
UnknownProperty: SIGNAL [propKey: ATOM];
UnknownCellClass: SIGNAL [class: Core.CellClass];
SaveCellType: PROC [cellType: Core.CellType, fileName: ROPENIL];
fileName=NIL => fileName ← Rope.Cat[CoreOps.GetCellTypeName[cellType], ".core"]
UnknownProperty RESUME => Property is not written.
UnknownCellClass RESUME => CoreOps.Recast. No recast proc => ERROR.
ReportSaveCellType: PROC [cellType: Core.CellType, fileName: ROPENIL] RETURNS [props: LIST OF ATOM, classes: LIST OF Core.CellClass];
Same as SaveCellType but catches unknown signals and returns a list of them when finished.
RestoreCellType: PROC [cellName: ROPENIL, fileName: ROPENIL] RETURNS [cellType: Core.CellType];
fileName=NIL AND cellName=NIL => ERROR
fileName=NIL => fileName ← Rope.Cat[cellName, ".core"]
Unknown properties or cell classes => ERROR
Always returns an imports
IO Registration
Class
RegisterClass: PROC [class: Core.CellClass, write: ClassWriteProc, read: ClassReadProc] RETURNS [sameClass: Core.CellClass];
ClassWriteProc: TYPE = PROC [h: Handle, cellType: Core.CellType, wireIDTab: HashTable.Table];
ClassReadProc: TYPE = PROC [h: Handle, cellType: Core.CellType, wireIDTab: HashTable.Table];
Property
RegisterProperty: PROC [prop: ATOM, write: PropWriteProc, read: PropReadProc] RETURNS [sameProp: ATOM];
PropWriteProc: TYPE = PROC [h: Handle, prop: ATOM, value: REF ANY];
PropReadProc: TYPE = PROC [h: Handle, prop: ATOM] RETURNS [value: REF ANY];
General
Handle: TYPE = REF HandleRec;
HandleRec: TYPE = RECORD[
cellType: Core.CellType ← NIL, -- current cell type
wire: Core.Wire ← NIL, -- current wire, NIL if none
fileName: Core.ROPENIL,
stream: Core.STREAMNIL,
cellTypeIDTab: HashTable.Table ← NIL,
ropeIDTab: HashTable.Table ← NIL,
atomIDTab: HashTable.Table ← NIL,
wireIDTab: HashTable.Table ← NIL,
properties: Core.Properties ← NIL];
On write cellTypeIDTab maps REF to ROPE. On read cellTypeIDTab maps ROPE to REF. Similarly for rope and atom tables.
IO Utilities
WriteCellType: PROC [h: Handle, cellType: Core.CellType];
ReadCellType: PROC [h: Handle] RETURNS [cellType: Core.CellType];
WriteWire: PROC [h: Handle, wireIDTab: HashTable.Table, wire: Core.Wire];
ReadWire: PROC [h: Handle, wireIDTab: HashTable.Table] RETURNS [wire: Core.Wire];
WriteProperties: PROC [h: Handle, properties: Core.Properties];
ReadProperties: PROC [h: Handle] RETURNS [properties: Core.Properties ← NIL];
WriteID: PROC [h: Handle, id: ROPE];
ReadID: PROC [h: Handle] RETURNS [id: ROPE];
WriteAtom: PROC [h: Handle, atom: ATOM];
ReadAtom: PROC [h: Handle] RETURNS [atom: ATOM];
WriteRope: PROC [h: Handle, rope: ROPE];
ReadRope: PROC [h: Handle] RETURNS [rope: ROPE];
WriteListOfRope: PROC [h: Handle, ropes: LIST OF ROPE];
ReadListOfRope: PROC [h: Handle] RETURNS [ropes: LIST OF ROPE];
WriteInt: PROC [h: Handle, int: INT];
ReadInt: PROC [h: Handle] RETURNS [int: INT];
WriteReal: PROC [h: Handle, real: REAL];
ReadReal: PROC [h: Handle] RETURNS [real: REAL];
WriteBool: PROC [h: Handle, bool: BOOL];
ReadBool: PROC [h: Handle] RETURNS [bool: BOOL];
WriteHashTable: PROC [h: Handle, table: HashTable.Table, eachPair: HashWriteProc];
HashWriteProc: TYPE = PROC [h: Handle, key: HashTable.Key, value: HashTable.Value];
ReadHashTable: PROC [h: Handle, eachPair: HashReadProc, equal: HashTable.EqualProc ← NIL, hash: HashTable.HashProc ← NIL] RETURNS [table: HashTable.Table];
HashReadProc: TYPE = PROC [h: Handle] RETURNS [key: HashTable.Key, value: HashTable.Value];
WriteCellTypeIDPair: HashWriteProc;
ReadCellTypeIDPair: HashReadProc;
WriteRopeIDPair: HashWriteProc;
ReadRopeIDPair: HashReadProc;
WriteAtomIDPair: HashWriteProc;
ReadAtomIDPair: HashReadProc;
END.