RoseWireTypeUseImpl.Mesa
Spreitzer, September 26, 1985 5:50:05 pm PDT
Barth, September 3, 1985 4:36:21 pm PDT
DIRECTORY AMTypes, Asserting, Basics, Core, CoreRecord, IO, PrincOps, Rope, RedBlackTree, RedBlackTreeExtras, RoseBehavior, RoseEvents, RosePrivates, RoseWireTypes, RoseWireTypeUse, VFonts;
RoseWireTypeUseImpl: CEDAR PROGRAM
IMPORTS RedBlackTree, RedBlackTreeExtras, Rope
EXPORTS RoseWireTypeUse
=
BEGIN OPEN RoseWireTypes, RoseWireTypeUse;
Table: TYPE = RedBlackTree.Table;
RoseWireTypeUser: TYPE = REF RoseWireTypeUserRep;
RoseWireTypeUserRep: PUBLIC TYPE = RECORD [
moduleRefs: ARRAY ModuleRefType OF Table ← ALL[NIL],
classes: Table ← RedBlackTreeExtras.NewRefTable[],
repAux: ROPENIL
];
CreateUser: PUBLIC PROC RETURNS [user: RoseWireTypeUser] = {
user ← NEW [RoseWireTypeUserRep ← []];
FOR mrt: ModuleRefType IN ModuleRefType DO
user.moduleRefs[mrt] ← RedBlackTreeExtras.NewRopeTable[];
ENDLOOP;
user ← user;
};
AddRWCAux: PUBLIC PROC [user: RoseWireTypeUser, rwc: RoseWireClass] = {
IF user.classes.Lookup[rwc] # NIL THEN RETURN;
user.classes.Insert[rwc, rwc];
IF rwc.super.MesaRepAux # NIL THEN {
dra: Mesa ← rwc.super.MesaRepAux[rwc];
user.repAux ← StmtCat[user.repAux, dra.mesa];
NoteMesa[user, dra];
SELECT rwc.structure FROM
atom => NULL;
sequence => AddRWCAux[user, rwc.super.SubClass[rwc, [subscript[0]]]];
record => {
user ← user;
FOR i: NAT IN [0 .. rwc.length) DO
swc: RoseWireClass = rwc.super.SubClass[rwc, [field[i]]];
AddRWCAux[user, swc];
ENDLOOP;
user ← user;
};
ENDCASE => ERROR;
};
};
NoteMesa: PUBLIC PROC [user: RoseWireTypeUser, mesa: Mesa] = {
NoteModuleRefs[user, Directory, mesa.directory];
NoteModuleRefs[user, Import, mesa.imports];
};
NoteModuleRefs: PUBLIC PROC [user: RoseWireTypeUser, type: ModuleRefType, refs: LOR] = {
SELECT type FROM
Open, Import, Export => NoteModuleRefs[user, Directory, refs];
Directory => NULL;
ENDCASE => ERROR;
FOR refs ← refs, refs.rest WHILE refs # NIL DO
mr: ROPE = refs.first;
IF user.moduleRefs[type].Lookup[mr] = NIL THEN {
user.moduleRefs[type].Insert[mr, mr];
};
ENDLOOP;
refs ← refs;
};
DestroyUser: PUBLIC PROC [user: RoseWireTypeUser] RETURNS [repAux: ROPE, moduleRefs: ModuleRefs] = {
Report: PROC [mrt: ModuleRefType] = {
NoteRef: PROC [data: REF ANY] RETURNS [stop: BOOLFALSE] --RedBlackTree.EachNode-- = {
r: ROPE = NARROW[data];
moduleRefs[mrt] ← CONS[r, moduleRefs[mrt]];
};
user.moduleRefs[mrt].EnumerateIncreasing[NoteRef];
user.moduleRefs[mrt].DestroyTable[];
};
repAux ← user.repAux;
moduleRefs ← ALL[NIL];
FOR mrt: ModuleRefType IN ModuleRefType DO Report[mrt] ENDLOOP;
user^ ← [classes: NIL];
};
StmtCat: PUBLIC PROC [s1, s2: ROPE] RETURNS [catted: ROPE] = {
IF s1.Length[] = 0 THEN RETURN [s2];
IF s2.Length[] = 0 THEN RETURN [s1];
catted ← s1.Cat[";\n", s2];
};
END.