RefTypes.mesa
Sturgis, November 20, 1988
Sturgis, September 5, 1989 9:48:36 am PDT
Last changed by Theimer on July 16, 1989 4:40:24 pm PDT
Spreitze, December 16, 1991 10:52 am PST
DIRECTORY
CirioTypes USING[BasicTypeInfo, CompilerContext, Node, Type];
RefTypes: CEDAR DEFINITIONS =
BEGIN
CC: TYPE = CirioTypes.CompilerContext;
Type: TYPE = CirioTypes.Type;
Node: TYPE = CirioTypes.Node;
BasicTypeInfo: TYPE = CirioTypes.BasicTypeInfo;
We do not include a CreateIndirectRefNode procedure, because a RefNode value is atomic, hence is covered by the general mechanism for indirects to atomic values.
Note: The clientTargetType is INT in REF INT. (We use the phrase ClientTarget to distinguish this type from the type of the (virtual) pair <type, ClientTarget>.
Note: The codeForClientTargetType is the type code that appears in the header for the records. It is not clear that this is the route by which Cirio should learn this number. Perhaps it should have been part of the clientTargetType already. Currently (March 4, 1989) it is used only in the CheckFamilyInclusion routine. Perhaps there is some better way to perform the same check. (We are only interested in whether then numbers agree, we don't care about their actual values.)
There are three classes of REF type: REF ANY, REF T, and NIL REF. All ref values belong to REF ANY, NIL REF is a subset of all REF types, and the only value in NIL REF is NIL. Thus, NIL belongs to all REF types.
In the following: CreateRefAnyType and CreateNilRefType always return the same type (respectively). If the type doesn't exist, it is created.
CreateRefAnyType: PROC[cc: CC, bti: BasicTypeInfo] RETURNS[Type];
CirioCode.GetTypeClass[type] = $refAny
CCTypes.GetTypeRepresentation will return bti.
CreateRefType: PROC[cc: CC, bti: BasicTypeInfo] RETURNS[Type];
CirioCode.GetTypeClass[type] = $ref
CCTypes.GetTypeRepresentation will return bti.
Call SetReferent to specify referent.
SetReferent: PROC [refType, clientTargetType: Type, codeForClientTargetType: INT, cc: CC];
CreateNilRefType: PROC[cc: CC] RETURNS[Type];
CirioCode.GetTypeClass[type] = $nilRef
CCTypes.GetTypeRepresentation will return NIL.
RefNodeInfo: TYPE = REF RefNodeInfoBody;
RefNodeInfoBody: TYPE = RECORD[
clientTargetType: Type,
codeForClientTargetType: INT,
indirectToClientTarget: Node,
data: REF ANY];
CreateRefNode: PROC[type: Type, info: RefNodeInfo, cc: CC] RETURNS[Node];
Ref nodes support the getNodeRepresentation object procedure (CedarCode.GetNodeRepresentation). They return the info parameter supplied to the Create call. (Nodes for a NIL ref must be created using the following procedure.)
CreateNilRefNode: PROC[cc: CC] RETURNS[Node];
If node ← CreateNilRefNode[cc], then GetNodeRepresentation[node, cc] returns NIL.
END..