TypeOpsImpl.mesa
Copyright Ó 1992 by Xerox Corporation. All rights reserved.
Theimer, May 17, 1989 3:56:05 pm PDT
Changed by Theimer on May 20, 1989 6:42:37 pm PDT
Last changed by Theimer on June 4, 1989 5:17:39 pm PDT
Last tweaked by Mike Spreitzer January 9, 1992 11:33 am PST
Willie-s, June 30, 1992 2:42 pm PDT
DIRECTORY
CCTypes USING [CCTypeProcs, CreateCedarType, PrintType],
CirioTypes USING[CompilerContext, Type, Node],
CedarCode USING [CreateCedarNode, OperationsBody, GetDataFromNode, GetTypeOfNode],
IO,
Rope USING[ROPE],
TypeOps USING [TypeIndirectNodeInfo];
=
BEGIN OPEN CCTypes;
CC: TYPE = CirioTypes.CompilerContext;
Type: TYPE = CirioTypes.Type;
Node: TYPE = CirioTypes.Node;
Type operations.
TypeTypeInfo: TYPE = REF TypeTypeInfoBody;
TypeTypeInfoBody: TYPE = RECORD [
underType: Type,
name: Rope.ROPE];
CreateTypeType:
PUBLIC PROC [cc:
CC]
RETURNS [Type] = {
type: Type ¬ CCTypes.CreateCedarType[$type, TypeTypeCCTypeProcs, IndirectTypeTypeCCTypeProcs, cc];
RETURN [type];
};
TypeTypeCCTypeProcs:
REF
CCTypes.CCTypeProcs ¬
NEW[CCTypes.CCTypeProcs ¬[
printType: TypeCCTypesPrintType]];
IndirectTypeTypeCCTypeProcs:
REF
CCTypes.CCTypeProcs ¬
NEW[CCTypes.CCTypeProcs ¬[
printType: TypeCCTypesPrintType]];
TypeCCTypesPrintType:
PROC [to:
IO.
STREAM, type: Type, printDepth:
INT, printWidth:
INT, cc:
CC, procData:
REF
ANY]
= {to.PutRope["TYPE"]};
Node operations.
CreateTypeIndirectNode:
PUBLIC PROC [type: Type, info:
REF
ANY]
RETURNS [Node] = {
RETURN [CedarCode.CreateCedarNode[TypeIndirectOps, type, info]];
};
TypeIndirectOps:
REF CedarCode.OperationsBody ¬
NEW[CedarCode.OperationsBody ¬[
load: TypeIndirectLoad,
show: TypeShow
]];
TypeIndirectLoad:
PROC [indirectType: Type, indirectNode: Node, cc:
CC]
RETURNS [Node] = {
RETURN [indirectNode];
};
TypeShow:
PROC [to:
IO.
STREAM, node: Node, depth:
INT, width:
INT, cc:
CC] = {
info: TypeOps.TypeIndirectNodeInfo ¬ NARROW[CedarCode.GetDataFromNode[node]];
defType: CirioTypes.Type ¬ info.getDefinitionType[info.data];
IF depth = 0
THEN {
defType: CirioTypes.Type ¬ CedarCode.GetTypeOfNode[node];
CCTypes.PrintType[to, defType, depth, width, cc];
}
ELSE {
CCTypes.PrintType[to, defType, depth, width, cc];
};
};