AddressesImpl.mesa
Created by Theimer: August 21, 1989 1:29:54 pm PDT
Last changed by Theimer on August 21, 1989 10:28:20 pm PDT
DIRECTORY
Addresses,
CCTypes USING [CCError, CCErrorCase, CCTypeProcs, CreateCedarType, LR, ConformanceCheck, GetGroundTypeClass, Operator],
CirioTypes USING [Type, TypedCode, CompilerContext, Node],
CedarCode USING [Code, CreateCedarNode, OperationsBody, GetDataFromNode, Operator],
IO USING [PutFR, card],
Rope USING[ROPE];
=
BEGIN OPEN CCTypes;
CC: TYPE = CirioTypes.CompilerContext;
Code: TYPE = CedarCode.Code;
Type: TYPE = CirioTypes.Type;
TypedCode: TYPE = CirioTypes.TypedCode;
Node: TYPE = CirioTypes.Node;
CCE: ERROR[case: CCTypes.CCErrorCase, msg: Rope.ROPE ← NIL] ← CCTypes.CCError;
Operator: TYPE = CedarCode.Operator;
Type operations
CreateAddressType:
PUBLIC PROC [cc:
CC]
RETURNS [Type] =
BEGIN
RETURN [CCTypes.CreateCedarType[$address, AddressTypeCCTypeProcs, NIL, cc]];
END;
AddressTypeCCTypeProcs:
REF
CCTypes.CCTypeProcs ←
NEW[CCTypes.CCTypeProcs ←[
checkConformance: AddressCCTypesCheckConformance,
printType: AddressCCTypesPrintType]];
Address
CCTypesCheckConformance:
PROC[valType, varType: Type, cc:
CC, procData:
REF
ANY]
RETURNS[CCTypes.ConformanceCheck] =
BEGIN
IF CCTypes.GetGroundTypeClass[varType, cc] = $address THEN RETURN[yes] ELSE RETURN[no];
END;
AddressCCTypesPrintType:
PROC [type: Type, printDepth:
INT, printWidth:
INT, cc:
CC, procData:
REF
ANY]
RETURNS [Rope.
ROPE] = {
RETURN ["ADDRESS"];
};
Node operations.
CreateAddressNode:
PUBLIC PROC [type: Type, info:
REF
ANY, cc:
CC]
RETURNS [Node] = {
RETURN [CedarCode.CreateCedarNode[AddressOps, type, info]];
};
AddressOps:
REF CedarCode.OperationsBody ←
NEW[CedarCode.OperationsBody ←[
show: AddressShow
]];
AddressShow:
PROC [node: Node, depth:
INT, width:
INT, cc:
CC]
RETURNS [Rope.
ROPE] = {
info: Addresses.AddressNodeInfo ← NARROW[CedarCode.GetDataFromNode[node]];
addressValue: CARD ← info.getAddressValue[info.data];
addressValueRope: Rope.ROPE ← IO.PutFR["%bB&", IO.card[addressValue]];
RETURN [addressValueRope];
};