LichenArrayStuff.mesa
Last tweaked by Mike Spreitzer on August 28, 1987 11:16:53 am PDT
DIRECTORY LichenCollections, LichenDataStructure, RefTab;
LichenArrayStuff:
CEDAR
DEFINITIONS
IMPORTS LichenCollections, RefTab
=
{OPEN LichenDataStructure, Colls:LichenCollections;
GIPair: TYPE = ARRAY End OF NATURAL;
PackArrayIndex: PROC [ArrayIndex] RETURNS [PackedArrayIndex];
UnpackArrayIndex: PROC [PackedArrayIndex] RETURNS [ArrayIndex];
Central: PROC [a: Array, ai: ArrayIndex] RETURNS [BOOL];
HasMiddle:
PROC [gp: GroupingParms]
RETURNS [has:
BOOL]
= INLINE {has ← gp.middle.maxPlusOne > gp.middle.min};
ComputeGroupingsIndex: PROC [a: Array, ai: ArrayIndex] RETURNS [gi2, gii2: Nat2, gi, cgii: NATURAL];
GPMiddle:
PROC [gp: GroupingParmses]
RETURNS [r2: Range2]
= INLINE {r2 ← [gp[Foo].middle, gp[Bar].middle]};
Gi2ToAir: PROC [a: Array, gi2: Nat2] RETURNS [air: Range2, ngii2: Nat2, ngii: NATURAL];
GiToGi2:
PROC [a: Array, gi:
NATURAL]
RETURNS [gi2: Nat2]
=
INLINE {
gi2[Foo] ← gi / a.groupingParmses[Bar].sum;
gi2[Bar] ← gi - gi2[Foo] * a.groupingParmses[Bar].sum};
ComputeJointGroupingsIndex:
PROC [a: Array, j: Joint, jii: Nat2]
RETURNS [jgi2: Nat2, jgi, ctii:
NATURAL, jiir: Range2];
<low side's groupings index, high side's gi> é joint groupings index
ArrayJointIndex:
PROC [a: Array, phase: Nat2]
RETURNS [i:
INT]
= INLINE {i ← a.jointsPeriod[Bar]*phase[Foo] + phase[Bar]};
Jgi2ToLair: PROC [a: Array, phase: Nat2, j: Joint, jgi2: Nat2] RETURNS [lair, jiir: Range2, jCount: NATURAL];
Jgi2ToGi: PROC [a: Array, d: Dim, phase: Nat2, j: Joint, jgi2: Nat2, side: End] RETURNS [gi2: Nat2, gi: NATURAL];
Jgi2ToGip: PROC [a: Array, d: Dim, phase: Nat2, j: Joint, jgi2: Nat2] RETURNS [gip: GIPair];
AgiToAi: PROC [a: Array, gi2, gii2: Nat2] RETURNS [ai: ArrayIndex];
EnumJgiOfGi: PROC [a: Array, gi2: Nat2, Consume: PROC [d: Dim, j: Joint, side: End, jgi2, phase: Nat2]];
GetArrayJoint:
PROC [a: Array, d: Dim, phase: Nat2]
RETURNS [j: Joint]
= INLINE {j ← NARROW[a.joints[d][ArrayJointIndex[a, phase]]]};
FetchTies:
PROC [j: Joint, jgi:
NATURAL]
RETURNS [ties: VarSet
--of Tie--]
~ INLINE {RETURN [Colls.DeRef[j.ties[jgi]].AsVar]};
FetchTie:
PROC [j: Joint, side: End, jgi:
NATURAL, g: Group]
RETURNS [tie: Tie]
= INLINE {rt: RefTable = NARROW[j.toTie[side][jgi]]; tie ← NARROW[rt.Fetch[g].val]};
BestGroup:
PROC [g: Group]
RETURNS [bg: Group]
= INLINE {IF g = NIL THEN bg ← g ELSE FOR bg ← g, bg.better WHILE bg.better # NIL DO NULL ENDLOOP};
BestTie:
PROC [x: Tie]
RETURNS [bx: Tie]
= INLINE {FOR bx ← x, bx.better WHILE bx.better # NIL DO NULL ENDLOOP};
GetArrayPortForPort: PROC [act: CellType, a: Array, index: ArrayIndex, ep: Port, mayAdd: BOOL] RETURNS [arrayPort: Port];
GetArrayPortForGroup: PROC [act: CellType, a: Array, index: ArrayIndex, g: Group, mayAdd: BOOL] RETURNS [arrayPort: Port];
EnumerateGroupsContainingPort: PROC [a: Array, ep: Port, Consume: PROC [gi2: Nat2, gi: NATURAL, g: Group]];
EnumerateArrayWiresContainingGroup: PROC [a: Array, gi2: Nat2, gi: NATURAL, g: Group, Consume: PROC [ArrayWire], addIfMissing: BOOL];
EnumerateGroupsOfArrayWire: PROC [a: Array, aw: ArrayWire, Consume: PROC [gi2: Nat2, gi: NATURAL, g: Group, membership: BoolSeq--group instance index b isMember--]];
PortToGroup:
PROC [a: Array, gi:
NATURAL, ep: Port]
RETURNS [g: Group] =
INLINE {
gs: Groupings = NARROW[a.groupingses[gi]];
g ← NARROW[gs.toGroup.Fetch[ep].val];
};
EnumerateJoints: PROC [a: Array, Consume: PROC [d: Dim, phase: Nat2, j: Joint]];
EnumerateTies: PROC [a: Array, Consume: PROC [d: Dim, phase: Nat2, jgi: NATURAL, jgi2: Nat2, j: Joint, tie: Tie]];
EnumerateTiesOfGroup: PROC [a: Array, gi2: Nat2, g: Group, Consume: PROC [d: Dim, phase: Nat2, jgi: NATURAL, jgi2: Nat2, j: Joint, tie: Tie, side: End]];
GroupInWireAt: PROC [a: Array, gi2: Nat2, g: Group, aw: ArrayWire, ai: ArrayIndex] RETURNS [BOOL];
ArrayEltPortsConnectedByJoint: PROC [a: Array, d: Dim, lowIndex: ArrayIndex, rp1, rp2: SidedPort] RETURNS [hypothetically, really: BOOL];
ArrayEltPortsConnected: PROC [a: Array, ai1, ai2: ArrayIndex, ep1, ep2: Port] RETURNS [hypothetically: BOOL];
GroupsHypotheticallyConnected: PROC [a: Array, j: Joint, jgi: NATURAL, gs: ARRAY End OF Group] RETURNS [BOOL];
GroupsActuallyConnected: PROC [a: Array, j: Joint, jgi: NATURAL, lai: Nat2, gs: ARRAY End OF Group] RETURNS [BOOL];
FetchRPD:
PROC [a: Array, d: Dim, rp: SidedPort]
RETURNS [rpd: SidedPortData]
= INLINE {rpd ← NARROW[a.toRole[d][rp.side].Fetch[rp.port].val]};
GetRoot: PROC [a: Array, d: Dim, rp: SidedPortData, clai: NATURAL] RETURNS [root: NATURAL];
GetNext: PROC [rp: SidedPortData, clai: NATURAL] RETURNS [next: NATURAL];
RPDNeedsLinks: PROC [a: Array, d: Dim, rpd: SidedPortData] RETURNS [needs: BOOL];
IsIncompleteArray: PROC [ct: CellType] RETURNS [BOOL];
MakeGroupsForPort: PROC [a: Array, ep: Port];
GetGroup: PROC [a: Array, gi: NATURAL, ep: Port, mayAdd: BOOL] RETURNS [g: Group];
MakeGroup: PROC [a: Array, gi2: Nat2, gs: Groupings] RETURNS [g: Group];
AddPortToGroup: PROC [a: Array, gi: NATURAL, ep: Port, g: Group, links: BOOL];
RemovePortFromGroup:
PROC [a: Array, gi:
NATURAL, ep: Port, g: Group];
Can not be called on incomplete arrays.
UnrolePort:
PROC [a: Array, ep: Port];
Can not be called on incomplete arrays.
AddTie: PROC [j: Joint, jgi: NATURAL, tie: Tie];
MakeArrayConnection:
PROC [ct: CellType, d: Dim, lowRange: Range2, rp1, rp2: SidedPort, may:
BOOL]
RETURNS [connected:
BOOL];
If NOT may, don't doubt hypotheses.
FlushArrayWires: PROC [a: Array, doomedArrayPorts: VarSet--of port of a--];
TrimEmptyGroups: PROC [a: Array];
ArrayWireForGroup: PROC [a: Array, index: ArrayIndex, gi: NATURAL, g: Group, mayAdd: BOOL] RETURNS [aw: ArrayWire];
SetArrayPortForGroup: PROC [a: Array, index: ArrayIndex, gi: NATURAL, g: Group, ap: Port];
SetArrayPortForPort: PROC [a: Array, index: ArrayIndex, ep, ap: Port];
EnsurePortForGroups: PROC [act: CellType, gis, giis: ARRAY End OF Nat2, gss: GroupListPair] RETURNS [ap: Port];
CrossATie: PROC [ct: CellType, d: Dim, fromP: Port, fromS: End] RETURNS [toP: Port];
ComputeTieCompleteAt: PROC [a: Array, d: Dim, tie: Tie, clai: NATURAL] RETURNS [complete: BOOL];
RetractFalseHypotheses: PROC [act: CellType];
TrimArray:
PROC [a: Array];
Remove SidedPortData.links where possible.
Remove Ties with one empty side.
DeleteGroup: PROC [a: Array, g: Group];
DeleteTie: PROC [j: Joint, jgi: NATURAL, tie: Tie];
FmtIndex: PROC [a: Array, index: ArrayIndex] RETURNS [asRope: ROPE];
Subscript: PROC [ROPE, INT] RETURNS [ROPE];
Subscript2: PROC [ROPE, ArrayIndex] RETURNS [ROPE];
}.