@@ -64,12 +64,7 @@ pub fn mk_unary(cx: @ext_ctxt, sp: span, op: ast::unop, e: @ast::expr)
64
64
mk_expr ( cx, sp, ast:: expr_unary ( op, e) )
65
65
}
66
66
pub fn mk_raw_path ( sp : span , +idents : ~[ ast:: ident ] ) -> @ast:: Path {
67
- let p = @ast:: Path { span : sp,
68
- global : false ,
69
- idents : idents,
70
- rp : None ,
71
- types : ~[ ] } ;
72
- return p;
67
+ mk_raw_path_ ( sp, idents, ~[ ] )
73
68
}
74
69
pub fn mk_raw_path_ ( sp : span ,
75
70
+idents : ~[ ast:: ident ] ,
@@ -82,11 +77,16 @@ pub fn mk_raw_path_(sp: span,
82
77
types : types }
83
78
}
84
79
pub fn mk_raw_path_global ( sp : span , +idents : ~[ ast:: ident ] ) -> @ast:: Path {
80
+ mk_raw_path_global_ ( sp, idents, ~[ ] )
81
+ }
82
+ pub fn mk_raw_path_global_ ( sp : span ,
83
+ +idents : ~[ ast:: ident ] ,
84
+ +types : ~[ @ast:: Ty ] ) -> @ast:: Path {
85
85
@ast:: Path { span : sp,
86
86
global : true ,
87
87
idents : idents,
88
88
rp : None ,
89
- types : ~ [ ] }
89
+ types : types }
90
90
}
91
91
pub fn mk_path ( cx : @ext_ctxt , sp : span , +idents : ~[ ast:: ident ] )
92
92
-> @ast:: expr {
@@ -271,6 +271,29 @@ pub fn mk_simple_block(cx: @ext_ctxt,
271
271
span : span,
272
272
}
273
273
}
274
+ pub fn mk_lambda_ ( cx : @ext_ctxt ,
275
+ span : span ,
276
+ fn_decl : ast:: fn_decl ,
277
+ blk : ast:: blk )
278
+ -> @ast:: expr {
279
+ mk_expr ( cx, span, ast:: expr_fn_block ( fn_decl, blk) )
280
+ }
281
+ pub fn mk_lambda ( cx : @ext_ctxt ,
282
+ span : span ,
283
+ fn_decl : ast:: fn_decl ,
284
+ expr : @ast:: expr )
285
+ -> @ast:: expr {
286
+ let blk = mk_simple_block ( cx, span, expr) ;
287
+ mk_lambda_ ( cx, span, fn_decl, blk)
288
+ }
289
+ pub fn mk_lambda_stmts ( cx : @ext_ctxt ,
290
+ span : span ,
291
+ fn_decl : ast:: fn_decl ,
292
+ stmts : ~[ @ast:: stmt ] )
293
+ -> @ast:: expr {
294
+ let blk = mk_block ( cx, span, ~[ ] , stmts, None ) ;
295
+ mk_lambda ( cx, span, fn_decl, blk)
296
+ }
274
297
pub fn mk_copy ( cx : @ext_ctxt , sp : span , e : @ast:: expr ) -> @ast:: expr {
275
298
mk_expr ( cx, sp, ast:: expr_copy ( e) )
276
299
}
@@ -337,12 +360,35 @@ pub fn mk_ty_path_global(cx: @ext_ctxt,
337
360
let ty = @ast:: Ty { id : cx. next_id ( ) , node : ty, span : span } ;
338
361
ty
339
362
}
363
+ pub fn mk_ty_rptr ( cx : @ext_ctxt ,
364
+ span : span ,
365
+ ty : @ast:: Ty ,
366
+ mutbl : ast:: mutability )
367
+ -> @ast:: Ty {
368
+ @ast:: Ty {
369
+ id : cx. next_id ( ) ,
370
+ span : span,
371
+ node : ast:: ty_rptr (
372
+ None ,
373
+ ast:: mt { ty : ty, mutbl : mutbl }
374
+ ) ,
375
+ }
376
+ }
377
+ pub fn mk_ty_infer ( cx : @ext_ctxt , span : span ) -> @ast:: Ty {
378
+ @ast:: Ty {
379
+ id : cx. next_id ( ) ,
380
+ node : ast:: ty_infer,
381
+ span : span,
382
+ }
383
+ }
340
384
pub fn mk_trait_ref_global ( cx : @ext_ctxt ,
341
385
span : span ,
342
386
+idents : ~[ ast:: ident ] )
343
387
-> @ast:: trait_ref
344
388
{
345
- let path = build:: mk_raw_path_global ( span, idents) ;
389
+ mk_trait_ref_ ( cx, build:: mk_raw_path_global ( span, idents) )
390
+ }
391
+ pub fn mk_trait_ref_ ( cx : @ext_ctxt , path : @ast:: Path ) -> @ast:: trait_ref {
346
392
@ast:: trait_ref {
347
393
path : path,
348
394
ref_id : cx. next_id ( )
@@ -371,6 +417,16 @@ pub fn mk_arg(cx: @ext_ctxt,
371
417
pub fn mk_fn_decl ( +inputs : ~[ ast:: arg ] , output : @ast:: Ty ) -> ast:: fn_decl {
372
418
ast:: fn_decl { inputs : inputs, output : output, cf : ast:: return_val }
373
419
}
420
+ pub fn mk_trait_ty_param_bound_global ( cx : @ext_ctxt ,
421
+ span : span ,
422
+ +idents : ~[ ast:: ident ] )
423
+ -> ast:: TyParamBound {
424
+ ast:: TraitTyParamBound ( mk_trait_ref_global ( cx, span, idents) )
425
+ }
426
+ pub fn mk_trait_ty_param_bound_ ( cx : @ext_ctxt ,
427
+ path : @ast:: Path ) -> ast:: TyParamBound {
428
+ ast:: TraitTyParamBound ( mk_trait_ref_ ( cx, path) )
429
+ }
374
430
pub fn mk_ty_param ( cx : @ext_ctxt ,
375
431
ident : ast:: ident ,
376
432
bounds : @OptVec < ast:: TyParamBound > )
0 commit comments