SaffronContextPrivateTypes:
CEDAR
DEFINITIONS ~ {
OPEN SaffronATDef, SaffronGenericDef;
Cross Module private procedures
GenVisibleNames:
PROC [vn: VisibleNames,
for:
PROC [name: IdNode, access: AccessValNode, value:
REF
ANY] ];
GenRopeNames: PROC [rns: RopeNames,
for: PROC [Rope.ROPE, REF ANY] ];
Environment
EnvironmentNode: TYPE ~ REF EnvironmentNodeBody;
EnvironmentNodeBody:
TYPE ~
RECORD [
interfaces: RopeNames
];
we use the same old data structure, hope to change it at some later date
Interfaces
Interfaces are not InterfaceTGNs. InterfaceTGNs occur inside type graphs, and point out to other contexts. Interfaces occur outside type graphs (and contexts) and point into contexts.
NOTE: We almost had to use proto and frozen interfaces, because we wanted to be able to have more than one module name for an interface. If this were implemented by adding the names one at a time to the interface, this would make the interface a modifiable data structure, which must then be frozen when placed in an environment. However, by using NameSequences (see below), which are built non-destructively, and building the interface directly from a NameSequence and a contextTree, we avoid having malleable interfaces.
InterfaceValNode: TYPE ~ REF InterfaceValNodeBody;
InterfaceValNodeBody:
TYPE ~
RECORD [
moduleNames: NameSequenceNode,
entries: VisibleNames,
ct: ContextTreeNode
];
Context Trees
ContextTreeNode: TYPE ~ REF ContextTreeNodeBody;
ContextTreeNodeBody:
TYPE ~
RECORD [
rib: ContextRibNode,
subTrees: CTCell,
lastSubTree: CTCell
];
CTCell: TYPE ~ REF CTCellBody;
CTCellBody:
TYPE ~
RECORD [
ctn: ContextTreeNode,
next: CTCell
];
Context Ribs
ContextRibNode: TYPE ~ REF ContextRibNodeBody;
ContextRibNodeBody:
TYPE ~
RECORD [
lc: LocalContextNode
];
Local Contexts
LocalContextNode: TYPE ~ REF LocalContextNodeBody;
LocalContextNodeBody:
TYPE ~
RECORD [
frozen: BOOLEAN ← FALSE,
rib: ContextRibNode,
lvtn: VisibleNames,
maxTGNodeIndex: INT ← 0,
bottom: TypeGraphNodeNode ← NIL,
top: TypeGraphNodeNode ← NIL,
paintIndex: INT ← 0,
unpaintedPaint: PaintNode ← NIL,
tgNodes: TypeGraphNodeNode ← NIL,
fieldLists: FrozenFieldListNode ← NIL
];
Locally Visible Names
Very simple for now, just a chained list of IdNodes
VisibleNames: TYPE ~ REF VisibleNamesBody;
VisibleNamesBody:
TYPE ~
RECORD [
first: VNCell
];
VNCell: TYPE ~ REF VNCellBody;
VNCellBody:
TYPE ~
RECORD [
id: IdNode,
access: AccessValNode,
value: REF ANY,
next: VNCell
];
Type Graph Nodes
TypeGraphNodeNode: TYPE ~ REF TypeGraphNodeNodeBody;
TypeGraphNodeNodeBody:
TYPE ~
RECORD [
shown: BOOLEAN, -- used during show routines
index: INT,
localContext: LocalContextNode,
body: REF ANY, -- many different types
next: TypeGraphNodeNode -- tgNodes chain from localContext
];
assorted body types
BaseTypes
BaseTypeTGN: TYPE ~ REF BaseTypeTGNBody;
BaseTypeTGNBody:
TYPE ~
RECORD [
typeName: Rope.ROPE
];
Top and Bottom
SpecialKind: TYPE ~ { bottom, top };
SpecialTGN: TYPE ~ REF SpecialTGNBody;
SpecialTGNBody:
TYPE ~
RECORD [
kind: SpecialKind
];
Named nodes (i.e., locally visible)
NamedTGN: TYPE ~ REF NamedTGNBody;
NamedTGNBody:
TYPE ~
RECORD [
name: IdNode,
access: AccessValNode, -- access is initially Nil
type: TypeGraphNodeNode, -- type is initially Nil
default: DefaultExpNode -- default is initially Nil
];
SubRange Nodes
SubrangeTGN: TYPE ~ REF SubrangeTGNBody;
SubrangeTGNBody:
TYPE ~
RECORD [
subrangeOf: TypeGraphNodeNode,
bounds: BoundsValNode
];
Record nodes
RecordTGN: TYPE ~ REF RecordTGNBody;
RecordTGNBody:
TYPE ~
RECORD [
paint: PaintNode,
machineDependent: BOOLEAN,
monitoredRecord: BOOLEAN,
ffl: FrozenFieldListNode
];
pointer type nodes
PointerTGN: TYPE ~ REF PointerTGNBody;
PointerTGNBody:
TYPE ~
RECORD [
ordered: BOOLEAN,
base: BOOLEAN,
readOnly: BOOLEAN,
bounds: BoundsValNode,
target: TypeGraphNodeNode
];
RefTGN: TYPE ~ REF RefTGNBody;
RefTGNBody:
TYPE ~
RECORD [
machineDependent: BOOLEAN,
target: TypeGraphNodeNode
];
VarTGN: TYPE ~ REF VarTGNBody;
VarTGNBody:
TYPE ~
RECORD [
target: TypeGraphNodeNode
];
base and pointer must both be pointerTGNs, base must have base = true
RelativeTGN: TYPE ~ REF RelativeTGNBody;
RelativeTGNBody:
TYPE ~
RECORD [
base: TypeGraphNodeNode,
pointer: TypeGraphNodeNode
];
refs point to encapsulated types
ReferentTGN: TYPE ~ REF ReferentTGNBody;
ReferentTGNBody:
TYPE ~
RECORD [
contents: TypeGraphNodeNode
];
List nodes
perhaps I could use record type constructors, except they are not set up for making cyclic types directly, and perhaps there are some special semantics associated with list types
ListTGN: TYPE ~ REF ListTGNBody;
ListTGNBody:
TYPE ~
RECORD [
readOnly: BOOLEAN,
first: TypeGraphNodeNode,
rest: ListTGN
];
EnumeratedType Nodes
EnumTGN: TYPE ~ REF EnumTGNBody;
EnumTGNBody:
TYPE ~
RECORD [
machineDependent: BOOLEAN,
paint: PaintNode,
firstElement: EnumElementCell,
lastElement: EnumElementCell
];
EnumElementCell: TYPE ~ REF EnumElementCellBody;
EnumElementCellBody:
TYPE ~
RECORD [
id: IdNode,
rep: ExpPTreeNode,
next: EnumElementCell
];
Field lists and frozen field lists
FieldNode: TYPE ~ REF FieldNodeBody;
FieldNodeBody:
TYPE ~
RECORD [
name: IdNode, -- (for unnamed fields, name = NIL)
pvn: PositionValNode,
avn: AccessValNode,
tgn: TypeGraphNodeNode,
default: DefaultExpNode
];
FieldListNode: TYPE ~ REF FieldListNodeBody;
FieldListNodeBody:
TYPE ~
RECORD [
any: BOOLEAN,
nFields: INT,
nCells: INT,
firstCell: FieldListCell,
lastCell: FieldListCell
];
FieldListCell: TYPE ~ REF FieldListCellBody;
FieldListCellBody:
TYPE ~
RECORD [
item: REF ANY, -- (an item is either a Field or a FrozenFieldList)
next: FieldListCell
];
FrozenFieldListNode: TYPE ~ REF FrozenFieldListNodeBody;
FrozenFieldListNodeBody:
TYPE ~
RECORD [
shown: BOOLEAN, -- used during show
variant: BOOLEAN, -- last field is a variant ffl, or is a variant part TGN
any: BOOLEAN,
nFields: CARDINAL,
next: FrozenFieldListNode,
fields: SEQUENCE nSlots: CARDINAL OF FFLSlot
];
FFLSlot:
TYPE ~
RECORD [
case: FFLCase,
name: IdNode,
pvn: PositionValNode,
avn: AccessValNode,
tgn: TypeGraphNodeNode,
default: DefaultExpNode,
ffl: FrozenFieldListNode
];
FFLCase: TYPE ~ { field, ffl };
VariantPart TGN and Union List
VariantPartTGN: TYPE ~ REF VariantPartTGNBody;
VariantPartTGNBody:
TYPE ~
RECORD [
flavor: VariantFlavorNode,
tagType: TypeGraphNodeNode,
types: FrozenUnionList
];
UnionListNode: TYPE ~ REF UnionListNodeBody;
UnionListNodeBody:
TYPE ~
RECORD [
nCells: CARDINAL,
first: UnionListCell,
last: UnionListCell
];
UnionListCell: TYPE ~ REF UnionListCellBody;
UnionListCellBody:
TYPE ~
RECORD [
id: IdNode,
ffl: FrozenFieldListNode,
next: UnionListCell
];
FrozenUnionList: TYPE ~ REF FrozenUnionListBody;
FrozenUnionListBody:
TYPE ~
RECORD [
data: SEQUENCE nTypes: CARDINAL OF FULSlot
];
FULSlot:
TYPE ~
RECORD [
id: IdNode,
ffl: FrozenFieldListNode
];
Variant Flavors
VariantFlavorNode: TYPE ~ REF VariantFlavorNodeBody;
VariantFlavorNodeBody:
TYPE ~
RECORD [
SELECT flavor: VFlavor
FROM
overlaid => [ ],
computed => [ ],
vanilla => [
id: IdNode,
position: PositionValNode,
access: AccessValNode
],
ENDCASE
];
VFlavor: TYPE ~ { overlaid, computed, vanilla };
Sequence TGNs
SequenceTGN: TYPE ~ REF SequenceTGNBody;
SequenceTGNBody:
TYPE ~
RECORD [
packed: BOOLEAN,
id: IdNode,
position: PositionValNode,
access: AccessValNode,
tagType: TypeGraphNodeNode,
type: TypeGraphNodeNode
];
Array TGN
ArrayTGN: TYPE ~ REF ArrayTGNBody;
ArrayTGNBody:
TYPE ~
RECORD [
packed: BOOLEAN,
indexType: TypeGraphNodeNode,
itemType: TypeGraphNodeNode
];
Descriptor TGN
DescriptorTGN: TYPE ~ REF DescriptorTGNBody;
DescriptorTGNBody:
TYPE ~
RECORD [
readonly: BOOLEAN,
itemType: TypeGraphNodeNode
];
Transfer TGN
TransferTGN: TYPE ~ REF TransferTGNBody;
TransferTGNBody:
TYPE ~
RECORD [
safe: BOOLEAN,
mode: TransferMode,
arguments: FrozenFieldListNode,
results: FrozenFieldListNode
];
TransferMode: TYPE ~ { proc, port, signal, error, process, program };
Zone TGN
ZoneTGN: TYPE ~ REF ZoneTGNBody;
ZoneTGNBody:
TYPE ~
RECORD [
uncounted: BOOLEAN
];
Long TGN
(For now we treat this as a constructor, but we could take it as a parameter during the construction of the underlying type)
(In the world of 16bit words, the underlying type must be a 16bit numerical quantity, a 16bit pointer, or an (array) descriptor. LONG makes it into a 32bit quantity. In other worlds, this may be a no-op, or not, depending.)
LongTGN: TYPE ~ REF LongTGNBody;
LongTGNBody:
TYPE ~
RECORD [
underlyingType: TypeGraphNodeNode
];
Interface TGN
InterfaceTGN: TYPE ~ REF InterfaceTGNBody;
InterfaceTGNBody:
TYPE ~
RECORD [
sharedAccess: BOOLEAN, -- allows access to private items
typeNames: VisibleNames
];
LinkTGN
used to interface between one module and another
LinkTGN: TYPE = REF LinkTGNBody;
LinkTGNBody: TYPE = RECORD[
tgn: TypeGraphNodeNode, -- in target module
if: InterfaceValNode, -- of target module
itemName: IdNode]; -- name of item in interface
Frame TGN
FrameTGN: TYPE ~ REF FrameTGNBody;
FrameTGNBody:
TYPE ~
RECORD [
FrameTGN: REF ANY
];
Specianated TGN
(we are either :
1) specializing a sequence or array of length 0,
2) discriminating a variant,
3) selecting an interface type.)
There is one syntactic case in which we can't tell which until the data structures are completely built. ("foo[red]"), so we use this more general term for now.)
(Dan Swinehart selected the word Specianated, if you can't figure out what this word means, try another field.)
(underlying type must be a variant style record type, a sequence style record type, an array type with empty index domain, or an interface TGN.)
(In the case of a def file TGN we do the appropriate look up, as this case can be distinguished during this construction pass.)
(only one of expParameter and idParam will be non nil)
SpecianatedTGN: TYPE ~ REF SpecianatedTGNBody;
SpecianatedTGNBody:
TYPE ~
RECORD [
expParam: ExpPTreeNode,
idParam: IdNode,
underlyingType: TypeGraphNodeNode
];
Opaque TGNs
OpaqueTGN: TYPE = REF OpaqueTGNBody;
OpaqueTGNBody: TYPE = RECORD[
paint: PaintNode,
optSize: ExpPTreeNode];
Paint nodes
PaintNode: TYPE ~ REF PaintNodeBody;
PaintNodeBody:
TYPE ~
RECORD [
parentlc: LocalContextNode,
index: INT
];
Default Exp Nodes
DefaultExpCase:
TYPE ~ { c1, c2, c3, c4, c5 };
see section 3.3.5 of Mesa manual
DefaultExpNode: TYPE ~ REF DefaultExpNodeBody;
DefaultExpNodeBody:
TYPE ~
RECORD [
case: DefaultExpCase,
exp: ExpPTreeNode
];
position val nodes
PositionValNode: TYPE ~ REF PositionValNodeBody;
PositionValNodeBody:
TYPE ~
RECORD [
index: ExpPTreeNode,
bounds: BoundsValNode
];
bounds val nodes
OpenClosed: TYPE ~ { open, closed };
BoundsValNode: TYPE ~ REF BoundsValNodeBody;
BoundsValNodeBody:
TYPE ~
RECORD [
left: OpenClosed,
first: ExpPTreeNode,
last: ExpPTreeNode,
right: OpenClosed
]; -- what about closed and open end points?
access val nodes
AccessValNode: TYPE ~ REF AccessValNodeBody;
AccessValNodeBody: TYPE ~ AccessValSet;
AccessValSet: TYPE ~ { empty, private, public, noOneShouldBeChecking, NotSureWhatItShouldBe };
ExpPTree
I can't remember why these boxes are needed (ExpPTree, ScopePTree, ...). Perhaps it is a flaw in the current version of ThreeCasabaFour.
ExpPTreeNode: TYPE ~ REF ExpPTreeNodeBody;
ExpPTreeNodeBody:
TYPE ~
RECORD [
node: ExpNode
];
ScopePTree
ScopePTreeNode: TYPE ~ REF ScopePTreeNodeBody;
ScopePTreeNodeBody:
TYPE ~
RECORD [
node: ScopeNode
];
ModulePPTreeNode
ModulePPTreeNode: TYPE ~ REF ModulePPTreeNodeBody;
ModulePPTreeNodeBody:
TYPE ~
RECORD [
node: ModulePNode
];
DefBodyPTreeNode
DefBodyPTreeNode: TYPE ~ REF DefBodyPTreeNodeBody;
DefBodyPTreeNodeBody:
TYPE ~
RECORD [
node: DefBodyNode
];
NameSequence
NameSequenceNode: TYPE = REF NameSequenceNodeBody;
NameSequenceNodeBody: TYPE = LIST OF IdNode;
RopeNames
RopeNames: TYPE = REF RopeNamesBody;
RopeNamesBody: TYPE = RECORD[
first: RNCell];
RNCell: TYPE = REF RNCellBody; RNCellBody: TYPE = RECORD[
name: Rope.ROPE, value: REF ANY, next: RNCell];
}.