@@ -22,7 +22,21 @@ import ast_builder::ast_builder;
22
22
import ast_builder:: methods;
23
23
import ast_builder:: path;
24
24
25
- impl compile for message {
25
+ trait gen_send {
26
+ fn gen_send ( cx : ext_ctxt ) -> @ast:: item ;
27
+ }
28
+
29
+ trait to_type_decls {
30
+ fn to_type_decls ( cx : ext_ctxt ) -> ~[ @ast:: item ] ;
31
+ fn to_endpoint_decls ( cx : ext_ctxt , dir : direction ) -> ~[ @ast:: item ] ;
32
+ }
33
+
34
+ trait gen_init {
35
+ fn gen_init ( cx : ext_ctxt ) -> @ast:: item ;
36
+ fn compile ( cx : ext_ctxt ) -> @ast:: item ;
37
+ }
38
+
39
+ impl compile of gen_send for message {
26
40
fn gen_send ( cx : ext_ctxt ) -> @ast:: item {
27
41
#debug ( "pipec: gen_send" ) ;
28
42
alt self {
@@ -80,7 +94,7 @@ impl compile for message {
80
94
81
95
let args_ast = vec:: append (
82
96
~[ cx. arg_mode ( @~"pipe",
83
- cx. ty_path ( path ( this. data_name ( ) )
97
+ cx. ty_path_ast_builder ( path ( this. data_name ( ) )
84
98
. add_tys ( cx. ty_vars ( this. ty_params ) ) ) ,
85
99
ast:: by_copy) ] ,
86
100
args_ast) ;
@@ -104,20 +118,20 @@ impl compile for message {
104
118
105
119
cx. item_fn_poly ( self . name ( ) ,
106
120
args_ast,
107
- cx. ty_nil ( ) ,
121
+ cx. ty_nil_ast_builder ( ) ,
108
122
self . get_params ( ) ,
109
123
cx. expr_block ( body) )
110
124
}
111
125
}
112
126
}
113
127
114
128
fn to_ty( cx: ext_ctxt) -> @ast:: ty {
115
- cx. ty_path_ast_builder ( path ( self . name )
116
- . add_tys ( cx. ty_vars ( self . ty_params ) ) )
129
+ cx. ty_path_ast_builder ( path ( self . name ( ) )
130
+ . add_tys ( cx. ty_vars ( self . get_params ( ) ) ) )
117
131
}
118
132
}
119
133
120
- impl compile for state {
134
+ impl compile of to_type_decls for state {
121
135
fn to_type_decls( cx: ext_ctxt) -> ~[ @ast:: item] {
122
136
#debug ( "pipec: to_type_decls" ) ;
123
137
// This compiles into two different type declarations. Say the
@@ -144,7 +158,7 @@ impl compile for state {
144
158
} ;
145
159
146
160
vec:: append_one ( tys,
147
- cx. ty_path ( ( dir + next_name)
161
+ cx. ty_path_ast_builder ( ( dir + next_name)
148
162
. add_tys ( next_tys) ) )
149
163
}
150
164
none { tys }
@@ -184,7 +198,7 @@ impl compile for state {
184
198
}
185
199
}
186
200
187
- impl compile for protocol {
201
+ impl compile of gen_init for protocol {
188
202
fn gen_init ( cx : ext_ctxt ) -> @ast:: item {
189
203
let start_state = self . states [ 0 ] ;
190
204
@@ -303,19 +317,3 @@ impl parse_utils of ext_ctxt_parse_utils for ext_ctxt {
303
317
}
304
318
}
305
319
306
- trait two_vector_utils < A , B > {
307
- fn zip ( ) -> ~[ ( A , B ) ] ;
308
- fn map < C > ( f : fn ( A , B ) -> C ) -> ~[ C ] ;
309
- }
310
-
311
- impl methods < A : copy , B : copy > of two_vector_utils < A , B > for ( ~[ A ] , ~[ B ] ) {
312
- fn zip ( ) -> ~[ ( A , B ) ] {
313
- let ( a, b) = self ;
314
- vec:: zip ( a, b)
315
- }
316
-
317
- fn map < C > ( f : fn ( A , B ) -> C ) -> ~[ C ] {
318
- let ( a, b) = self ;
319
- vec:: map2 ( a, b, f)
320
- }
321
- }
0 commit comments