Records.mesa
Copyright Ó 1991 by Xerox Corporation. All rights reserved.
Sturgis, November 20, 1988
Sturgis, December 11, 1989 1:21:37 pm PST
Spreitze, May 21, 1991 8:20 am PDT
DIRECTORY
CirioTypes USING[CompilerContext, Mem, Node, Type],
CirioSyntacticOperations USING [ParseTree],
Rope USING[ROPE];
Records: CEDAR DEFINITIONS =
BEGIN
CC: TYPE = CirioTypes.CompilerContext;
We begin with naked field lists
types
RecordTypeProcs: TYPE = RECORD[
createIndirectNode: PROC [cc: CC, data: REF ANY, indirectType, targetType: CirioTypes.Type, mem: CirioTypes.Mem] RETURNS [CirioTypes.Node],
getBitSize: PROC[indirectType: CirioTypes.Type, cc: CC, data: REF ANY] RETURNS[CARD],
getPaint: PROC[data: REF ANY] RETURNS[REF ANY],
comparePaint: PROC[data: REF ANY, otherPaint: REF ANY] RETURNS[BOOLEAN],
nFields: PROC[data: REF ANY] RETURNS[INT],
fieldIndexToName: PROC[index: INT, data: REF ANY] RETURNS[Rope.ROPE],
nameToFieldIndex: PROC[name: Rope.ROPE, data: REF ANY] RETURNS[INT],
fieldIndexToType: PROC[index: INT, cc: CC, data: REF ANY] RETURNS[CirioTypes.Type],
fieldIndexToDefault: PROC[index: INT, cc: CC, data: REF ANY] RETURNS[CirioSyntacticOperations.ParseTree, CirioTypes.Node],
fieldIndexToFieldCase: PROC[index: INT, cc: CC, data: REF ANY] RETURNS[FieldCase],
fieldIndexToCompileTimeConstantValue: PROC[index: INT, cc: CC, data: REF ANY] RETURNS[CirioTypes.Node]];
note: field indices are in [0..nFields)
note: nameToFieldIndex returns -1 if there is no such field
note: getPaint returns NIL for unpainted records. comparePaint[data, otherPaint] returns TRUE if getPaint[data]^ = otherPaint^. [don't call comparePaint if one of them has nil paint.] If comparePaint[data, getPaint[otherData]] = TRUE, then the two record types are guaranteed to be the same. I.E. they have the same textual point of declaration.
FieldCase: TYPE = {
nodeTimeReadWrite, -- the field exists in memory and is modifiable
nodeTimeReadOnly, -- the field exists in memory, but it is not modifiable
nodeTimeConstant, -- the field does not exist in memory, but its value can not be computed until we know the actual location of some other appropriate data structure, e.g., a global or local frame.
typeTimeConstant -- the field does not exist in memory and the value can be computed without reference to the contents of memory
};
CreateRecordType: PROC[procs: REF RecordTypeProcs, cc: CC, data: REF ANY] RETURNS[CirioTypes.Type];
CirioCode.GetTypeClass[type] = $record
CCTypes.GetTypeRepresentation will return data.
CreateFieldListType: PROC[procs: REF RecordTypeProcs, cc: CC, data: REF ANY] RETURNS[CirioTypes.Type];
field lists are record-like entities that occur embedded in other values. For example, the preamble fields of a variant record are a field-list type. FieldLists behave exactly like records, except that when they are shown they appear as a naked list of field values, not enclosed in brackets.
CirioCode.GetTypeClass[type] = $record
CCTypes.GetTypeRepresentation will return data.
nodes
RecordNodeProcs: TYPE = RECORD[
extractField: PROC[index: INT, fieldType: CirioTypes.Type, data: REF ANY, cc: CC] RETURNS[CirioTypes.Node]];
IndirectRecordNodeProcs: TYPE = RECORD[
selectField: PROC[index: INT, indirectFieldType: CirioTypes.Type, data: REF ANY, cc: CC] RETURNS[CirioTypes.Node],
fieldIndexToNodeTimeConstantValue: PROC[index: INT, fieldType: CirioTypes.Type, data: REF ANY, cc: CC] RETURNS[CirioTypes.Node],
note: fieldIndexToNodeTimeConstantValue is used to compute the value of procedure constants.
getPointer: PROC[data: REF ANY, cc: CC] RETURNS[CirioTypes.Node]];
CreateIndirectRecordNode: PROC[targetRecordType: CirioTypes.Type, procs: REF IndirectRecordNodeProcs, data: REF ANY, cc: CC] RETURNS[CirioTypes.Node];
ConstructRecordNode: PROC[recordType: CirioTypes.Type, fields: LIST OF CirioTypes.Node, cc: CC] RETURNS[CirioTypes.Node];
In both of these routines, the targetRecordType or recordType can be either a record type or a fieldList type.
END..