RopePorts.Mesa
last edited by Spreitzer September 6, 1984 3:35:43 pm PDT
DIRECTORY Asserting, AssertingIO, FS, IO, Rope, RoseCreate, RoseTranslateTypes, RoseTranslateInsides, RoseTypes;
RopePorts: CEDAR PROGRAM
IMPORTS AssertingIO, FS, IO, RoseTranslateInsides
EXPORTS RoseCreate =
BEGIN OPEN RoseTypes, RoseTranslateTypes, RoseTranslateInsides;
PortsFromROPE: PUBLIC PROC [asRope: ROPE] RETURNS [ports: Ports] =
{ports ← PortsFromStream[IO.RIS[asRope]]};
PortsFromFile: PUBLIC PROC [fileName: ROPE] RETURNS [ports: Ports] =
{ports ← PortsFromStream[FS.StreamOpen[fileName]]};
PortsFromStream: PUBLIC PROC [stream: STREAM] RETURNS [ports: Ports] =
BEGIN
length: CARDINAL ← stream.GetCard[];
ports ← NEW [PortsRep[length]];
FOR portIndex: CARDINAL IN [0 .. length) DO
job: Job ← NEW [JobRep ← [
exec: NIL,
rootName: NIL,
from: NIL,
log: viewerLog,
type: Other]];
any: REF ANY;
bits: [0 .. 16);
typeAsRope: ROPE;
ports[portIndex].firstWord ← stream.GetCard[];
ports[portIndex].wordCount ← stream.GetCard[];
ports[portIndex].name ← stream.GetRopeLiteral[];
typeAsRope ← stream.GetRopeLiteral[];
job.from ← IO.RIS[typeAsRope];
any ← ParseExpression[job];
WITH any SELECT FROM
sti: SignalTypeInvocation => ports[portIndex].type ← sti.st;
id: ID => {sti: SignalTypeInvocation ← InstantiateSignalType[job, id.rope, NIL]; ports[portIndex].type ← sti.st};
ENDCASE => ERROR;
bits ← stream.GetCard[];
ports[portIndex].input ← (bits MOD 2) >= 1;
ports[portIndex].output ← (bits MOD 4) >= 2;
ports[portIndex].XPhobic ← (bits MOD 8) >= 4;
ports[portIndex].special ← (bits MOD 16) >= 8;
ports[portIndex].other ← AssertingIO.Read[stream];
ENDLOOP;
[] ← stream.SkipWhitespace[flushComments: FALSE];
IF NOT stream.EndOf[] THEN ERROR;
END;
END.