CirioTypes.Mesa
Copyright Ó 1990, 1991, 1992 by Xerox Corporation. All rights reserved.
Sturgis, September 5, 1989 2:31:27 pm PDT
Last changed by Theimer on June 28, 1989 12:59:54 pm PDT
Last tweaked by Mike Spreitzer on January 8, 1992 11:51 am PST
Laurie Horton, February 24, 1992 4:36 pm PST
Philip James, February 24, 1992 1:35 pm PST
Started: November 5, 1988 3:31:42 pm PST
Sturgis: November 5, 1988 3:51:22 pm PST
DIRECTORY Basics, CirioMemory, IO, Rope;
CirioTypes: CEDAR DEFINITIONS
IMPORTS CirioMemory =
BEGIN
ROPE: TYPE ~ Rope.ROPE;
Nat: TYPE ~ INT[0..INT.LAST];
It is really a bit of a mess at the moment. The implementation is essentially tied to Cedar. Most of the relevant implementation is in CCTypesImpl.
Code: TYPE = REF CodeBody;
CodeBody: TYPE;
TypedCode: TYPE = RECORD[code: Code, type: Type];
CC: TYPE = CompilerContext;
CompilerContext: TYPE = REF CompilerContextBody;
CompilerContextBody: TYPE = RECORD[
nameScope: Node,
moduleScope: ModuleScope,
ctc: CompilerTypeContext];
CompilerTypeContext: TYPE = REF CompilerTypeContextBody;
CompilerTypeContextBody: TYPE;
Type: TYPE = REF TypeBody;
TypeClass: TYPE = ATOM; -- {wrong, amnode, numeric, Boolean, record . . . etc}
NarrowToType: PROC[ref: REF ANY] RETURNS[Type];
TypeIsntNil: PROC [Type, CC] RETURNS [Type];
If arg isn't NIL, returns arg; if arg is NIL, raises an error.
Node: TYPE = REF NodeBody;
ModuleScope: TYPE = REF ModuleScopeBody;
ModuleScopeBody: TYPE = RECORD [
GetModule: PROC [moduleScope: ModuleScope, name: ROPE, nToSkip: INT] RETURNS [Node],
GetInterfaceRecord: PROC [moduleScope: ModuleScope, name: ROPE] RETURNS [Node],
data: REF ANY];
BitAddr
A BitAddr represents a position in or length of memory.
BitAddr: TYPE ~ CirioMemory.BitAddr;
The first part is in Addressing Units (ie, increments of debuggee pointers). ABS[bits] < bitsPerTargetAu.
zeroBA: BitAddr ~ CirioMemory.zeroBA;
unspecdBA: BitAddr ~ CirioMemory.unspecdBA;
ptrSize: BitAddr ~ [4, 0];
bitsPerAu: Nat ~ 8;
bitsPerPtr: Nat ~ 32;
BaCons: PROC [aus: CARD, bits: INT] RETURNS [BitAddr]
~ INLINE {RETURN CirioMemory.BaCons[aus, bits]};
BaAsAbs: PROC [ba: BitAddr] RETURNS [BitAddr];
Result is equivalent to arg, and has non-negative bits.
BaAdd: PROC [a, b: BitAddr] RETURNS [BitAddr]
~ INLINE {RETURN CirioMemory.BaAdd[a, b]};
BaAddOffset: PROC [ba: BitAddr, bits: INT] RETURNS [BitAddr]
~ INLINE {RETURN CirioMemory.BaAddOffset[ba, bits]};
BaSub: PROC [a, b: BitAddr] RETURNS [BitAddr]
~ INLINE {RETURN CirioMemory.BaSub[a, b]};
BaMul: PROC [ba: BitAddr, by: CARD] RETURNS [BitAddr]
~ INLINE {RETURN CirioMemory.BaMul[ba, by]};
BaCompare: PROC [a, b: BitAddr] RETURNS [Basics.Comparison];
BitsToBa: PROC [bits: INT] RETURNS [BitAddr]
~ INLINE {RETURN CirioMemory.BitsToBa[bits]};
BaToBits: PROC [ba: BitAddr] RETURNS [CARD]
~ INLINE {RETURN CirioMemory.BaToBits[ba]};
AusToBa: PROC [aus: CARD] RETURNS [BitAddr]
~ INLINE {RETURN CirioMemory.AusToBa[aus]};
BaToAus: PROC [ba: BitAddr] RETURNS [CARD]
~ INLINE {RETURN CirioMemory.BaToAus[ba]};
PtrToBa: PROC [ptr: CARD] RETURNS [BitAddr]
~ INLINE {RETURN CirioMemory.PtrToBa[ptr]};
BaToPtr: PROC [ba: BitAddr] RETURNS [CARD]
~ INLINE {RETURN CirioMemory.BaToPtr[ba]};
BitStretch: TYPE ~ CirioMemory.BitStretch;
BsCompose: PROC [main, inner: BitStretch] RETURNS [within: BOOL, compd: BitStretch]
inner is interpreted relative to main; compd tells whether all of compd lies within main.
~ INLINE {RETURN CirioMemory.BsCompose[main, inner]};
Mem
Mem: TYPE = CirioMemory.Mem;
noMem: Mem = CirioMemory.noMem;
PtrReg: TYPE ~ CirioMemory.PtrReg;
MemSubfield: PROC [mem: Mem, rel: BitStretch] RETURNS [Mem]
~ INLINE {RETURN CirioMemory.MemSubfield[mem, rel]};
MemShift: PROC [mem: Mem, offset: BitAddr] RETURNS [Mem]
~ INLINE {RETURN CirioMemory.MemShift[mem, offset]};
MemIndirect: PROC [mem: Mem, size: BitAddr ← unspecdBA, offset: BitAddr ← zeroBA] RETURNS [Mem]
~ INLINE {RETURN CirioMemory.MemIndirect[mem, size, offset]};
MemGetStretch: PROC [mem: Mem] RETURNS [BitStretch]
~ INLINE {RETURN CirioMemory.MemGetStretch[mem]};
MemGetSize: PROC [mem: Mem] RETURNS [BitAddr]
~ INLINE {RETURN CirioMemory.MemGetSize[mem]};
MemGetStart: PROC [mem: Mem] RETURNS [BitAddr]
~ INLINE {RETURN CirioMemory.MemGetStart[mem]};
MemRead: PROC [mem: Mem, bitSize: CARD, offset: BitAddr] RETURNS [CARD]
~ INLINE {RETURN CirioMemory.MemRead[mem, bitSize, offset]};
MemWrite: PROC [mem: Mem, bits: CARD, bitSize: CARD, offset: BitAddr]
~ INLINE {CirioMemory.MemWrite[mem, bits, bitSize, offset]};
MemPtrRegIndirect: PROC [mem: Mem, ptrReg: PtrReg, size, offset: BitAddr, keepFrame: BOOL] RETURNS [Mem]
~ INLINE {RETURN CirioMemory.MemPtrRegIndirect[mem, ptrReg, size, offset, keepFrame]};
MemReadPtrReg: PROC [mem: Mem, ptrReg: PtrReg] RETURNS [BitStretch]
~ INLINE {RETURN CirioMemory.MemReadPtrReg[mem, ptrReg]};
MemReadSegReg: PROC [mem: Mem, segName: ROPE, segNum: INT] RETURNS [BitStretch]
~ INLINE {RETURN CirioMemory.MemReadSegReg[mem, segName, segNum]};
MemSelectSegment: PROC [mem: Mem, segName: ROPE, segNum: INT, keepFrame: BOOL] RETURNS [Mem]
~ INLINE {RETURN CirioMemory.MemSelectSegment[mem, segName, segNum, keepFrame]};
Cirio address definition
Are these defunct?
CirioAddress: TYPE = REF CirioAddressBody;
CirioAddressBody: TYPE = RECORD [
isNil: PROC [CirioAddress] RETURNS [BOOL],
readBits: PROC[byteOffset: CARD ← 0, bitOffset: CARD ← 0, bitSize: CARD, data: CirioAddress] RETURNS[CARD],
writeBits: PROC[byteOffset: CARD ← 0, bitOffset: CARD ← 0, bitSize: CARD, data: CirioAddress, bits: CARD],
followPointer: PROC[byteOffset: CARD ← 0, data: CirioAddress] RETURNS[CirioAddress],
asCard: PROC[data: CirioAddress] RETURNS[CARD],
data: REF ANY
];
remark: This type is intended to provide binary access to the target world. Further, sitting in CirioTypes makes it part of the root of the world. The readBits and writeBits procedures expect that bitSize will always be <= 32. The bits transfered are the bitSize low-order bits of the CARD.
Type details (exposed for debugging).
TypeBody: PRIVATE TYPE ~ RECORD[
class: TypeClass,
procs: REF CCTypeProcs,
procData: REF ANY,
defaultType: Type,
indirectType: Type,
targetType: Type];
CCTypeProcs: TYPE = RECORD[
createIndirectNode: PROC [cc: CC, procData: REF ANY, indirectType, targetType: Type, mem: Mem] RETURNS [Node],
Invoked only on indirect types.
checkConformance: PROC[valType, varType: Type, cc: CC, procData: REF ANY] RETURNS[ConformanceCheck],
storable: PROC[valType, indirectType: Type, cc: CC, procData: REF ANY] RETURNS[BOOLEAN],
checkFamilyInclusion: PROC[valType, varType: Type, cc: CC, procData: REF ANY] RETURNS[BOOLEAN],
isASingleton: PROC[type: Type, cc: CC, procData: REF ANY] RETURNS[BOOLEAN],
binaryOperandTypes: PROC[op: Operator, left, right: Type, cc: CC, procData: REF ANY] RETURNS[BinaryTargetTypes],
isAnIndirect: PROC[type: Type, cc: CC, procData: REF ANY] RETURNS[BOOLEAN],
getRTargetType: PROC[type: Type, cc: CC, procData: REF ANY] RETURNS[Type],
getLTargetType: PROC[type: Type, cc: CC, procData: REF ANY] RETURNS[Type],
getFieldsType: PROC[rcdType: Type, cc: CC, procData: REF ANY] RETURNS[Type],
getRefType: PROC[rhs: Type, cc: CC, procData: REF ANY] RETURNS[Type],
hasIdField: PROC[id: ROPE, fieldContext: Type, cc: CC, procData: REF ANY] RETURNS[IdFieldCase],
containsVariance: PROC[type: Type, cc: CC, procData: REF ANY] RETURNS[BOOLEAN],
getNVariants: PROC[type: Type, cc: CC, procData: REF ANY] RETURNS[INT],
asIndexSet: PROC[type: Type, cc: CC, procData: REF ANY] RETURNS[Type],
operand: PROC[op: Operator, lr: LR, tc: TypedCode, cc: CC, procData: REF ANY] RETURNS[TypedCode],
applyOperand: PROC[operatorType: Type, operand: ParseTree, cc: CC, procData: REF ANY] RETURNS[TypedCode],
indexOperand: PROC[operatorType: Type, operand: ParseTree, cc: CC, procData: REF ANY] RETURNS[TypedCode],
coerceToType: PROC[targetType: Type, tc: TypedCode, cc: CC, procData: REF ANY] RETURNS[TypedCode],
binaryOp: PROC[op: Operator, left, right: TypedCode, cc: CC, procData: REF ANY] RETURNS[TypedCode],
unaryOp: PROC[op: Operator, arg: TypedCode, cc: CC, procData: REF ANY] RETURNS[TypedCode],
nAryOperandType: PROC[op: Operator, typeSoFar, nextType: Type, cc: CC, procData: REF ANY] RETURNS[Type],
nAryOp: PROC[op: Operator, args: LIST OF TypedCode, cc: CC, procData: REF ANY] RETURNS[TypedCode],
typeOp: PROC[op: Operator, type: Type, cc: CC, procData: REF ANY] RETURNS[TypedCode],
typeOp2OperandType: PROC[op: Operator, type: Type, cc: CC, procData: REF ANY] RETURNS[Type],
typeOp2: PROC[op: Operator, type: Type, arg: TypedCode, cc: CC, procData: REF ANY] RETURNS[TypedCode],
constructor: PROC[list: LIST OF ParseTree, targetType: Type, cc: CC, procData: REF ANY] RETURNS[TypedCode],
pairConstructor: PROC[list: LIST OF NameArgPair, targetType: Type, cc: CC, procData: REF ANY] RETURNS[TypedCode],
store: PROC[value: TypedCode, indirect: TypedCode, cc: CC, procData: REF ANY] RETURNS[TypedCode],
load: PROC[indirect: TypedCode, cc: CC, procData: REF ANY] RETURNS[TypedCode],
extractIdField: PROC[id: ROPE, fieldContext: Type, cc: CC, procData: REF ANY] RETURNS[TypedCode],
loadIdVal: PROC[id: ROPE, targetType: Type, cc: CC, procData: REF ANY] RETURNS[TypedCode],
selectIdField: PROC[id: ROPE, fieldIndirectContext: Type, cc: CC, procData: REF ANY] RETURNS[TypedCode],
loadIdField: PROC[id: ROPE, fieldIndirectContext: Type, cc: CC, procData: REF ANY] RETURNS[TypedCode],
apply: PROC[operator: TypedCode, operand: TypedCode, cc: CC, procData: REF ANY] RETURNS[TypedCode],
index: PROC[operator: TypedCode, operand: TypedCode, cc: CC, procData: REF ANY] RETURNS[TypedCode],
getTypeRepresentation: PROC[type: Type, cc: CC, procData: REF ANY] RETURNS[REF ANY],
getNElements: PROC[type: Type, cc: CC, procData: REF ANY] RETURNS[CARD],
getBitSize: PROC[indirectType, targetType: Type, cc: CC, procData: REF ANY] RETURNS[CARD],
We only ask bitSize of indirect types; the answer is the size of the referent.
note: we include bitSize as a proc because in some cases it requires bitSize information from component types. We wish to avoid analyzing the component types while constructing this AnalyzedSEHBody. So, we compute the bitSize lazily and record it in private when we have it. Hopefull, no call on bitSize will be made until the analysis is complete.
further note: The individual computations of bitSize are supposed to be inspired by [PCedar2.0]<Mimosa>SymbolOpsImpl.BitsForType.
getScopeIndex: PROC [type: Type, cc: CC, procData: REF ANY] RETURNS [CARD],
getGroundType: PROC[type: Type, cc: CC, procData: REF ANY] RETURNS[Type],
printType: PROC [to: IO.STREAM, type: Type, printDepth: INT, printWidth: INT, cc: CC, procData: REF ANY]
];
ConformanceCheck: TYPE = {yes, dontKnow, no};
Operator: TYPE = ATOM;
BinaryTargetTypes: TYPE = RECORD[tLeft, tRight: Type];
IdFieldCase: TYPE = {yes, possible, no};
LR: TYPE = {left, right, unary, nary};
NameArgPair: TYPE = RECORD[id: ROPE, arg: ParseTree];
ParseTree: TYPE ~ REF ParseTreeBody; ParseTreeBody: PRIVATE TYPE;
RHS info for many Types:
BasicTypeInfo: TYPE ~ REF BasicTypeInfoPrivate;
BasicTypeInfoPrivate: TYPE ~ RECORD [
createIndirectNode: PROC [bti: BasicTypeInfo, cc: CC, indirectType, targetType: Type, mem: Mem] RETURNS [Node],
getBitSize: PROC[bti: BasicTypeInfo, cc: CC, indirectType, targetType: Type] RETURNS[CARD],
btiData: REF ANY];
Node details (exposed for debugging).
NodeBody: PRIVATE TYPE = RECORD[
ops: REF OperationsBody,
type: Type,
data: REF ANY];
OperationsBody: TYPE = RECORD[
makeAMNode: PROC[sourceType: Type, node: Node, cc: CC] RETURNS[Node],
examineBoolean: PROC[node: Node, cc: CC] RETURNS[BOOLEAN],
examineParseTree: PROC[node: Node, cc: CC] RETURNS[ParseTree],
getCurrentType: PROC[node: Node, cc: CC] RETURNS[Type],
getNameContext: PROC[scopeIndex: CARDINAL, node: Node, cc: CC] RETURNS[Node],
advanceNameScope: PROC[node: Node, cc: CC] RETURNS[Node],
coerce: PROC[sourceType, targetType: Type, node: Node, cc: CC] RETURNS[Node],
binaryOp: PROC[op: Operator, leftType, rightType: Type, leftNode, rightNode: Node, cc: CC] RETURNS[Node],
unaryOp: PROC[op: Operator, type: Type, node: Node, cc: CC] RETURNS[Node],
store: PROC[valType: Type, valNode: Node, indirectType: Type, indirectNode: Node, cc: CC],
load: PROC[indirectType: Type, indirectNode: Node, cc: CC] RETURNS[Node],
forceIn: PROC[type: Type, node: Node, cc: CC] RETURNS[Node],
extractField: PROC[id: ROPE, type: Type, node: Node, cc: CC] RETURNS[Node],
selectField: PROC[id: ROPE, indirectType: Type, indirectNode: Node, cc: CC] RETURNS[Node],
selectNestedBlock: PROC[set: INT, depth: INT, indirectType: Type, indirectNode: Node, cc: CC] RETURNS[Node],
apply: PROC[operatorType: Type, operandType: Type, operator: Node, operand: Node, cc: CC] RETURNS[Node],
index: PROC[indirectOperatorType: Type, operandType: Type, indirectOperator: Node, operand: Node, cc: CC] RETURNS[Node],
asIndex: PROC[type: Type, node: Node, cc: CC] RETURNS[CARD],
perhaps the following should be in a different group
show: PROC[to: IO.STREAM, node: Node, depth: INT, width: INT, cc: CC],
getNodeRepresentation: PROC[node: Node, cc: CC] RETURNS[REF ANY]
];
END..