@@ -110,7 +110,8 @@ impl compile of gen_send for message {
110
110
111
111
cx. item_fn_poly( self . name( ) ,
112
112
args_ast,
113
- cx. ty_path_ast_builder( path( next. data_name( ) , span)
113
+ cx. ty_path_ast_builder( path( next. data_name( ) ,
114
+ span)
114
115
. add_tys( next_tys) ) ,
115
116
self . get_params( ) ,
116
117
cx. expr_block( body) )
@@ -230,7 +231,6 @@ impl compile of to_type_decls for state {
230
231
self . ty_params ) ) ;
231
232
}
232
233
else {
233
- let ext_cx = cx;
234
234
vec:: push ( items,
235
235
cx. item_ty_poly (
236
236
self . data_name ( ) ,
@@ -240,7 +240,7 @@ impl compile of to_type_decls for state {
240
240
. add_tys ( ~[ cx. ty_path_ast_builder (
241
241
( self . proto . name + self . data_name ( ) )
242
242
. add_tys ( cx. ty_vars ( self . ty_params ) ) ) ,
243
- #ast [ ty ] { buffer } ] ) ) ,
243
+ self . proto . buffer_ty_path ( cx ) ] ) ) ,
244
244
self . ty_params ) ) ;
245
245
} ;
246
246
items
@@ -288,7 +288,7 @@ impl compile of gen_init for protocol {
288
288
289
289
fn gen_buffer_init ( ext_cx : ext_ctxt ) -> @ast:: expr {
290
290
ext_cx. rec ( self . states . map_to_vec ( |s| {
291
- let fty = ext_cx . ty_path_ast_builder ( path ( s . name , s . span ) ) ;
291
+ let fty = s . to_ty ( ext_cx ) ;
292
292
ext_cx. field_imm ( s. name , #ast { pipes:: mk_packet :: < $( fty ) > ( ) } )
293
293
} ) )
294
294
}
@@ -318,19 +318,40 @@ impl compile of gen_init for protocol {
318
318
} }
319
319
}
320
320
321
+ fn buffer_ty_path ( cx : ext_ctxt ) -> @ast:: ty {
322
+ let mut params = ~[ ] ;
323
+ for ( copy self. states) . each |s| {
324
+ for s. ty_params. each |tp| {
325
+ if !params. contains ( tp) {
326
+ vec:: push ( params, tp) ;
327
+ }
328
+ }
329
+ }
330
+
331
+ cx. ty_path_ast_builder ( path ( @~"buffer", self . span )
332
+ . add_tys ( cx. ty_vars ( params) ) )
333
+ }
334
+
321
335
fn gen_buffer_type ( cx : ext_ctxt ) -> @ast:: item {
322
336
let ext_cx = cx;
323
- cx. item_ty (
337
+ let mut params = ~[ ] ;
338
+ let fields = do ( copy self . states ) . map_to_vec |s| {
339
+ for s. ty_params . each |tp| {
340
+ if !params. contains ( tp) {
341
+ vec:: push ( params, tp) ;
342
+ }
343
+ }
344
+ let ty = s. to_ty ( cx) ;
345
+ let fty = #ast[ ty] {
346
+ pipes:: packet<$( ty) >
347
+ } ;
348
+ cx. ty_field_imm ( s. name , fty)
349
+ } ;
350
+
351
+ cx. item_ty_poly (
324
352
@~"buffer",
325
- cx. ty_rec (
326
- ( copy self . states ) . map_to_vec (
327
- |s| {
328
- let ty = cx. ty_path_ast_builder ( path ( s. name , s. span ) ) ;
329
- let fty = #ast[ ty] {
330
- pipes:: packet<$( ty) >
331
- } ;
332
- cx. ty_field_imm ( s. name , fty)
333
- } ) ) )
353
+ cx. ty_rec ( fields) ,
354
+ params)
334
355
}
335
356
336
357
fn compile ( cx : ext_ctxt ) -> @ast:: item {
0 commit comments