~
BEGIN
Tree:
TYPE =
REF;
-- one of:
LIST OF Tree
ATOM
ROPE
AttributedNode
REF MPTree.Node
REF MPLeaves.HTNode
REF MPLeaves.LTNode
Attributes:
TYPE =
LIST
OF
REF
ANY;
This has alternating keys and values, where the keys are always atoms.
AttributedNode: TYPE = REF AttributedNodeRep;
AttributedNodeRep:
TYPE =
RECORD [
attributes: Attributes,
syntaxNodeName: ATOM,
syntaxNode: MPTree.Link
];
Context: TYPE = REF ContextRep;
ContextRep:
TYPE =
RECORD [
A context corresponds to a lexical scope of the program
parent: Context ¬ NIL,
types: TypeGraph,
symbols: SymTab.Ref,
moduleName: ROPE, -- the name of the containing module
fieldListLast: FieldList ¬ NIL, -- for accumulating field lists for DEFINITIONS
concreteForOpaque: LIST OF ConcreteForOpaque,
exports: LIST OF Export,
scopeKind: ScopeKind ¬ local
];
ScopeKind:
TYPE = {local, globalDefs, globalImpl};
ConcreteForOpaque:
TYPE =
RECORD [concrete, opaque: TypeCode];
Export:
TYPE =
RECORD [interfaceName:
ROPE, fieldList: FieldList];
FieldList: TYPE = LIST OF FieldListItem;
FieldListItem:
TYPE =
RECORD [name:
ROPE, rangeType: TypeCode, initialValue: Tree ¬
NIL];
For records and structures, the names and types of the fields. The names might be NIL, but if one is, they all are.
VariantList: TYPE = LIST OF VariantListItem;
VariantListItem:
TYPE =
RECORD [value:
REF
ANY, chooses: FieldList];
TypeGraph: TYPE = REF TypeGraphRep;
TypeGraphRep:
TYPE =
RECORD [n:
CARD, tab: CardTab.Ref, interfaceTable: SymTab.Ref, gensym:
INT ¬ 0];
nullTypeCode: TypeCode =
LAST[
CARD];
TypeInfoClass:
TYPE = {simple, definition, initial, qualifiedVariant, scalar, reference, descriptor, control, enumerated, subrange, union, sequence, record, array, frame, type, notImplemented};
TypeClass: TYPE = ATOM; -- Could be an enumeration someday. These ATOMs are in ALL CAPS
typeInfoClassForTypeClass: ARRAY TypeClass OF TypeInfoClass = [
definition: definition,
cardinal: scalar,
longCardinal: scalar,
integer: scalar,
longInteger: scalar,
real: scalar,
character: scalar,
atom: scalar,
rope: scalar,
list: reference,
ref: reference,
pointer: reference,
longPointer: reference,
descriptor: notImplemented,
longDescriptor: notImplemented,
basePointer: notImplemented,
relativePointer: notImplemented,
procedure: control,
signal: control,
error: control,
program: control,
port: notImplemented,
enumerated: enumerated,
subrange: subrange,
union: union,
sequence: sequence,
record: record,
structure: record,
array: array,
countedZone: simple,
uncountedZone: simple,
simple: simple,
unspecified: simple,
process: simple,
type: type,
opaque: simple,
any: simple,
globalFrame: frame,
localFrame: frame
];
EnumerationItem:
TYPE =
RECORD [name:
ROPE, value:
CARD];
Type: TYPE = REF TypeRep;
TypeRep:
TYPE =
RECORD [
typeCode: TypeCode ¬ TypeCode.LAST,
ext: REF ¬ NIL, -- for extensions
class: TypeClass,
v:
SELECT infoClass: TypeInfoClass
FROM
simple => [],
definition => [qualifier, shortName:
ROPE, groundType: TypeCode],
This is for hanging a name on a type; follow the groundType to get at the real thing
initial => [environmentModule:
ROPE, tree: Tree, groundType: TypeCode],
This is for hanging an initial value on a type; follow the groundType to get at the type itself. environmentModule tells the module that the expression tree occured in
qualifiedVariant => [qualifier: ROPE, groundType: TypeCode],
scalar => [],
cardinal is short (at least 16 bits), longCardinal is long (at least 32 bits)
reference => [referentType: TypeCode],
control => [argumentType, returnType: TypeCode],
enumerated => [items:
LIST
OF EnumerationItem],
The names of the elements; for machine-dependent records, some elements may not be named
subrange => [groundType: TypeCode, first, last: REF],
union => [tagName:
ROPE, tagType: TypeCode, variantList: VariantList],
This is for variant records.
sequence => [limitName: ROPE, domainType, rangeType: TypeCode],
record => [fieldList: FieldList],
array => [domainType, rangeType: TypeCode],
frame => [fieldList: FieldList],
type => [value: TypeCode],
notImplemented => []
ENDCASE
];
SymbolTableEntry: TYPE = REF SymbolTableEntryRep;
SymbolTableEntryRep:
TYPE =
RECORD [
SELECT tag: *
FROM
directory => [import, export, share: BOOL ¬ FALSE, from: ROPE, hasUsing: BOOL, using: LIST OF ROPE, interfaceRecordType: REF TypeRep.record], -- an element in the directory
other => [typeCode: TypeCode, readonly: BOOL, constantValue: REF, qualifier: ROPE ¬ NIL],
ENDCASE
];