DIRECTORY Ascii, IO, Rope, TSObject, TSGlue, TSTypes, TSDumper, JaMFnsDefs, ViewerIO; TSDumperImpl: CEDAR PROGRAM IMPORTS TSObject, IO, TSTypes, JaMFnsDefs, ViewerIO EXPORTS TSDumper = BEGIN OPEN TSTypes, TSGlue; ROPE: TYPE = Rope.ROPE; stream: IO.STREAM _ NIL; Stream: PROC RETURNS [IO.STREAM] = { IF stream=NIL THEN stream _ ViewerIO.CreateViewerStreams["Boxes.log"].out; RETURN[stream] }; oneLine: NAT _ 0; -- non-zero puts stuff on one line SameLine: PROC = {oneLine_oneLine+1}; Indent: PROC [i: NAT] = {IF oneLine=0 THEN THROUGH [0..i) DO Pc['.]; Pc[Ascii.TAB] ENDLOOP}; DumpList: PUBLIC PROC [list: TSObject.ItemList, indent: NAT _ 0] = { oldOneLine: NAT _ oneLine; lastThingWasCharBox: BOOLEAN _ FALSE; source: TSObject.ListReader; FinishCharBox: PROC = { IF lastThingWasCharBox THEN {Pc['"]; Pl[" Chars"]; lastThingWasCharBox _ FALSE} }; DumpException: PROC[x: REF ANY] = { FinishCharBox[]; Indent[indent]; SELECT TRUE FROM ISTYPE[x, TSObject.Glue] => { glue: TSObject.Glue _ NARROW[x]; Pd[glue.space]; Pr["plus"]; Pd[glue.stretch]; Pr["minus"]; Pd[glue.shrink]; Pl["glue"]; }; ISTYPE[x, TSObject.Box] => TRUSTED { box: TSObject.Box _ NARROW[x]; Pd[box.extent[left]]; Pr["+"]; Pd[box.extent[right]]; Pr["wide"]; Pd[box.extent[up]]; Pr["high"]; Pd[box.extent[down]]; Pr["deep"]; WITH b: box SELECT FROM char => { Pc['"]; Pc[source.CurrentChar[]]; Pc['"]; Pl[" CharBox"]; }; list => { IF b.direction = down THEN Pr["vbox"] ELSE Pr["hbox"]; Stream[].Put[IO.real[b.glueset.value]]; Pl[" glueset"]; DumpList[b.items, indent+1]; Indent[indent+1]; Pl["endbox"]; }; rule => Pl["rule"]; ENDCASE => Pl["box"]; }; ISTYPE[x, TSObject.Kerf] => { k: TSObject.Kerf _ NARROW[x]; p: LIST OF REF ANY _ k.prebreak; SameLine[]; WHILE p # NIL DO DumpException[p.first]; p _ p.rest; ENDLOOP; Pl["pre"]; p _ k.join; WHILE p # NIL DO DumpException[p.first]; p _ p.rest; ENDLOOP; Pl["join"]; p _ k.postbreak; WHILE p # NIL DO DumpException[p.first]; p _ p.rest; ENDLOOP; Pl["post"]; oneLine _ oldOneLine; Stream[].Put[IO.real[k.penalty]]; Pl[" penalty"]; }; ISTYPE[x, TSObject.Kern] => { Pd[NARROW[x, TSObject.Kern]^]; Pl["kern"]; }; ENDCASE => {IO.Put[Stream[],IO.refAny[x]]}; }; source _ list.CreateReader[]; UNTIL source.End[] DO SELECT source.CurrentTag[] FROM char => { IF NOT lastThingWasCharBox THEN {Indent[indent]; Pc['"]}; Pc[source.CurrentChar[]]; lastThingWasCharBox _ TRUE }; space => { IF NOT lastThingWasCharBox THEN {Indent[indent]; Pc['"]}; Pc['\\];Pc[' ]; lastThingWasCharBox _ TRUE }; hyphen => { IF NOT lastThingWasCharBox THEN {Indent[indent]; Pc['"]}; Pc['\\];Pc['-]; lastThingWasCharBox _ TRUE }; exception => DumpException[source.CurrentItem[]]; ENDCASE => ERROR; source.Next[]; ENDLOOP; FinishCharBox[]; oneLine _ oldOneLine; IF indent = 0 THEN Pl[""]; }; Pc: PROC[c: CHAR] = {IO.PutChar[Stream[],c]}; Pr: PROC[r: ROPE] = {IO.PutRope[Stream[],r]; Pc[' ]}; Pl: PROC[r: ROPE] = TRUSTED {IO.PutRope[Stream[],r]; IF JaMFnsDefs.GetJaMBreak[] THEN ERROR ABORTED; IF oneLine=0 THEN IO.PutRope[Stream[],"\n"] ELSE Pc[' ]}; Pd: PROC[d: Dimn] = {OPEN IO; Put[Stream[],real[DimnRatio[d,pt]], rope[" pt "]]}; DumpReset: PUBLIC PROC [] = {stream _ NIL}; DumpText: PUBLIC PROC [t: REF READONLY TEXT] = { {OPEN IO; Put[Stream[],text[t],char[CR]]}; }; END. ’TSDumperImpl.mesa Dumps boxes and glue, for debugging Michael Plass, November 15, 1983 1:16 pm Last Edited by: Beach, May 24, 1983 9:11 am ΚΆ– "cedar" style˜JšΟc™Jš#™#Jš)™)J™+JšΟk œ žœB˜VJ˜šœžœž˜Jšžœ žœ˜3Jšžœ ˜—Jšžœžœ˜Jšžœžœžœ˜J˜Jšœžœžœžœ˜š Οnœžœžœžœžœ˜$Jšžœžœžœ8˜JJšžœ˜Jšœ˜—J˜Jšœ žœ"˜4JšŸœžœ˜%JšŸœžœžœžœ žœžœžœžœžœ˜\J˜šŸœžœžœ#žœ ˜DJšœ žœ ˜Jšœžœžœ˜%J˜šŸ œžœ˜Jšžœžœ.žœ˜OJ˜—šŸ œžœžœžœ˜#J˜J˜šžœžœž˜šžœ˜Jšœžœ˜ J˜WJ˜—šžœžœ˜$Jšœžœ˜J˜J˜"J˜J˜!šžœžœž˜˜ J˜9J˜—˜ Jšžœžœ žœ ˜6Jšœ žœ˜'J˜J˜J˜J˜ J˜—J˜Jšžœ˜—J˜—šžœ˜Jšœžœ˜Jš œžœžœžœžœ˜ J˜ šžœžœž˜J˜J˜ Jšžœ˜—J˜ J˜ šžœžœž˜J˜J˜ Jšžœ˜—J˜ J˜šžœžœž˜J˜J˜ Jšžœ˜—J˜ J˜Jšœ žœ˜!J˜J˜—šžœ˜Jšœžœ˜J˜ J˜—Jšžœžœ˜+—J˜—J˜šžœž˜šžœž˜˜ Jšžœžœžœ˜9Jšœ0ž˜4J˜—˜ Jšžœžœžœ˜9Jšœ&ž˜*J˜—˜ Jšžœžœžœ˜9Jšœ&ž˜*J˜—J˜1Jšžœžœ˜—J˜Jšžœ˜—J˜J˜Jšžœ žœ˜J˜J˜—JšŸœžœžœžœ˜-JšŸœžœžœžœ˜5JšŸœžœžœžœžœžœžœžœžœžœ žœžœžœ ˜žJšŸœžœ žœžœ5˜QJ˜JšŸ œžœžœžœ˜+J˜š Ÿœžœžœžœžœžœ˜0Jšœžœžœžœ˜*J˜J˜—Jšžœ˜J˜J˜J˜J˜—…— ΐ