diff options
| author | Kiet Tran <ktt3ja@gmail.com> | 2013-11-24 18:38:41 -0500 |
|---|---|---|
| committer | Kiet Tran <ktt3ja@gmail.com> | 2013-11-24 18:38:41 -0500 |
| commit | 9a4c8da5015d8f08310dd2123959761fea84d0f6 (patch) | |
| tree | d865cae1dbb90eb8b9d2d76b75b1884841f82e11 /src/libsyntax | |
| parent | b3ff24adaa8c7f9c48c525f284526c23ffd33fcb (diff) | |
| download | rust-9a4c8da5015d8f08310dd2123959761fea84d0f6.tar.gz rust-9a4c8da5015d8f08310dd2123959761fea84d0f6.zip | |
Add comments to ast, ast_map, ty, and pat_util
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 11 | ||||
| -rw-r--r-- | src/libsyntax/ast_map.rs | 6 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 4cba8093980..dacd7a09f9b 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -173,6 +173,8 @@ pub struct DefId { node: NodeId, } +/// Item definitions in the currently-compiled crate would have the CrateNum +/// LOCAL_CRATE in their DefId. pub static LOCAL_CRATE: CrateNum = 0; pub static CRATE_NODE_ID: NodeId = 0; @@ -244,6 +246,10 @@ pub enum Def { @Def, // closed over def NodeId, // expr node that creates the closure NodeId), // id for the block/body of the closure expr + + /// Note that if it's a tuple struct's definition, the node id + /// of the DefId refers to the struct_def.ctor_id (whereas normally it + /// refers to the item definition's id). DefStruct(DefId), DefTyParamBinder(NodeId), /* struct, impl or trait with ty params */ DefRegion(NodeId), @@ -451,6 +457,7 @@ pub enum Stmt_ { // FIXME (pending discussion of #1697, #2178...): local should really be // a refinement on pat. +/// Local represents a `let` statement, e.g., `let <pat>:<ty> = <expr>;` #[deriving(Eq, Encodable, Decodable,IterBytes)] pub struct Local { ty: Ty, @@ -553,6 +560,10 @@ pub enum Expr_ { ExprAssignOp(NodeId, BinOp, @Expr, @Expr), ExprField(@Expr, Ident, ~[Ty]), ExprIndex(NodeId, @Expr, @Expr), + + /// Expression that looks like a "name". For example, + /// `std::vec::from_elem::<uint>` is an ExprPath that's the "name" part + /// of a function call. ExprPath(Path), /// The special identifier `self`. diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs index c5ad3714917..218aead6f52 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -111,12 +111,18 @@ pub enum ast_node { node_trait_method(@trait_method, DefId /* trait did */, @path /* path to the trait */), node_method(@method, DefId /* impl did */, @path /* path to the impl */), + + /// node_variant represents a variant of an enum, e.g., for + /// `enum A { B, C, D }`, there would be a node_item for `A`, and a + /// node_variant item for each of `B`, `C`, and `D`. node_variant(variant, @item, @path), node_expr(@Expr), node_stmt(@Stmt), node_arg(@Pat), node_local(Ident), node_block(Block), + + /// node_struct_ctor represents a tuple struct. node_struct_ctor(@struct_def, @item, @path), node_callee_scope(@Expr) } |
