3 # Takes a set of ps images (belonging to one file) and produces a
4 # conglomerate picture of that file: static functions in the middle,
5 # others around it. Each one gets a box about its area.
9 my $SCRUNCH = $ARGV [0];
10 my $BOXSCRUNCH = $ARGV [1];
14 shift @ARGV; # skip SCRUNCH and BOXSCRUNCH
18 DecorateFuncs
(@ARGV);
21 #TMPFILE=`mktemp ${TMPDIR:-/tmp}/$$.XXXXXX`
26 foreach $Tmp (@ARGV) {
27 $ArgList .= "'$Tmp' ";
30 my @Arranged = `../draw_arrangement $SCRUNCH 0 360 0 $ArgList`;
32 my $CFile = $ARGV [0];
33 $CFile =~ s/\.c\..*$/.c/;
34 if ($DEBUG) { print ("% Conglomeration of $CFile\n"); }
36 print "gsave angle rotate\n";
38 # Now output the file, except last line.
39 my $LastLine = pop (@Arranged);
40 my $Fill = Box_2
($LastLine,$CFile);
42 # Draw box with file name
43 my @Output = Box
('normal', 'Helvetica-Bold', 32, $CFile, $LastLine);
44 splice(@Output, $#Output, 0, "grestore\n");
48 #add a duplicate box to test if this works
56 $BBoxLine =~ /(-?[\d.]+)\s+(-?[\d.]+)\s+(-?[\d.]+)\s+(-?[\d.]+)/;
58 # XMin, YMin, XMax, YMax
59 return ($1 * $BOXSCRUNCH, $2 * $BOXSCRUNCH,
60 $3 * $BOXSCRUNCH, $4 * $BOXSCRUNCH);
65 # Box (type, font, fontsize, Label, BBoxLine)
75 # print (STDERR "Box ('$Type', '$Font', '$Fontsize', '$Label', '$BBoxLine')\n");
76 push (@Output, "% start of box\n");
78 push (@Output, "D5\n") if ($Type eq "dashed");
80 # print (STDERR "BBoxLine: '$BBoxLine'\n");
81 # print (STDERR "Parsed: '" . join ("' '", ParseBound ($BBoxLine)) . "\n");
82 my ($XMin, $YMin, $XMax, $YMax) = ParseBound
($BBoxLine);
84 my $LeftSpaced = $XMin + 6;
85 my $BottomSpaced = $YMin + 6;
87 # Put black box around it
89 "($Label) $LeftSpaced $BottomSpaced $Fontsize /$Font\n",
90 "$YMin $XMin $YMax $XMax U\n"
94 push (@Output, "D\n") if ($Type eq "dashed");
96 push (@Output, "% end of box\n");
99 push (@Output, "% bound $XMin $YMin $XMax $YMax\n");
106 my $BBoxLine = shift;
108 my $CovFile = "./coverage.dat";
109 my ($XMin, $YMin, $XMax, $YMax) = ParseBound
($BBoxLine);
110 my @output = `fgrep $CFile $CovFile`;
112 my ($junk, $Class, $per) = split /\t/, $output[0];
113 return "$XMin $YMin $XMax $YMax $Class\n";
115 # Decorate (rgb-vals(1 string) filename)
119 my $Filename = shift;
121 my @Input = ReadPS
($Filename);
122 my $LastLine = pop (@Input);
125 # Color at the beginning.
126 push (@Output, "C$RGB\n");
128 # Now output the file, except last line.
129 push (@Output, @Input);
131 # Draw dashed box with function name
132 # FIXME Make bound cover the label as well!
133 my $FuncName = $Filename;
134 $FuncName =~ s/^[^.]+\.c\.(.+?)\..*$/$1/;
136 push (@Output, Box
('dashed', 'Helvetica', 24, $FuncName, $LastLine));
139 WritePS
($Filename, @Output);
144 # Add colored boxes around functions
150 foreach $FName (@ARGV)
152 $FName =~ /\+([A-Z]+)\+/;
155 if ($FType eq 'STATIC') {
156 Decorate
("2", $FName); # Light green.
158 elsif ($FType eq 'INDIRECT') {
159 Decorate
("3", $FName); # Green.
161 elsif ($FType eq 'EXPORTED') {
162 Decorate
("4", $FName); # Red.
164 elsif ($FType eq 'NORMAL') {
165 Decorate
("5", $FName); # Blue.
168 die ("Unknown extension $FName");
176 my $Filename = shift;
179 open (INFILE
, "$Filename") or die ("Could not read $Filename: $!");
180 @Contents = <INFILE
>;
188 my $Filename = shift;
190 open (OUTFILE
, ">$Filename")
191 or die ("Could not write $Filename: $!");