@@ -171,10 +171,19 @@ where
171
171
// | | (on successful return) | +_4 |
172
172
// +-+----------------------------------+------------+
173
173
174
- write ! (
175
- w,
176
- r#"<table border="1" cellborder="1" cellspacing="0" cellpadding="3" sides="rb">"# ,
177
- ) ?;
174
+ // N.B., Some attributes (`align`, `balign`) are repeated on parent elements and their
175
+ // children. This is because `xdot` seemed to have a hard time correctly propagating
176
+ // attributes. Make sure to test the output before trying to remove the redundancy.
177
+ // Notably, `align` was found to have no effect when applied only to <table>.
178
+
179
+ let table_fmt = concat ! (
180
+ " border=\" 1\" " ,
181
+ " cellborder=\" 1\" " ,
182
+ " cellspacing=\" 0\" " ,
183
+ " cellpadding=\" 3\" " ,
184
+ " sides=\" rb\" " ,
185
+ ) ;
186
+ write ! ( w, r#"<table{fmt}>"# , fmt = table_fmt) ?;
178
187
179
188
// A + B: Block header
180
189
if self . state_formatter . column_names ( ) . is_empty ( ) {
@@ -186,7 +195,7 @@ where
186
195
// C: Entry state
187
196
self . bg = Background :: Light ;
188
197
self . results . seek_to_block_start ( block) ;
189
- self . write_row_with_full_state ( w, "" , "(on_entry )" ) ?;
198
+ self . write_row_with_full_state ( w, "" , "(on entry )" ) ?;
190
199
191
200
// D: Statement transfer functions
192
201
for ( i, statement) in body[ block] . statements . iter ( ) . enumerate ( ) {
@@ -212,7 +221,7 @@ where
212
221
self . write_row ( w, "" , "(on successful return)" , |this, w, fmt| {
213
222
write ! (
214
223
w,
215
- r#"<td colspan="{colspan}" {fmt} align="left">"# ,
224
+ r#"<td balign="left" colspan="{colspan}" {fmt} align="left">"# ,
216
225
colspan = num_state_columns,
217
226
fmt = fmt,
218
227
) ?;
@@ -311,7 +320,9 @@ where
311
320
f : impl FnOnce ( & mut Self , & mut W , & str ) -> io:: Result < ( ) > ,
312
321
) -> io:: Result < ( ) > {
313
322
let bg = self . toggle_background ( ) ;
314
- let fmt = format ! ( "sides=\" tl\" {}" , bg. attr( ) ) ;
323
+ let valign = if mir. starts_with ( "(on " ) && mir != "(on entry)" { "bottom" } else { "top" } ;
324
+
325
+ let fmt = format ! ( "valign=\" {}\" sides=\" tl\" {}" , valign, bg. attr( ) ) ;
315
326
316
327
write ! (
317
328
w,
@@ -345,7 +356,7 @@ where
345
356
colspan = this. num_state_columns( ) ,
346
357
fmt = fmt,
347
358
) ?;
348
- pretty_print_state_elems ( w, analysis, state. iter ( ) , "," , LIMIT_40_ALIGN_1 ) ?;
359
+ pretty_print_state_elems ( w, analysis, state. iter ( ) , ", " , LIMIT_30_ALIGN_1 ) ?;
349
360
write ! ( w, "}}</td>" )
350
361
} )
351
362
}
@@ -387,7 +398,6 @@ pub struct SimpleDiff<T: Idx> {
387
398
}
388
399
389
400
impl < T : Idx > SimpleDiff < T > {
390
- #![ allow( unused) ]
391
401
pub fn new ( bits_per_block : usize ) -> Self {
392
402
SimpleDiff { prev_state : BitSet :: new_empty ( bits_per_block) , prev_loc : Location :: START }
393
403
}
@@ -417,8 +427,8 @@ where
417
427
}
418
428
419
429
self . prev_loc = location;
420
- write ! ( w, r#"<td {fmt} align="left">"# , fmt = fmt) ?;
421
- results. seek_before ( location) ;
430
+ write ! ( w, r#"<td {fmt} balign="left" align="left">"# , fmt = fmt) ?;
431
+ results. seek_after ( location) ;
422
432
let curr_state = results. get ( ) ;
423
433
write_diff ( & mut w, results. analysis ( ) , & self . prev_state , curr_state) ?;
424
434
self . prev_state . overwrite ( curr_state) ;
@@ -434,7 +444,6 @@ pub struct TwoPhaseDiff<T: Idx> {
434
444
}
435
445
436
446
impl < T : Idx > TwoPhaseDiff < T > {
437
- #![ allow( unused) ]
438
447
pub fn new ( bits_per_block : usize ) -> Self {
439
448
TwoPhaseDiff { prev_state : BitSet :: new_empty ( bits_per_block) , prev_loc : Location :: START }
440
449
}
@@ -445,7 +454,7 @@ where
445
454
A : Analysis < ' tcx > ,
446
455
{
447
456
fn column_names ( & self ) -> & [ & str ] {
448
- & [ "ENTRY " , " EXIT " ]
457
+ & [ "BEFORE " , " AFTER " ]
449
458
}
450
459
451
460
fn write_state_for_location (
@@ -465,7 +474,7 @@ where
465
474
466
475
self . prev_loc = location;
467
476
468
- // Entry
477
+ // Before
469
478
470
479
write ! ( w, r#"<td {fmt} align="left">"# , fmt = fmt) ?;
471
480
results. seek_before ( location) ;
@@ -474,7 +483,7 @@ where
474
483
self . prev_state . overwrite ( curr_state) ;
475
484
write ! ( w, "</td>" ) ?;
476
485
477
- // Exit
486
+ // After
478
487
479
488
write ! ( w, r#"<td {fmt} align="left">"# , fmt = fmt) ?;
480
489
results. seek_after ( location) ;
@@ -492,7 +501,6 @@ pub struct BlockTransferFunc<'a, 'tcx, T: Idx> {
492
501
}
493
502
494
503
impl < T : Idx > BlockTransferFunc < ' mir , ' tcx , T > {
495
- #![ allow( unused) ]
496
504
pub fn new (
497
505
body : & ' mir mir:: Body < ' tcx > ,
498
506
trans_for_block : IndexVec < BasicBlock , GenKillSet < T > > ,
@@ -527,12 +535,12 @@ where
527
535
for set in & [ & block_trans. gen , & block_trans. kill ] {
528
536
write ! (
529
537
w,
530
- r#"<td {fmt} rowspan="{rowspan}" align="center ">"# ,
538
+ r#"<td {fmt} rowspan="{rowspan}" balign="left" align="left ">"# ,
531
539
fmt = fmt,
532
540
rowspan = rowspan
533
541
) ?;
534
542
535
- pretty_print_state_elems ( & mut w, results. analysis ( ) , set. iter ( ) , " \n " , None ) ?;
543
+ pretty_print_state_elems ( & mut w, results. analysis ( ) , set. iter ( ) , BR_LEFT , None ) ?;
536
544
write ! ( w, "</td>" ) ?;
537
545
}
538
546
@@ -564,25 +572,28 @@ fn write_diff<A: Analysis<'tcx>>(
564
572
565
573
if !set. is_empty ( ) {
566
574
write ! ( w, r#"<font color="darkgreen">+"# ) ?;
567
- pretty_print_state_elems ( w, analysis, set. iter ( ) , "," , LIMIT_40_ALIGN_1 ) ?;
575
+ pretty_print_state_elems ( w, analysis, set. iter ( ) , ", " , LIMIT_30_ALIGN_1 ) ?;
568
576
write ! ( w, r#"</font>"# ) ?;
569
577
}
570
578
571
579
if !set. is_empty ( ) && !clear. is_empty ( ) {
572
- write ! ( w, "<br/>" ) ?;
580
+ write ! ( w, "{}" , BR_LEFT ) ?;
573
581
}
574
582
575
583
if !clear. is_empty ( ) {
576
584
write ! ( w, r#"<font color="red">-"# ) ?;
577
- pretty_print_state_elems ( w, analysis, clear. iter ( ) , "," , LIMIT_40_ALIGN_1 ) ?;
585
+ pretty_print_state_elems ( w, analysis, clear. iter ( ) , ", " , LIMIT_30_ALIGN_1 ) ?;
578
586
write ! ( w, r#"</font>"# ) ?;
579
587
}
580
588
581
589
Ok ( ( ) )
582
590
}
583
591
592
+ const BR_LEFT : & ' static str = r#"<br align="left"/>"# ;
593
+ const BR_LEFT_SPACE : & ' static str = r#"<br align="left"/> "# ;
594
+
584
595
/// Line break policy that breaks at 40 characters and starts the next line with a single space.
585
- const LIMIT_40_ALIGN_1 : Option < LineBreak > = Some ( LineBreak { sequence : "<br/> " , limit : 40 } ) ;
596
+ const LIMIT_30_ALIGN_1 : Option < LineBreak > = Some ( LineBreak { sequence : BR_LEFT_SPACE , limit : 30 } ) ;
586
597
587
598
struct LineBreak {
588
599
sequence : & ' static str ,
@@ -613,25 +624,25 @@ where
613
624
let mut line_break_inserted = false ;
614
625
615
626
for idx in elems {
616
- if first {
617
- first = false ;
618
- } else {
619
- write ! ( w, "{}" , sep) ?;
620
- curr_line_width += sep_width;
621
- }
622
-
623
627
buf. clear ( ) ;
624
628
analysis. pretty_print_idx ( & mut buf, idx) ?;
625
629
let idx_str =
626
630
str:: from_utf8 ( & buf) . expect ( "Output of `pretty_print_idx` must be valid UTF-8" ) ;
627
631
let escaped = dot:: escape_html ( idx_str) ;
628
632
let escaped_width = escaped. chars ( ) . count ( ) ;
629
633
630
- if let Some ( line_break) = & line_break {
631
- if curr_line_width + sep_width + escaped_width > line_break. limit {
632
- write ! ( w, "{}" , line_break. sequence) ?;
633
- line_break_inserted = true ;
634
- curr_line_width = 0 ;
634
+ if first {
635
+ first = false ;
636
+ } else {
637
+ write ! ( w, "{}" , sep) ?;
638
+ curr_line_width += sep_width;
639
+
640
+ if let Some ( line_break) = & line_break {
641
+ if curr_line_width + sep_width + escaped_width > line_break. limit {
642
+ write ! ( w, "{}" , line_break. sequence) ?;
643
+ line_break_inserted = true ;
644
+ curr_line_width = 0 ;
645
+ }
635
646
}
636
647
}
637
648
0 commit comments