Skip to content

Add comments to ast, ast_map, ty, and pat_util #10600

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 25, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/librustc/middle/pat_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ pub fn pat_is_binding_or_wild(dm: resolve::DefMap, pat: @Pat) -> bool {
}
}

/// Call `it` on every "binding" in a pattern, e.g., on `a` in
/// `match foo() { Some(a) => (), None => () }`
pub fn pat_bindings(dm: resolve::DefMap,
pat: @Pat,
it: |BindingMode, NodeId, Span, &Path|) {
Expand Down
5 changes: 5 additions & 0 deletions src/librustc/middle/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,9 @@ pub enum AutoRef {

pub type ctxt = @ctxt_;

/// The data structure to keep track of all the information that typechecker
/// generates so that so that it can be reused and doesn't have to be redone
/// later on.
struct ctxt_ {
diag: @mut syntax::diagnostic::span_handler,
interner: @mut HashMap<intern_key, ~t_box_>,
Expand Down Expand Up @@ -296,6 +299,8 @@ struct ctxt_ {
trait_refs: @mut HashMap<NodeId, @TraitRef>,
trait_defs: @mut HashMap<DefId, @TraitDef>,

/// Despite its name, `items` does not only map NodeId to an item but
/// also to expr/stmt/local/arg/etc
items: ast_map::map,
intrinsic_defs: @mut HashMap<ast::DefId, t>,
freevars: freevars::freevar_map,
Expand Down
11 changes: 11 additions & 0 deletions src/libsyntax/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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`.
Expand Down
6 changes: 6 additions & 0 deletions src/libsyntax/ast_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down