@@ -26,7 +26,6 @@ extern crate syntax;
26
26
extern crate rustc;
27
27
28
28
use std:: rc:: Rc ;
29
- use std:: gc:: { Gc , GC } ;
30
29
31
30
use syntax:: ast;
32
31
use syntax:: codemap;
@@ -35,6 +34,7 @@ use syntax::ext::base::{ExtCtxt, MacResult, MacExpr, DummyResult};
35
34
use syntax:: parse:: token;
36
35
use syntax:: print:: pprust;
37
36
use syntax:: fold:: Folder ;
37
+ use syntax:: ptr:: P ;
38
38
39
39
use rustc:: plugin:: Registry ;
40
40
@@ -111,7 +111,7 @@ struct NfaGen<'a> {
111
111
}
112
112
113
113
impl < ' a > NfaGen < ' a > {
114
- fn code ( & mut self ) -> Gc < ast:: Expr > {
114
+ fn code ( & mut self ) -> P < ast:: Expr > {
115
115
// Most or all of the following things are used in the quasiquoted
116
116
// expression returned.
117
117
let num_cap_locs = 2 * self . prog . num_captures ( ) ;
@@ -332,7 +332,7 @@ fn exec<'t>(which: ::regex::native::MatchKind, input: &'t str,
332
332
333
333
// Generates code for the `add` method, which is responsible for adding
334
334
// zero-width states to the next queue of states to visit.
335
- fn add_insts ( & self ) -> Gc < ast:: Expr > {
335
+ fn add_insts ( & self ) -> P < ast:: Expr > {
336
336
let arms = self . prog . insts . iter ( ) . enumerate ( ) . map ( |( pc, inst) | {
337
337
let nextpc = pc + 1 ;
338
338
let body = match * inst {
@@ -433,7 +433,7 @@ fn exec<'t>(which: ::regex::native::MatchKind, input: &'t str,
433
433
434
434
// Generates the code for the `step` method, which processes all states
435
435
// in the current queue that consume a single character.
436
- fn step_insts ( & self ) -> Gc < ast:: Expr > {
436
+ fn step_insts ( & self ) -> P < ast:: Expr > {
437
437
let arms = self . prog . insts . iter ( ) . enumerate ( ) . map ( |( pc, inst) | {
438
438
let nextpc = pc + 1 ;
439
439
let body = match * inst {
@@ -524,17 +524,15 @@ fn exec<'t>(which: ::regex::native::MatchKind, input: &'t str,
524
524
// Translates a character class into a match expression.
525
525
// This avoids a binary search (and is hopefully replaced by a jump
526
526
// table).
527
- fn match_class ( & self , casei : bool , ranges : & [ ( char , char ) ] ) -> Gc < ast:: Expr > {
528
- let expr_true = quote_expr ! ( self . cx, true ) ;
529
-
527
+ fn match_class ( & self , casei : bool , ranges : & [ ( char , char ) ] ) -> P < ast:: Expr > {
530
528
let mut arms = ranges. iter ( ) . map ( |& ( mut start, mut end) | {
531
529
if casei {
532
530
start = start. to_uppercase ( ) ;
533
531
end = end. to_uppercase ( ) ;
534
532
}
535
533
let pat = self . cx . pat ( self . sp , ast:: PatRange ( quote_expr ! ( self . cx, $start) ,
536
534
quote_expr ! ( self . cx, $end) ) ) ;
537
- self . cx . arm ( self . sp , vec ! ( pat) , expr_true )
535
+ self . cx . arm ( self . sp , vec ! ( pat) , quote_expr ! ( self . cx , true ) )
538
536
} ) . collect :: < Vec < ast:: Arm > > ( ) ;
539
537
540
538
arms. push ( self . wild_arm_expr ( quote_expr ! ( self . cx, false ) ) ) ;
@@ -546,7 +544,7 @@ fn exec<'t>(which: ::regex::native::MatchKind, input: &'t str,
546
544
// Generates code for checking a literal prefix of the search string.
547
545
// The code is only generated if the regex *has* a literal prefix.
548
546
// Otherwise, a no-op is returned.
549
- fn check_prefix ( & self ) -> Gc < ast:: Expr > {
547
+ fn check_prefix ( & self ) -> P < ast:: Expr > {
550
548
if self . prog . prefix . len ( ) == 0 {
551
549
self . empty_block ( )
552
550
} else {
@@ -570,32 +568,32 @@ fn exec<'t>(which: ::regex::native::MatchKind, input: &'t str,
570
568
// A wild-card arm is automatically added that executes a no-op. It will
571
569
// never be used, but is added to satisfy the compiler complaining about
572
570
// non-exhaustive patterns.
573
- fn match_insts ( & self , mut arms : Vec < ast:: Arm > ) -> Gc < ast:: Expr > {
571
+ fn match_insts ( & self , mut arms : Vec < ast:: Arm > ) -> P < ast:: Expr > {
574
572
arms. push ( self . wild_arm_expr ( self . empty_block ( ) ) ) ;
575
573
self . cx . expr_match ( self . sp , quote_expr ! ( self . cx, pc) , arms)
576
574
}
577
575
578
- fn empty_block ( & self ) -> Gc < ast:: Expr > {
576
+ fn empty_block ( & self ) -> P < ast:: Expr > {
579
577
quote_expr ! ( self . cx, { } )
580
578
}
581
579
582
580
// Creates a match arm for the instruction at `pc` with the expression
583
581
// `body`.
584
- fn arm_inst ( & self , pc : uint , body : Gc < ast:: Expr > ) -> ast:: Arm {
582
+ fn arm_inst ( & self , pc : uint , body : P < ast:: Expr > ) -> ast:: Arm {
585
583
let pc_pat = self . cx . pat_lit ( self . sp , quote_expr ! ( self . cx, $pc) ) ;
586
584
587
585
self . cx . arm ( self . sp , vec ! ( pc_pat) , body)
588
586
}
589
587
590
588
// Creates a wild-card match arm with the expression `body`.
591
- fn wild_arm_expr ( & self , body : Gc < ast:: Expr > ) -> ast:: Arm {
589
+ fn wild_arm_expr ( & self , body : P < ast:: Expr > ) -> ast:: Arm {
592
590
ast:: Arm {
593
591
attrs : vec ! ( ) ,
594
- pats : vec ! ( box ( GC ) ast:: Pat {
592
+ pats : vec ! ( P ( ast:: Pat {
595
593
id: ast:: DUMMY_NODE_ID ,
596
594
span: self . sp,
597
595
node: ast:: PatWild ( ast:: PatWildSingle ) ,
598
- } ) ,
596
+ } ) ) ,
599
597
guard : None ,
600
598
body : body,
601
599
}
@@ -605,8 +603,8 @@ fn exec<'t>(which: ::regex::native::MatchKind, input: &'t str,
605
603
// Converts `xs` to a `[x1, x2, .., xN]` expression by calling `to_expr`
606
604
// on each element in `xs`.
607
605
fn vec_expr < T , It : Iterator < T > > ( & self , xs : It ,
608
- to_expr : |& ExtCtxt , T | -> Gc < ast:: Expr > )
609
- -> Gc < ast:: Expr > {
606
+ to_expr : |& ExtCtxt , T | -> P < ast:: Expr > )
607
+ -> P < ast:: Expr > {
610
608
let exprs = xs. map( |x| to_expr( self . cx, x) ) . collect ( ) ;
611
609
self . cx. expr_vec( self . sp, exprs)
612
610
}
@@ -618,13 +616,13 @@ fn parse(cx: &mut ExtCtxt, tts: &[ast::TokenTree]) -> Option<String> {
618
616
let mut parser = cx. new_parser_from_tts ( tts) ;
619
617
let entry = cx. expander ( ) . fold_expr ( parser. parse_expr ( ) ) ;
620
618
let regex = match entry. node {
621
- ast:: ExprLit ( lit) => {
619
+ ast:: ExprLit ( ref lit) => {
622
620
match lit. node {
623
621
ast:: LitStr ( ref s, _) => s. to_string ( ) ,
624
622
_ => {
625
623
cx. span_err ( entry. span , format ! (
626
624
"expected string literal but got `{}`" ,
627
- pprust:: lit_to_string( & * lit) ) . as_slice ( ) ) ;
625
+ pprust:: lit_to_string( & * * lit) ) . as_slice ( ) ) ;
628
626
return None
629
627
}
630
628
}
0 commit comments