@@ -279,10 +279,10 @@ pub fn mk_lambda_(cx: @ext_ctxt,
279
279
mk_expr ( cx, span, ast:: expr_fn_block ( fn_decl, blk) )
280
280
}
281
281
pub fn mk_lambda ( cx : @ext_ctxt ,
282
- span : span ,
283
- fn_decl : ast:: fn_decl ,
284
- expr : @ast:: expr )
285
- -> @ast:: expr {
282
+ span : span ,
283
+ fn_decl : ast:: fn_decl ,
284
+ expr : @ast:: expr )
285
+ -> @ast:: expr {
286
286
let blk = mk_simple_block ( cx, span, expr) ;
287
287
mk_lambda_ ( cx, span, fn_decl, blk)
288
288
}
@@ -294,6 +294,13 @@ pub fn mk_lambda_stmts(cx: @ext_ctxt,
294
294
let blk = mk_block ( cx, span, ~[ ] , stmts, None ) ;
295
295
mk_lambda ( cx, span, fn_decl, blk)
296
296
}
297
+ pub fn mk_lambda_no_args ( cx : @ext_ctxt ,
298
+ span : span ,
299
+ expr : @ast:: expr )
300
+ -> @ast:: expr {
301
+ let fn_decl = mk_fn_decl ( ~[ ] , mk_ty_infer ( cx, span) ) ;
302
+ mk_lambda ( cx, span, fn_decl, expr)
303
+ }
297
304
pub fn mk_copy ( cx : @ext_ctxt , sp : span , e : @ast:: expr ) -> @ast:: expr {
298
305
mk_expr ( cx, sp, ast:: expr_copy ( e) )
299
306
}
@@ -303,11 +310,20 @@ pub fn mk_managed(cx: @ext_ctxt, sp: span, e: @ast::expr) -> @ast::expr {
303
310
pub fn mk_pat ( cx : @ext_ctxt , span : span , +pat : ast:: pat_ ) -> @ast:: pat {
304
311
@ast:: pat { id : cx. next_id ( ) , node : pat, span : span }
305
312
}
313
+ pub fn mk_pat_wild ( cx : @ext_ctxt , span : span ) -> @ast:: pat {
314
+ mk_pat ( cx, span, ast:: pat_wild)
315
+ }
316
+ pub fn mk_pat_lit ( cx : @ext_ctxt ,
317
+ span : span ,
318
+ expr : @ast:: expr ) -> @ast:: pat {
319
+ mk_pat ( cx, span, ast:: pat_lit ( expr) )
320
+ }
306
321
pub fn mk_pat_ident ( cx : @ext_ctxt ,
307
322
span : span ,
308
323
ident : ast:: ident ) -> @ast:: pat {
309
324
mk_pat_ident_with_binding_mode ( cx, span, ident, ast:: bind_by_copy)
310
325
}
326
+
311
327
pub fn mk_pat_ident_with_binding_mode ( cx : @ext_ctxt ,
312
328
span : span ,
313
329
ident : ast:: ident ,
@@ -435,8 +451,38 @@ pub fn mk_ty_param(cx: @ext_ctxt,
435
451
}
436
452
pub fn mk_lifetime ( cx : @ext_ctxt ,
437
453
span : span ,
438
- ident : ast:: ident ) -> ast :: Lifetime
439
- {
454
+ ident : ast:: ident )
455
+ -> ast :: Lifetime {
440
456
ast:: Lifetime { id : cx. next_id ( ) , span : span, ident : ident }
441
457
}
442
-
458
+ pub fn mk_arm ( cx : @ext_ctxt ,
459
+ span : span ,
460
+ pats : ~[ @ast:: pat ] ,
461
+ expr : @ast:: expr )
462
+ -> ast:: arm {
463
+ ast:: arm {
464
+ pats : pats,
465
+ guard : None ,
466
+ body : mk_simple_block ( cx, span, expr)
467
+ }
468
+ }
469
+ pub fn mk_unreachable ( cx : @ext_ctxt , span : span ) -> @ast:: expr {
470
+ let loc = cx. codemap ( ) . lookup_char_pos ( span. lo ) ;
471
+ mk_call_global (
472
+ cx,
473
+ span,
474
+ ~[
475
+ cx. ident_of ( ~"core") ,
476
+ cx. ident_of ( ~"sys") ,
477
+ cx. ident_of ( ~"begin_unwind") ,
478
+ ] ,
479
+ ~[
480
+ mk_uniq_str ( cx, span, ~"internal error: entered unreachable code") ,
481
+ mk_uniq_str ( cx, span, loc. file . name ) ,
482
+ mk_uint ( cx, span, loc. line ) ,
483
+ ]
484
+ )
485
+ }
486
+ pub fn mk_unreachable_arm ( cx : @ext_ctxt , span : span ) -> ast:: arm {
487
+ mk_arm ( cx, span, ~[ mk_pat_wild ( cx, span) ] , mk_unreachable ( cx, span) )
488
+ }
0 commit comments