-- RTTypesPrivate.Mesa
-- last modified on December 21, 1982 2:32 pm by Paul Rovner

DIRECTORY
AMBridge USING[TVHeadType, WordSequence, RemoteRef, RemotePointer, nilRemotePointer,
RemoteFrameHandle, RemoteGlobalFrameHandle],
AMTypes USING[Status],
PrincOps USING[ProcDesc, SignalDesc, FrameHandle, GlobalFrameHandle, GFTIndex, BytePC,
EPRange, ControlLink, StateVector],
Rope USING[ROPE],
RTBasic USING[Type, TypedVariable, Index],
RTCommon USING[Field],
RTSymbolDefs USING[SymbolTableBase, SymbolIdIndex, BodyIndex, CallableBodyIndex],
WorldVM USING[World];

RTTypesPrivate: DEFINITIONS
= BEGIN OPEN AMBridge, AMTypes, PrincOps, RTBasic, RTSymbolDefs, WorldVM;

-- T Y P E S
TypedVariableRec: TYPE = RECORD
--needed for non-local tv's, embedded tvs, tvs with status # mutable, and non-REF tvs
[ referentType: TypeBundle,
head: TypedVariableHead,
status: Status ← mutable,
field: SELECT tag: * FROM
entire => [],
embedded => [fd: FieldDescriptor],
constant => [value: WordSequence]
ENDCASE];

TypeBundle: TYPE = RECORD[type: Type, tag: TypedVariable ← NIL];

TypedVariableHead: TYPE = RECORD
[ SELECT tag: TVHeadType FROM
reference => [ref: REF ANY],
remoteReference => [remoteRef: RemoteRef],
copiedRemoteObject => [world: World ← ,
worldIncarnation: LONG CARDINAL,
copy: WordSequence],

pointer => [ptr: LONG POINTER],
remotePointer => [remotePointer: RemotePointer],

gfh => [gfh: GlobalFrameHandle],
remoteGFH => [remoteGlobalFrameHandle: RemoteGlobalFrameHandle],

fh => [fh: FrameHandle,
bti: BodyIndex,
evalStack: POINTER TO PrincOps.StateVector,
isCatchFrame: BOOLFALSE,
return: BOOL,
contextPC: BOOL],
remoteFH =>
[remoteFrameHandle: RemoteFrameHandle,
bti: BodyIndex,
evalStack: WordSequence ← ,
isCatchFrame: BOOLFALSE,
return: BOOL,
contextPC: BOOL],
constant => [],
remoteConstant => [world: World ← , worldIncarnation: LONG CARDINAL]
ENDCASE];

FieldDescriptor: TYPE = RECORD
[ wordOffset: INTEGER,
extent: SELECT magnitude: * FROM
small => [field: RTCommon.Field],
large => [size: CARDINAL],
ENDCASE
];

EVRange: TYPE = [0..4*EPRange);

-- PROCEDURES
GetIdConstantValue: PROC[tv: TypedVariable,
stb: SymbolTableBase,
isei: SymbolIdIndex]
RETURNS[WordSequence];

BuildRecordFieldDescriptor: PROC[parentTV: TypedVariable,
fieldBitOffset,
fieldBits,
bitsForType: INT]
RETURNS[fD: FieldDescriptor];

GetTVZones: PROC RETURNS[qz, pz: ZONE]; -- Exported by RTTypedVariablesImpl


ValueAddress: TYPE = RECORD
[SELECT tag: * FROM
constant =>
[value: WordSequence ← ],
pointer =>
[ptr: LONG POINTERNIL, --includes the word offset
fd: FieldDescriptor
← [wordOffset: 0, extent: large[size: 0]]],
remotePointer =>
[ptr: RemotePointer ← nilRemotePointer, --includes word offset
fd: FieldDescriptor
← [wordOffset: 0, extent: large[size: 0]]],
copiedRemoteObject =>
[ptr: LONG POINTERNIL, --includes the word offset
fd: FieldDescriptor
← [wordOffset: 0, extent: large[size: 0]]]
ENDCASE];

GetValueAddress: PROC[tv: TypedVariable, mutableOnly: BOOLFALSE]
RETURNS[ValueAddress]; -- Raises NotMutable

RecordComponentISEI: PROC[type: Type--record--,
index: Index,
p: PROC[stb: SymbolTableBase,
isei: SymbolIdIndex]];

ComponentISEI
: PROC[type: Type--record, union, enumerated--,
index: Index,
p: PROC[stb: SymbolTableBase, isei: SymbolIdIndex]];

PDToName: PROC[pd: ProcDesc] RETURNS[Rope.ROPE];
SEDToName: PROC[sed: SignalDesc] RETURNS[Rope.ROPE];
GFHToName: PROC[gfh: GlobalFrameHandle] RETURNS[Rope.ROPE];

GFT: PROC [gftx: GFTIndex] RETURNS [frame: GlobalFrameHandle, epbase: CARDINAL];
GetCBTI: PROC[stb: SymbolTableBase, epn: CARDINAL]
RETURNS[cbti: CallableBodyIndex];
ConvertCbti: PROC [lastBti: BodyIndex,
pc, start: BytePC,
base: SymbolTableBase]
RETURNS [bti: BodyIndex];
GetEp: PROC [pc: BytePC, gf: GlobalFrameHandle, stb: SymbolTableBase]
RETURNS [ep: EVRange, start: BytePC];
GetPc: PROC[gf: GlobalFrameHandle, i: EVRange] RETURNS [BytePC];

BitsForType: PROC[type: Type]
RETURNS [bft: LONG CARDINAL, argumentRecord, interfaceRecord: BOOL];

GetOrigin: PROC[type: Type] RETURNS[origin: INTEGER]; -- for subrange types

UnwindIndirectProcDesc
: PROC[icl: ControlLink] RETURNS[ProcDesc];

END.