-- RTTRemoteBridge.Mesa
-- last modified on September 10, 1982 10:42 am by Paul Rovner

DIRECTORY
RTTBridge USING[WordSequence],
RTTypes USING[Status, TV, TypedVariable, Type],
WorldVM USING[World, Address, ShortAddress];

RTTRemoteBridge: DEFINITIONS
= BEGIN

-- T Y P E S
TV: TYPE = RTTypes.TV;
TypedVariable: TYPE = RTTypes.TypedVariable;
Status: TYPE = RTTypes.Status;

Type: TYPE = RTTypes.Type;

World: TYPE = WorldVM.World;

RemoteRef: TYPE = RECORD[world: World ← ,
worldIncarnation: LONG CARDINAL,
ref: WorldVM.Address];
nilRemoteRef: RemoteRef = [world: NIL, ref: 0, worldIncarnation: 0];
RemotePointer: TYPE = RECORD
[world: World ← ,
worldIncarnation: LONG CARDINAL,
ptr: WorldVM.Address];
nilRemotePointer: RemotePointer = [world: NIL, ptr: 0, worldIncarnation: 0];
RemoteFrameHandle: TYPE = RECORD
[world: World ← ,
worldIncarnation: LONG CARDINAL,
fh: WorldVM.ShortAddress];
nilRemoteFrameHandle: RemoteFrameHandle = [world: NIL, fh: 0, worldIncarnation: 0];
RemoteGlobalFrameHandle: TYPE = RECORD
[world: World ← ,
worldIncarnation: LONG CARDINAL,
gfh: WorldVM.ShortAddress];
nilRemoteGlobalFrameHandle: RemoteGlobalFrameHandle = [world: NIL, gfh: 0, worldIncarnation: 0];
RemotePD: TYPE = RECORD [world: World ← ,
worldIncarnation: LONG CARDINAL,
pd: UNSPECIFIED];
nilRemotePD: RemotePD = [world: NIL, pd: 0, worldIncarnation: 0];
RemoteSED: TYPE = RECORD[world: World ← ,
worldIncarnation: LONG CARDINAL,
sed: UNSPECIFIED];
nilRemoteSED: RemoteSED = [world: NIL, sed: 0, worldIncarnation: 0];

-- P R O C E D U R E S

TVForRemoteReferent: PROC[remoteRef: RemoteRef, status: Status ← mutable]
RETURNS[TypedVariable];

RemoteRefFromTV: PROC[tv: TypedVariable] RETURNS[RemoteRef];
-- If possible, this returns the REF which points to the value represented
-- by the specified TypedVariable. Raises InternalTV if tv is embedded,
-- NotVar if TVStatus[tv] # mutable.

TVForRemotePointerReferent: PROC[remotePointer: RemotePointer,
type: Type,
status: Status ← mutable]
RETURNS[TypedVariable];

RemotePointerFromTV: PROC[tv: TypedVariable] RETURNS[RemotePointer];
-- If possible, this returns the LONG POINTER which points to the value
-- represented by the specified TypedVariable.
-- Raises MalformedTV if tv is a REF or a REF's component
-- Raises InternalTV if tv is embedded and not word aligned
-- Raises NotVar if TVStatus[tv] # mutable.

TVForRemoteFHReferent: PROC[remoteFrameHandle: RemoteFrameHandle,
evalStack: RTTBridge.WordSequence ← NIL]
RETURNS[TypedVariable];
-- all such tvs have the same (distinguished) type: fhType

RemoteFHFromTV: PROC[tv: TypedVariable] RETURNS[RemoteFrameHandle];

TVForRemoteGFHReferent:
PROC[remoteGlobalFrameHandle: RemoteGlobalFrameHandle]
RETURNS[TypedVariable];
-- all such tvs have the same (distinguished) type: gfhType

RemoteGFHFromTV: PROC[tv: TypedVariable] RETURNS[RemoteGlobalFrameHandle];

TVForRemotePD: PROC[remotePD: RemotePD] RETURNS[TypedVariable--procedure--];

TVToRemotePD: PROC[tv: TypedVariable--procedure, program--]
RETURNS[RemotePD];

TVForRemoteSED: PROC[remoteSED: RemoteSED]
RETURNS[TypedVariable--signal, error--];

TVToRemoteSED: PROC[tv: TypedVariable] RETURNS[RemoteSED];

IsRemote: PROC[tv: TypedVariable] RETURNS[BOOLEAN];

GetWorld: PROC[tv: TypedVariable] RETURNS[World];

GetWorldIncarnation: PROC[tv: TypedVariable] RETURNS[LONG CARDINAL];

END.