DIRECTORY Basics, ImagerFont, IO, Real, Rope, RoseControl, RoseWireClasses, RoseWireTypes, VFonts; RoseBoolImpl: CEDAR PROGRAM IMPORTS ImagerFont, IO, Real, Rope, RoseControl, RoseWireTypes EXPORTS RoseWireClasses, RoseControl = BEGIN OPEN RoseWireTypes; GetBool: PUBLIC PROC RETURNS [RoseWireClass] = {RETURN[boolClass]}; boolSuperClass: RoseWireSuperClass _ NEW[RoseWireSuperClassRec _ [ GetType: BoolGetType, ListFormats: BoolListFormats, GetFormat: BoolGetFormat, SelectorOffset: NIL, SubType: NIL, SubClass: NIL, Bits: BoolBits, MesaRepresentation: BoolMesaRepresentation, MesaRepAux: NIL, flavor: simple, Initialize: BoolInitialize, Transduce: BoolTransduce ]]; boolClass: RoseWireClass _ NEW[RoseWireClassRec _ [ structure: atom, dereference: FALSE, addressContaining: FALSE, classData: NIL, super: boolSuperClass]]; BoolGetType: PROC [rwc: RoseWireClass, wire: Wire] RETURNS [rwt: RoseWireType] = { IF StructureOfWire[wire] # atom THEN ERROR; RETURN[boolType]; }; boolType: PUBLIC RoseWireType _ NEW[RoseWireTypeRec _ [ class: boolClass, typeData: NIL, length: 0, other: NIL]]; BoolListFormats: PROC [rwt: RoseWireType] RETURNS [lor: LOR] = { lor _ LIST["2", "4", "8", "16", "idiosyncratic"]; }; BoolGetFormat: PROC [rwt: RoseWireType, formatName: ROPE] RETURNS [format: Format] = { format _ SELECT TRUE FROM formatName=NIL, formatName.Equal["16"], formatName.Equal["8"], formatName.Equal["4"], formatName.Equal["2"] => numericFormat, formatName.Equal["idiosyncratic"] => idiosyncraticFormat, ENDCASE => ERROR; }; BoolBits: PROC [rwt: RoseWireClass] RETURNS [n: INT] = {RETURN[1]}; BoolMesaRepresentation: PROC [rwc: RoseWireClass] RETURNS [mesa: Mesa] = { mesa _ [mesa: "BOOL"]}; BoolInitialize: PROC [rwt: RoseWireType, p: Ptr, steady: BOOL] = { WriteBool[p, FALSE]; }; BoolTransduce: PROC [fromS: Strength, fromT, toT: RoseWireType, fromP, toP: Ptr] = { IF fromT # boolType THEN ERROR; IF toT # RoseControl.bitType THEN ERROR; RoseControl.WriteSwitch[ toP, SELECT ReadBool[fromP] FROM FALSE => [s: [q: fromS, u: none, d: fromS], val: L], TRUE => [s: [q: fromS, u: fromS, d: none], val: H], ENDCASE => ERROR ]; }; numericFormat: Format _ NEW [FormatRep _ [ FormatValue: NumericFormatValue, ParseValue: NumericParseValue, MaxWidth: NumericMaxWidth, key: "2"]]; NumericFormatValue: PROC [rwt: RoseWireType, f: Format, p: Ptr] RETURNS [r: ROPE] = { r _ SELECT ReadBool[p] FROM FALSE => "0H", TRUE => "1H", ENDCASE => ERROR; }; NumericParseValue: PROC [rwt: RoseWireType, f: Format, p: Ptr, s: STREAM] RETURNS [ok: BOOL] = { c1: CHAR = s.GetChar[]; c2: CHAR = s.GetChar[]; val: BOOL; SELECT c1 FROM '0 => val _ FALSE; '1 => val _ TRUE; ENDCASE => RETURN [FALSE]; SELECT c2 FROM 'B, 'Q, 'O, 'H => NULL; ENDCASE => RETURN [FALSE]; WriteBool[p, val]; ok _ TRUE; }; NumericMaxWidth: PROC [rwt: RoseWireType, fmt: Format, font: VFonts.Font] RETURNS [max: INT] = { max _ Real.Round[ImagerFont.RopeWidth[font, "XH"].x]; }; idiosyncraticFormat: Format _ NEW [FormatRep _ [ FormatValue: IdioFormatValue, ParseValue: IdioParseValue, MaxWidth: IdioMaxWidth, key: "idiosyncratic"]]; IdioFormatValue: PROC [rwt: RoseWireType, f: Format, p: Ptr] RETURNS [r: ROPE] = { r _ SELECT ReadBool[p] FROM FALSE => "FALSE", TRUE => "TRUE", ENDCASE => ERROR; }; IdioParseValue: PROC [rwt: RoseWireType, f: Format, p: Ptr, s: STREAM] RETURNS [ok: BOOL] = { toke: ROPE = s.GetTokenRope[WireValBreak].token; val: BOOL; SELECT TRUE FROM toke.Equal["TRUE"] => val _ TRUE; toke.Equal["FALSE"] => val _ FALSE; ENDCASE => RETURN [FALSE]; WriteBool[p, val]; ok _ TRUE; }; IdioMaxWidth: PROC [rwt: RoseWireType, fmt: Format, font: VFonts.Font] RETURNS [max: INT] = { max _ Real.Round[ImagerFont.RopeWidth[font, "FALSE"].x]; }; BoolArrayPtr: TYPE = LONG POINTER TO PACKED ARRAY [0 .. Basics.bitsPerWord) OF BOOL; ReadBool: PUBLIC PROC [p: Ptr] RETURNS [b: BOOL] = TRUSTED { bap: BoolArrayPtr = LOOPHOLE[p.word]; b _ bap[p.bit]; }; WriteBool: PUBLIC PROC [p: Ptr, b: BOOL] = TRUSTED { bap: BoolArrayPtr = LOOPHOLE[p.word]; bap[p.bit] _ b; }; END. ͺRoseBoolImpl.mesa Copyright c 1985 by Xerox Corporation. All rights reserved. Barth, September 5, 1985 6:37:22 pm PDT Spreitzer, November 18, 1985 10:22:29 pm PST Κ– "cedar" style˜codešœ™Kšœ Οmœ1™Kšžœ˜&—K˜Kšžœžœ˜K˜š Οnœžœžœžœžœ ˜CK˜—šœ%žœ˜BKšœ˜Kšœ˜Kšœ˜Kšœžœ˜Kšœ žœ˜ Kšœ žœ˜Kšœ˜Kšœ+˜+Kšœ žœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜K˜—šœžœ˜3Kšœ˜Kšœ žœ˜Kšœžœ˜Kšœ žœ˜Kšœ˜K˜—š  œžœ"žœ˜RKšžœžœžœ˜+Kšžœ ˜Kšœ˜K˜—šœ žœžœ˜7Kšœ˜Kšœ žœ˜Kšœ ˜ Kšœžœ˜ K˜—š œžœžœžœ˜@Kšœžœ'˜1Kšœ˜K˜—š  œžœ!žœžœ˜Všœ žœžœž˜Kšœ žœo˜}Kšœ9˜9Kšžœžœ˜—Kšœ˜K˜—š  œžœžœžœžœ˜CK˜—š œžœžœ˜JKšœ˜K˜—š œžœ%žœ˜BKšœ žœ˜K˜K˜—š  œžœA˜TKšžœžœžœ˜Kšžœžœžœ˜(šœ˜K˜šžœž˜Kšžœ/˜4Kšžœ/˜3Kšžœž˜—K˜—K˜K˜—šœžœ˜*Kšœ ˜ K˜Kšœ˜Kšœ ˜ K˜—š œžœ(žœžœ˜Ušœžœ ž˜Kšžœ ˜Kšžœ ˜ Kšžœžœ˜—K˜K˜—š  œžœ+žœžœžœ˜`Kšœžœ˜Kšœžœ˜Kšœžœ˜ šžœž˜Kšœ žœ˜Kšœ žœ˜Kšžœžœžœ˜—šžœž˜Kšœžœ˜Kšžœžœžœ˜—Kšœ˜Kšœžœ˜ K˜K˜—š œžœ5žœžœ˜`Kšœ5˜5K˜K˜—šœžœ˜0Kšœ˜K˜Kšœ˜Kšœ˜K˜—š œžœ(žœžœ˜Ršœžœ ž˜Kšžœ ˜Kšžœ ˜Kšžœžœ˜—K˜K˜—š  œžœ+žœžœžœ˜]Kšœžœ&˜0Kšœžœ˜ šžœžœž˜Kšœžœ˜!Kšœžœ˜#Kšžœžœžœ˜—Kšœ˜Kšœžœ˜ K˜K˜—š  œžœ5žœžœ˜]Kšœ8˜8K˜K˜—Kšœžœžœžœžœžœžœžœžœ˜TK˜š  œžœžœ žœžœžœ˜