@@ -21,15 +21,16 @@ use std::fmt;
21
21
use std:: fmt:: Show ;
22
22
use std:: option:: Option ;
23
23
use std:: rc:: Rc ;
24
+ use std:: gc:: Gc ;
24
25
use serialize:: { Encodable , Decodable , Encoder , Decoder } ;
25
26
26
27
/// 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 > ;
28
29
29
30
#[ allow( non_snake_case_functions) ]
30
31
/// Construct a P<T> from a T value.
31
32
pub fn P < T : ' static > ( value : T ) -> P < T > {
32
- @ value
33
+ box ( GC ) value
33
34
}
34
35
35
36
// FIXME #6993: in librustc, uses of "ident" should be replaced
@@ -217,7 +218,7 @@ pub enum DefRegion {
217
218
218
219
// The set of MetaItems that define the compilation environment of the crate,
219
220
// used to drive conditional compilation
220
- pub type CrateConfig = Vec < @ MetaItem > ;
221
+ pub type CrateConfig = Vec < Gc < MetaItem > > ;
221
222
222
223
#[ deriving( Clone , PartialEq , Eq , Encodable , Decodable , Hash ) ]
223
224
pub struct Crate {
@@ -232,7 +233,7 @@ pub type MetaItem = Spanned<MetaItem_>;
232
233
#[ deriving( Clone , Encodable , Decodable , Eq , Hash ) ]
233
234
pub enum MetaItem_ {
234
235
MetaWord ( InternedString ) ,
235
- MetaList ( InternedString , Vec < @ MetaItem > ) ,
236
+ MetaList ( InternedString , Vec < Gc < MetaItem > > ) ,
236
237
MetaNameValue ( InternedString , Lit ) ,
237
238
}
238
239
@@ -264,8 +265,8 @@ impl PartialEq for MetaItem_ {
264
265
#[ deriving( Clone , PartialEq , Eq , Encodable , Decodable , Hash ) ]
265
266
pub struct Block {
266
267
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 > > ,
269
270
pub id : NodeId ,
270
271
pub rules : BlockCheckMode ,
271
272
pub span : Span ,
@@ -281,7 +282,7 @@ pub struct Pat {
281
282
#[ deriving( Clone , PartialEq , Eq , Encodable , Decodable , Hash ) ]
282
283
pub struct FieldPat {
283
284
pub ident : Ident ,
284
- pub pat : @ Pat ,
285
+ pub pat : Gc < Pat > ,
285
286
}
286
287
287
288
#[ deriving( Clone , PartialEq , Eq , Encodable , Decodable , Hash ) ]
@@ -301,18 +302,18 @@ pub enum Pat_ {
301
302
// which it is. The resolver determines this, and
302
303
// records this pattern's NodeId in an auxiliary
303
304
// 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
306
307
* 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 > ) ,
313
314
// [a, b, ..i, y, z] is represented as
314
315
// 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 > > ) ,
316
317
PatMac ( Mac ) ,
317
318
}
318
319
@@ -365,13 +366,13 @@ pub type Stmt = Spanned<Stmt_>;
365
366
#[ deriving( Clone , PartialEq , Eq , Encodable , Decodable , Hash ) ]
366
367
pub enum Stmt_ {
367
368
// could be an item or a local (let) binding:
368
- StmtDecl ( @ Decl , NodeId ) ,
369
+ StmtDecl ( Gc < Decl > , NodeId ) ,
369
370
370
371
// expr without trailing semi-colon (must have unit type):
371
- StmtExpr ( @ Expr , NodeId ) ,
372
+ StmtExpr ( Gc < Expr > , NodeId ) ,
372
373
373
374
// expr with trailing semi-colon (may have any type):
374
- StmtSemi ( @ Expr , NodeId ) ,
375
+ StmtSemi ( Gc < Expr > , NodeId ) ,
375
376
376
377
// bool: is there a trailing sem-colon?
377
378
StmtMac ( Mac , bool ) ,
@@ -391,8 +392,8 @@ pub enum LocalSource {
391
392
#[ deriving( PartialEq , Eq , Encodable , Decodable , Hash ) ]
392
393
pub struct Local {
393
394
pub ty : P < Ty > ,
394
- pub pat : @ Pat ,
395
- pub init : Option < @ Expr > ,
395
+ pub pat : Gc < Pat > ,
396
+ pub init : Option < Gc < Expr > > ,
396
397
pub id : NodeId ,
397
398
pub span : Span ,
398
399
pub source : LocalSource ,
@@ -403,23 +404,23 @@ pub type Decl = Spanned<Decl_>;
403
404
#[ deriving( PartialEq , Eq , Encodable , Decodable , Hash ) ]
404
405
pub enum Decl_ {
405
406
// a local (let) binding:
406
- DeclLocal ( @ Local ) ,
407
+ DeclLocal ( Gc < Local > ) ,
407
408
// an item binding:
408
- DeclItem ( @ Item ) ,
409
+ DeclItem ( Gc < Item > ) ,
409
410
}
410
411
411
412
#[ deriving( Clone , PartialEq , Eq , Encodable , Decodable , Hash ) ]
412
413
pub struct Arm {
413
414
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 > ,
417
418
}
418
419
419
420
#[ deriving( Clone , PartialEq , Eq , Encodable , Decodable , Hash ) ]
420
421
pub struct Field {
421
422
pub ident : SpannedIdent ,
422
- pub expr : @ Expr ,
423
+ pub expr : Gc < Expr > ,
423
424
pub span : Span ,
424
425
}
425
426
@@ -446,56 +447,56 @@ pub struct Expr {
446
447
447
448
#[ deriving( Clone , PartialEq , Eq , Encodable , Decodable , Hash ) ]
448
449
pub enum Expr_ {
449
- ExprVstore ( @ Expr , ExprVstore ) ,
450
+ ExprVstore ( Gc < Expr > , ExprVstore ) ,
450
451
// 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 > ) ,
462
463
// FIXME #6993: change to Option<Name>
463
- ExprForLoop ( @ Pat , @ Expr , P < Block > , Option < Ident > ) ,
464
+ ExprForLoop ( Gc < Pat > , Gc < Expr > , P < Block > , Option < Ident > ) ,
464
465
// Conditionless loop (can be exited with break, cont, or ret)
465
466
// FIXME #6993: change to Option<Name>
466
467
ExprLoop ( P < Block > , Option < Ident > ) ,
467
- ExprMatch ( @ Expr , Vec < Arm > ) ,
468
+ ExprMatch ( Gc < Expr > , Vec < Arm > ) ,
468
469
ExprFnBlock ( P < FnDecl > , P < Block > ) ,
469
470
ExprProc ( P < FnDecl > , P < Block > ) ,
470
471
ExprBlock ( P < Block > ) ,
471
472
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 > ) ,
476
477
477
478
/// Expression that looks like a "name". For example,
478
479
/// `std::slice::from_elem::<uint>` is an ExprPath that's the "name" part
479
480
/// of a function call.
480
481
ExprPath ( Path ) ,
481
482
482
- ExprAddrOf ( Mutability , @ Expr ) ,
483
+ ExprAddrOf ( Mutability , Gc < Expr > ) ,
483
484
ExprBreak ( Option < Ident > ) ,
484
485
ExprAgain ( Option < Ident > ) ,
485
- ExprRet ( Option < @ Expr > ) ,
486
+ ExprRet ( Option < Gc < Expr > > ) ,
486
487
487
488
ExprInlineAsm ( InlineAsm ) ,
488
489
489
490
ExprMac ( Mac ) ,
490
491
491
492
// A struct literal expression.
492
- ExprStruct ( Path , Vec < Field > , Option < @ Expr > /* base */ ) ,
493
+ ExprStruct ( Path , Vec < Field > , Option < Gc < Expr > > /* base */ ) ,
493
494
494
495
// A vector literal constructed from one repeated element.
495
- ExprRepeat ( @ Expr /* element */ , @ Expr /* count */ ) ,
496
+ ExprRepeat ( Gc < Expr > /* element */ , Gc < Expr > /* count */ ) ,
496
497
497
498
// No-op: used solely so we can pretty-print faithfully
498
- ExprParen ( @ Expr )
499
+ ExprParen ( Gc < Expr > )
499
500
}
500
501
501
502
// When the main rust parser encounters a syntax-extension invocation, it
@@ -667,7 +668,7 @@ pub struct TypeMethod {
667
668
#[ deriving( Clone , PartialEq , Eq , Encodable , Decodable , Hash ) ]
668
669
pub enum TraitMethod {
669
670
Required ( TypeMethod ) ,
670
- Provided ( @ Method ) ,
671
+ Provided ( Gc < Method > ) ,
671
672
}
672
673
673
674
#[ deriving( Clone , PartialEq , Eq , Encodable , Decodable , Hash ) ]
@@ -782,16 +783,16 @@ pub enum Ty_ {
782
783
TyBox ( P < Ty > ) ,
783
784
TyUniq ( P < Ty > ) ,
784
785
TyVec ( P < Ty > ) ,
785
- TyFixedLengthVec ( P < Ty > , @ Expr ) ,
786
+ TyFixedLengthVec ( P < Ty > , Gc < Expr > ) ,
786
787
TyPtr ( MutTy ) ,
787
788
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 > ) ,
792
793
TyTup ( Vec < P < Ty > > ) ,
793
794
TyPath ( Path , Option < OwnedSlice < TyParamBound > > , NodeId ) , // for #7264; see above
794
- TyTypeof ( @ Expr ) ,
795
+ TyTypeof ( Gc < Expr > ) ,
795
796
// TyInfer means the type should be inferred instead of it having been
796
797
// specified. This can appear anywhere in a type.
797
798
TyInfer ,
@@ -808,8 +809,8 @@ pub struct InlineAsm {
808
809
pub asm : InternedString ,
809
810
pub asm_str_style : StrStyle ,
810
811
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 > ) > ,
813
814
pub volatile : bool ,
814
815
pub alignstack : bool ,
815
816
pub dialect : AsmDialect
@@ -818,7 +819,7 @@ pub struct InlineAsm {
818
819
#[ deriving( Clone , PartialEq , Eq , Encodable , Decodable , Hash ) ]
819
820
pub struct Arg {
820
821
pub ty : P < Ty > ,
821
- pub pat : @ Pat ,
822
+ pub pat : Gc < Pat > ,
822
823
pub id : NodeId ,
823
824
}
824
825
@@ -832,7 +833,7 @@ impl Arg {
832
833
node : TyInfer ,
833
834
span : DUMMY_SP ,
834
835
} ) ,
835
- pat : @ Pat {
836
+ pat : box ( GC ) Pat {
836
837
id : DUMMY_NODE_ID ,
837
838
node : PatIdent ( BindByValue ( mutability) , path, None ) ,
838
839
span : span
@@ -903,14 +904,14 @@ pub struct Mod {
903
904
/// to the last token in the external file.
904
905
pub inner : Span ,
905
906
pub view_items : Vec < ViewItem > ,
906
- pub items : Vec < @ Item > ,
907
+ pub items : Vec < Gc < Item > > ,
907
908
}
908
909
909
910
#[ deriving( Clone , PartialEq , Eq , Encodable , Decodable , Hash ) ]
910
911
pub struct ForeignMod {
911
912
pub abi : Abi ,
912
913
pub view_items : Vec < ViewItem > ,
913
- pub items : Vec < @ ForeignItem > ,
914
+ pub items : Vec < Gc < ForeignItem > > ,
914
915
}
915
916
916
917
#[ deriving( Clone , PartialEq , Eq , Encodable , Decodable , Hash ) ]
@@ -922,7 +923,7 @@ pub struct VariantArg {
922
923
#[ deriving( Clone , PartialEq , Eq , Encodable , Decodable , Hash ) ]
923
924
pub enum VariantKind {
924
925
TupleVariantKind ( Vec < VariantArg > ) ,
925
- StructVariantKind ( @ StructDef ) ,
926
+ StructVariantKind ( Gc < StructDef > ) ,
926
927
}
927
928
928
929
#[ deriving( Clone , PartialEq , Eq , Encodable , Decodable , Hash ) ]
@@ -936,7 +937,7 @@ pub struct Variant_ {
936
937
pub attrs : Vec < Attribute > ,
937
938
pub kind : VariantKind ,
938
939
pub id : NodeId ,
939
- pub disr_expr : Option < @ Expr > ,
940
+ pub disr_expr : Option < Gc < Expr > > ,
940
941
pub vis : Visibility ,
941
942
}
942
943
@@ -984,7 +985,7 @@ pub enum ViewItem_ {
984
985
// (containing arbitrary characters) from which to fetch the crate sources
985
986
// For example, extern crate whatever = "github.com/mozilla/rust"
986
987
ViewItemExternCrate ( Ident , Option < ( InternedString , StrStyle ) > , NodeId ) ,
987
- ViewItemUse ( @ ViewPath ) ,
988
+ ViewItemUse ( Gc < ViewPath > ) ,
988
989
}
989
990
990
991
// Meta-data associated with an item
@@ -1007,7 +1008,7 @@ pub struct AttrId(pub uint);
1007
1008
pub struct Attribute_ {
1008
1009
pub id : AttrId ,
1009
1010
pub style : AttrStyle ,
1010
- pub value : @ MetaItem ,
1011
+ pub value : Gc < MetaItem > ,
1011
1012
pub is_sugared_doc : bool ,
1012
1013
}
1013
1014
@@ -1105,18 +1106,18 @@ pub struct Item {
1105
1106
1106
1107
#[ deriving( Clone , PartialEq , Eq , Encodable , Decodable , Hash ) ]
1107
1108
pub enum Item_ {
1108
- ItemStatic ( P < Ty > , Mutability , @ Expr ) ,
1109
+ ItemStatic ( P < Ty > , Mutability , Gc < Expr > ) ,
1109
1110
ItemFn ( P < FnDecl > , FnStyle , Abi , Generics , P < Block > ) ,
1110
1111
ItemMod ( Mod ) ,
1111
1112
ItemForeignMod ( ForeignMod ) ,
1112
1113
ItemTy ( P < Ty > , Generics ) ,
1113
1114
ItemEnum ( EnumDef , Generics ) ,
1114
- ItemStruct ( @ StructDef , Generics ) ,
1115
+ ItemStruct ( Gc < StructDef > , Generics ) ,
1115
1116
ItemTrait ( Generics , Sized , Vec < TraitRef > , Vec < TraitMethod > ) ,
1116
1117
ItemImpl ( Generics ,
1117
1118
Option < TraitRef > , // (optional) trait this impl implements
1118
1119
P < Ty > , // self
1119
- Vec < @ Method > ) ,
1120
+ Vec < Gc < Method > > ) ,
1120
1121
// a macro invocation (which includes macro definition)
1121
1122
ItemMac ( Mac ) ,
1122
1123
}
@@ -1142,9 +1143,9 @@ pub enum ForeignItem_ {
1142
1143
// that we trans.
1143
1144
#[ deriving( PartialEq , Eq , Encodable , Decodable , Hash ) ]
1144
1145
pub 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 > ) ,
1148
1149
}
1149
1150
1150
1151
#[ cfg( test) ]
0 commit comments