DIRECTORY FS, IO, Ports, Rope, RosemaryVector; RosemaryVectorImpl: CEDAR PROGRAM IMPORTS FS, IO, Ports, Rope EXPORTS RosemaryVector = BEGIN OPEN RosemaryVector; OpenVectorFile: PUBLIC PROC [fileName: Rope.ROPE, port: Ports.Port, read: BOOL _ TRUE] RETURNS [vectorFile: VectorFile] = { vectorFile _ NEW [VectorFileRec]; vectorFile.port _ port; vectorFile.stream _ FS.StreamOpen[fileName, IF read THEN $read ELSE $create]; }; CloseVectorFile: PUBLIC PROC [vectorFile: VectorFile] = { IO.Close[vectorFile.stream]; }; WriteVector: PUBLIC PROC [vectorFile: VectorFile, neverSayExpect: BOOL _ FALSE] = { WriteDrive: PROC [d: Ports.Drive] = { IO.PutRope[vectorFile.stream, Ports.driveNames[IF neverSayExpect AND d=expect THEN none ELSE d]]; IO.PutRope[vectorFile.stream, " "]; }; WriteLevel: PROC [l: Ports.Level] = { IO.PutRope[vectorFile.stream, Ports.levelNames[l]]; IO.PutRope[vectorFile.stream, " "]; }; WriteBool: PROC [b: BOOL] = { IO.PutRope[vectorFile.stream, IF b THEN "T " ELSE "F "]; }; WritePort: PROC [p: Ports.Port] = { IF p.levelType=composite THEN FOR i: NAT IN [0..p.size) DO WritePort[p[i]]; ENDLOOP ELSE { IO.PutRope[vectorFile.stream, Ports.driveTypeNames[p.driveType]]; IO.PutRope[vectorFile.stream, " "]; SELECT p.driveType FROM aggregate => WriteDrive[p.d]; seperate => FOR i: NAT IN [0..p.ds.size) DO WriteDrive[p.ds[i]]; ENDLOOP; ENDCASE => ERROR; SELECT p.levelType FROM l => WriteLevel[p.l]; ls => FOR i: NAT IN [0..p.ls.size) DO WriteLevel[p.ls[i]]; ENDLOOP; b => WriteBool[p.b]; bs => FOR i: NAT IN [0..p.bs.size) DO WriteBool[p.bs[i]]; ENDLOOP; c => IO.PutF[vectorFile.stream, "%g ", IO.card[p.c]]; lc => IO.PutF[vectorFile.stream, "%g ", IO.card[p.lc]]; q => FOR i: NAT IN [0..4) DO IO.PutF[vectorFile.stream, "%g ", IO.card[p.q[i]]]; ENDLOOP; ENDCASE => ERROR; }; }; WritePort[vectorFile.port]; }; ReadVector: PUBLIC PROC [vectorFile: VectorFile] = { ReadDrive: PROC RETURNS [d: Ports.Drive] = { name: Rope.ROPE _ IO.GetID[vectorFile.stream]; d _ Ports.FindDrive[name]; }; ReadLevel: PROC RETURNS [l: Ports.Level] = { name: Rope.ROPE _ IO.GetID[vectorFile.stream]; l _ Ports.FindLevel[name]; }; ReadBool: PROC RETURNS [b: BOOL] = { name: Rope.ROPE _ IO.GetID[vectorFile.stream]; b _ SELECT TRUE FROM Rope.Equal[name, "T"] => TRUE, Rope.Equal[name, "F"] => FALSE, ENDCASE => ERROR; }; ReadPort: PROC [p: Ports.Port] = { IF p.levelType=composite THEN FOR i: NAT IN [0..p.size) DO ReadPort[p[i]]; ENDLOOP ELSE { name: Rope.ROPE _ IO.GetID[vectorFile.stream]; p.driveType _ Ports.FindDriveType[name]; SELECT p.driveType FROM aggregate => p.d _ ReadDrive[]; seperate => FOR i: NAT IN [0..p.ds.size) DO p.ds[i] _ ReadDrive[]; ENDLOOP; ENDCASE => ERROR; SELECT p.levelType FROM l => p.l _ ReadLevel[]; ls => FOR i: NAT IN [0..p.ls.size) DO p.ls[i] _ ReadLevel[]; ENDLOOP; b => p.b _ ReadBool[]; bs => FOR i: NAT IN [0..p.bs.size) DO p.bs[i] _ ReadBool[]; ENDLOOP; c => p.c _ IO.GetCard[vectorFile.stream]; lc => p.lc _ IO.GetCard[vectorFile.stream]; q => FOR i: NAT IN [0..4) DO p.q[i] _ IO.GetCard[vectorFile.stream]; ENDLOOP; ENDCASE => ERROR; }; }; ReadPort[vectorFile.port]; }; END. ˆRosemaryVectorImpl.mesa Copyright c 1985, 1986 by Xerox Corporation. All rights reserved. Barth, February 2, 1987 3:09:58 pm PST Κa˜codešœ™Kšœ Οmœ7™BKšœ&™&—K˜šΟk œžœžœ˜.K˜—šΟnœžœž˜!Kšžœžœžœ ˜Kšžœžœžœ˜3—K˜šŸœžœžœžœžœžœžœ˜{Kšœ žœ˜!Kšœ˜Kš œžœžœžœžœ ˜MKšœ˜K˜—šŸœžœžœ˜9Kšžœ˜Kšœ˜J˜—š Ÿ œžœžœ*žœžœ˜SK˜šŸ œžœ˜%Kš žœ-žœžœ žœžœ˜aKšžœ!˜#K˜K˜—šŸ œžœ˜%Kšžœ1˜3Kšžœ!˜#K˜K˜—šŸ œžœžœ˜Kšžœžœžœžœ˜8K˜K˜—šŸ œžœ˜#š žœžœžœžœžœ ž˜:K˜Kšž˜—šžœ˜Kšžœ?˜AKšžœ!˜#šžœ ž˜Kšœ˜šœ žœžœžœž˜+Kšœ˜Kšžœ˜—Kšžœžœ˜—šžœ ž˜Kšœ˜šœžœžœžœž˜%Kšœ˜Kšžœ˜—Kšœ˜šœžœžœžœž˜%Kšœ˜Kšžœ˜—Kšœžœ žœ ˜5Kšœžœ žœ ˜7šœžœžœžœž˜Kšžœ žœ˜3Kšžœ˜—Kšžœžœ˜—K˜—K˜K˜—Kšœ˜Kšœ˜J˜—šŸ œžœžœ˜4K˜šŸ œžœžœ˜,Kšœ žœžœ˜.Kšœ˜Kšœ˜K˜—šŸ œžœžœ˜,Kšœ žœžœ˜.Kšœ˜K˜K˜—šŸœžœžœžœ˜$Kšœ žœžœ˜.šœžœžœž˜Kšœžœ˜Kšœžœ˜Kšžœžœ˜—K˜K˜—šŸœžœ˜"š žœžœžœžœžœ ž˜:Kšœ˜Kšž˜—šžœ˜Kšœ žœžœ˜.Kšœ(˜(šžœ ž˜Kšœ˜šœ žœžœžœž˜+Kšœ˜Kšžœ˜—Kšžœžœ˜—šžœ ž˜Kšœ˜šœžœžœžœž˜%Kšœ˜Kšžœ˜—Kšœ˜šœžœžœžœž˜%Kšœ˜Kšžœ˜—Kšœ žœ˜)Kšœ žœ˜+šœžœžœžœž˜Kšœ žœ˜'Kšžœ˜—Kšžœžœ˜—K˜—K˜K˜—Kšœ˜Kšœ˜J˜—Jšžœ˜J˜—…— 6