@@ -10,7 +10,6 @@ import front::lexer;
10
10
import front:: codemap;
11
11
import front:: codemap:: codemap;
12
12
import front:: ast;
13
- import middle:: ty;
14
13
import util:: common;
15
14
import option:: some;
16
15
import option:: none;
@@ -29,7 +28,7 @@ import pp::eof;
29
28
import ppaux:: * ;
30
29
31
30
fn print_crate ( session sess, @ast:: crate crate, str filename ,
32
- io:: writer out, mode mode ) {
31
+ io:: writer out, & pp_ann ann ) {
33
32
let vec[ pp:: breaks] boxes = [ ] ;
34
33
auto r = lexer:: gather_comments_and_literals ( sess, filename) ;
35
34
auto s =
@@ -40,7 +39,7 @@ fn print_crate(session sess, @ast::crate crate, str filename,
40
39
mutable cur_cmnt=0 u,
41
40
mutable cur_lit=0 u,
42
41
mutable boxes=boxes,
43
- mode=mode ) ;
42
+ ann=ann ) ;
44
43
print_mod ( s, crate . node. module , crate . node. attrs ) ;
45
44
eof ( s. s ) ;
46
45
}
@@ -297,6 +296,8 @@ fn print_item(&ps s, &@ast::item item) {
297
296
hardbreak_if_not_bol ( s) ;
298
297
maybe_print_comment ( s, item. span . lo ) ;
299
298
print_outer_attributes ( s, item. attrs ) ;
299
+ auto ann_node = node_item ( s, item) ;
300
+ s. ann . pre ( ann_node) ;
300
301
alt ( item. node ) {
301
302
case ( ast:: item_const ( ?ty, ?expr) ) {
302
303
head ( s, "const" ) ;
@@ -470,15 +471,7 @@ fn print_item(&ps s, &@ast::item item) {
470
471
print_block ( s, dt. body ) ;
471
472
}
472
473
}
473
-
474
- // Print the node ID if necessary. TODO: type as well.
475
- alt ( s. mode ) {
476
- case ( mo_identified) {
477
- space ( s. s ) ;
478
- synth_comment ( s, int:: to_str ( item. id , 10 u) ) ;
479
- }
480
- case ( _) { /* no-op */ }
481
- }
474
+ s. ann . post ( ann_node) ;
482
475
}
483
476
484
477
fn print_outer_attributes ( & ps s, vec[ ast:: attribute ] attrs ) {
@@ -530,6 +523,8 @@ fn print_stmt(&ps s, &ast::stmt st) {
530
523
531
524
fn print_block ( & ps s, ast:: block blk) {
532
525
maybe_print_comment ( s, blk. span . lo ) ;
526
+ auto ann_node = node_block ( s, blk) ;
527
+ s. ann . pre ( ann_node) ;
533
528
bopen ( s) ;
534
529
for ( @ast:: stmt st in blk. node. stmts) { print_stmt ( s, * st) }
535
530
alt ( blk. node . expr ) {
@@ -541,15 +536,7 @@ fn print_block(&ps s, ast::block blk) {
541
536
case ( _) { }
542
537
}
543
538
bclose ( s, blk. span ) ;
544
-
545
- // Print the node ID if necessary: TODO: type as well.
546
- alt ( s. mode ) {
547
- case ( mo_identified) {
548
- space ( s. s ) ;
549
- synth_comment ( s, "block " + int:: to_str ( blk. node . id , 10 u) ) ;
550
- }
551
- case ( _) { /* no-op */ }
552
- }
539
+ s. ann . post ( ann_node) ;
553
540
}
554
541
555
542
fn print_if ( & ps s, & @ast:: expr test, & ast:: block block,
@@ -597,11 +584,8 @@ fn print_if(&ps s, &@ast::expr test, &ast::block block,
597
584
fn print_expr ( & ps s, & @ast:: expr expr) {
598
585
maybe_print_comment ( s, expr. span . lo ) ;
599
586
ibox ( s, indent_unit) ;
600
- alt ( s. mode ) {
601
- case ( mo_untyped) { /* no-op */ }
602
- case ( mo_typed ( _) ) { popen ( s) ; }
603
- case ( mo_identified) { popen ( s) ; }
604
- }
587
+ auto ann_node = node_expr ( s, expr) ;
588
+ s. ann . pre ( ann_node) ;
605
589
alt ( expr. node ) {
606
590
case ( ast:: expr_vec ( ?exprs, ?mut , ?kind) ) {
607
591
ibox ( s, indent_unit) ;
@@ -926,23 +910,7 @@ fn print_expr(&ps s, &@ast::expr expr) {
926
910
927
911
}
928
912
}
929
- // Print the type or node ID if necessary.
930
-
931
- alt ( s. mode ) {
932
- case ( mo_untyped) { /* no-op */ }
933
- case ( mo_typed ( ?tcx) ) {
934
- space ( s. s ) ;
935
- word ( s. s , "as" ) ;
936
- space ( s. s ) ;
937
- word ( s. s , ppaux:: ty_to_str ( tcx, ty:: expr_ty ( tcx, expr) ) ) ;
938
- pclose ( s) ;
939
- }
940
- case ( mo_identified) {
941
- space ( s. s ) ;
942
- synth_comment ( s, int:: to_str ( expr. id , 10 u) ) ;
943
- pclose ( s) ;
944
- }
945
- }
913
+ s. ann . post ( ann_node) ;
946
914
end ( s) ;
947
915
}
948
916
@@ -960,16 +928,6 @@ fn print_decl(&ps s, &@ast::decl decl) {
960
928
}
961
929
case ( _) {
962
930
word_nbsp ( s, "auto" ) ;
963
-
964
- // Print the type or node ID if necessary.
965
- alt ( s. mode ) {
966
- case ( mo_untyped) { /* no-op */ }
967
- case ( mo_typed ( ?tcx) ) {
968
- auto lty = ty:: node_id_to_type ( tcx, loc. node . id ) ;
969
- word_space ( s, ppaux:: ty_to_str ( tcx, lty) ) ;
970
- }
971
- case ( mo_identified) { /* no-op */ }
972
- }
973
931
}
974
932
}
975
933
word ( s. s , loc. node . ident ) ;
@@ -1015,6 +973,8 @@ fn print_path(&ps s, &ast::path path) {
1015
973
1016
974
fn print_pat ( & ps s, & @ast:: pat pat) {
1017
975
maybe_print_comment ( s, pat. span . lo ) ;
976
+ auto ann_node = node_pat ( s, pat) ;
977
+ s. ann . pre ( ann_node) ;
1018
978
alt ( pat. node ) {
1019
979
case ( ast:: pat_wild) { word ( s. s , "_" ) ; }
1020
980
case ( ast:: pat_bind ( ?id) ) { word ( s. s , "?" + id) ; }
@@ -1028,15 +988,7 @@ fn print_pat(&ps s, &@ast::pat pat) {
1028
988
}
1029
989
}
1030
990
}
1031
-
1032
- // Print the node ID if necessary. TODO: type as well.
1033
- alt ( s. mode ) {
1034
- case ( mo_identified) {
1035
- space ( s. s ) ;
1036
- synth_comment ( s, int:: to_str ( pat. id , 10 u) ) ;
1037
- }
1038
- case ( _) { /* no-op */ }
1039
- }
991
+ s. ann . post ( ann_node) ;
1040
992
}
1041
993
1042
994
fn print_fn ( & ps s, ast:: fn_decl decl, ast:: proto proto, str name ,
0 commit comments