SetInsulationImpl.Mesa
Last tweaked by Mike Spreitzer on December 15, 1987 4:31:21 pm PST
DIRECTORY BiRels, SetBasics, AbSets;
SetInsulationImpl: CEDAR PROGRAM
IMPORTS BiRels, SetBasics, AbSets
EXPORTS AbSets
=
BEGIN OPEN SetBasics, BiRels, Sets:AbSets, Sets;
DefaultInsulate: PUBLIC PROC [set: Set] RETURNS [UWSet] ~ {
RETURN AsUW[[insClass, AV[set.Refify]]]};
insClass: SetClass ~ CreateClass[[
Primitive: InsulatePrimitive,
HasMember: InsulateHasMember,
Scan: InsulateScan,
TheElt: InsulateTheElt,
GetOne: InsulateGetOne,
Get3: InsulateGet3,
Size: InsulateSize,
IsDense: InsulateIsDense,
GetBounds: InsulateGetBounds,
Copy: InsulateCopy,
ValueOf: InsulateValueOf,
QuaBiRel: InsulateQuaBiRel,
QuaIntInterval: InsulateQuaIntInterval,
SpaceOf: InsulateSpaceOf,
mutability: readonly]];
InsulatePrimitive: PROC [set: Set, op: ATOM, arg1, arg2: REF ANY] RETURNS [PrimitiveAnswer] ~ {
subj: Set ~ DeRef[set.data.VA];
SELECT op FROM
$HasMember, $Scan, $TheElt, $GetOne, $Get3, $Size, $IsDense, $GetBounds, $Copy, $ValueOf, $QuaBiRel, $QuaIntInterval => RETURN [IF subj.Primitive[op, arg1, arg2] THEN yes ELSE no];
ENDCASE => RETURN [no];
};
InsulateHasMember: PROC [set: Set, elt: Value] RETURNS [BOOL] ~ {
subj: Set ~ DeRef[set.data.VA];
RETURN subj.HasMember[elt]};
InsulateScan: PROC [set: Set, Test: Tester, ro: RelOrder] RETURNS [MaybeValue] ~ {
subj: Set ~ DeRef[set.data.VA];
RETURN subj.Scan[Test, ro]};
InsulateTheElt: PROC [set: Set] RETURNS [Value] ~ {
subj: Set ~ DeRef[set.data.VA];
RETURN subj.TheElt[]};
InsulateGetOne: PROC [set: Set, remove: BOOL, ro: RelOrder] RETURNS [MaybeValue] ~ {
subj: Set ~ DeRef[set.data.VA];
IF remove THEN set.Complain[notVariable];
RETURN subj.class.GetOne[subj, remove, ro]};
InsulateGet3: PROC [set: Set, elt: Value, want: TripleBool] RETURNS [TripleMaybeValue] ~ {
subj: Set ~ DeRef[set.data.VA];
RETURN subj.Get3[elt, want]};
InsulateSize: PROC [set: Set, limit: EINT] RETURNS [EINT] ~ {
subj: Set ~ DeRef[set.data.VA];
RETURN subj.Size[limit]};
InsulateIsDense: PROC [set: Set, when: When] RETURNS [BOOL] ~ {
subj: Set ~ DeRef[set.data.VA];
RETURN subj.IsDense[when]};
InsulateGetBounds: PROC [set: Set, want: EndBools] RETURNS [MaybeInterval] ~ {
subj: Set ~ DeRef[set.data.VA];
RETURN subj.GetBounds[want]};
InsulateCopy: PROC [set: Set] RETURNS [VarSet] ~ {
subj: Set ~ DeRef[set.data.VA];
RETURN subj.Copy[]};
InsulateValueOf: PROC [set: Set] RETURNS [ConstSet] ~ {
subj: Set ~ DeRef[set.data.VA];
RETURN subj.ValueOf[]};
InsulateQuaBiRel: PROC [set: Set] RETURNS [found: BOOL, class, data: REF ANY] ~ {
subj: Set ~ DeRef[set.data.VA];
mbr: MaybeBiRel ~ SetQuaBiRel[subj];
IF NOT mbr.found THEN RETURN [FALSE, badBiRel.class, badBiRel.data];
{ibr: BiRel ~ mbr.it.Insulate[];
RETURN [TRUE, ibr.class, ibr.data]}};
InsulateQuaIntInterval: PROC [set: Set] RETURNS [MaybeIntInterval] ~ {
subj: Set ~ DeRef[set.data.VA];
RETURN subj.QuaIntInterval[]};
InsulateSpaceOf: PROC [set: Set] RETURNS [Space] ~ {
subj: Set ~ DeRef[set.data.VA];
RETURN subj.SpaceOf[]};
END.