(index<- )
./
librustc
/
front
/
assign_node_ids_and_map.rs
git branch: * master 5200215 auto merge of #14035 : alexcrichton/rust/experimental, r=huonw
modified: Mon Mar 17 15:02:24 2014
1
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
2
// file at the top-level directory of this distribution and at
3
// http://rust-lang.org/COPYRIGHT.
4
//
5
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
// option. This file may not be copied, modified, or distributed
9
// except according to those terms.
10
11
use
driver::session::Session
;
12
13
use
syntax::ast
;
14
use
syntax::ast_map
;
15
16
struct
NodeIdAssigner
<'a>
{
17
sess:
&'a
Session
18
}
19
20
impl
<'a>
ast_map::FoldOps
for
NodeIdAssigner
<'a>
{
21
fn new_id
(
&self
,
old_id
:
ast::NodeId
)
->
ast::NodeId
{
22
assert_eq!
(
old_id
,
ast::DUMMY_NODE_ID
)
;
23
self
.sess
.next_node_id
()
24
}
25
}
26
27
pub
fn
assign_node_ids_and_map
(
sess
: &
Session
,
krate
:
ast::Crate
)
->
(
ast::Crate
,
ast_map::Map
)
{
28
ast_map::map_crate
(
krate
,
NodeIdAssigner
{
sess:
sess
}
)
29
}
librustc/front/assign_node_ids_and_map.rs:15:1-15:1 -struct- definition:
struct NodeIdAssigner<'a> {
sess: &'a Session
}
references:- 2
20:
impl<'a> ast_map::FoldOps for NodeIdAssigner<'a> {
21:
fn new_id(&self, old_id: ast::NodeId) -> ast::NodeId {
--
27:
pub fn assign_node_ids_and_map(sess: &Session, krate: ast::Crate) -> (ast::Crate, ast_map::Map) {
28:
ast_map::map_crate(krate, NodeIdAssigner { sess: sess })
29:
}