--routeHugs.mesa DIRECTORY RouteDefs; RouteHugs:PROGRAM IMPORTS RouteDefs EXPORTS RouteDefs=BEGIN OPEN RouteDefs; Error:SIGNAL=CODE; MakeHugs:PUBLIC CtlProc=BEGIN FOR pwl:PathwayListPtr←paths,pwl.t UNTIL pwl=NIL DO []←Hug[pwl.h.path.h,x]; ENDLOOP; ShowHugs[]; RETURN[-1]; END; Hug:PROCEDURE[path:PathPtr,side:Side] RETURNS[Side]=BEGIN IF path=NIL THEN RETURN[x] ELSE BEGIN chan:RectanglePtr=path.channel; inter:RectanglePtr=path.inter; h:Huggers=path.huggers; alreadyValid:BOOLEAN=path.huggers.valid; path.huggers.valid←TRUE; SELECT TRUE FROM path.index#NIL=>IF side#x THEN RETURN[x]; inter#NIL AND chan#NIL=>Error; inter=NIL AND chan=NIL=>Error; alreadyValid=>IF inter=NIL THEN RETURN[h.ch]; inter#NIL=> path.huggers←[ch:x, n:Hug[path.n,s], s:Hug[path.s,n], e:Hug[path.e,w], w:Hug[path.w,e], valid:TRUE]; ENDCASE=>path.huggers.ch←SELECT Count[path,x] FROM 0=>x, >0=>IF chan.orient=hor THEN n ELSE w, ENDCASE=>IF chan.orient=hor THEN s ELSE e; IF inter#NIL THEN RETURN[SELECT side FROM n=>h.n, s=>h.s, e=>h.e, ENDCASE=>h.w]; []←Hug[path.n,s]; []←Hug[path.s,n]; []←Hug[path.e,w]; []←Hug[path.w,e]; RETURN[path.huggers.ch]; END; END; Count:PROCEDURE[pp:PathPtr,side:Side] RETURNS[c:INTEGER]=BEGIN path:PathPtr=SELECT side FROM n=>pp.n, s=>pp.s, e=>pp.e, w=>pp.w, ENDCASE=>pp; c←0; IF path=NIL OR path.index#NIL THEN RETURN[0]; IF path.channel#NIL THEN BEGIN rect:RectanglePtr=path.channel; IF rect.orient=hor AND path.n#NIL THEN c←c+1; IF rect.orient=hor AND path.s#NIL THEN c←c-1; IF rect.orient#hor AND path.w#NIL THEN c←c+1; IF rect.orient#hor AND path.e#NIL THEN c←c-1; END; IF path.inter#NIL THEN BEGIN type:InterType=MakeType [n:path.n#NIL,s:path.s#NIL,e:path.e#NIL,w:path.w#NIL]; SELECT side FROM e,w=>SELECT type FROM 5,9,13=>c←c+1; 6,10,14=>c←c-1; ENDCASE; n,s=>SELECT type FROM 9,10,11=>c←c+1; 5,6,7=>c←c-1; ENDCASE; ENDCASE=>Error; END; IF side=x THEN c←c+Count[path,e]+Count[path,w]+Count[path,n]+Count[path,s] ELSE c←c+Count[path,side]; END; ShowHugs:PUBLIC PROCEDURE=BEGIN ShowLabel["HUGS"]; FOR pwl:PathwayListPtr←paths,pwl.t UNTIL pwl=NIL DO pathway:PathwayPtr=pwl.h; FOR pl:PathListPtr←pathway.path,pl.t UNTIL pl=NIL DO path:PathPtr=pl.h; IF path.index#NIL THEN LOOP; Return[]; IF path.channel#NIL THEN ShowDecimal[path.channel.channelNo,"chan "] ELSE ShowDecimal[path.inter.channelNo,"inter "]; ShowDecimal[path.circuit," circuit "]; ShowChar[' ]; ShowSide[path.huggers.ch]; ShowSide[path.huggers.n]; ShowSide[path.huggers.s]; ShowSide[path.huggers.e]; ShowSide[path.huggers.w]; ENDLOOP; ENDLOOP; END; ShowSide:PROCEDURE[s:Side]=BEGIN ShowChar[SELECT s FROM n=>'n,s=>'s,e=>'e,w=>'w,ENDCASE=>'x]; END; END. ShowHugs:PUBLIC PROCEDURE=BEGIN ShowLabel["HUGS"]; FOR pwl:PathwayListPtr←paths,pwl.t UNTIL pwl=NIL DO pathway:PathwayPtr=pwl.h; FOR pl:PathListPtr←pathway.path,pl.t UNTIL pl=NIL DO path:PathPtr=pl.h; Blab:PROCEDURE[a,b:Side]=BEGIN IF b=x THEN RETURN; Return[]; IF a=x THEN ShowDecimal[path.channel.channelNo,"chan "] ELSE ShowDecimal[path.inter.channelNo,"inter "]; ShowDecimal[path.circuit," circuit "]; ShowChar[' ]; ShowSide[a]; ShowSide[b]; END; Blab[x,path.huggers.ch]; Blab[n,path.huggers.n]; Blab[s,path.huggers.s]; Blab[e,path.huggers.e]; Blab[w,path.huggers.w]; ENDLOOP; ENDLOOP; END;