DIRECTORY Basics USING [BYTE, HighHalf, LowHalf], IO USING [GetChar, PutChar, STREAM], IPXerox USING [EncodingValue, SequenceType, ShortEncodingValue, ShortNumber, Token]; IPXeroxImpl: CEDAR PROGRAM IMPORTS Basics, IO EXPORTS IPXerox ~ BEGIN OPEN IPXerox; STREAM: TYPE ~ IO.STREAM; BYTE: TYPE ~ Basics.BYTE; PutByte: PROC[stream: STREAM, byte: BYTE] ~ INLINE { IO.PutChar[stream, VAL[byte]] }; PutToken: PUBLIC PROC[stream: STREAM, token: Token] ~ { WITH token: token SELECT FROM shortNumber => { x: [0..77777B] ~ token.number-ShortNumber.FIRST; PutByte[stream, x/400B]; PutByte[stream, x MOD 400B]; }; shortOp => { PutByte[stream, 200B+ORD[token.op]]; }; longOp => { x: [0..17777B] ~ ORD[token.op]; PutByte[stream, 240B+x/400B]; PutByte[stream, x MOD 400B]; }; shortSequence => { PutByte[stream, 300B+ORD[token.type]]; PutByte[stream, token.length]; }; longSequence => { highByte: BYTE ~ Basics.HighHalf[token.length]; -- this does the bounds check lowWord: CARDINAL ~ Basics.LowHalf[token.length]; PutByte[stream, 340B+ORD[token.type]]; PutByte[stream, highByte]; PutByte[stream, lowWord/400B]; PutByte[stream, lowWord MOD 400B]; }; ENDCASE => ERROR; }; GetByte: PROC[stream: STREAM] RETURNS[BYTE] ~ INLINE { RETURN[ORD[CHAR[IO.GetChar[stream]]]] }; GetToken: PUBLIC PROC[stream: STREAM] RETURNS[Token] ~ { b: BYTE ~ GetByte[stream]; SELECT b FROM <200B => RETURN[[shortNumber[b*400B+GetByte[stream]+ShortNumber.FIRST]]]; <240B => RETURN[[shortOp[VAL[b MOD 40B]]]]; <300B => RETURN[[longOp[VAL[(b MOD 40B)*400B+GetByte[stream]]]]]; <340B => RETURN[[shortSequence[type: VAL[b MOD 40B], length: GetByte[stream]]]]; <400B => { length: INT _ GetByte[stream]; length _ length*400B+GetByte[stream]; length _ length*400B+GetByte[stream]; RETURN[[longSequence[type: VAL[b MOD 40B], length: length]]]; }; ENDCASE => ERROR; }; END. ~IPXeroxImpl.mesa Copyright c 1984 Xerox Corporation. All rights reserved. Doug Wyatt, November 10, 1984 7:01:43 pm PST ʘšœ™Jšœ Ïmœ.™9Jšœ,™,—J˜šÏk ˜ Jšœžœžœ˜'Jšžœžœžœ˜$JšœžœG˜TJ˜—Jšœ žœž˜Jšžœ ž˜Jšžœ˜Jšœžœžœ ˜J˜Jšžœžœžœžœ˜Jšžœžœ žœ˜J˜š Ïnœžœ žœžœžœ˜4Jšžœžœ˜Jšœ˜J˜—šŸœžœžœ žœ˜7šžœžœž˜šœ˜Jšœ*žœ˜0Jšœ˜Jšœžœ˜Jšœ˜—šœ ˜ Jšœžœ ˜$Jšœ˜—šœ ˜ Jšœžœ ˜Jšœ˜Jšœžœ˜Jšœ˜—šœ˜Jšœžœ˜&Jšœ˜Jšœ˜—šœ˜Jšœ žœ"Ïc˜MJšœ žœ ˜1Jšœžœ˜&Jšœ˜Jšœ˜Jšœžœ˜"Jšœ˜—Jšžœžœ˜—J˜J˜—š Ÿœžœ žœžœžœžœ˜6Jšžœžœžœžœ˜%Jšœ˜J˜—š Ÿœžœžœ žœžœ ˜8Jšœžœ˜šžœž˜ Jšœ žœ1žœ˜IJšœ žœ žœžœ ˜+Jšœ žœ žœžœ˜AJšœ žœžœžœ"˜Pšœ ˜ Jšœžœ˜Jšœ%˜%Jšœ%˜%Jšžœžœžœ˜=J˜—Jšžœžœ˜—J˜J˜—Jšžœ˜—…—* Ã