BiRelDefaults3.Mesa
Last tweaked by Mike Spreitzer on December 14, 1987 1:15:11 pm PST
DIRECTORY AbSets, Atom, BiRelBasics, BiRels, IntStuff, SetBasics;
BiRelDefaults3:
CEDAR
PROGRAM
IMPORTS AbSets, BiRels, SetBasics
EXPORTS BiRels
=
BEGIN OPEN IntStuff, SetBasics, Sets:AbSets, Sets, BiRelBasics, BiRels;
DefaultInsulate:
PUBLIC
PROC [br: BiRel]
RETURNS [UWBiRel] ~ {
fnl: BoolPair ~ br.Functional[];
RETURN AsUW[[insClasses[fnl[leftToRight]][fnl[rightToLeft]], br.Refify]]};
InsClasses: TYPE ~ ARRAY --l2r--BOOL OF ARRAY --r2l--BOOL OF BiRelClass;
insClasses: REF InsClasses ~ NEW [InsClasses];
InsPrimitive:
PROC [br: BiRel, op:
ATOM, arg1, arg2:
REF
ANY ←
NIL]
RETURNS [PrimitiveAnswer] ~ {
rbr: REF BiRel ~ NARROW[br.data];
SELECT op
FROM
$AsSet, $HasPair, $Image, $Apply, $ScanRestriction, $Get3, $Index, $RestrictionSize, $GetBounds, $Copy, $ValueOf, $SetOn, $CurSetOn, $Spaces, $IsDense, $SideFixed => RETURN [IF rbr^.GoodImpl[op, arg1, arg2] THEN yes ELSE no];
$GetOne => {
remove: BOOL ~ ToBool[arg1];
RETURN [IF remove OR rbr^.GoodImpl[op, arg1, arg2] THEN yes ELSE no]};
ENDCASE => RETURN [pass];
};
InsAsSet:
PROC [br: BiRel, ro: RelOrder]
RETURNS [Set
--of REF Pair--] ~ {
rbr: REF BiRel ~ NARROW[br.data];
RETURN rbr^.Insulate.AsSet[ro]};
InsHasPair:
PROC [br: BiRel, pair: Pair]
RETURNS [
BOOL] ~ {
rbr: REF BiRel ~ NARROW[br.data];
RETURN rbr^.HasPair[pair]};
InsImage:
PROC [br: BiRel, set: Set, dir: Direction]
RETURNS [Set] ~ {
rbr: REF BiRel ~ NARROW[br.data];
RETURN [rbr^.Image[set, dir].Insulate]};
InsApply:
PROC [br: BiRel, v: Value, dir: Direction]
RETURNS [MaybeValue] ~ {
rbr: REF BiRel ~ NARROW[br.data];
RETURN rbr^.Apply[v, dir]};
InsScanRestriction:
PROC [br: BiRel, sets: SetPair,
Test: Tester, ro: RelOrder]
RETURNS [MaybePair] ~ {
rbr: REF BiRel ~ NARROW[br.data];
RETURN rbr^.ScanRestriction[sets, Test, ro]};
InsGetOne:
PROC [br: BiRel, remove:
BOOL, ro: RelOrder]
RETURNS [MaybePair] ~ {
rbr: REF BiRel ~ NARROW[br.data];
IF remove THEN br.Complain[notVariable];
RETURN rbr^.GetOne[remove, ro]};
InsGet3:
PROC [br: BiRel, pair: Pair, ro: RelOrder, want: TripleBool]
RETURNS [TripleMaybePair] ~ {
rbr: REF BiRel ~ NARROW[br.data];
RETURN rbr^.Get3[pair, ro, want]};
InsIndex:
PROC [br, goal: IntRel, bounds: IntInterval, bwd:
BOOL]
RETURNS [MaybeValue] ~ {
rbr: REF BiRel ~ NARROW[br.data];
RETURN rbr^.Index[goal, bounds, bwd]};
InsRestrictionSize:
PROC [br: BiRel, sets: SetPair, limit:
EINT]
RETURNS [
EINT] ~ {
rbr: REF BiRel ~ NARROW[br.data];
RETURN rbr^.RestrictionSize[sets, limit]};
InsGetBounds:
PROC [br: BiRel, want: EndBools, ro: RelOrder]
RETURNS [MaybePairInterval] ~ {
rbr: REF BiRel ~ NARROW[br.data];
RETURN rbr^.GetBounds[want, ro]};
InsCopy:
PROC [br: BiRel]
RETURNS [VarBiRel] ~ {
rbr: REF BiRel ~ NARROW[br.data];
RETURN rbr^.Copy};
InsValueOf:
PROC [br: BiRel]
RETURNS [ConstBiRel] ~ {
rbr: REF BiRel ~ NARROW[br.data];
RETURN rbr^.ValueOf};
InsSetOn:
PROC [br: BiRel, side: Side]
RETURNS [UWSet] ~ {
rbr: REF BiRel ~ NARROW[br.data];
RETURN rbr^.SetOn[side]};
InsCurSetOn:
PROC [br: BiRel, side: Side]
RETURNS [ConstSet] ~ {
rbr: REF BiRel ~ NARROW[br.data];
RETURN rbr^.CurSetOn[side]};
InsSpaces:
PROC [br: BiRel]
RETURNS [SpacePair] ~ {
rbr: REF BiRel ~ NARROW[br.data];
RETURN rbr^.Spaces[]};
InsIsDense:
PROC [br: BiRel, when: When, side: Side]
RETURNS [
BOOL] ~ {
rbr: REF BiRel ~ NARROW[br.data];
RETURN rbr^.IsDense[when, side]};
InsSideFixed:
PROC [br: BiRel, side: Side]
RETURNS [
BOOL] ~ {
rbr: REF BiRel ~ NARROW[br.data];
RETURN rbr^.SideFixed[side]};
Start:
PROC ~ {
FOR l2r:
BOOL
IN
BOOL
DO
FOR r2l:
BOOL
IN
BOOL
DO
insClasses[l2r][r2l] ← CreateClass[[
Primitive: InsPrimitive,
AsSet: InsAsSet,
HasPair: InsHasPair,
Image: InsImage,
Apply: InsApply,
ScanRestriction: InsScanRestriction,
GetOne: InsGetOne,
Get3: InsGet3,
Index: InsIndex,
RestrictionSize: InsRestrictionSize,
GetBounds: InsGetBounds,
Copy: InsCopy,
ValueOf: InsValueOf,
SetOn: InsSetOn,
CurSetOn: InsCurSetOn,
Spaces: InsSpaces,
IsDense: InsIsDense,
SideFixed: InsSideFixed,
functional: [l2r, r2l],
mutability: readonly]];
ENDLOOP ENDLOOP;
RETURN};
Start[];
END.