@@ -171,6 +171,7 @@ use middle::trans::tvec;
171
171
use middle:: trans:: type_of;
172
172
use middle:: ty;
173
173
use util:: common:: indenter;
174
+ use util:: ppaux:: { Repr , vec_map_to_str} ;
174
175
175
176
use std:: hashmap:: HashMap ;
176
177
use std:: vec;
@@ -179,7 +180,6 @@ use syntax::ast::ident;
179
180
use syntax:: ast_util:: path_to_ident;
180
181
use syntax:: ast_util;
181
182
use syntax:: codemap:: { span, dummy_sp} ;
182
- use syntax:: print:: pprust:: pat_to_str;
183
183
184
184
// An option identifying a literal: either a unit-like struct or an
185
185
// expression.
@@ -353,19 +353,17 @@ pub struct Match<'self> {
353
353
data : ArmData < ' self >
354
354
}
355
355
356
- pub fn match_to_str ( bcx : @mut Block , m : & Match ) -> ~str {
357
- if bcx. sess ( ) . verbose ( ) {
358
- // for many programs, this just take too long to serialize
359
- fmt ! ( "%?" , m. pats. map( |p| pat_to_str( * p, bcx. sess( ) . intr( ) ) ) )
360
- } else {
361
- fmt ! ( "%u pats" , m. pats. len( ) )
356
+ impl < ' self > Repr for Match < ' self > {
357
+ fn repr ( & self , tcx : ty:: ctxt ) -> ~str {
358
+ if tcx. sess . verbose ( ) {
359
+ // for many programs, this just take too long to serialize
360
+ self . pats . repr ( tcx)
361
+ } else {
362
+ fmt ! ( "%u pats" , self . pats. len( ) )
363
+ }
362
364
}
363
365
}
364
366
365
- pub fn matches_to_str ( bcx : @mut Block , m : & [ Match ] ) -> ~str {
366
- fmt ! ( "%?" , m. map( |n| match_to_str( bcx, n) ) )
367
- }
368
-
369
367
pub fn has_nested_bindings ( m : & [ Match ] , col : uint ) -> bool {
370
368
for br in m. iter ( ) {
371
369
match br. pats [ col] . node {
@@ -381,9 +379,9 @@ pub fn expand_nested_bindings<'r>(bcx: @mut Block,
381
379
col : uint ,
382
380
val : ValueRef )
383
381
-> ~[ Match < ' r > ] {
384
- debug ! ( "expand_nested_bindings(bcx=%s, m=%s, col=%u, val=%? )" ,
382
+ debug ! ( "expand_nested_bindings(bcx=%s, m=%s, col=%u, val=%s )" ,
385
383
bcx. to_str( ) ,
386
- matches_to_str ( bcx, m ) ,
384
+ m . repr ( bcx. tcx ( ) ) ,
387
385
col,
388
386
bcx. val_to_str( val) ) ;
389
387
let _indenter = indenter ( ) ;
@@ -416,7 +414,7 @@ pub fn assert_is_binding_or_wild(bcx: @mut Block, p: @ast::pat) {
416
414
bcx. sess ( ) . span_bug (
417
415
p. span ,
418
416
fmt ! ( "Expected an identifier pattern but found p: %s" ,
419
- pat_to_str ( p , bcx . sess ( ) . intr ( ) ) ) ) ;
417
+ p . repr ( bcx . tcx ( ) ) ) ) ;
420
418
}
421
419
}
422
420
@@ -429,9 +427,9 @@ pub fn enter_match<'r>(bcx: @mut Block,
429
427
val : ValueRef ,
430
428
e : enter_pat )
431
429
-> ~[ Match < ' r > ] {
432
- debug ! ( "enter_match(bcx=%s, m=%s, col=%u, val=%? )" ,
430
+ debug ! ( "enter_match(bcx=%s, m=%s, col=%u, val=%s )" ,
433
431
bcx. to_str( ) ,
434
- matches_to_str ( bcx, m ) ,
432
+ m . repr ( bcx. tcx ( ) ) ,
435
433
col,
436
434
bcx. val_to_str( val) ) ;
437
435
let _indenter = indenter ( ) ;
@@ -467,7 +465,7 @@ pub fn enter_match<'r>(bcx: @mut Block,
467
465
}
468
466
}
469
467
470
- debug ! ( "result=%s" , matches_to_str ( bcx, result ) ) ;
468
+ debug ! ( "result=%s" , result . repr ( bcx. tcx ( ) ) ) ;
471
469
472
470
return result;
473
471
}
@@ -478,9 +476,9 @@ pub fn enter_default<'r>(bcx: @mut Block,
478
476
col : uint ,
479
477
val : ValueRef )
480
478
-> ~[ Match < ' r > ] {
481
- debug ! ( "enter_default(bcx=%s, m=%s, col=%u, val=%? )" ,
479
+ debug ! ( "enter_default(bcx=%s, m=%s, col=%u, val=%s )" ,
482
480
bcx. to_str( ) ,
483
- matches_to_str ( bcx, m ) ,
481
+ m . repr ( bcx. tcx ( ) ) ,
484
482
col,
485
483
bcx. val_to_str( val) ) ;
486
484
let _indenter = indenter ( ) ;
@@ -525,9 +523,9 @@ pub fn enter_opt<'r>(bcx: @mut Block,
525
523
variant_size : uint ,
526
524
val : ValueRef )
527
525
-> ~[ Match < ' r > ] {
528
- debug ! ( "enter_opt(bcx=%s, m=%s, col=%u, val=%? )" ,
526
+ debug ! ( "enter_opt(bcx=%s, m=%s, col=%u, val=%s )" ,
529
527
bcx. to_str( ) ,
530
- matches_to_str ( bcx, m ) ,
528
+ m . repr ( bcx. tcx ( ) ) ,
531
529
col,
532
530
bcx. val_to_str( val) ) ;
533
531
let _indenter = indenter ( ) ;
@@ -637,9 +635,9 @@ pub fn enter_rec_or_struct<'r>(bcx: @mut Block,
637
635
fields : & [ ast:: ident ] ,
638
636
val : ValueRef )
639
637
-> ~[ Match < ' r > ] {
640
- debug ! ( "enter_rec_or_struct(bcx=%s, m=%s, col=%u, val=%? )" ,
638
+ debug ! ( "enter_rec_or_struct(bcx=%s, m=%s, col=%u, val=%s )" ,
641
639
bcx. to_str( ) ,
642
- matches_to_str ( bcx, m ) ,
640
+ m . repr ( bcx. tcx ( ) ) ,
643
641
col,
644
642
bcx. val_to_str( val) ) ;
645
643
let _indenter = indenter ( ) ;
@@ -672,9 +670,9 @@ pub fn enter_tup<'r>(bcx: @mut Block,
672
670
val : ValueRef ,
673
671
n_elts : uint )
674
672
-> ~[ Match < ' r > ] {
675
- debug ! ( "enter_tup(bcx=%s, m=%s, col=%u, val=%? )" ,
673
+ debug ! ( "enter_tup(bcx=%s, m=%s, col=%u, val=%s )" ,
676
674
bcx. to_str( ) ,
677
- matches_to_str ( bcx, m ) ,
675
+ m . repr ( bcx. tcx ( ) ) ,
678
676
col,
679
677
bcx. val_to_str( val) ) ;
680
678
let _indenter = indenter ( ) ;
@@ -698,9 +696,9 @@ pub fn enter_tuple_struct<'r>(bcx: @mut Block,
698
696
val : ValueRef ,
699
697
n_elts : uint )
700
698
-> ~[ Match < ' r > ] {
701
- debug ! ( "enter_tuple_struct(bcx=%s, m=%s, col=%u, val=%? )" ,
699
+ debug ! ( "enter_tuple_struct(bcx=%s, m=%s, col=%u, val=%s )" ,
702
700
bcx. to_str( ) ,
703
- matches_to_str ( bcx, m ) ,
701
+ m . repr ( bcx. tcx ( ) ) ,
704
702
col,
705
703
bcx. val_to_str( val) ) ;
706
704
let _indenter = indenter ( ) ;
@@ -723,9 +721,9 @@ pub fn enter_box<'r>(bcx: @mut Block,
723
721
col : uint ,
724
722
val : ValueRef )
725
723
-> ~[ Match < ' r > ] {
726
- debug ! ( "enter_box(bcx=%s, m=%s, col=%u, val=%? )" ,
724
+ debug ! ( "enter_box(bcx=%s, m=%s, col=%u, val=%s )" ,
727
725
bcx. to_str( ) ,
728
- matches_to_str ( bcx, m ) ,
726
+ m . repr ( bcx. tcx ( ) ) ,
729
727
col,
730
728
bcx. val_to_str( val) ) ;
731
729
let _indenter = indenter ( ) ;
@@ -750,9 +748,9 @@ pub fn enter_uniq<'r>(bcx: @mut Block,
750
748
col : uint ,
751
749
val : ValueRef )
752
750
-> ~[ Match < ' r > ] {
753
- debug ! ( "enter_uniq(bcx=%s, m=%s, col=%u, val=%? )" ,
751
+ debug ! ( "enter_uniq(bcx=%s, m=%s, col=%u, val=%s )" ,
754
752
bcx. to_str( ) ,
755
- matches_to_str ( bcx, m ) ,
753
+ m . repr ( bcx. tcx ( ) ) ,
756
754
col,
757
755
bcx. val_to_str( val) ) ;
758
756
let _indenter = indenter ( ) ;
@@ -777,9 +775,9 @@ pub fn enter_region<'r>(bcx: @mut Block,
777
775
col : uint ,
778
776
val : ValueRef )
779
777
-> ~[ Match < ' r > ] {
780
- debug ! ( "enter_region(bcx=%s, m=%s, col=%u, val=%? )" ,
778
+ debug ! ( "enter_region(bcx=%s, m=%s, col=%u, val=%s )" ,
781
779
bcx. to_str( ) ,
782
- matches_to_str ( bcx, m ) ,
780
+ m . repr ( bcx. tcx ( ) ) ,
783
781
col,
784
782
bcx. val_to_str( val) ) ;
785
783
let _indenter = indenter ( ) ;
@@ -1213,11 +1211,11 @@ pub fn compile_guard(bcx: @mut Block,
1213
1211
vals : & [ ValueRef ] ,
1214
1212
chk : Option < mk_fail > )
1215
1213
-> @mut Block {
1216
- debug ! ( "compile_guard(bcx=%s, guard_expr=%s, m=%s, vals=%? )" ,
1214
+ debug ! ( "compile_guard(bcx=%s, guard_expr=%s, m=%s, vals=%s )" ,
1217
1215
bcx. to_str( ) ,
1218
1216
bcx. expr_to_str( guard_expr) ,
1219
- matches_to_str ( bcx, m ) ,
1220
- vals . map ( |v| bcx. val_to_str( * v) ) ) ;
1217
+ m . repr ( bcx. tcx ( ) ) ,
1218
+ vec_map_to_str ( vals , |v| bcx. val_to_str( * v) ) ) ;
1221
1219
let _indenter = indenter ( ) ;
1222
1220
1223
1221
let mut bcx = bcx;
@@ -1267,10 +1265,10 @@ pub fn compile_submatch(bcx: @mut Block,
1267
1265
m : & [ Match ] ,
1268
1266
vals : & [ ValueRef ] ,
1269
1267
chk : Option < mk_fail > ) {
1270
- debug ! ( "compile_submatch(bcx=%s, m=%s, vals=%? )" ,
1268
+ debug ! ( "compile_submatch(bcx=%s, m=%s, vals=%s )" ,
1271
1269
bcx. to_str( ) ,
1272
- matches_to_str ( bcx, m ) ,
1273
- vals . map ( |v| bcx. val_to_str( * v) ) ) ;
1270
+ m . repr ( bcx. tcx ( ) ) ,
1271
+ vec_map_to_str ( vals , |v| bcx. val_to_str( * v) ) ) ;
1274
1272
let _indenter = indenter ( ) ;
1275
1273
1276
1274
/*
@@ -1427,6 +1425,7 @@ fn compile_submatch_continue(mut bcx: @mut Block,
1427
1425
1428
1426
// Decide what kind of branch we need
1429
1427
let opts = get_options ( bcx, m, col) ;
1428
+ debug ! ( "options=%?" , opts) ;
1430
1429
let mut kind = no_branch;
1431
1430
let mut test_val = val;
1432
1431
if opts. len ( ) > 0 u {
@@ -1914,12 +1913,12 @@ fn bind_irrefutable_pat(bcx: @mut Block,
1914
1913
1915
1914
debug ! ( "bind_irrefutable_pat(bcx=%s, pat=%s, binding_mode=%?)" ,
1916
1915
bcx. to_str( ) ,
1917
- pat_to_str ( pat, bcx . sess ( ) . intr ( ) ) ,
1916
+ pat. repr ( bcx . tcx ( ) ) ,
1918
1917
binding_mode) ;
1919
1918
1920
1919
if bcx. sess ( ) . asm_comments ( ) {
1921
1920
add_comment ( bcx, fmt ! ( "bind_irrefutable_pat(pat=%s)" ,
1922
- pat_to_str ( pat, bcx . sess ( ) . intr ( ) ) ) ) ;
1921
+ pat. repr ( bcx . tcx ( ) ) ) ) ;
1923
1922
}
1924
1923
1925
1924
let _indenter = indenter ( ) ;
0 commit comments