SaffronBaseDecls.ThreeC4
Copyright Ó 1987 by Xerox Corporation. All rights reserved.
Shoup, August 8, 1986 5:53:23 pm PDT
Bill Jackson (bj) April 27, 1987 3:45:56 pm PDT
Lucy Hederman August 17, 1987 2:54:00 pm PDT
Sturgis, July 21, 1987 3:19:59 pm PDT
SaffronGeneric: Module = Begin
GenericToken
Decimalnum: GenericToken = "tokenDECIMAL";
Octalnum: GenericToken = "tokenOCTAL";
Hexnum: GenericToken = "tokenHEX";
Id: GenericToken = "tokenID";
String: GenericToken = "tokenROPE";
Flnum: GenericToken = "tokenREAL";
Char: GenericToken = "tokenCHAR";
Atom: GenericToken = "tokenATOM";
End;
SaffronBase: Module = Begin
BOOLEAN: CedarType;
INT: CedarType;
ROPE: CedarType From Rope;
STREAM: CedarType From IO;
Misc
True: BaseFunction [] Returns [BOOLEAN];
False: BaseFunction [] Returns [BOOLEAN];
Error: BaseFunction [ROPE] Returns [BOOLEAN];
NullId: BaseFunction [] Returns [Id];
RopeFromId:
BaseFunction [Id]
Returns [ROPE];
RopeFromString:
BaseFunction [String]
Returns [ROPE];
ExpPTrees are used to bundle up Exps from the Abstract parse tree so that they can be passed around.
ExpPTree: BaseType;
NullExpPTree: BaseFunction [] Returns [ExpPTree];
ScopePTrees are used to bundle up Scopes from the Abstract parse tree so that they can be passed around.
ScopePTree: BaseType;
ModulePPTree:  BaseType;
ReadDefFile:
BaseFunction [ROPE]
Returns [ModulePPTree];
DefBodyPTree:  BaseType;
Environment
Environment: BaseType;
FakeDamageEnvironment:
BaseFunction [Environment.arg]
Returns [Environment.res]
DamagedReps [Environment.arg];
CreateEmptyEnvironment:
BaseFunction []
Returns [Environment];
AddInterfaceToEnvironment:
BaseFunction [Environment.arg, ROPE, InterfaceVal]
Returns [Environment.res]
DamagedReps [Environment.arg];
LookupInterfaceInEnv:
BaseFunction [Environment, ROPE]
Returns [InterfaceVal];
IsInterfaceInEnv:
BaseFunction [Environment, ROPE]
Returns [BOOLEAN];
Interfaces
InterfaceVal: BaseType;
CreateInterfaceFromContextTree:
BaseFunction [ContextTree, NameSequence]
Returns [InterfaceVal];
LookupInterfaceEntry:
BaseFunction [InterfaceVal, Id]
Returns [AccessVal, TypeGraphNode];
CreateEmptyInterfaceTGN:
BaseFunction [LocalContext.arg]
Returns [LocalContext.res, TypeGraphNode]
DamagedReps [ LocalContext.arg ];
CreateLinkTGN:
BaseFunction [LocalContext.arg, TypeGraphNode.entry, InterfaceVal, Id]
Returns [LocalContext.res, TypeGraphNode.link]
DamagedReps [ LocalContext.arg ];
AddTGNToInterfaceTGN:
BaseFunction [LocalContext.arg, TypeGraphNode.interface, Id, AccessVal, TypeGraphNode.entry]
Returns [LocalContext.res]
DamagedReps [ LocalContext.arg ];
CreateInterfaceTGNFromInterface:
BaseFunction [LocalContext.arg, InterfaceVal]
Returns [LocalContext.res, TypeGraphNode]
DamagedReps [LocalContext.arg ];
I will have to use this function at some point
LookupTypeNameInInterfaceTGN:
BaseFunction [LocalContext, Id, TypeGraphNode.interface ]
Returns [TypeGraphNode.res];
Next two functions used for Open (BindList)
RenameInterface:
BaseFunction [LocalContext.arg, Id, TypeGraphNode.interface]
Returns [ LocalContext.res ]
DamagedReps[ LocalContext.arg ];
OpenInterface:
BaseFunction [LocalContext.arg, TypeGraphNode.interface]
Returns [ LocalContext.res ]
DamagedReps[ LocalContext.arg ];
Context
A LocalContext is a mathematical structure. It has a universe of nodes of varying types. In the mathematical world, the recursion equations define a specific representative of the isomorphism class of that mathematical structure. The universe of that representative consists of some subset of the integers. In the implementation to be constructed here, the "index" field of a node contains the node value to be used in the mathematical world. i.e., if n is a node representation, ER(n) is simply n.index and F(n) = n.index.
We assume that when an operation on a LocalContext, lc, involves nodes of that structure, these will be nodes within ER(lc). The implementation checks for this. The key reason that this works is that under these conditions, the rest of the body of n is in the ER(lc), even though not in ER(n). This requires a slight modification to the assumptions in the paper. In particular, definition 7.3 makes too strong a requirement. The conclusions of def 7.3 need only follow for some recursion equations, not all. Exactly how to state this I have not yet figured out. I will write a more detailed justification later.
Notice that we assume ER(n) is unmodifiable, thus there is no sharing between n and its containing LocalContext.
In addition, we remark that one need not actually include the index field in the implementation, or the checks. Presumably one has proven that for all reachable configurations the check will succeed, hence one need not perform it. Second, the code never looks at the index field, hence if the field is removed then the resulting computation will be isomorphic to a computation including the index field. Hence, the resulting LocalContext representation will be isomorphic to the representation of the computation that includes the field, hence isomorphic to the result in the mathematical world.
WARNING: All of the above leads to the following remarks. Some of the mathematical values below are represented by a rather indirect means, namely a pointer to a record with a field containing the value. (Or without the field...) Other mathematical values are reprsenented by large data structures that include some of the records just described. Whenever an operation is to be performed on more than one mathematical value, where the representations have this form, then one must always be sure that all the records involved belong to the same large data structure.
ContextRib
ContextRib: BaseType;
RootContextRib:
BaseFunction [ ]
Returns [ ContextRib ];
LocalContext
LocalContext: BaseType;
CreateEmptyContext:
BaseFunction [ ContextRib ]
Returns [ LocalContext ];
FreezeLocalContext:
BaseFunction [ LocalContext ]
Returns [ ContextRib ]
DamagedReps [ LocalContext ];
FakeDamageContext:
BaseFunction [ LocalContext.arg ]
Returns [ LocalContext.res ]
DamagedReps [ LocalContext.arg ];
ContextTree
ContextTree: BaseType;
EmptyContextTree:
BaseFunction [ ContextRib ]
Returns [ ContextTree ];
AddSubContextTree:
BaseFunction [ ContextTree.tree, ContextTree.subtree ]
Returns [ContextTree]
DamagedReps [ContextTree.tree];
FakeDamageContextTree:
BaseFunction [ ContextTree.arg ]
Returns [ ContextTree.res ]
DamagedReps [ContextTree.arg];
TypeGraphNode
TypeGraphNode: BaseType;
FindBottomTGN:
BaseFunction [ LocalContext ]
Returns [ TypeGraphNode ];
FindTopTGN:
BaseFunction [ LocalContext ]
Returns [ TypeGraphNode ];
FindLocallyVisibleTGN:
BaseFunction [ LocalContext, Id ]
Returns [ TypeGraphNode ];
CreateLocallyVisibleTGN:
BaseFunction [ LocalContext.arg, Id, AccessVal ]
Returns [ LocalContext.res, TypeGraphNode ]
DamagedReps[ LocalContext.arg ];
AddArcFromLVTGNToTGN:
BaseFunction [ LocalContext.arg, TypeGraphNode.from, AccessVal, TypeGraphNode.to, DefaultExp ]
Returns [ LocalContext.res ]
DamagedReps[ LocalContext.arg ];
CreateRecordTGN:
BaseFunction [ LocalContext.arg, Paint, BOOLEAN.machineDependent, BOOLEAN.monitored, FrozenFieldList ]
Returns [ LocalContext.res, TypeGraphNode ]
DamagedReps[ LocalContext.arg ];
CreateRefTGN:
BaseFunction [ LocalContext.arg, BOOLEAN.machineDependent, TypeGraphNode.referent ]
Returns [ LocalContext.res, TypeGraphNode.ref ]
DamagedReps[ LocalContext.arg ];
CreateEmptyEnumTypeTGN:
BaseFunction [ LocalContext.arg, BOOLEAN.machineDependent ]
Returns [ LocalContext.res, TypeGraphNode ]
DamagedReps[ LocalContext.arg ];
AppendElementToEnumTypeTGN:
BaseFunction [ LocalContext.arg, TypeGraphNode, Id, ExpPTree ]
Returns [ LocalContext.res ]
DamagedReps[ LocalContext.arg ];
CreateVariantPartTGN:
BaseFunction [LocalContext.arg, VariantFlavor, TypeGraphNode.tag, UnionList]
Returns [ LocalContext.res, TypeGraphNode.var ]
DamagedReps[ LocalContext.arg, UnionList ];
CreateSequenceTGN:
BaseFunction [ LocalContext.arg, BOOLEAN, Id, PositionVal, AccessVal, TypeGraphNode.tag, TypeGraphNode.component]
Returns [ LocalContext.res, TypeGraphNode.sequence ]
DamagedReps[ LocalContext.arg ];
CreateSubrangeTGN:
BaseFunction [ LocalContext.arg, TypeGraphNode.typeId, BoundsVal]
Returns [ LocalContext.res, TypeGraphNode.res ]
DamagedReps[ LocalContext.arg ];
CreatePointerTGN:
BaseFunction [ LocalContext.arg, BOOLEAN.ordered, BOOLEAN.base, BoundsVal, BOOLEAN.readonly, TypeGraphNode.arg ]
Returns [ LocalContext.res, TypeGraphNode.res]
DamagedReps[ LocalContext.arg ];
CreateVarTGN:
BaseFunction [ LocalContext.arg, TypeGraphNode.arg ]
Returns [ LocalContext.res, TypeGraphNode.res ]
DamagedReps[ LocalContext.arg ];
CreateListTGN:
BaseFunction [ LocalContext.arg, BOOLEAN.readonly, TypeGraphNode.arg ]
Returns [ LocalContext.res, TypeGraphNode.res ]
DamagedReps[ LocalContext.arg ];
CreateArrayTGN:
BaseFunction [ LocalContext.arg, BOOLEAN.packed, TypeGraphNode.index, TypeGraphNode.item]
Returns [ LocalContext.res, TypeGraphNode.res ]
DamagedReps[ LocalContext.arg ];
CreateDescriptorTGN:
BaseFunction [ LocalContext.arg, BOOLEAN.readonly, TypeGraphNode.arg]
Returns [ LocalContext.res, TypeGraphNode.res ]
DamagedReps[ LocalContext.arg ];
CreateTransferTGN:
BaseFunction [ LocalContext.arg, BOOLEAN.safe, ROPE.transferMode, FrozenFieldList.input, FrozenFieldList.output]
Returns [ LocalContext.res, TypeGraphNode ]
DamagedReps[ LocalContext.arg ];
CreateRelativeTGN:
BaseFunction [ LocalContext.arg, TypeGraphNode.base, TypeGraphNode.arg]
Returns [ LocalContext.res, TypeGraphNode.res ]
DamagedReps[ LocalContext.arg ];
CreateZoneTGN:
BaseFunction [ LocalContext.arg, BOOLEAN.uncounted]
Returns [ LocalContext.res, TypeGraphNode ]
DamagedReps[ LocalContext.arg ];
CreateLongTGN:
BaseFunction [ LocalContext.arg, TypeGraphNode.arg]
Returns [ LocalContext.res, TypeGraphNode.res ]
DamagedReps[ LocalContext.arg ];
FindFrameTGN:
BaseFunction [ LocalContext, Id]
Returns [ TypeGraphNode ];
CreateSpecianatedTGNUsingExp:
BaseFunction [ LocalContext.arg, TypeGraphNode.underlyingType, ExpPTree]
Returns [ LocalContext.res, TypeGraphNode.res ]
DamagedReps[ LocalContext.arg ];
CreateSpecianatedTGNUsingId:
BaseFunction [ LocalContext.arg, TypeGraphNode.underlyingType, Id]
Returns [ LocalContext.res, TypeGraphNode.res ]
DamagedReps[ LocalContext.arg ];
CreateOpaqueTGN:
BaseFunction [LocalContext.arg, Paint, ExpPTree]
Returns [ LocalContext.res, TypeGraphNode.res ]
DamagedReps[ LocalContext.arg ];
Fields and FieldLists
Field: BaseType;
FieldList: BaseType;
FrozenFieldList: BaseType;
AnyFieldList:
BaseFunction [ ]
Returns [ FieldList ];
CreateNamedField:
BaseFunction [ Id, PositionVal, AccessVal, TypeGraphNode, DefaultExp ]
Returns [ Field ];
CreateUnnamedField:
BaseFunction [ TypeGraphNode, DefaultExp ]
Returns [ Field ];
CreateEmptyFieldList:
BaseFunction [ ]
Returns [ FieldList ];
AppendFieldToFieldList:
BaseFunction [FieldList.arg, Field ]
Returns [ FieldList.res ]
DamagedReps[ FieldList.arg ];
FreezeFieldList:
BaseFunction [LocalContext.arg, FieldList ]
Returns [ LocalContext.res, FrozenFieldList ]
DamagedReps[ LocalContext.arg, FieldList ];
Variant Parts and Unions
UnionList: BaseType;
CreateEmptyUnionList:
BaseFunction [ ]
Returns [ UnionList ];
AppendToUnionList:
BaseFunction [UnionList.arg, Id, FrozenFieldList ]
Returns [ UnionList.res ]
DamagedReps[ UnionList.arg ];
VariantFlavor: BaseType;
OverlaidVariantFlavorConst:
BaseFunction [ ]
Returns [ VariantFlavor ];
ComputedVariantFlavorConst:
BaseFunction [ ]
Returns [ VariantFlavor ];
VanillaVariantFlavorVal:
BaseFunction [Id, PositionVal, AccessVal]
Returns [ VariantFlavor ];
Paint
Paint: BaseType;
GetUnpaintedPaint:
BaseFunction [ LocalContext.arg ]
Returns [ LocalContext.res, Paint ]
DamagedReps[ LocalContext.arg ];
GetUniquePaint:
BaseFunction [ LocalContext.arg ]
Returns [ LocalContext.res, Paint ]
DamagedReps[ LocalContext.arg ];
(doesn't really damage LocalContext.arg, but makes for easier writing of some function bodies, e.g., MakeType)
Bounds
BoundsVal: BaseType;
NullBounds:
BaseFunction [ ]
Returns [ BoundsVal ];
BoundsValFun:
BaseFunction [ ROPE.leftparen, ExpPTree.lower, ExpPTree.upper, ROPE.rightparen]
Returns [ BoundsVal ];
The ROPEs are the parens : "[" or "(" and "]" or ")"
Position
PositionVal: BaseType;
NullPosition:
BaseFunction [ ]
Returns [ PositionVal ];
PositionValFun:
BaseFunction [ ExpPTree, BoundsVal]
Returns [ PositionVal ];
Access
AccessVal: BaseType;
AccessValConst:
BaseFunction [ ROPE ]
Returns [ AccessVal ];
NullAccessVal:
BaseFunction []
Returns [ AccessVal ];
Default
DefaultExp: BaseType;
DefaultExpVal:
BaseFunction [ROPE.case, ExpPTree]
Returns [DefaultExp];
case indicates which type of default is specified - "","←","𡤎","←TRASH","𡤎|TRASH" - see Mesa manual 3.25
NullDefaultVal:
BaseFunction []
Returns [DefaultExp];
NameSequence
NameSequence: BaseType;
EmptyNameSequence:
BaseFunction []
Returns [NameSequence];
InsertNameOnNameSequence:
BaseFunction [Id, NameSequence.arg]
Returns [NameSequence.res]
DamagedReps [NameSequence.arg];
End.
eof...