-- file: TexParagraphImpl.mesa -- Pascal-to-Mesa translator output, translated at September 27, 1985 10:21:37 am PDT DIRECTORY PascalBasic, TexTypes, TexInteraction, TexMemory, TexSymbols, TexOps, TexParagraph, TexSysdepInline; TexParagraphImpl: PROGRAM IMPORTS PascalBasic, TexTypes, TexInteraction, TexMemory, TexSymbols, TexOps, TexSysdepInline EXPORTS TexParagraph = PUBLIC BEGIN OPEN PascalBasic, TexTypes, TexInteraction, TexMemory, TexSymbols, TexOps, TexParagraph, TexSysdepInline; --:814----821: Passive: Halfword; PassNumber: Halfword; --:821----823: ActiveWidth: LONG POINTER TO ARRAY PascalInteger[1..6] OF Scaled ← PascalStaticZone.NEW[ARRAY PascalInteger[1..6] OF Scaled]; CurActiveWidth: LONG POINTER TO ARRAY PascalInteger[1..6] OF Scaled ← PascalStaticZone.NEW[ARRAY PascalInteger[1..6] OF Scaled]; Background: LONG POINTER TO ARRAY PascalInteger[1..6] OF Scaled ← PascalStaticZone.NEW[ARRAY PascalInteger[1..6] OF Scaled]; BreakWidth: LONG POINTER TO ARRAY PascalInteger[1..6] OF Scaled ← PascalStaticZone.NEW[ARRAY PascalInteger[1..6] OF Scaled]; --:823 --825:-- NoShrinkErrorYet: PascalBoolean; --:825----828:-- CurP: Halfword; SecondPass: PascalBoolean; Threshold: PascalInteger; --:828----833: MinimalDemerits: LONG POINTER TO ARRAY PascalInteger[0..3] OF Scaled ← PascalStaticZone.NEW[ARRAY PascalInteger[0..3] OF Scaled]; MinimumDemerits: Scaled; BestPlace: LONG POINTER TO ARRAY PascalInteger[0..3] OF Halfword ← PascalStaticZone.NEW[ARRAY PascalInteger[0..3] OF Halfword]; BestPlLine: LONG POINTER TO ARRAY PascalInteger[0..3] OF Halfword ← PascalStaticZone.NEW[ARRAY PascalInteger[0..3] OF Halfword]; --:833----839:-- DiscWidth: Scaled; --:839----847:-- EasyLine: Halfword; LastSpecialLine: Halfword; FirstWidth: Scaled; SecondWidth: Scaled; FirstIndent: Scaled; SecondIndent: Scaled; --:847----872:-- BestBet: Halfword; FewestDemerits: PascalInteger; BestLine: Halfword; ActualLooseness: PascalInteger; LineDiff: PascalInteger; --:872----892:--Hc: LONG POINTER TO ARRAY PascalInteger[0..65] OF Halfword ← PascalStaticZone.NEW[ARRAY PascalInteger[0..65] OF Halfword]; Hn: SmallNumber; Ha: Halfword; Hb: Halfword; Hf: InternalFontNumber; Hu: LONG POINTER TO ARRAY PascalInteger[1..63] OF AsciiCode ← PascalStaticZone.NEW[ARRAY PascalInteger[1..63] OF AsciiCode]; --:892----900:--Hyf: LONG POINTER TO ARRAY PascalInteger[0..64] OF PascalInteger[0..9] ← PascalStaticZone.NEW[ARRAY PascalInteger[0..64] OF PascalInteger[0..9]]; --:900 --905:-- HyphenPassed: SmallNumber; --:905----921: Trie: LONG POINTER TO ARRAY TriePointer OF TwoHalves ← PascalStaticZone.NEW[ARRAY TriePointer OF TwoHalves]; HyfDistance: LONG POINTER TO ARRAY Quarterword OF SmallNumber ← PascalStaticZone.NEW[ARRAY Quarterword OF SmallNumber]; HyfNum: LONG POINTER TO ARRAY Quarterword OF SmallNumber ← PascalStaticZone.NEW[ARRAY Quarterword OF SmallNumber]; HyfNext: LONG POINTER TO ARRAY Quarterword OF Quarterword ← PascalStaticZone.NEW[ARRAY Quarterword OF Quarterword]; --:921----926: HyphWord: LONG POINTER TO ARRAY HyphPointer OF StrNumber ← PascalStaticZone.NEW[ARRAY HyphPointer OF StrNumber]; HyphList: LONG POINTER TO ARRAY HyphPointer OF Halfword ← PascalStaticZone.NEW[ARRAY HyphPointer OF Halfword]; HyphCount: HyphPointer; --:926 --943:--TrieOpHash: LONG POINTER TO ARRAY PascalInteger[0..510] OF Quarterword ← PascalStaticZone.NEW[ARRAY PascalInteger[0..510] OF Quarterword]; TrieOpPtr: Quarterword; --:943----945:--TrieC: LONG POINTER TO PACKED ARRAY TriePointer OF AsciiCode ← PascalStaticZone.NEW[PACKED ARRAY TriePointer OF AsciiCode]; TrieO: LONG POINTER TO PACKED ARRAY TriePointer OF Quarterword ← PascalStaticZone.NEW[PACKED ARRAY TriePointer OF Quarterword]; TrieL: LONG POINTER TO PACKED ARRAY TriePointer OF TriePointer ← PascalStaticZone.NEW[PACKED ARRAY TriePointer OF TriePointer]; TrieR: LONG POINTER TO PACKED ARRAY TriePointer OF TriePointer ← PascalStaticZone.NEW[PACKED ARRAY TriePointer OF TriePointer]; TriePtr: TriePointer; --:945----946:--TrieHash: LONG POINTER TO PACKED ARRAY TriePointer OF TriePointer ← PascalStaticZone.NEW[PACKED ARRAY TriePointer OF TriePointer]; --:946 --950:--TrieTaken: LONG POINTER TO PACKED ARRAY TriePointer OF PascalBoolean ← PascalStaticZone.NEW[PACKED ARRAY TriePointer OF PascalBoolean]; TrieMin: TriePointer; TrieMax: TriePointer; --826:-- FiniteShrink: PROCEDURE[P: Halfword] RETURNS[FiniteShrinkResult: Halfword] = BEGIN Q:Halfword; IF NoShrinkErrorYet THEN BEGIN NoShrinkErrorYet←FALSE; BEGIN IF Interaction=3 THEN NULL;PrintNl[134];Print[776]; END; BEGIN HelpPtr←5;HelpLine↑[4]←777;HelpLine↑[3]←778;HelpLine↑[2]←779; HelpLine↑[1]←780;HelpLine↑[0]←781; END;Error[]; END;Q←NewSpec[P]; Mem[Q]↑.Hh.B1←0;DeleteGlueRef[P];FiniteShrinkResult←Q; END;--:826----829: PostLineBreak: PROCEDURE[FinalWidowPenalty: PascalInteger] = BEGIN Q, R, S:Halfword;DiscBreak:PascalBoolean;CurWidth:Scaled; CurIndent:Scaled;T:Quarterword;Pen:PascalInteger;CurLine:Halfword; --878:--Q←Mem[BestBet+1]↑.Hh.Rh;CurP←0;DO R←Q; Q←Mem[Q+1]↑.Hh.Lh;Mem[R+1]↑.Hh.Lh←CurP;CurP←R; IF Q=0--:878-- THEN EXIT; ENDLOOP; CurLine←CurList.PgField+1;DO--880:----881:----887: Q←Mem[CurP+1]↑.Hh.Rh; DiscBreak←FALSE; {IF Q#0 THEN IF Mem[Q]↑.Hh.B0=10 THEN BEGIN DeleteGlueRef[Mem[Q+1]↑.Hh. Lh];Mem[Q+1]↑.Hh.Lh←Eqtb↑[3034].Hh.Rh;Mem[Q]↑.Hh.B1←9; Mem[Eqtb↑[3034].Hh.Rh]↑.Hh.Rh←Mem[Eqtb↑[3034].Hh.Rh]↑.Hh.Rh+1; GOTO Label30; END ELSE BEGIN IF Mem[Q]↑.Hh.B0=7 THEN--882:--BEGIN T←Mem[Q]↑.Hh.B1;--883: IF T=0 THEN R←Mem[Q]↑.Hh.Rh ELSE BEGIN R←Q; WHILE INT[T]>1 DO BEGIN R←Mem[R]↑.Hh.Rh;T←T-1; END ENDLOOP ;S←Mem[R]↑.Hh.Rh; IF NOT ( INT[S]>=HiMemMin) THEN IF Mem[CurP+1]↑.Hh.Lh#0 THEN IF Mem[Mem[CurP +1]↑.Hh.Lh+1]↑.Hh.Rh=S THEN S←R;R←Mem[S]↑.Hh.Rh;Mem[S]↑.Hh.Rh←0; FlushNodeList[Mem[Q]↑.Hh.Rh];Mem[Q]↑.Hh.B1←0; END--:883--; IF Mem[Q+1]↑.Hh.Rh#0 THEN--884:--BEGIN S←Mem[Q+1]↑.Hh.Rh; WHILE Mem[S]↑.Hh.Rh#0 DO S←Mem[S]↑.Hh.Rh ENDLOOP ;Mem[S]↑.Hh.Rh←R; R←Mem[Q+1]↑.Hh.Rh;Mem[Q+1]↑.Hh.Rh←0; END--:884--; IF Mem[Q+1]↑.Hh.Lh#0 THEN--885:--BEGIN S←Mem[Q+1]↑.Hh.Lh;Mem[Q]↑.Hh.Rh←S; WHILE Mem[S]↑.Hh.Rh#0 DO S←Mem[S]↑.Hh.Rh ENDLOOP ;Mem[Q+1]↑.Hh.Lh←0;Q←S; END--:885--;Mem[Q]↑.Hh.Rh←R;DiscBreak←TRUE; END--:882--; IF NOT ( INT[Q]>=HiMemMin) THEN IF(Mem[Q]↑.Hh.B0=9)OR (Mem[Q]↑.Hh.B0=11) THEN Mem[ Q+1]↑.Int←0; END ELSE BEGIN Q←64997; WHILE Mem[Q]↑.Hh.Rh#0 DO Q←Mem[Q]↑.Hh.Rh ENDLOOP ; END;--886:--R←NewParamGlue[8]; Mem[R]↑.Hh.Rh←Mem[Q]↑.Hh.Rh;Mem[Q]↑.Hh.Rh←R;Q←R--:886--;EXITS Label30 => NULL};--:881--R←Mem[Q]↑.Hh.Rh;Mem[Q]↑.Hh.Rh←0;Q←Mem[64997]↑.Hh.Rh;Mem[64997]↑.Hh.Rh←R; IF Eqtb↑[3033].Hh.Rh#0 THEN BEGIN R←NewParamGlue[7];Mem[R]↑.Hh.Rh←Q; Q←R; END--:887--;--889: IF INT[CurLine]>LastSpecialLine THEN BEGIN CurWidth←SecondWidth; CurIndent←SecondIndent; END ELSE IF Eqtb↑[3556].Hh.Rh=0 THEN BEGIN CurWidth←FirstWidth; CurIndent←FirstIndent; END ELSE BEGIN CurWidth←Mem[Eqtb↑[3556].Hh.Rh+ INT[2]*CurLine]↑.Int; CurIndent←Mem[Eqtb↑[3556].Hh.Rh+ INT[2]*CurLine-1]↑.Int; END; AdjustTail←64995;JustBox←Hpack[Q,CurWidth,0]; Mem[JustBox+4]↑.Int←CurIndent--:889--;--888:--AppendToVlist[JustBox]; IF 64995#AdjustTail THEN BEGIN Mem[CurList.TailField]↑.Hh.Rh←Mem[ 64995]↑.Hh.Rh;CurList.TailField←AdjustTail; END;AdjustTail←0--:888--; --890:--IF CurLine+1#BestLine THEN BEGIN Pen←Eqtb↑[4780].Int; IF CurLine=CurList.PgField+1 THEN Pen←Pen+Eqtb↑[4772].Int; IF CurLine+2=BestLine THEN Pen←Pen+FinalWidowPenalty; IF DiscBreak THEN Pen←Pen+Eqtb↑[4775].Int; IF Pen#0 THEN BEGIN R←NewPenalty[Pen]; Mem[CurList.TailField]↑.Hh.Rh←R;CurList.TailField←R; END; END--:890 --:880--;CurLine←CurLine+1;CurP←Mem[CurP+1]↑.Hh.Lh; IF CurP#0 THEN--879:--BEGIN R←64997; {WHILE TRUE DO BEGIN Q←Mem[R]↑.Hh.Rh; IF Q=Mem[CurP+1]↑.Hh.Rh THEN GOTO Label31;IF( INT[Q]>=HiMemMin) THEN GOTO Label31; IF( INT[Mem[Q]↑.Hh.B0]<9) THEN GOTO Label31;R←Q; END ENDLOOP ; EXITS Label31 => NULL};IF R#64997 THEN BEGIN Mem[R]↑.Hh.Rh←0; FlushNodeList[Mem[64997]↑.Hh.Rh];Mem[64997]↑.Hh.Rh←Q; END; END--:879--; IF CurP=0 THEN EXIT; ENDLOOP; IF(CurLine#BestLine)OR (Mem[64997]↑.Hh.Rh#0) THEN Confusion[796]; CurList.PgField← INT[BestLine]-1; END;--:877----895:----906: Reconstitute: PROCEDURE[J,N: SmallNumber] RETURNS[ReconstituteResult: SmallNumber] = BEGIN P:Halfword;S:Halfword;Q:FourQuarters;C:Quarterword;D:Quarterword; W:Scaled;R:PascalInteger[0..FontMemSize];--907:----910: HyphenPassed←0;S←64996;W←0; D←Hu↑[J];C←D;{WHILE TRUE DO BEGIN DO {--Label22:--P←GetAvail[];Mem[P]↑.Hh.B0←Hf; Mem[P]↑.Hh.B1←C;Mem[S]↑.Hh.Rh←P;--908:--IF J=N THEN GOTO Label30; Q←FontInfo↑[CharBase↑[Hf]+D].Qqqq;IF( PascalMODPower2Mask[(Q.B2),3])#1 THEN GOTO Label30; R←LigKernBase↑[Hf]+Q.B3;C←Hu↑[J+1]; WHILE TRUE DO BEGIN Q←FontInfo↑[R].Qqqq; IF Q.B1=C THEN BEGIN IF PascalODD[Hyf↑[J]]AND (HyphenPassed=0) THEN HyphenPassed←J;IF INT[Q.B2]<128 THEN--909:--BEGIN D←Q.B3;J←J+1;S←P; GOTO Label22; END--:909-- ELSE BEGIN W←FontInfo↑[KernBase↑[Hf]+Q.B3].Int; GOTO Label30; END; END ELSE IF INT[Q.B0]<128 THEN R←R+1 ELSE GOTO Label30; END--:908-- ENDLOOP ;EXIT; EXITS Label22 => NULL} ENDLOOP; END ENDLOOP ; EXITS Label30 => NULL};--:907--IF S#64996 THEN BEGIN P←NewLigature[Hf,D,Mem[64996]↑.Hh.Rh]; Mem[64996]↑.Hh.Rh←P; END--:910--;--911: IF W#0 THEN Mem[Mem[64996]↑.Hh.Rh]↑.Hh.Rh←NewKern[W]--:911--; ReconstituteResult←J; END;--:906-- END.