DIRECTORY
AMBridge USING [TVToLC],
AMTypes USING [IndexToTV, TV],
IO USING [PutF],
PrintTV USING [RegisterRefPrintProc, RegisterTVPrintProc, RefPrintProc, TVPrintProc],
Pup USING [Address, Host, Net, Socket],
PupType USING [CardFromSocket];
PupDebug:
CEDAR
PROGRAM
IMPORTS AMBridge, AMTypes, IO, PrintTV, PupType = {
PrintRefPupAddress: PrintTV.RefPrintProc = {
[ref: REF READONLY ANY, data: REF ANY, stream: STREAM, depth: INT ← 4, width: INT ← 32, verbose: BOOL ← FALSE] RETURNS [useOld: BOOL ← FALSE]
foo: REF READONLY Pup.Address ← NARROW[ref];
socket: LONG CARDINAL ← PupType.CardFromSocket[foo.socket];
IO.PutF[stream, "%B#%B#%B", [integer[foo.net]], [integer[foo.host]], [cardinal[socket]] ];
};
PrintTVPupAddress: PrintTV.TVPrintProc =
TRUSTED {
[tv: TV, data: REF ANY, stream: STREAM, depth: INT ← 4, width: INT ← 32, verbose: BOOL ← FALSE] RETURNS [useOld: BOOL ← FALSE]
foo: Pup.Address;
socket: LONG CARDINAL;
netTV: AMTypes.TV ← AMTypes.IndexToTV[tv, 1];
hostTV: AMTypes.TV ← AMTypes.IndexToTV[tv, 2];
socketTV: AMTypes.TV ← AMTypes.IndexToTV[tv, 3];
socketTVa: AMTypes.TV ← AMTypes.IndexToTV[socketTV, 1];
socketTVb: AMTypes.TV ← AMTypes.IndexToTV[socketTV, 2];
socketTVc: AMTypes.TV ← AMTypes.IndexToTV[socketTV, 3];
socketTVd: AMTypes.TV ← AMTypes.IndexToTV[socketTV, 4];
foo.net ← [AMBridge.TVToLC[netTV]];
foo.host ← [AMBridge.TVToLC[hostTV]];
foo.socket.a ← AMBridge.TVToLC[socketTVa];
foo.socket.b ← AMBridge.TVToLC[socketTVb];
foo.socket.c ← AMBridge.TVToLC[socketTVc];
foo.socket.d ← AMBridge.TVToLC[socketTVd];
socket ← PupType.CardFromSocket[foo.socket];
IO.PutF[stream, "%B#%B#%B", [cardinal[foo.net]], [cardinal[foo.host]], [cardinal[socket]] ];
};
PrintTVPupNet: PrintTV.TVPrintProc =
TRUSTED {
[tv: TV, data: REF ANY, stream: STREAM, depth: INT ← 4, width: INT ← 32, verbose: BOOL ← FALSE] RETURNS [useOld: BOOL ← FALSE]
net: Pup.Net;
net ← [AMBridge.TVToLC[tv]];
IO.PutF[stream, "%B", [cardinal[net]] ];
};
PrintTVPupHost: PrintTV.TVPrintProc =
TRUSTED {
[tv: TV, data: REF ANY, stream: STREAM, depth: INT ← 4, width: INT ← 32, verbose: BOOL ← FALSE] RETURNS [useOld: BOOL ← FALSE]
host: Pup.Host;
host ← [AMBridge.TVToLC[tv]];
IO.PutF[stream, "%B", [cardinal[host]] ];
};
PrintTVPupSocket: PrintTV.TVPrintProc =
TRUSTED {
[tv: TV, data: REF ANY, stream: STREAM, depth: INT ← 4, width: INT ← 32, verbose: BOOL ← FALSE] RETURNS [useOld: BOOL ← FALSE]
socket: Pup.Socket;
socketTVa: AMTypes.TV ← AMTypes.IndexToTV[tv, 1];
socketTVb: AMTypes.TV ← AMTypes.IndexToTV[tv, 2];
socketTVc: AMTypes.TV ← AMTypes.IndexToTV[tv, 3];
socketTVd: AMTypes.TV ← AMTypes.IndexToTV[tv, 4];
socket.a ← AMBridge.TVToLC[socketTVa];
socket.b ← AMBridge.TVToLC[socketTVb];
socket.c ← AMBridge.TVToLC[socketTVc];
socket.d ← AMBridge.TVToLC[socketTVd];
IO.PutF[stream, "%B", [cardinal[PupType.CardFromSocket[socket]]] ];
};
PrintTV.RegisterRefPrintProc[CODE[Pup.Address], PrintRefPupAddress];
PrintTV.RegisterTVPrintProc[CODE[Pup.Address], PrintTVPupAddress];
PrintTV.RegisterTVPrintProc[CODE[Pup.Net], PrintTVPupNet];
PrintTV.RegisterTVPrintProc[CODE[Pup.Host], PrintTVPupHost];
PrintTV.RegisterTVPrintProc[CODE[Pup.Socket], PrintTVPupSocket];