@@ -26,6 +26,7 @@ extern crate syntax;
2626extern crate rustc;
2727
2828use std:: rc:: Rc ;
29+ use std:: gc:: { Gc , GC } ;
2930
3031use syntax:: ast;
3132use syntax:: codemap;
@@ -110,7 +111,7 @@ struct NfaGen<'a> {
110111}
111112
112113impl < ' a > NfaGen < ' a > {
113- fn code ( & mut self ) -> @ ast:: Expr {
114+ fn code ( & mut self ) -> Gc < ast:: Expr > {
114115 // Most or all of the following things are used in the quasiquoted
115116 // expression returned.
116117 let num_cap_locs = 2 * self . prog . num_captures ( ) ;
@@ -331,7 +332,7 @@ fn exec<'t>(which: ::regex::native::MatchKind, input: &'t str,
331332
332333 // Generates code for the `add` method, which is responsible for adding
333334 // 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 > {
335336 let arms = self . prog . insts . iter ( ) . enumerate ( ) . map ( |( pc, inst) | {
336337 let nextpc = pc + 1 ;
337338 let body = match * inst {
@@ -432,7 +433,7 @@ fn exec<'t>(which: ::regex::native::MatchKind, input: &'t str,
432433
433434 // Generates the code for the `step` method, which processes all states
434435 // in the current queue that consume a single character.
435- fn step_insts ( & self ) -> @ ast:: Expr {
436+ fn step_insts ( & self ) -> Gc < ast:: Expr > {
436437 let arms = self . prog . insts . iter ( ) . enumerate ( ) . map ( |( pc, inst) | {
437438 let nextpc = pc + 1 ;
438439 let body = match * inst {
@@ -523,7 +524,7 @@ fn exec<'t>(which: ::regex::native::MatchKind, input: &'t str,
523524 // Translates a character class into a match expression.
524525 // This avoids a binary search (and is hopefully replaced by a jump
525526 // 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 > {
527528 let expr_true = quote_expr ! ( self . cx, true ) ;
528529
529530 let mut arms = ranges. iter ( ) . map ( |& ( mut start, mut end) | {
@@ -545,7 +546,7 @@ fn exec<'t>(which: ::regex::native::MatchKind, input: &'t str,
545546 // Generates code for checking a literal prefix of the search string.
546547 // The code is only generated if the regex *has* a literal prefix.
547548 // Otherwise, a no-op is returned.
548- fn check_prefix ( & self ) -> @ ast:: Expr {
549+ fn check_prefix ( & self ) -> Gc < ast:: Expr > {
549550 if self . prog . prefix . len ( ) == 0 {
550551 self . empty_block ( )
551552 } else {
@@ -569,28 +570,28 @@ fn exec<'t>(which: ::regex::native::MatchKind, input: &'t str,
569570 // A wild-card arm is automatically added that executes a no-op. It will
570571 // never be used, but is added to satisfy the compiler complaining about
571572 // 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 > {
573574 arms. push ( self . wild_arm_expr ( self . empty_block ( ) ) ) ;
574575 self . cx . expr_match ( self . sp , quote_expr ! ( self . cx, pc) , arms)
575576 }
576577
577- fn empty_block ( & self ) -> @ ast:: Expr {
578+ fn empty_block ( & self ) -> Gc < ast:: Expr > {
578579 quote_expr ! ( self . cx, { } )
579580 }
580581
581582 // Creates a match arm for the instruction at `pc` with the expression
582583 // `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 {
584585 let pc_pat = self . cx . pat_lit ( self . sp , quote_expr ! ( self . cx, $pc) ) ;
585586
586587 self . cx . arm ( self . sp , vec ! ( pc_pat) , body)
587588 }
588589
589590 // 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 {
591592 ast:: Arm {
592593 attrs : vec ! ( ) ,
593- pats : vec ! ( @ ast:: Pat {
594+ pats : vec ! ( box ( GC ) ast:: Pat {
594595 id: ast:: DUMMY_NODE_ID ,
595596 span: self . sp,
596597 node: ast:: PatWild ,
@@ -603,8 +604,9 @@ fn exec<'t>(which: ::regex::native::MatchKind, input: &'t str,
603604
604605 // Converts `xs` to a `[x1, x2, .., xN]` expression by calling `to_expr`
605606 // 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 > {
608610 let exprs = xs. map( |x| to_expr( self . cx, x) ) . collect ( ) ;
609611 self . cx. expr_vec( self . sp, exprs)
610612 }
0 commit comments