@@ -91,24 +91,21 @@ impure fn print_type(ps s, @ast.ty ty) {
91
91
commasep[ ast. ty_field ] ( s, fields, f) ;
92
92
pclose ( s) ;
93
93
}
94
- case ( ast. ty_fn ( ?proto, ?inputs, ?output) ) {
95
- if ( proto == ast. proto_fn ) { wrd ( s, "fn" ) ; }
96
- else { wrd ( s, "iter" ) ; }
97
- popen ( s) ;
98
- impure fn print_arg ( ps s, ast. ty_arg input ) {
99
- if ( middle. ty . mode_is_alias ( input. mode ) ) { wrd ( s, "&" ) ; }
100
- print_type ( s, input. ty ) ;
101
- }
102
- auto f = print_arg;
103
- commasep[ ast. ty_arg ] ( s, inputs, f) ;
104
- pclose ( s) ;
105
- if ( output. node != ast. ty_nil ) {
106
- space ( s) ;
94
+ case ( ast. ty_obj ( ?methods) ) {
95
+ wrd1 ( s, "obj" ) ;
96
+ bopen ( s) ;
97
+ for ( ast. ty_method m in methods) {
107
98
hbox ( s) ;
108
- wrd1 ( s, "->" ) ;
109
- print_type ( s, output) ;
99
+ print_ty_fn ( s, m. proto , option. some [ str] ( m. ident ) ,
100
+ m. inputs , m. output ) ;
101
+ wrd ( s, ";" ) ;
110
102
end ( s) ;
103
+ line ( s) ;
111
104
}
105
+ bclose ( s) ;
106
+ }
107
+ case ( ast. ty_fn ( ?proto, ?inputs, ?output) ) {
108
+ print_ty_fn ( s, proto, option. none [ str] , inputs, output) ;
112
109
}
113
110
case ( ast. ty_path ( ?path, _) ) {
114
111
print_path ( s, path) ;
@@ -528,7 +525,6 @@ impure fn print_expr(ps s, @ast.expr expr) {
528
525
}
529
526
// TODO: extension 'body'
530
527
}
531
- case ( _) { wrd ( s, "X" ) ; }
532
528
}
533
529
end ( s) ;
534
530
}
@@ -730,3 +726,28 @@ fn escape_str(str st, char to_escape) -> str {
730
726
impure fn print_string ( ps s, str st) {
731
727
wrd ( s, "\" " ) ; wrd ( s, escape_str ( st, '"' ) ) ; wrd ( s, "\" " ) ;
732
728
}
729
+
730
+ impure fn print_ty_fn ( ps s, ast. proto proto , option. t[ str] id ,
731
+ vec[ ast. ty_arg] inputs , @ast. ty output ) {
732
+ if ( proto == ast. proto_fn ) { wrd ( s, "fn" ) ; }
733
+ else { wrd ( s, "iter" ) ; }
734
+ alt ( id) {
735
+ case ( option. some [ str] ( ?id) ) { space ( s) ; wrd ( s, id) ; }
736
+ case ( _) { }
737
+ }
738
+ popen ( s) ;
739
+ impure fn print_arg ( ps s, ast. ty_arg input ) {
740
+ if ( middle. ty . mode_is_alias ( input. mode ) ) { wrd ( s, "&" ) ; }
741
+ print_type ( s, input. ty ) ;
742
+ }
743
+ auto f = print_arg;
744
+ commasep[ ast. ty_arg ] ( s, inputs, f) ;
745
+ pclose ( s) ;
746
+ if ( output. node != ast. ty_nil ) {
747
+ space ( s) ;
748
+ hbox ( s) ;
749
+ wrd1 ( s, "->" ) ;
750
+ print_type ( s, output) ;
751
+ end ( s) ;
752
+ }
753
+ }
0 commit comments