VersionMapDefaultsImpl.mesa
Russ Atkinson, April 19, 1983 9:55 am
These definitions give access to the default source and object version maps.
DIRECTORY
BcdDefs USING [VersionStamp],
Rope USING [ROPE],
VersionMap USING [Map, MapList, RestoreMapFromFile, VersionToName],
VersionMapDefaults USING [];
VersionMapDefaultsImpl: CEDAR MONITOR
IMPORTS VersionMap
EXPORTS VersionMapDefaults
= BEGIN OPEN Rope;
Operations on default version map lists.
WhichMapList: TYPE = ATOM;
$Source => the source symbol version map list (initially from CedarSource.VersionMap)
$Symbols => the source symbol version map list (initially from CedarSymbols.VersionMap)
other => a user-defined version map variety (initially empty)
assumeImmutable: BOOLTRUE;
root: EntryList ← NIL;
EntryList: TYPE = LIST OF Entry;
Entry: TYPE = RECORD [key: ATOMNIL, mapList: VersionMap.MapList ← NIL];
FileNameFromVersion: PUBLIC PROC
[which: ATOM, version: BcdDefs.VersionStamp] RETURNS [name: ROPENIL] = {
... returns a name corresponding to the given version stamp in the indicated map list (does not check for multiple names, since that is the responsibility of the version map creator).
mapList: VersionMap.MapList ← GetMapList[which];
IF mapList # NIL THEN
name ← VersionMap.VersionToName[mapList, version].name;
};
GetMapList: PUBLIC ENTRY PROC
[which: ATOM] RETURNS [list: VersionMap.MapList ← NIL] = {
... gets the current selected version map list. If there is no such map, then NIL will be returned unless which = $Source or which = $Symbols, which will restore the official version maps from CedarSource.VersionMap or CedarSymbols.VersionMap respectively.
mapFileName: ROPENIL;
FOR eList: EntryList ← root, eList.rest WHILE eList # NIL DO
IF eList.first.key = which THEN RETURN [eList.first.mapList];
ENDLOOP;
SELECT which FROM
$Source => mapFileName ← "CedarSource.VersionMap";
$Symbols => mapFileName ← "CedarSymbols.VersionMap";
ENDCASE => RETURN;
list ← LIST[VersionMap.RestoreMapFromFile[mapFileName, TRUE]];
root ← CONS[Entry[which, list], root];
};
AddToMapList: PUBLIC ENTRY PROC [which: ATOM, map: VersionMap.Map] = {
... adds a new map to the lookup list. Use this proc for adding personal version maps.
mapList: VersionMap.MapList ← LIST[map];
IF map = NIL THEN RETURN;
FOR eList: EntryList ← root, eList.rest WHILE eList # NIL DO
IF eList.first.key = which THEN {
mapList.rest ← eList.first.mapList;
eList.first.mapList ← mapList;
RETURN};
ENDLOOP;
There is no mapList under this key, so add it
root ← CONS[Entry[which, mapList], root];
};
SetMapList: PUBLIC ENTRY PROC [which: ATOM, list: VersionMap.MapList ← NIL] = {
.. sets the current version map for source files. Since there can be a race between GetMapList and SetMapList, this operation should not be casually used!
FOR eList: EntryList ← root, eList.rest WHILE eList # NIL DO
IF eList.first.key = which THEN {
eList.first.mapList ← list;
RETURN};
ENDLOOP;
There is no mapList under this key, so add it
root ← CONS[Entry[which, list], root];
};
END.