SiroccoGraphObjectsImpl.Mesa
Copyright Ó 1986, 1987 by Xerox Corporation. All rights reserved.
Bhargava, August 9, 1986 2:56:46 pm PDT
Demers, December 29, 1986 9:48:13 pm PST
Bill Jackson (bj) August 27, 1987 0:51:34 am PDT
DIRECTORY
RefTab USING [ Create, Ref ],
Rope USING [ ROPE ],
SiroccoBaseDef USING [ ItemFromContext ],
SiroccoCGDef USING [ BaseTypeKind, Generic, ItemKind, ValueKind ],
SiroccoPrivate USING [ AbstractValue, AbstractValueObject, CONTEXT, GraphRep, ITEM, ItemRep, NodeRep, TypeGraph, TypeGraphNode ],
SiroccoPrivateTypes;
SiroccoGraphObjectsImpl: CEDAR PROGRAM
IMPORTS SiroccoBaseDef, RefTab
EXPORTS SiroccoBaseDef ~ {
OPEN SiroccoBaseDef, SiroccoCGDef, SiroccoPrivate, SiroccoPrivateTypes;
ROPE: TYPE ~ Rope.ROPE;
Type Graph/Node Creators
internal for now!
MakeItem: PUBLIC PROC [ name: ROPE, position: INT, kind: SiroccoCGDef.ItemKind ]
RETURNS [ item: ITEMNIL ] ~ {
type: TypeGraphNode ~ NEW [NodeRep ← [specifics: NIL]];
value: AbstractValue ~ CreateIndirectAVN[NIL];
item ← NEW [ItemRep ←
[ name: name, position: position, kind: kind, type: type, value: value, state: unvisited ]];
};
Primitive Creators
CreateEmptyTGN: PUBLIC PROC [ context: CONTEXT ]
RETURNS [ new: TypeGraph ← NIL ] ~ {
reftab: RefTab.Ref ~ RefTab.Create[];
new ← NEW [GraphRep ← [context: context, reftab: reftab]];
};
CreatePrimitiveTGN: PUBLIC PROC [ class: Generic ]
RETURNS [ node: TypeGraphNode ← NIL ] ~ {
node ← NEW [NodeRep ← [class: class] ];
};
Primary Creators
CreateArrayTGN: PUBLIC PROC [ length: AbstractValue, subtype: TypeGraphNode ] RETURNS [ node: TypeGraphNode ← NIL ] ~ {
atgn: ArrayTGN ~ NEW [ArrayTGNBody ← [length: length, itemType: subtype]];
node ← atgn;
};
CreateBaseTypeTGN: PUBLIC PROC [ kind: BaseTypeKind ]
RETURNS [ node: TypeGraphNode ← NIL ] ~ {
btgn: BaseTypeTGN ~ NEW [BaseTypeTGNBody ← [type: kind]];
node ← btgn;
};
CreateChoiceTGN: PUBLIC PROC [ ktype: TypeGraphNode, union: TypeGraphNode]
RETURNS [ node: TypeGraphNode ← NIL ] ~ {
ctgn: ChoiceTGN ~ NEW [ChoiceTGNBody ← [ktype: ktype, union: union]];
node ← ctgn;
};
CreateDerefTGN: PUBLIC PROC [ context: CONTEXT, item: ROPE ]
RETURNS [ node: TypeGraphNode ← NIL ] ~ {
referent: TypeGraphNode ~ ItemFromContext[context, item].type;
tgn: DerefTGN ~ NEW [DerefTGNBody ← [item: item, type: referent]];
node ← tgn;
};
CreateEnumerationTGN: PUBLIC PROC [ enum: TypeGraphNode ]
RETURNS [ node: TypeGraphNode ← NIL ] ~ {
etgn: EnumTGN ~ NEW [EnumTGNBody ← [enum: enum]];
node ← etgn;
};
CreateErrorTGN: PUBLIC PROC [ fieldlist: TypeGraphNode ]
RETURNS [ node: TypeGraphNode ← NIL ] ~ {
etgn: ErrorTGN ~ NEW [ErrorTGNBody ← [fieldlist: fieldlist]];
node ← etgn
};
CreateLinkTGN: PUBLIC PROC [ context: CONTEXT, interface: ROPE, item: ROPE ]
RETURNS [ node: TypeGraphNode ← NIL ] ~ {
imports: CONTEXT ~ context; -- RemoteContext[context, interface];
referent: TypeGraphNode ~ ItemFromContext[imports, item].type;
tgn: LinkTGN ~ NEW [LinkTGNBody ← [tgn: referent, interface: interface, item: item]];
node ← tgn;
};
CreateProcTGN: PUBLIC PROC [ args: TypeGraphNode, results: TypeGraphNode,
errors: TypeGraphNode ] RETURNS [ node: TypeGraphNode ← NIL ] ~ {
ptgn: ProcTGN ~ NEW [ProcTGNBody ← [args: args, results: results, errors: errors]];
node ← ptgn;
};
CreateRecordTGN: PUBLIC PROC [ fieldlist: TypeGraphNode ]
RETURNS [ node: TypeGraphNode ← NIL ] ~ {
rtgn: RecordTGN ~ NEW [RecordTGNBody ← [fieldlist: fieldlist]];
node ← rtgn;
};
CreateSequenceTGN: PUBLIC PROC [ maxlength: AbstractValue,
subtype: TypeGraphNode ] RETURNS [ node: TypeGraphNode ← NIL ] ~ {
stgn: SequenceTGN ~ NEW [SequenceTGNBody ← [maxlength: maxlength,
subtype: subtype]];
node ← stgn;
};
Secondary Creators
CreateFieldListTGN: PUBLIC PROC [ tag: ROPE, ordinal: AbstractValue ]
RETURNS [ node: TypeGraphNode ← NIL ] ~ {
fltgn: FieldListTGN ~ NEW [FieldListTGNBody ← [tag: tag, ordinal: ordinal]];
node ← fltgn;
};
CreateUnionTGN: PUBLIC PROC [ namelist: TypeGraphNode, type: TypeGraphNode ]
RETURNS [ node: TypeGraphNode ← NIL ] ~ {
utgn: UnionTGN ~ NEW [UnionTGNBody ← [namelist: namelist, type: type]];
node ← utgn;
};
CreateFieldTGN: PUBLIC PROC [ namelist: TypeGraphNode, type: TypeGraphNode ]
RETURNS [ node: TypeGraphNode ← NIL ] ~ {
ftgn: FieldTGN ~ NEW [FieldTGNBody ← [namelist: namelist, type: type]];
node ← ftgn;
};
CreateEmptyFieldTGN: PUBLIC PROC [ ]
RETURNS [ node: TypeGraphNode ← NIL ] ~ {
node ← CreateFieldTGN[NIL, NIL];
};
Concatination operators
FieldListTGNConcat: PUBLIC PROC [ value: TypeGraphNode, next: TypeGraphNode ]
RETURNS [ node: TypeGraphNode ← NIL ] ~ {
tgn: HackTGN ~ NEW [HackTGNBody ← [value: value, next: next]];
node ← tgn;
};
UnionTGNConcat: PUBLIC PROC [ value: TypeGraphNode, next: TypeGraphNode ]
RETURNS [ node: TypeGraphNode ← NIL ] ~ {
tgn: HackTGN ~ NEW [HackTGNBody ← [value: value, next: next]];
node ← tgn;
};
FieldTGNConcat: PUBLIC PROC [ value: TypeGraphNode, next: TypeGraphNode ]
RETURNS [ node: TypeGraphNode ← NIL ] ~ {
tgn: HackTGN ~ NEW [HackTGNBody ← [value: value, next: next]];
node ← tgn;
};
Abstract Value Node Creators
internal for now!
CreateIndirectAVN: PUBLIC PROC [ specifics: REF ]
RETURNS [ value: AbstractValue ← NIL ] ~ {
new: REF AbstractValueObject ~ NEW [AbstractValueObject ←
[ kind: indirect, specifics: specifics ]];
value ← new;
};
Primary Creators
CreateNullAVN: PUBLIC PROC [ ]
RETURNS [ value: AbstractValue ← NIL ] ~ {
};
CreateLogicalAVN: PUBLIC PROC [ b: BOOLEAN ]
RETURNS [ value: AbstractValue ← NIL ] ~ {
avn: LogicalAVN ~ NEW [LogicalAVNBody ← [value: b]];
value ← avn;
};
CreateNumericalAVN: PUBLIC PROC [ num: CARD ]
RETURNS [ value: AbstractValue ← NIL ] ~ {
avn: NumericalAVN ~ NEW [NumericalAVNBody ←
[inverted: FALSE, value: num]];
value ← avn;
};
CreateRopeAVN: PUBLIC PROC [ r1: ROPE ]
RETURNS [ value: AbstractValue ← NIL ] ~ {
avn: RopeAVN ~ NEW [RopeAVNBody ← [value: r1]];
value ← avn;
};
Secondary Creators
CreateBindingAVN: PUBLIC PROC [ tgn: TypeGraphNode, node: AbstractValue ]
RETURNS [ value: AbstractValue ← NIL ] ~ {
avn: BindingAVN ~ NEW [BindingAVNBody ←
[ tgn: tgn, node: node ]];
value ← avn;
};
CreateConstructorAVN: PUBLIC PROC [ node: AbstractValue ]
RETURNS [ value: AbstractValue ← NIL ] ~ {
avn: ConstructorAVN ~ NEW [ConstructorAVNBody ← [ node: node ]];
value ← avn;
};
CreateDerefAVN: PUBLIC PROC [ context: CONTEXT, item: ROPE ]
RETURNS [ value: AbstractValue ← NIL ] ~ {
referent: AbstractValue ~ ItemFromContext[context, item].value;
avn: DerefAVN ~ NEW [DerefAVNBody ← [item: item, value: referent]];
value ← avn;
};
CreateGroupingAVN: PUBLIC PROC [ node: AbstractValue ]
RETURNS [ value: AbstractValue ← NIL ] ~ {
avn: GroupingAVN ~ NEW [GroupingAVNBody ← [ node: node ]];
value ← avn;
};
CreateLinkAVN: PUBLIC PROC [ context: CONTEXT, interface: ROPE, item: ROPE ]
RETURNS [ value: AbstractValue ← NIL ] ~ {
imports: CONTEXT ~ context; -- RemoteContext[context, interface];
referent: AbstractValue ~ ItemFromContext[imports, item].value;
avn: LinkAVN ~ NEW [LinkAVNBody ← [avn: referent, interface: interface, item: item]];
value ← avn;
};
CreateNegativeAVN: PUBLIC PROC [ old: AbstractValue ]
RETURNS [ value: AbstractValue ← NIL ] ~ {
child: NumericalAVN ~ NARROW[old];
avn: NumericalAVN ~ NEW [NumericalAVNBody ←
[inverted: ( NOT child.inverted ), value: child.value]];
value ← avn;
};
CreateVariantAVN: PUBLIC PROC [ id: ROPE, node: AbstractValue ]
RETURNS [ value: AbstractValue ← NIL ] ~ {
avn: VariantAVN ~ NEW [VariantAVNBody ← [ id: id, node: node ]];
value ← avn;
};
ConstructorAVNConcat: PUBLIC PROC [ value: AbstractValue, next: AbstractValue ]
RETURNS [ node: AbstractValue ← NIL ] ~ {
tgn: HackAVN ~ NEW [HackAVNBody ← [value: value, next: next]];
node ← tgn;
};
GroupingAVNConcat: PUBLIC PROC [ value: AbstractValue, next: AbstractValue ]
RETURNS [ node: AbstractValue ← NIL ] ~ {
tgn: HackAVN ~ NEW [HackAVNBody ← [value: value, next: next]];
node ← tgn;
};
Error Handling
Something: SIGNAL ~ CODE;
UndefinedSymbol: PROC [ name: ROPE ] ~ {
SIGNAL Something;
};
}.