@@ -26,6 +26,7 @@ extern crate syntax;
26
26
extern crate rustc;
27
27
28
28
use std:: rc:: Rc ;
29
+ use std:: gc:: { Gc , GC } ;
29
30
30
31
use syntax:: ast;
31
32
use syntax:: codemap;
@@ -110,7 +111,7 @@ struct NfaGen<'a> {
110
111
}
111
112
112
113
impl < ' a > NfaGen < ' a > {
113
- fn code ( & mut self ) -> @ ast:: Expr {
114
+ fn code ( & mut self ) -> Gc < ast:: Expr > {
114
115
// Most or all of the following things are used in the quasiquoted
115
116
// expression returned.
116
117
let num_cap_locs = 2 * self . prog . num_captures ( ) ;
@@ -331,7 +332,7 @@ fn exec<'t>(which: ::regex::native::MatchKind, input: &'t str,
331
332
332
333
// Generates code for the `add` method, which is responsible for adding
333
334
// zero-width states to the next queue of states to visit.
334
- fn add_insts ( & self ) -> @ ast:: Expr {
335
+ fn add_insts ( & self ) -> Gc < ast:: Expr > {
335
336
let arms = self . prog . insts . iter ( ) . enumerate ( ) . map ( |( pc, inst) | {
336
337
let nextpc = pc + 1 ;
337
338
let body = match * inst {
@@ -432,7 +433,7 @@ fn exec<'t>(which: ::regex::native::MatchKind, input: &'t str,
432
433
433
434
// Generates the code for the `step` method, which processes all states
434
435
// in the current queue that consume a single character.
435
- fn step_insts ( & self ) -> @ ast:: Expr {
436
+ fn step_insts ( & self ) -> Gc < ast:: Expr > {
436
437
let arms = self . prog . insts . iter ( ) . enumerate ( ) . map ( |( pc, inst) | {
437
438
let nextpc = pc + 1 ;
438
439
let body = match * inst {
@@ -523,7 +524,7 @@ fn exec<'t>(which: ::regex::native::MatchKind, input: &'t str,
523
524
// Translates a character class into a match expression.
524
525
// This avoids a binary search (and is hopefully replaced by a jump
525
526
// table).
526
- fn match_class ( & self , casei : bool , ranges : & [ ( char , char ) ] ) -> @ ast:: Expr {
527
+ fn match_class ( & self , casei : bool , ranges : & [ ( char , char ) ] ) -> Gc < ast:: Expr > {
527
528
let expr_true = quote_expr ! ( self . cx, true ) ;
528
529
529
530
let mut arms = ranges. iter ( ) . map ( |& ( mut start, mut end) | {
@@ -545,7 +546,7 @@ fn exec<'t>(which: ::regex::native::MatchKind, input: &'t str,
545
546
// Generates code for checking a literal prefix of the search string.
546
547
// The code is only generated if the regex *has* a literal prefix.
547
548
// Otherwise, a no-op is returned.
548
- fn check_prefix ( & self ) -> @ ast:: Expr {
549
+ fn check_prefix ( & self ) -> Gc < ast:: Expr > {
549
550
if self . prog . prefix . len ( ) == 0 {
550
551
self . empty_block ( )
551
552
} else {
@@ -569,28 +570,28 @@ fn exec<'t>(which: ::regex::native::MatchKind, input: &'t str,
569
570
// A wild-card arm is automatically added that executes a no-op. It will
570
571
// never be used, but is added to satisfy the compiler complaining about
571
572
// non-exhaustive patterns.
572
- fn match_insts ( & self , mut arms : Vec < ast:: Arm > ) -> @ ast:: Expr {
573
+ fn match_insts ( & self , mut arms : Vec < ast:: Arm > ) -> Gc < ast:: Expr > {
573
574
arms. push ( self . wild_arm_expr ( self . empty_block ( ) ) ) ;
574
575
self . cx . expr_match ( self . sp , quote_expr ! ( self . cx, pc) , arms)
575
576
}
576
577
577
- fn empty_block ( & self ) -> @ ast:: Expr {
578
+ fn empty_block ( & self ) -> Gc < ast:: Expr > {
578
579
quote_expr ! ( self . cx, { } )
579
580
}
580
581
581
582
// Creates a match arm for the instruction at `pc` with the expression
582
583
// `body`.
583
- fn arm_inst ( & self , pc : uint , body : @ ast:: Expr ) -> ast:: Arm {
584
+ fn arm_inst ( & self , pc : uint , body : Gc < ast:: Expr > ) -> ast:: Arm {
584
585
let pc_pat = self . cx . pat_lit ( self . sp , quote_expr ! ( self . cx, $pc) ) ;
585
586
586
587
self . cx . arm ( self . sp , vec ! ( pc_pat) , body)
587
588
}
588
589
589
590
// Creates a wild-card match arm with the expression `body`.
590
- fn wild_arm_expr ( & self , body : @ ast:: Expr ) -> ast:: Arm {
591
+ fn wild_arm_expr ( & self , body : Gc < ast:: Expr > ) -> ast:: Arm {
591
592
ast:: Arm {
592
593
attrs : vec ! ( ) ,
593
- pats : vec ! ( @ ast:: Pat {
594
+ pats : vec ! ( box ( GC ) ast:: Pat {
594
595
id: ast:: DUMMY_NODE_ID ,
595
596
span: self . sp,
596
597
node: ast:: PatWild ,
@@ -603,8 +604,9 @@ fn exec<'t>(which: ::regex::native::MatchKind, input: &'t str,
603
604
604
605
// Converts `xs` to a `[x1, x2, .., xN]` expression by calling `to_expr`
605
606
// on each element in `xs`.
606
- fn vec_expr < T , It : Iterator < T > > ( & self , xs : It , to_expr : |& ExtCtxt , T | -> @ast:: Expr )
607
- -> @ast:: Expr {
607
+ fn vec_expr < T , It : Iterator < T > > ( & self , xs : It ,
608
+ to_expr : |& ExtCtxt , T | -> Gc < ast:: Expr > )
609
+ -> Gc < ast:: Expr > {
608
610
let exprs = xs. map( |x| to_expr( self . cx, x) ) . collect ( ) ;
609
611
self . cx. expr_vec( self . sp, exprs)
610
612
}
0 commit comments