@@ -21,15 +21,16 @@ use std::fmt;
2121use std:: fmt:: Show ;
2222use std:: option:: Option ;
2323use std:: rc:: Rc ;
24+ use std:: gc:: Gc ;
2425use serialize:: { Encodable , Decodable , Encoder , Decoder } ;
2526
2627/// A pointer abstraction. FIXME(eddyb) #10676 use Rc<T> in the future.
27- pub type P < T > = @ T ;
28+ pub type P < T > = Gc < T > ;
2829
2930#[ allow( non_snake_case_functions) ]
3031/// Construct a P<T> from a T value.
3132pub fn P < T : ' static > ( value : T ) -> P < T > {
32- @ value
33+ box ( GC ) value
3334}
3435
3536// FIXME #6993: in librustc, uses of "ident" should be replaced
@@ -217,7 +218,7 @@ pub enum DefRegion {
217218
218219// The set of MetaItems that define the compilation environment of the crate,
219220// used to drive conditional compilation
220- pub type CrateConfig = Vec < @ MetaItem > ;
221+ pub type CrateConfig = Vec < Gc < MetaItem > > ;
221222
222223#[ deriving( Clone , PartialEq , Eq , Encodable , Decodable , Hash ) ]
223224pub struct Crate {
@@ -232,7 +233,7 @@ pub type MetaItem = Spanned<MetaItem_>;
232233#[ deriving( Clone , Encodable , Decodable , Eq , Hash ) ]
233234pub enum MetaItem_ {
234235 MetaWord ( InternedString ) ,
235- MetaList ( InternedString , Vec < @ MetaItem > ) ,
236+ MetaList ( InternedString , Vec < Gc < MetaItem > > ) ,
236237 MetaNameValue ( InternedString , Lit ) ,
237238}
238239
@@ -264,8 +265,8 @@ impl PartialEq for MetaItem_ {
264265#[ deriving( Clone , PartialEq , Eq , Encodable , Decodable , Hash ) ]
265266pub struct Block {
266267 pub view_items : Vec < ViewItem > ,
267- pub stmts : Vec < @ Stmt > ,
268- pub expr : Option < @ Expr > ,
268+ pub stmts : Vec < Gc < Stmt > > ,
269+ pub expr : Option < Gc < Expr > > ,
269270 pub id : NodeId ,
270271 pub rules : BlockCheckMode ,
271272 pub span : Span ,
@@ -281,7 +282,7 @@ pub struct Pat {
281282#[ deriving( Clone , PartialEq , Eq , Encodable , Decodable , Hash ) ]
282283pub struct FieldPat {
283284 pub ident : Ident ,
284- pub pat : @ Pat ,
285+ pub pat : Gc < Pat > ,
285286}
286287
287288#[ deriving( Clone , PartialEq , Eq , Encodable , Decodable , Hash ) ]
@@ -301,18 +302,18 @@ pub enum Pat_ {
301302 // which it is. The resolver determines this, and
302303 // records this pattern's NodeId in an auxiliary
303304 // set (of "pat_idents that refer to nullary enums")
304- PatIdent ( BindingMode , Path , Option < @ Pat > ) ,
305- PatEnum ( Path , Option < Vec < @ Pat > > ) , /* "none" means a * pattern where
305+ PatIdent ( BindingMode , Path , Option < Gc < Pat > > ) ,
306+ PatEnum ( Path , Option < Vec < Gc < Pat > > > ) , /* "none" means a * pattern where
306307 * we don't bind the fields to names */
307- PatStruct ( Path , Vec < FieldPat > , bool ) ,
308- PatTup ( Vec < @ Pat > ) ,
309- PatBox ( @ Pat ) ,
310- PatRegion ( @ Pat ) , // reference pattern
311- PatLit ( @ Expr ) ,
312- PatRange ( @ Expr , @ Expr ) ,
308+ PatStruct ( Path , Vec < FieldPat > , bool ) ,
309+ PatTup ( Vec < Gc < Pat > > ) ,
310+ PatBox ( Gc < Pat > ) ,
311+ PatRegion ( Gc < Pat > ) , // reference pattern
312+ PatLit ( Gc < Expr > ) ,
313+ PatRange ( Gc < Expr > , Gc < Expr > ) ,
313314 // [a, b, ..i, y, z] is represented as
314315 // PatVec(~[a, b], Some(i), ~[y, z])
315- PatVec ( Vec < @ Pat > , Option < @ Pat > , Vec < @ Pat > ) ,
316+ PatVec ( Vec < Gc < Pat > > , Option < Gc < Pat > > , Vec < Gc < Pat > > ) ,
316317 PatMac ( Mac ) ,
317318}
318319
@@ -365,13 +366,13 @@ pub type Stmt = Spanned<Stmt_>;
365366#[ deriving( Clone , PartialEq , Eq , Encodable , Decodable , Hash ) ]
366367pub enum Stmt_ {
367368 // could be an item or a local (let) binding:
368- StmtDecl ( @ Decl , NodeId ) ,
369+ StmtDecl ( Gc < Decl > , NodeId ) ,
369370
370371 // expr without trailing semi-colon (must have unit type):
371- StmtExpr ( @ Expr , NodeId ) ,
372+ StmtExpr ( Gc < Expr > , NodeId ) ,
372373
373374 // expr with trailing semi-colon (may have any type):
374- StmtSemi ( @ Expr , NodeId ) ,
375+ StmtSemi ( Gc < Expr > , NodeId ) ,
375376
376377 // bool: is there a trailing sem-colon?
377378 StmtMac ( Mac , bool ) ,
@@ -391,8 +392,8 @@ pub enum LocalSource {
391392#[ deriving( PartialEq , Eq , Encodable , Decodable , Hash ) ]
392393pub struct Local {
393394 pub ty : P < Ty > ,
394- pub pat : @ Pat ,
395- pub init : Option < @ Expr > ,
395+ pub pat : Gc < Pat > ,
396+ pub init : Option < Gc < Expr > > ,
396397 pub id : NodeId ,
397398 pub span : Span ,
398399 pub source : LocalSource ,
@@ -403,23 +404,23 @@ pub type Decl = Spanned<Decl_>;
403404#[ deriving( PartialEq , Eq , Encodable , Decodable , Hash ) ]
404405pub enum Decl_ {
405406 // a local (let) binding:
406- DeclLocal ( @ Local ) ,
407+ DeclLocal ( Gc < Local > ) ,
407408 // an item binding:
408- DeclItem ( @ Item ) ,
409+ DeclItem ( Gc < Item > ) ,
409410}
410411
411412#[ deriving( Clone , PartialEq , Eq , Encodable , Decodable , Hash ) ]
412413pub struct Arm {
413414 pub attrs : Vec < Attribute > ,
414- pub pats : Vec < @ Pat > ,
415- pub guard : Option < @ Expr > ,
416- pub body : @ Expr ,
415+ pub pats : Vec < Gc < Pat > > ,
416+ pub guard : Option < Gc < Expr > > ,
417+ pub body : Gc < Expr > ,
417418}
418419
419420#[ deriving( Clone , PartialEq , Eq , Encodable , Decodable , Hash ) ]
420421pub struct Field {
421422 pub ident : SpannedIdent ,
422- pub expr : @ Expr ,
423+ pub expr : Gc < Expr > ,
423424 pub span : Span ,
424425}
425426
@@ -446,56 +447,56 @@ pub struct Expr {
446447
447448#[ deriving( Clone , PartialEq , Eq , Encodable , Decodable , Hash ) ]
448449pub enum Expr_ {
449- ExprVstore ( @ Expr , ExprVstore ) ,
450+ ExprVstore ( Gc < Expr > , ExprVstore ) ,
450451 // First expr is the place; second expr is the value.
451- ExprBox ( @ Expr , @ Expr ) ,
452- ExprVec ( Vec < @ Expr > ) ,
453- ExprCall ( @ Expr , Vec < @ Expr > ) ,
454- ExprMethodCall ( SpannedIdent , Vec < P < Ty > > , Vec < @ Expr > ) ,
455- ExprTup ( Vec < @ Expr > ) ,
456- ExprBinary ( BinOp , @ Expr , @ Expr ) ,
457- ExprUnary ( UnOp , @ Expr ) ,
458- ExprLit ( @ Lit ) ,
459- ExprCast ( @ Expr , P < Ty > ) ,
460- ExprIf ( @ Expr , P < Block > , Option < @ Expr > ) ,
461- ExprWhile ( @ Expr , P < Block > ) ,
452+ ExprBox ( Gc < Expr > , Gc < Expr > ) ,
453+ ExprVec ( Vec < Gc < Expr > > ) ,
454+ ExprCall ( Gc < Expr > , Vec < Gc < Expr > > ) ,
455+ ExprMethodCall ( SpannedIdent , Vec < P < Ty > > , Vec < Gc < Expr > > ) ,
456+ ExprTup ( Vec < Gc < Expr > > ) ,
457+ ExprBinary ( BinOp , Gc < Expr > , Gc < Expr > ) ,
458+ ExprUnary ( UnOp , Gc < Expr > ) ,
459+ ExprLit ( Gc < Lit > ) ,
460+ ExprCast ( Gc < Expr > , P < Ty > ) ,
461+ ExprIf ( Gc < Expr > , P < Block > , Option < Gc < Expr > > ) ,
462+ ExprWhile ( Gc < Expr > , P < Block > ) ,
462463 // FIXME #6993: change to Option<Name>
463- ExprForLoop ( @ Pat , @ Expr , P < Block > , Option < Ident > ) ,
464+ ExprForLoop ( Gc < Pat > , Gc < Expr > , P < Block > , Option < Ident > ) ,
464465 // Conditionless loop (can be exited with break, cont, or ret)
465466 // FIXME #6993: change to Option<Name>
466467 ExprLoop ( P < Block > , Option < Ident > ) ,
467- ExprMatch ( @ Expr , Vec < Arm > ) ,
468+ ExprMatch ( Gc < Expr > , Vec < Arm > ) ,
468469 ExprFnBlock ( P < FnDecl > , P < Block > ) ,
469470 ExprProc ( P < FnDecl > , P < Block > ) ,
470471 ExprBlock ( P < Block > ) ,
471472
472- ExprAssign ( @ Expr , @ Expr ) ,
473- ExprAssignOp ( BinOp , @ Expr , @ Expr ) ,
474- ExprField ( @ Expr , Ident , Vec < P < Ty > > ) ,
475- ExprIndex ( @ Expr , @ Expr ) ,
473+ ExprAssign ( Gc < Expr > , Gc < Expr > ) ,
474+ ExprAssignOp ( BinOp , Gc < Expr > , Gc < Expr > ) ,
475+ ExprField ( Gc < Expr > , Ident , Vec < P < Ty > > ) ,
476+ ExprIndex ( Gc < Expr > , Gc < Expr > ) ,
476477
477478 /// Expression that looks like a "name". For example,
478479 /// `std::slice::from_elem::<uint>` is an ExprPath that's the "name" part
479480 /// of a function call.
480481 ExprPath ( Path ) ,
481482
482- ExprAddrOf ( Mutability , @ Expr ) ,
483+ ExprAddrOf ( Mutability , Gc < Expr > ) ,
483484 ExprBreak ( Option < Ident > ) ,
484485 ExprAgain ( Option < Ident > ) ,
485- ExprRet ( Option < @ Expr > ) ,
486+ ExprRet ( Option < Gc < Expr > > ) ,
486487
487488 ExprInlineAsm ( InlineAsm ) ,
488489
489490 ExprMac ( Mac ) ,
490491
491492 // A struct literal expression.
492- ExprStruct ( Path , Vec < Field > , Option < @ Expr > /* base */ ) ,
493+ ExprStruct ( Path , Vec < Field > , Option < Gc < Expr > > /* base */ ) ,
493494
494495 // A vector literal constructed from one repeated element.
495- ExprRepeat ( @ Expr /* element */ , @ Expr /* count */ ) ,
496+ ExprRepeat ( Gc < Expr > /* element */ , Gc < Expr > /* count */ ) ,
496497
497498 // No-op: used solely so we can pretty-print faithfully
498- ExprParen ( @ Expr )
499+ ExprParen ( Gc < Expr > )
499500}
500501
501502// When the main rust parser encounters a syntax-extension invocation, it
@@ -667,7 +668,7 @@ pub struct TypeMethod {
667668#[ deriving( Clone , PartialEq , Eq , Encodable , Decodable , Hash ) ]
668669pub enum TraitMethod {
669670 Required ( TypeMethod ) ,
670- Provided ( @ Method ) ,
671+ Provided ( Gc < Method > ) ,
671672}
672673
673674#[ deriving( Clone , PartialEq , Eq , Encodable , Decodable , Hash ) ]
@@ -782,16 +783,16 @@ pub enum Ty_ {
782783 TyBox ( P < Ty > ) ,
783784 TyUniq ( P < Ty > ) ,
784785 TyVec ( P < Ty > ) ,
785- TyFixedLengthVec ( P < Ty > , @ Expr ) ,
786+ TyFixedLengthVec ( P < Ty > , Gc < Expr > ) ,
786787 TyPtr ( MutTy ) ,
787788 TyRptr ( Option < Lifetime > , MutTy ) ,
788- TyClosure ( @ ClosureTy , Option < Lifetime > ) ,
789- TyProc ( @ ClosureTy ) ,
790- TyBareFn ( @ BareFnTy ) ,
791- TyUnboxedFn ( @ UnboxedFnTy ) ,
789+ TyClosure ( Gc < ClosureTy > , Option < Lifetime > ) ,
790+ TyProc ( Gc < ClosureTy > ) ,
791+ TyBareFn ( Gc < BareFnTy > ) ,
792+ TyUnboxedFn ( Gc < UnboxedFnTy > ) ,
792793 TyTup ( Vec < P < Ty > > ) ,
793794 TyPath ( Path , Option < OwnedSlice < TyParamBound > > , NodeId ) , // for #7264; see above
794- TyTypeof ( @ Expr ) ,
795+ TyTypeof ( Gc < Expr > ) ,
795796 // TyInfer means the type should be inferred instead of it having been
796797 // specified. This can appear anywhere in a type.
797798 TyInfer ,
@@ -808,8 +809,8 @@ pub struct InlineAsm {
808809 pub asm : InternedString ,
809810 pub asm_str_style : StrStyle ,
810811 pub clobbers : InternedString ,
811- pub inputs : Vec < ( InternedString , @ Expr ) > ,
812- pub outputs : Vec < ( InternedString , @ Expr ) > ,
812+ pub inputs : Vec < ( InternedString , Gc < Expr > ) > ,
813+ pub outputs : Vec < ( InternedString , Gc < Expr > ) > ,
813814 pub volatile : bool ,
814815 pub alignstack : bool ,
815816 pub dialect : AsmDialect
@@ -818,7 +819,7 @@ pub struct InlineAsm {
818819#[ deriving( Clone , PartialEq , Eq , Encodable , Decodable , Hash ) ]
819820pub struct Arg {
820821 pub ty : P < Ty > ,
821- pub pat : @ Pat ,
822+ pub pat : Gc < Pat > ,
822823 pub id : NodeId ,
823824}
824825
@@ -832,7 +833,7 @@ impl Arg {
832833 node : TyInfer ,
833834 span : DUMMY_SP ,
834835 } ) ,
835- pat : @ Pat {
836+ pat : box ( GC ) Pat {
836837 id : DUMMY_NODE_ID ,
837838 node : PatIdent ( BindByValue ( mutability) , path, None ) ,
838839 span : span
@@ -903,14 +904,14 @@ pub struct Mod {
903904 /// to the last token in the external file.
904905 pub inner : Span ,
905906 pub view_items : Vec < ViewItem > ,
906- pub items : Vec < @ Item > ,
907+ pub items : Vec < Gc < Item > > ,
907908}
908909
909910#[ deriving( Clone , PartialEq , Eq , Encodable , Decodable , Hash ) ]
910911pub struct ForeignMod {
911912 pub abi : Abi ,
912913 pub view_items : Vec < ViewItem > ,
913- pub items : Vec < @ ForeignItem > ,
914+ pub items : Vec < Gc < ForeignItem > > ,
914915}
915916
916917#[ deriving( Clone , PartialEq , Eq , Encodable , Decodable , Hash ) ]
@@ -922,7 +923,7 @@ pub struct VariantArg {
922923#[ deriving( Clone , PartialEq , Eq , Encodable , Decodable , Hash ) ]
923924pub enum VariantKind {
924925 TupleVariantKind ( Vec < VariantArg > ) ,
925- StructVariantKind ( @ StructDef ) ,
926+ StructVariantKind ( Gc < StructDef > ) ,
926927}
927928
928929#[ deriving( Clone , PartialEq , Eq , Encodable , Decodable , Hash ) ]
@@ -936,7 +937,7 @@ pub struct Variant_ {
936937 pub attrs : Vec < Attribute > ,
937938 pub kind : VariantKind ,
938939 pub id : NodeId ,
939- pub disr_expr : Option < @ Expr > ,
940+ pub disr_expr : Option < Gc < Expr > > ,
940941 pub vis : Visibility ,
941942}
942943
@@ -984,7 +985,7 @@ pub enum ViewItem_ {
984985 // (containing arbitrary characters) from which to fetch the crate sources
985986 // For example, extern crate whatever = "github.com/mozilla/rust"
986987 ViewItemExternCrate ( Ident , Option < ( InternedString , StrStyle ) > , NodeId ) ,
987- ViewItemUse ( @ ViewPath ) ,
988+ ViewItemUse ( Gc < ViewPath > ) ,
988989}
989990
990991// Meta-data associated with an item
@@ -1007,7 +1008,7 @@ pub struct AttrId(pub uint);
10071008pub struct Attribute_ {
10081009 pub id : AttrId ,
10091010 pub style : AttrStyle ,
1010- pub value : @ MetaItem ,
1011+ pub value : Gc < MetaItem > ,
10111012 pub is_sugared_doc : bool ,
10121013}
10131014
@@ -1105,18 +1106,18 @@ pub struct Item {
11051106
11061107#[ deriving( Clone , PartialEq , Eq , Encodable , Decodable , Hash ) ]
11071108pub enum Item_ {
1108- ItemStatic ( P < Ty > , Mutability , @ Expr ) ,
1109+ ItemStatic ( P < Ty > , Mutability , Gc < Expr > ) ,
11091110 ItemFn ( P < FnDecl > , FnStyle , Abi , Generics , P < Block > ) ,
11101111 ItemMod ( Mod ) ,
11111112 ItemForeignMod ( ForeignMod ) ,
11121113 ItemTy ( P < Ty > , Generics ) ,
11131114 ItemEnum ( EnumDef , Generics ) ,
1114- ItemStruct ( @ StructDef , Generics ) ,
1115+ ItemStruct ( Gc < StructDef > , Generics ) ,
11151116 ItemTrait ( Generics , Sized , Vec < TraitRef > , Vec < TraitMethod > ) ,
11161117 ItemImpl ( Generics ,
11171118 Option < TraitRef > , // (optional) trait this impl implements
11181119 P < Ty > , // self
1119- Vec < @ Method > ) ,
1120+ Vec < Gc < Method > > ) ,
11201121 // a macro invocation (which includes macro definition)
11211122 ItemMac ( Mac ) ,
11221123}
@@ -1142,9 +1143,9 @@ pub enum ForeignItem_ {
11421143// that we trans.
11431144#[ deriving( PartialEq , Eq , Encodable , Decodable , Hash ) ]
11441145pub enum InlinedItem {
1145- IIItem ( @ Item ) ,
1146- IIMethod ( DefId /* impl id */ , bool /* is provided */ , @ Method ) ,
1147- IIForeign ( @ ForeignItem ) ,
1146+ IIItem ( Gc < Item > ) ,
1147+ IIMethod ( DefId /* impl id */ , bool /* is provided */ , Gc < Method > ) ,
1148+ IIForeign ( Gc < ForeignItem > ) ,
11481149}
11491150
11501151#[ cfg( test) ]
0 commit comments