FOR portIndex:
CARDINAL
IN [0 .. length)
DO
CheckField:
PROC [f: Field, type: NodeType, flavor:
ROPE] = {
need: NAT ← type.procs.Bits[type].container;
IF f.bitCount # need
THEN Error[
IO.PutFR[
"port %g's width is %g, but its type (%g) wants %g",
[rope[name]],
[integer[f.bitCount]],
[rope[type.procs.UserDescription[type]]],
[integer[need]]
]];
};
simple: Field ← GetField[stream];
switch: Field ← GetField[stream];
name: ROPE ← stream.GetRopeLiteral[];
typeAsRope: ROPE ← stream.GetRopeLiteral[];
job: Job ←
NEW [JobRep ← [
exec: NIL,
rootName: NIL,
from: IO.RIS[typeAsRope],
log: viewerLog,
type: Other]];
any: REF ANY ← ParseExpression[job];
type: NodeType ←
WITH any
SELECT
FROM
sti: SignalTypeInvocation => sti.st,
id: ID => InstantiateSignalType[job, id.rope, NIL].st,
ENDCASE => ERROR;
simpleType, switchType: NodeType;
flags: [0 .. 16) ← stream.GetCard[];
other: Assertions ← AssertingIO.Read[stream];
[simpleType, switchType] ← BothTypes[type];
ports[portIndex] ← [
simple: simple,
switch: switch,
name: name,
type: type,
input: (flags MOD 2) >= 1,
output: (flags MOD 4) >= 2,
XPhobic: (flags MOD 8) >= 4,
instructionsSimple: (flags MOD 16) >= 8,
other: other];
IF simpleType # NIL THEN CheckField[simple, simpleType, "simple"];
IF switchType # NIL THEN CheckField[switch, switchType, "switch"];
ENDLOOP;