File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -91,9 +91,22 @@ trait ext_ctxt_ast_builder {
91
91
+params : ~[ ast:: ty_param ] ) -> @ast:: item ;
92
92
fn item_ty ( name : ident , ty : @ast:: ty ) -> @ast:: item ;
93
93
fn ty_vars ( +ty_params : ~[ ast:: ty_param ] ) -> ~[ @ast:: ty ] ;
94
+ fn ty_field_imm ( name : ident , ty : @ast:: ty ) -> ast:: ty_field ;
95
+ fn ty_rec ( +~[ ast:: ty_field ] ) -> @ast:: ty ;
94
96
}
95
97
96
98
impl ast_builder of ext_ctxt_ast_builder for ext_ctxt {
99
+ fn ty_field_imm ( name : ident , ty : @ast:: ty ) -> ast:: ty_field {
100
+ { node : { ident : name, mt : { ty: ty, mutbl : ast:: m_imm } } ,
101
+ span: empty_span ( ) }
102
+ }
103
+
104
+ fn ty_rec ( +fields : ~[ ast:: ty_field ] ) -> @ast:: ty {
105
+ @{ id: self . next_id ( ) ,
106
+ node: ast:: ty_rec ( fields) ,
107
+ span: empty_span ( ) }
108
+ }
109
+
97
110
fn ty_param ( id : ast:: ident , +bounds : ~[ ast:: ty_param_bound ] )
98
111
-> ast:: ty_param
99
112
{
Original file line number Diff line number Diff line change @@ -204,6 +204,7 @@ impl compile of to_type_decls for state {
204
204
205
205
impl compile of gen_init for protocol {
206
206
fn gen_init ( cx : ext_ctxt ) -> @ast:: item {
207
+ #debug ( "gen_init" ) ;
207
208
let start_state = self . states [ 0 ] ;
208
209
209
210
let body = alt start_state. dir {
@@ -237,6 +238,23 @@ impl compile of gen_init for protocol {
237
238
server_states += s. to_endpoint_decls ( cx, recv) ;
238
239
}
239
240
241
+ if self . is_bounded ( ) {
242
+ vec:: push (
243
+ items,
244
+ cx. item_ty (
245
+ @~"buffer",
246
+ cx. ty_rec (
247
+ ( copy self . states ) . map_to_vec (
248
+ |s| cx. ty_field_imm (
249
+ s. name ,
250
+ cx. ty_path_ast_builder (
251
+ ( path ( @~"pipes")
252
+ + @~"packet")
253
+ . add_ty (
254
+ cx. ty_path_ast_builder (
255
+ path ( s. name ) ) ) ) ) ) ) ) )
256
+ }
257
+
240
258
vec:: push ( items,
241
259
cx. item_mod ( @~"client",
242
260
client_states) ) ;
You can’t perform that action at this time.
0 commit comments