-- file: TexParagraph3Impl.mesa -- Pascal-to-Mesa translator output, translated at September 27, 1985 10:21:38 am PDT DIRECTORY PascalBasic, TexTypes, TexInteraction, TexMemory, TexSymbols, TexOps, TexParagraph, TexSysdepInline; TexParagraph3Impl: PROGRAM IMPORTS TexTypes, TexInteraction, TexMemory, TexSymbols, TexOps, TexParagraph, TexSysdepInline EXPORTS TexParagraph = PUBLIC BEGIN OPEN PascalBasic, TexTypes, TexInteraction, TexMemory, TexSymbols, TexOps, TexParagraph, TexSysdepInline; TryBreak: PROCEDURE[Pi: PascalInteger,BreakType: SmallNumber] = BEGIN R:Halfword;PrevR:Halfword;OldL:Halfword; NoBreakYet:PascalBoolean;--830:--PrevPrevR:Halfword;S:Halfword;Q:Halfword; V:Halfword;T:Quarterword;F:InternalFontNumber;L:Halfword; NodeRStaysActive:PascalBoolean;LineWidth:Scaled;FitClass:PascalInteger[0..3];B:Halfword; D:PascalInteger;ArtificialBadness:PascalBoolean;SaveLink:Halfword; Shortfall:Scaled;--:830-- TryBreakInner: PROCEDURE = BEGIN --836: BEGIN IF NoBreakYet THEN--837:--BEGIN NoBreakYet←FALSE; BreakWidth↑[1]←Background↑[1];BreakWidth↑[2]←Background↑[2]; BreakWidth↑[3]←Background↑[3];BreakWidth↑[4]←Background↑[4]; BreakWidth↑[5]←Background↑[5];BreakWidth↑[6]←Background↑[6]; {IF(BreakType=0)OR (CurP=0) THEN BEGIN S←CurP; WHILE S#0 DO BEGIN IF( INT[S]>=HiMemMin) THEN GOTO Label30; SELECT Mem[S]↑.Hh.B0 FROM 10 =>--838:--BEGIN V←Mem[S+1]↑.Hh.Lh; BreakWidth↑[1]←BreakWidth↑[1]-Mem[V+1]↑.Int; BreakWidth↑[2+Mem[V]↑.Hh.B0]←BreakWidth↑[2+Mem[V]↑.Hh.B0]-Mem[V+2]↑.Int; BreakWidth↑[6]←BreakWidth↑[6]-Mem[V+3]↑.Int; END--:838--;12 => NULL; 9,11 =>BreakWidth↑[1]←BreakWidth↑[1]-Mem[S+1]↑.Int; ENDCASE => GOTO Label30 ; S←Mem[S]↑.Hh.Rh; END ENDLOOP ; END ELSE--840:--BEGIN T←Mem[CurP]↑.Hh.B1;S←CurP; WHILE INT[T]>0 DO BEGIN T←T-1;S←Mem[S]↑.Hh.Rh;--841: IF( INT[S]>=HiMemMin) THEN BEGIN F←Mem[S]↑.Hh.B0; BreakWidth↑[1]←BreakWidth↑[1]-FontInfo↑[WidthBase↑[F]+FontInfo↑ [CharBase↑[F]+Mem[S]↑.Hh.B1].Qqqq.B0].Int; END ELSE SELECT Mem[S]↑.Hh.B0 FROM 6 =>BEGIN F←Mem[S+1]↑.Hh.B0; BreakWidth↑[1]←BreakWidth↑[1]-FontInfo↑[WidthBase↑[F]+FontInfo↑ [CharBase↑[F]+Mem[S+1]↑.Hh.B1].Qqqq.B0].Int; END; 0,1,2,11 =>BreakWidth↑[1]←BreakWidth↑[1]-Mem[S+1]↑.Int; ENDCASE =>Confusion[782]--:841--; END ENDLOOP ;S←Mem[CurP+1]↑.Hh.Rh; WHILE S#0 DO BEGIN--842:--IF( INT[S]>=HiMemMin) THEN BEGIN F←Mem[S]↑.Hh.B0; BreakWidth↑[1]←BreakWidth↑[1]+FontInfo↑[WidthBase↑[F]+FontInfo↑ [CharBase↑[F]+Mem[S]↑.Hh.B1].Qqqq.B0].Int; END ELSE SELECT Mem[S]↑.Hh.B0 FROM 6 =>BEGIN F←Mem[S+1]↑.Hh.B0; BreakWidth↑[1]←BreakWidth↑[1]+FontInfo↑[WidthBase↑[F]+FontInfo↑ [CharBase↑[F]+Mem[S+1]↑.Hh.B1].Qqqq.B0].Int; END; 0,1,2,11 =>BreakWidth↑[1]←BreakWidth↑[1]+Mem[S+1]↑.Int; ENDCASE =>Confusion[783]--:842--;S←Mem[S]↑.Hh.Rh; END ENDLOOP ; BreakWidth↑[1]←BreakWidth↑[1]+DiscWidth; END--:840--;EXITS Label30 => NULL}; END--:837--;--843: IF Mem[PrevR]↑.Hh.B0=2 THEN BEGIN Mem[PrevR+1]↑.Int← Mem[PrevR+1]↑.Int-CurActiveWidth↑[1]+BreakWidth↑[1]; Mem[PrevR+2]↑.Int←Mem[PrevR+2]↑.Int-CurActiveWidth↑[2]+BreakWidth↑[2]; Mem[PrevR+3]↑.Int←Mem[PrevR+3]↑.Int-CurActiveWidth↑[3]+BreakWidth↑[3]; Mem[PrevR+4]↑.Int←Mem[PrevR+4]↑.Int-CurActiveWidth↑[4]+BreakWidth↑[4]; Mem[PrevR+5]↑.Int←Mem[PrevR+5]↑.Int-CurActiveWidth↑[5]+BreakWidth↑[5]; Mem[PrevR+6]↑.Int←Mem[PrevR+6]↑.Int-CurActiveWidth↑[6]+BreakWidth↑[6]; END ELSE IF PrevR=64994 THEN BEGIN ActiveWidth↑[1]←BreakWidth↑[1]; ActiveWidth↑[2]←BreakWidth↑[2];ActiveWidth↑[3]←BreakWidth↑[3]; ActiveWidth↑[4]←BreakWidth↑[4];ActiveWidth↑[5]←BreakWidth↑[5]; ActiveWidth↑[6]←BreakWidth↑[6]; END ELSE BEGIN Q←GetNode[7]; Mem[Q]↑.Hh.Rh←R;Mem[Q]↑.Hh.B0←2;Mem[Q]↑.Hh.B1←0; Mem[Q+1]↑.Int←BreakWidth↑[1]-CurActiveWidth↑[1]; Mem[Q+2]↑.Int←BreakWidth↑[2]-CurActiveWidth↑[2]; Mem[Q+3]↑.Int←BreakWidth↑[3]-CurActiveWidth↑[3]; Mem[Q+4]↑.Int←BreakWidth↑[4]-CurActiveWidth↑[4]; Mem[Q+5]↑.Int←BreakWidth↑[5]-CurActiveWidth↑[5]; Mem[Q+6]↑.Int←BreakWidth↑[6]-CurActiveWidth↑[6];Mem[PrevR]↑.Hh.Rh←Q; PrevPrevR←PrevR;PrevR←Q; END--:843--; MinimumDemerits←MinimumDemerits+ABS[Eqtb↑[4783].Int]; FOR i:INT IN [ INT[0 ].. INT[3 ]] DO FitClass ← i; IF MinimalDemerits↑[FitClass]<=MinimumDemerits THEN--845:--BEGIN Q←GetNode[2];Mem[Q]↑.Hh.Rh←Passive; Passive←Q;Mem[Q+1]↑.Hh.Rh←CurP;PassNumber←PassNumber+1; Mem[Q]↑.Hh.Lh←PassNumber;Mem[Q+1]↑.Hh.Lh←BestPlace↑[FitClass]; Q←GetNode[3];Mem[Q+1]↑.Hh.Rh←Passive; Mem[Q+1]↑.Hh.Lh←BestPlLine↑[FitClass]+1;Mem[Q]↑.Hh.B1←FitClass; Mem[Q]↑.Hh.B0←BreakType;Mem[Q+2]↑.Int←MinimalDemerits↑[FitClass]; Mem[Q]↑.Hh.Rh←R;Mem[PrevR]↑.Hh.Rh←Q;PrevR←Q; IF Eqtb↑[4799].Int>0 THEN--846:--BEGIN PrintNl[784]; PrintInt[Mem[Passive]↑.Hh.Lh];Print[785];PrintInt[ INT[Mem[Q+1]↑.Hh.Lh]-1]; PrintChar[46];PrintInt[FitClass];IF BreakType=1 THEN PrintChar[45]; Print[786];PrintInt[Mem[Q+2]↑.Int];Print[787]; IF Mem[Passive+1]↑.Hh.Lh=0 THEN PrintChar[48] ELSE PrintInt[Mem[Mem[ Passive+1]↑.Hh.Lh]↑.Hh.Lh]; END--:846--; END--:845--; MinimalDemerits↑[FitClass]←1073741823; ENDLOOP; MinimumDemerits←1073741823;--844: IF R#64994 THEN BEGIN Q←GetNode[7];Mem[Q]↑.Hh.Rh←R;Mem[Q]↑.Hh.B0←2; Mem[Q]↑.Hh.B1←0;Mem[Q+1]↑.Int←CurActiveWidth↑[1]-BreakWidth↑[1]; Mem[Q+2]↑.Int←CurActiveWidth↑[2]-BreakWidth↑[2]; Mem[Q+3]↑.Int←CurActiveWidth↑[3]-BreakWidth↑[3]; Mem[Q+4]↑.Int←CurActiveWidth↑[4]-BreakWidth↑[4]; Mem[Q+5]↑.Int←CurActiveWidth↑[5]-BreakWidth↑[5]; Mem[Q+6]↑.Int←CurActiveWidth↑[6]-BreakWidth↑[6];Mem[PrevR]↑.Hh.Rh←Q; PrevPrevR←PrevR;PrevR←Q; END--:844--; END--:836--; END;--831: {IF ABS[Pi]>=10000 THEN IF Pi>0 THEN GOTO Label10 ELSE Pi←-10000--:831--; NoBreakYet←TRUE;PrevR←64994;OldL←0; CurActiveWidth↑[1]←ActiveWidth↑[1]; CurActiveWidth↑[2]←ActiveWidth↑[2]; CurActiveWidth↑[3]←ActiveWidth↑[3]; CurActiveWidth↑[4]←ActiveWidth↑[4]; CurActiveWidth↑[5]←ActiveWidth↑[5]; CurActiveWidth↑[6]←ActiveWidth↑[6]; WHILE TRUE DO BEGIN DO {--Label22:--R←Mem[PrevR]↑.Hh.Rh;--832: IF Mem[R]↑.Hh.B0=2 THEN BEGIN CurActiveWidth↑[1]← CurActiveWidth↑[1]+Mem[R+1]↑.Int;CurActiveWidth↑[2]←CurActiveWidth↑[2]+Mem[R+2]↑.Int; CurActiveWidth↑[3]←CurActiveWidth↑[3]+Mem[R+3]↑.Int; CurActiveWidth↑[4]←CurActiveWidth↑[4]+Mem[R+4]↑.Int; CurActiveWidth↑[5]←CurActiveWidth↑[5]+Mem[R+5]↑.Int; CurActiveWidth↑[6]←CurActiveWidth↑[6]+Mem[R+6]↑.Int; PrevPrevR←PrevR;PrevR←R; GOTO Label22; END--:832--;--835: BEGIN L←Mem[R+1]↑.Hh.Lh; IF INT[L]>OldL THEN BEGIN IF(MinimumDemerits<1073741823)AND (( OldL#EasyLine)OR (R=64994)) THEN TryBreakInner[];IF R=64994 THEN GOTO Label10; --850:--IF INT[L]>EasyLine THEN BEGIN LineWidth←SecondWidth;OldL←65514; END ELSE BEGIN OldL←L; IF INT[L]>LastSpecialLine THEN LineWidth←SecondWidth ELSE IF Eqtb↑[3556]. Hh.Rh=0 THEN LineWidth←FirstWidth ELSE LineWidth←Mem[Eqtb↑[3556].Hh. Rh+ INT[2]*L]↑.Int; END--:850--; END; END--:835--;--851: BEGIN ArtificialBadness←FALSE; Shortfall←LineWidth-CurActiveWidth↑[1];IF Shortfall>0 THEN--852: IF(CurActiveWidth↑[3]#0)OR (CurActiveWidth↑[4]#0)OR (CurActiveWidth↑ [5]#0) THEN BEGIN B←0;FitClass←2; END ELSE BEGIN {IF Shortfall>7230584 THEN IF CurActiveWidth↑[2]<1663497 THEN BEGIN B←10000;FitClass←0; GOTO Label31; END; B←Badness[Shortfall,CurActiveWidth↑[2]]; IF INT[B]>12 THEN IF INT[B]>99 THEN FitClass←0 ELSE FitClass←1 ELSE FitClass ←2;EXITS Label31 => NULL}; END--:852-- ELSE--853: BEGIN IF-Shortfall>CurActiveWidth↑[6] THEN B←10001 ELSE B←Badness[ -Shortfall,CurActiveWidth↑[6]]; IF INT[B]>12 THEN FitClass←3 ELSE FitClass←2; END--:853--; {IF( INT[B]>10000)OR (Pi=-10000) THEN--854: BEGIN IF SecondPass AND (MinimumDemerits=1073741823)AND ( Mem[R]↑.Hh.Rh=64994)AND (PrevR=64994) THEN BEGIN B←0;ArtificialBadness←TRUE; END ELSE IF B>Threshold THEN GOTO Label60;NodeRStaysActive←FALSE; END--:854-- ELSE BEGIN PrevR←R;IF B>Threshold THEN GOTO Label22; NodeRStaysActive←TRUE; END;--855:----859:--D←Eqtb↑[4769].Int+B;D←D*D; IF Pi#0 THEN IF Pi>0 THEN D←D+Pi*Pi ELSE IF Pi>-10000 THEN D←D-Pi*Pi; IF(BreakType=1)AND (Mem[R]↑.Hh.B0=1) THEN IF CurP#0 THEN D←D+Eqtb↑[4781] .Int ELSE D←D+Eqtb↑[4782].Int; IF ABS[FitClass-Mem[R]↑.Hh.B1]>1 THEN D←D+Eqtb↑[4783].Int--:859--; IF Eqtb↑[4799].Int>0 THEN--856:--BEGIN IF PrintedNode#CurP THEN--857: BEGIN PrintNl[210]; IF CurP=0 THEN ShortDisplay[Mem[PrintedNode]↑.Hh.Rh] ELSE BEGIN SaveLink←Mem[CurP]↑.Hh.Rh;Mem[CurP]↑.Hh.Rh←0;PrintNl[210]; ShortDisplay[Mem[PrintedNode]↑.Hh.Rh];Mem[CurP]↑.Hh.Rh←SaveLink; END; PrintedNode←CurP; END--:857--;PrintNl[64]; IF CurP=0 THEN PrintEsc[458] ELSE IF Mem[CurP]↑.Hh.B0#10 THEN BEGIN IF Mem[CurP]↑.Hh.B0=12 THEN PrintEsc[392] ELSE IF Mem[CurP]↑.Hh.B0=7 THEN PrintEsc[220] ELSE IF Mem[CurP]↑.Hh.B0=11 THEN PrintEsc[212] ELSE PrintEsc[214]; END;Print[788]; IF Mem[R+1]↑.Hh.Rh=0 THEN PrintChar[48] ELSE PrintInt[Mem[Mem[R+1]↑.Hh.Rh ]↑.Hh.Lh];Print[789]; IF ArtificialBadness THEN PrintChar[42] ELSE PrintInt[B];Print[790]; PrintInt[Pi];Print[791];PrintInt[D]; END--:856--;D←D+Mem[R+2]↑.Int; IF D<=MinimalDemerits↑[FitClass] THEN BEGIN MinimalDemerits↑[FitClass] ←D;BestPlace↑[FitClass]←Mem[R+1]↑.Hh.Rh;BestPlLine↑[FitClass]←L; IF D<MinimumDemerits THEN MinimumDemerits←D; END--:855--; IF NodeRStaysActive THEN GOTO Label22;EXITS Label60 => NULL};--860: Mem[PrevR]↑.Hh.Rh←Mem[R]↑.Hh.Rh;FreeNode[R,3]; IF PrevR=64994 THEN--861:--BEGIN R←Mem[64994]↑.Hh.Rh; IF Mem[R]↑.Hh.B0=2 THEN BEGIN ActiveWidth↑[1]←ActiveWidth↑[1]+Mem[R+1]↑. Int;ActiveWidth↑[2]←ActiveWidth↑[2]+Mem[R+2]↑.Int; ActiveWidth↑[3]←ActiveWidth↑[3]+Mem[R+3]↑.Int; ActiveWidth↑[4]←ActiveWidth↑[4]+Mem[R+4]↑.Int; ActiveWidth↑[5]←ActiveWidth↑[5]+Mem[R+5]↑.Int; ActiveWidth↑[6]←ActiveWidth↑[6]+Mem[R+6]↑.Int; CurActiveWidth↑[1]←ActiveWidth↑[1]; CurActiveWidth↑[2]←ActiveWidth↑[2]; CurActiveWidth↑[3]←ActiveWidth↑[3]; CurActiveWidth↑[4]←ActiveWidth↑[4]; CurActiveWidth↑[5]←ActiveWidth↑[5]; CurActiveWidth↑[6]←ActiveWidth↑[6];Mem[64994]↑.Hh.Rh←Mem[R]↑.Hh.Rh; FreeNode[R,7]; END; END--:861 ELSE IF Mem[PrevR]↑.Hh.B0=2 THEN BEGIN R←Mem[PrevR]↑.Hh.Rh; IF R=64994 THEN BEGIN CurActiveWidth↑[1]←CurActiveWidth↑[1]-Mem[ PrevR+1]↑.Int; CurActiveWidth↑[2]←CurActiveWidth↑[2]-Mem[PrevR+2]↑.Int; CurActiveWidth↑[3]←CurActiveWidth↑[3]-Mem[PrevR+3]↑.Int; CurActiveWidth↑[4]←CurActiveWidth↑[4]-Mem[PrevR+4]↑.Int; CurActiveWidth↑[5]←CurActiveWidth↑[5]-Mem[PrevR+5]↑.Int; CurActiveWidth↑[6]←CurActiveWidth↑[6]-Mem[PrevR+6]↑.Int; Mem[PrevPrevR]↑.Hh.Rh←64994;FreeNode[PrevR,7];PrevR←PrevPrevR; END ELSE IF Mem[R]↑.Hh.B0=2 THEN BEGIN CurActiveWidth↑[1]← CurActiveWidth↑[1]+Mem[R+1]↑.Int; CurActiveWidth↑[2]←CurActiveWidth↑[2]+Mem[R+2]↑.Int; CurActiveWidth↑[3]←CurActiveWidth↑[3]+Mem[R+3]↑.Int; CurActiveWidth↑[4]←CurActiveWidth↑[4]+Mem[R+4]↑.Int; CurActiveWidth↑[5]←CurActiveWidth↑[5]+Mem[R+5]↑.Int; CurActiveWidth↑[6]←CurActiveWidth↑[6]+Mem[R+6]↑.Int; Mem[PrevR+1]↑.Int←Mem[PrevR+1]↑.Int+Mem[R+1]↑.Int; Mem[PrevR+2]↑.Int←Mem[PrevR+2]↑.Int+Mem[R+2]↑.Int; Mem[PrevR+3]↑.Int←Mem[PrevR+3]↑.Int+Mem[R+3]↑.Int; Mem[PrevR+4]↑.Int←Mem[PrevR+4]↑.Int+Mem[R+4]↑.Int; Mem[PrevR+5]↑.Int←Mem[PrevR+5]↑.Int+Mem[R+5]↑.Int; Mem[PrevR+6]↑.Int←Mem[PrevR+6]↑.Int+Mem[R+6]↑.Int; Mem[PrevR]↑.Hh.Rh←Mem[R]↑.Hh.Rh;FreeNode[R,7]; END; END--:860--; END--:851--; EXIT; EXITS Label22 => NULL} ENDLOOP; END ENDLOOP ;EXITS Label10 => NULL};--858: IF CurP=PrintedNode THEN IF CurP#0 THEN IF Mem[CurP]↑.Hh.B0=7 THEN BEGIN T←Mem[CurP]↑.Hh.B1;WHILE INT[T]>0 DO BEGIN T←T-1; PrintedNode←Mem[PrintedNode]↑.Hh.Rh; END ENDLOOP ; END--:858--; END;--:829----877: END.