@@ -10,7 +10,7 @@ use crate::{
10
10
parser:: ast:: { BinOp_ , DatatypeName , Field , VariantName } ,
11
11
shared:: {
12
12
ast_debug:: { AstDebug , AstWriter } ,
13
- format_oxford_list,
13
+ debug_print , format_oxford_list,
14
14
unique_map:: UniqueMap ,
15
15
} ,
16
16
typing:: ast:: { self as T , MatchArm_ , MatchPattern , UnannotatedPat_ as TP } ,
@@ -526,7 +526,6 @@ fn combine_pattern_fields(
526
526
fn combine_recur ( vec : & mut VVFields ) -> Vec < VFields > {
527
527
if let Some ( ( f, ( ndx, ( ty, pats) ) ) ) = vec. pop ( ) {
528
528
let rec_fields = combine_recur ( vec) ;
529
- // println!("rec fields: {:?}", rec_fields);
530
529
let mut output = vec ! [ ] ;
531
530
for entry in rec_fields {
532
531
for pat in pats. clone ( ) {
@@ -535,7 +534,6 @@ fn combine_pattern_fields(
535
534
output. push ( entry) ;
536
535
}
537
536
}
538
- // println!("output: {:?}", output);
539
537
output
540
538
} else {
541
539
// Base case: a single match of no fields. We must have at least one, or else we would
@@ -544,11 +542,8 @@ fn combine_pattern_fields(
544
542
}
545
543
}
546
544
547
- // println!("init fields: {:?}", fields);
548
545
let mut vvfields: VVFields = fields. into_iter ( ) . collect :: < Vec < _ > > ( ) ;
549
- // println!("vv fields: {:?}", vvfields);
550
546
let output_vec = combine_recur ( & mut vvfields) ;
551
- // println!("output: {:?}", output_vec);
552
547
output_vec
553
548
. into_iter ( )
554
549
. map ( |vfields| UniqueMap :: maybe_from_iter ( vfields. into_iter ( ) ) . unwrap ( ) )
@@ -676,14 +671,12 @@ pub fn compile_match(
676
671
} ;
677
672
678
673
while let Some ( ( cur_id, init_fringe, matrix) ) = work_queue. pop ( ) {
679
- // println!("---\nwork queue entry: {}", cur_id);
680
- // println!("fringe:");
681
- // for elem in &init_fringe {
682
- // print!(" ");
683
- // elem.print_verbose();
684
- // }
685
- // println!("matrix:");
686
- // matrix.print_verbose();
674
+ debug_print ! (
675
+ context. debug. match_work_queue,
676
+ ( "work queue entry" => cur_id; fmt) ,
677
+ ( lines "fringe" => & init_fringe; sdbg) ,
678
+ ( "matrix" => matrix; verbose)
679
+ ) ;
687
680
let redefined: Option < WorkResult > =
688
681
match compile_match_head ( context, init_fringe. clone ( ) , matrix) {
689
682
MatchStep :: Leaf ( leaf) => compilation_results. insert ( cur_id, WorkResult :: Leaf ( leaf) ) ,
@@ -769,8 +762,10 @@ fn compile_match_head(
769
762
mut fringe : VecDeque < FringeEntry > ,
770
763
mut matrix : PatternMatrix ,
771
764
) -> MatchStep {
772
- // println!("------\ncompilning with fringe:");
773
- // println!("{:#?}", fringe);
765
+ debug_print ! (
766
+ context. debug. match_specialization,
767
+ ( "-----\n compiling with fringe dueue entry" => fringe; dbg)
768
+ ) ;
774
769
if matrix. is_empty ( ) {
775
770
MatchStep :: Failure
776
771
} else if let Some ( leaf) = matrix. wild_arm_opt ( & fringe) {
@@ -785,12 +780,13 @@ fn compile_match_head(
785
780
let mut arms = BTreeMap :: new ( ) ;
786
781
for lit in lits {
787
782
let lit_loc = lit. loc ;
788
- // println!( "specializing to {:?}", lit);
783
+ debug_print ! ( context . debug . match_specialization , ( "specializing to" => lit ; fmt ) ) ;
789
784
let ( mut new_binders, inner_matrix) = matrix. specialize_literal ( & lit) ;
790
- // println!("binders: {:#?}", new_binders);
785
+ debug_print ! (
786
+ context. debug. match_specialization,
787
+ ( "binders" => & new_binders; dbg) , ( "specialized" => inner_matrix)
788
+ ) ;
791
789
subject_binders. append ( & mut new_binders) ;
792
- // println!("specialized:");
793
- // inner_matrix.print();
794
790
ice_assert ! (
795
791
context. env,
796
792
arms. insert( lit, inner_matrix) . is_none( ) ,
@@ -799,7 +795,7 @@ fn compile_match_head(
799
795
) ;
800
796
}
801
797
let ( mut new_binders, default) = matrix. specialize_default ( ) ;
802
- // println!( "default binders: {:#?}", new_binders);
798
+ debug_print ! ( context . debug . match_specialization , ( "default binders" => & new_binders; dbg ) ) ;
803
799
subject_binders. append ( & mut new_binders) ;
804
800
MatchStep :: LiteralSwitch {
805
801
subject,
@@ -813,12 +809,11 @@ fn compile_match_head(
813
809
. pop_front ( )
814
810
. expect ( "ICE empty fringe in match compilation" ) ;
815
811
let mut subject_binders = vec ! [ ] ;
816
- // println!("------\nsubject:");
817
- // subject.print();
818
- // println!("--\ncompile match head:");
819
- // subject.print();
820
- // println!("--\nmatrix;");
821
- // matrix.print();
812
+ debug_print ! (
813
+ context. debug. match_specialization,
814
+ ( "subject" => subject) ,
815
+ ( "matrix" => matrix)
816
+ ) ;
822
817
823
818
let ( mident, datatype_name) = subject
824
819
. ty
@@ -837,9 +832,8 @@ fn compile_match_head(
837
832
}
838
833
839
834
let tyargs = subject. ty . value . type_arguments ( ) . unwrap ( ) . clone ( ) ;
840
- // treat it as a head constructor
841
- // assert!(!ctors.is_empty());
842
835
836
+ // treat it as a head constructor
843
837
let mut unmatched_variants = context
844
838
. enum_variants ( & mident, & datatype_name)
845
839
. into_iter ( )
@@ -860,12 +854,13 @@ fn compile_match_head(
860
854
. iter ( )
861
855
. map ( |( _, _, ty) | ty)
862
856
. collect :: < Vec < _ > > ( ) ;
863
- // println!( "specializing to {:?}", ctor);
857
+ debug_print ! ( context . debug . match_specialization , ( "specializing to" => ctor; dbg ) ) ;
864
858
let ( mut new_binders, inner_matrix) = matrix. specialize ( context, & ctor, bind_tys) ;
865
- // println!("binders: {:#?}", new_binders);
859
+ debug_print ! (
860
+ context. debug. match_specialization,
861
+ ( "binders" => & new_binders; dbg) , ( "specialized" => inner_matrix)
862
+ ) ;
866
863
subject_binders. append ( & mut new_binders) ;
867
- // println!("specialized:");
868
- // inner_matrix.print();
869
864
ice_assert ! (
870
865
context. env,
871
866
arms. insert( ctor, ( fringe_binders, inner_fringe, inner_matrix) )
@@ -1717,11 +1712,10 @@ fn find_counterexample(
1717
1712
mident : ModuleIdent ,
1718
1713
datatype_name : DatatypeName ,
1719
1714
) -> Option < Vec < CounterExample > > {
1720
- // println!("matrix types:");
1721
- // for ty in &matrix.tys {
1722
- // ty.print_verbose();
1723
- // }
1724
-
1715
+ debug_print ! (
1716
+ context. debug. match_counterexample,
1717
+ ( lines "matrix types" => & matrix. tys; verbose)
1718
+ ) ;
1725
1719
// TODO: if we ever want to match against structs, this needs to behave differently
1726
1720
if context. is_struct ( & mident, & datatype_name) {
1727
1721
let ( _, default) = matrix. specialize_default ( ) ;
@@ -1829,8 +1823,7 @@ fn find_counterexample(
1829
1823
arity : u32 ,
1830
1824
ndx : & mut u32 ,
1831
1825
) -> Option < Vec < CounterExample > > {
1832
- // println!("checking matrix");
1833
- // matrix.print_verbose();
1826
+ debug_print ! ( context. debug. match_counterexample, ( "checking matrix" => matrix; verbose) ) ;
1834
1827
let result = if matrix. patterns_empty ( ) {
1835
1828
None
1836
1829
} else if let Some ( ty) = matrix. tys . first ( ) {
@@ -1863,21 +1856,17 @@ fn find_counterexample(
1863
1856
assert ! ( matrix. is_empty( ) ) ;
1864
1857
Some ( make_wildcards ( arity as usize ) )
1865
1858
} ;
1866
- // print!("result:");
1867
- // match result {
1868
- // Some(ref n) => println!("{:#?}", n),
1869
- // None => println!("NONE"),
1870
- // }
1871
- // println!();
1859
+ debug_print ! ( context. debug. match_counterexample, ( opt "result" => & result; sdbg) ) ;
1872
1860
result
1873
1861
}
1874
1862
1875
1863
let mut ndx = 0 ;
1876
1864
if let Some ( mut counterexample) = find_counterexample ( context, matrix, 1 , & mut ndx) {
1877
- // println!("counterexamples: {}", counterexample.len());
1878
- // for ce in &counterexample {
1879
- // println!("{}", ce);
1880
- // }
1865
+ debug_print ! (
1866
+ context. debug. match_counterexample,
1867
+ ( "counterexamples #" => counterexample. len( ) ; fmt) ,
1868
+ ( lines "counterexamples" => & counterexample; fmt)
1869
+ ) ;
1881
1870
assert ! ( counterexample. len( ) == 1 ) ;
1882
1871
let counterexample = counterexample. remove ( 0 ) ;
1883
1872
let msg = format ! ( "Pattern '{}' not covered" , counterexample) ;
0 commit comments