SaffronContextPrivateTypes.Mesa
Copyright Ó 1987 by Xerox Corporation. All rights reserved.
Sturgis, July 15, 1987 12:56:40 pm PDT
Bill Jackson (bj) August 12, 1987 4:50:05 pm PDT
James Rauen, July 16, 1988 2:33:27 pm PDT
Last edited by: James Rauen August 25, 1988 4:17:24 pm PDT
DIRECTORY
BigCardinals USING [BigCARD],
BigIntegers USING [BigINT],
Rope USING [ ROPE ],
SaffronATDef USING [ DeclarationNode, DefBodyNode, ExpNode, InitializationNode, ModulePNode, ScopeNode, TypeExpNode ],
SaffronBaseDef USING [ProcedureGraphNode, ProgramFragmentNode, ProgramGraphNode],
SaffronContext USING [ ],
SaffronGenericDef USING [ IdNode ];
SaffronContextPrivateTypes:
CEDAR
DEFINITIONS = {
OPEN AT: SaffronATDef, BD: SaffronBaseDef, GEN: SaffronGenericDef;
Cross Module private procedures
TypeProc: TYPE = PROC [name: GEN.IdNode, access: AccessValNode, type: TypeGraphNodeNode, default: DefaultExpNode];
ConstantProc: TYPE = PROC [name: GEN.IdNode, access: AccessValNode, type: TypeGraphNodeNode, value: ValueNode];
VarProc: TYPE = PROC [name: GEN.IdNode, access: AccessValNode, type: TypeGraphNodeNode, default: DefaultExpNode];
MapOntoFields: PROC [fields: FieldListNode, typeProc: TypeProc, constantProc: ConstantProc, varProc: VarProc];
GenRopeNames: PROC [rns: RopeNames,
for: PROC [Rope.ROPE, REF ANY] ];
MapOntoLocalNames: PROC [vn: VisibleNames, typeProc: TypeProc, constantProc: ConstantProc, varProc: VarProc];
MapOntoAllVisibleNames: PROC [vn: VisibleNames, typeProc: TypeProc, constantProc: ConstantProc, varProc: VarProc];
GenVisibleNames: PROC [vn: VisibleNames,
for: PROC [name: GEN.IdNode, access: AccessValNode, value: REF ANY] ];
Environments
An Environment accumulates all the definitions files which (recursively) appear in the directory of the main file. There is a cell in the environment for each such file; this cell maps the file's name to its context tree. There is also a field in the Environment for the context tree of the main file.
EnvironmentNode: TYPE = REF EnvironmentNodeBody;
EnvironmentNodeBody:
TYPE =
RECORD [
mainFileName: Rope.ROPE,
mainContextTree: ContextTreeNode,
firstIncludedFile: IncludedFileCell,
lastIncludedFile: IncludedFileCell
];
IncludedFileCell: TYPE = REF IncludedFileCellBody;
IncludedFileCellBody:
TYPE =
RECORD [
fileName: Rope.ROPE,
next: IncludedFileCell,
contextTree: ContextTreeNode,
c:
SELECT kind: *
FROM
definitions => [],
implementation => [code: BD.ProgramGraphNode],
ENDCASE
];
Context Trees
Context Trees
ContextTreeNode: TYPE = REF ContextTreeNodeBody;
ContextTreeNodeBody:
TYPE =
RECORD [
firstSubTree: CTCell,
lastSubTree: CTCell,
rib: ContextRibNode
];
CTCell: TYPE = REF CTCellBody;
CTCellBody:
TYPE =
RECORD [
ctn: ContextTreeNode,
next: CTCell
];
Context Ribs
ContextRibNode: TYPE = REF ContextRibNodeBody;
ContextRibNodeBody:
TYPE =
RECORD [
lc: LocalContextNode
];
Local Contexts
A local context represents a particular scope (containing declarations and, perhaps, code) in a Cedar program.
LocalContextNode: TYPE = REF LocalContextNodeBody;
LocalContextNodeBody:
TYPE =
RECORD [
parentRib: ContextRibNode,
nestingDepthInFrame: INT ← TRASH, -- 0 = base context for frame, 1 = nested 1 deep, etc.
contents: LocalContextContents,
fields: FieldListNode,
maxTGNodeIndex: INT ← 0,
paintIndex: INT ← 0,
unpaintedPaint: PaintNode ← NIL,
tgNodes: TypeGraphNodeNode ← NIL,
dependencyGraph: DependencyGraphNode
];
LocalContextContents: TYPE = REF LocalContextContentsBody;
LocalContextContentsBody:
TYPE =
RECORD [
foo:
SELECT status: *
FROM
unfrozen => [],
frozen => [block: TypeGraphNodeNode] -- must be a block tgn or module tgn
ENDCASE
];
Type Graph Nodes
TypeGraphNodeListNode: TYPE = REF TypeGraphNodeListNodeBody;
TypeGraphNodeListNodeBody: TYPE = LIST OF TypeGraphNodeNode;
TypeGraphNodeNode: TYPE = REF TypeGraphNodeNodeBody;
TypeGraphNodeNodeBody:
TYPE =
RECORD [
shown: BOOLEAN, -- used during show routines
index: INT,
localContext: LocalContextNode,
next: TypeGraphNodeNode, -- tgNodes chain from localContext
body: REF ANY
];
Values
ValueNode: TYPE = REF ValueNodeBody;
StaticValueNode: TYPE = REF static ValueNodeBody;
ValueNodeBody:
TYPE =
RECORD [
k:
SELECT kind: *
FROM
dummy => [info: Rope.ROPE],
unparsed => [parseTree: AT.ExpNode],
defaultMe => [],
static => [code: BD.ProgramFragmentNode, type: TypeGraphNodeNode, body: REF ANY],
trash => [code: BD.ProgramFragmentNode, type: TypeGraphNodeNode],
runtime => [code: BD.ProgramFragmentNode, type: TypeGraphNodeNode],
ENDCASE
];
body must be one of the ...Val's defined below.
Specific Types and Values
Following are the definitions of the variant parts of TypeGraphNodeNodes and ValueNodes. Note that the variant part of every ValueNode contains a field pointing to the value's type...this is necessary for implementing the valueType[] function.
Array
ArrayTGN: TYPE = REF ArrayTGNBody;
ArrayTGNBody:
TYPE =
RECORD [
packed: BOOLEAN,
indexType: TypeGraphNodeNode, -- must be element type
itemType: TypeGraphNodeNode
];
ArrayVal: TYPE = REF ArrayValBody;
ArrayValBody:
TYPE =
RECORD [
indices: StaticValueNode, -- type must be type.body.indexType
items: LIST OF StaticValueNode
];
type must be array type
Invariants: If v: ArrayVal, then
length[v.items] = numberOfElements[v.type.body.index]
& for all e v.items,
equivalent[valueType[e], v.type.body.itemType]
Atom
AtomTGN: TYPE = REF AtomTGNBody;
AtomTGNBody: TYPE = RECORD[];
AtomVal: TYPE = REF AtomValBody;
AtomValBody:
TYPE =
RECORD [
name: Rope.ROPE
];
Block
BlockTGN: TYPE = REF BlockTGNBody;
BlockTGNBody:
TYPE =
RECORD [
ffl: FrozenFieldListNode
];
BlockVal: TYPE = REF BlockValBody;
BlockValBody:
TYPE =
RECORD [
code: BD.ProgramFragmentNode
];
Since exactly one instance of each block type is created, we can use one structure (a FrozenFieldListNode) to represent both the type and the value.
Condition **
ConditionTGN: TYPE = REF ConditionTGNBody;
ConditionTGNBody: TYPE = RECORD[];
No ConditionVal.
Descriptor **
DescriptorTGN: TYPE = REF DescriptorTGNBody;
DescriptorTGNBody:
TYPE =
RECORD [
readonly: BOOLEAN,
itemType: TypeGraphNodeNode
];
Help! I don't know what this is!
Element
Discussion
Element types are defined in section 3.1 of the Mesa manual. Their properties are detailed in section 4.7 of CLRM (where they are referred to as "Discrete Types").
For each element type T, there exists an isomorphism FT: T b {