PointerTypes.mesa
Copyright Ó 1991 by Xerox Corporation. All rights reserved.
theimer May 1, 1989 4:54:28 pm PDT
Sturgis, September 11, 1989 2:15:56 pm PDT
Last changed by Theimer on July 16, 1989 4:42:04 pm PDT
DIRECTORY
CirioTypes USING[BasicTypeInfo, CirioAddress, CompilerContext, Node, Type];
PointerTypes:
CEDAR
DEFINITIONS =
BEGIN
CC: TYPE = CirioTypes.CompilerContext;
Type: TYPE = CirioTypes.Type;
Node: TYPE = CirioTypes.Node;
BasicTypeInfo: TYPE = CirioTypes.BasicTypeInfo;
We do not include a CreateIndirectPointerNode procedure, because a PointerNode value is atomic, hence is covered by the general mechanism for indirects to atomic values.
Note: The clientTargetType is INT in POINTER INT. (We use the phrase ClientTarget to distinguish this type from the type of the (virtual) pair <type, ClientTarget>.
Note: For pointer types we don't have the header in front of each record pointed to, as we do for REF types.
There are two classes of POINTER type: POINTER T, and NIL POINTER. NIL POINTER is a subset of all POINTER types, and the only value in NIL POINTER is NIL. Thus, NIL belongs to all POINTER types.
In the following: CreateNilRefType always returns the same type. If the type doesn't exist, it is created.
CreatePointerType:
PROC[clientTargetType: Type, cc:
CC, bti: BasicTypeInfo]
RETURNS[Type];
CirioCode.GetTypeClass[type] = $ref
CCTypes.GetTypeRepresentation will return NIL.
GetReferentType:
PROC[pointerType: Type]
RETURNS[Type];
Returns the clientTargetType given to CreatePointerType.
CreateNilPointerType:
PROC[cc:
CC]
RETURNS[Type];
CirioCode.GetTypeClass[type] = $nilRef
CCTypes.GetTypeRepresentation will return NIL.
PointerNodeInfo: TYPE = REF PointerNodeInfoBody;
PointerNodeInfoBody:
TYPE =
RECORD[
clientTargetType: Type,
indirectToClientTarget: Node,
getAddress: PROC[data: REF ANY, cc: CC] RETURNS [CirioTypes.CirioAddress],
pointerAdd: PROC[offset: INT, data: REF ANY, cc: CC] RETURNS [CirioTypes.Node],
pointerCardValue: PROC[data: REF ANY] RETURNS [CARD],
data: REF ANY];
CreatePointerNode:
PROC[type: Type, info: PointerNodeInfo, cc:
CC]
RETURNS[Node];
Pointer nodes support the getNodeRepresentation object procedure (CedarCode.GetNodeRepresentation). They return the info parameter supplied to the Create call. (Nodes for a NIL pointer must be created using the following procedure.)
CreateNilPointerNode:
PROC[cc:
CC]
RETURNS[Node];
If node ← CreateNilPointerNode[cc], then GetNodeRepresentation[node, cc] returns NIL.
END..