auto merge of #8527 : pnkfelix/rust/fsk-visitor-vpar-defaults-step1, r=nikomatsakis
Rewriting visit.rs to operate on a borrowed `&mut V` where `<V:Visitor>` r? @nikomatsakis r? @pcwalton This is the first in a planned series of incremental pull requests. (There will probably be five pull requests including this one, though they can be combined or split as necessary.) Part of #7081. (But definitely does *not* complete it, not on its own, and not even after all five parts land; there are still a few loose ends to tie up or trim afterwards.) The bulk of this change for this particular PR is pnkfelix@3d83010, which has the changes necessary to visit.rs to support everything else that comes later. The other commits are illustrating the standard mechanical transformation that I am applying. One important point for nearly *all* of these pull requests: I was deliberately *not* trying to be intelligent in the transformation. * My goal was to minimize code churn, and make the transformation as mechanical as possible. * For example, I kept the separation between the Visitor struct (corresponding to the earlier vtable of functions that were potentially closed over local state) and the explicitly passed (and clones) visitor Env. I am certain that this is almost always unnecessary, and a later task will be to go through an meld the Env's into the Visitors as appropriate. (My original goal had been to make such melding part of this task; that's why I turned them into a (Env, vtable) tuple way back when. But I digress.) * Also, my main goal here was to get rid of the record of `@fn`'s as described by the oldvisit.rs API. (This series gets rid of all but one such case; I'm still investigating that.) There is *still* plenty of `@`-boxing left to be removed, I'm sure, and even still some `@fn`'s too; removing all of those is not the goal here; its just to get rid of the encoded protocol of `@fn`'s in the (old)visit API. To see where things will be going in the future (i.e., to get a sneak-preview of future pull-requests in the series), see: * https://github.com/pnkfelix/rust/commits/fsk-visitor-vpar-defaults-step1 (that's this one) * https://github.com/pnkfelix/rust/commits/fsk-visitor-vpar-defaults-step2 * https://github.com/pnkfelix/rust/commits/fsk-visitor-vpar-defaults-step3 * https://github.com/pnkfelix/rust/commits/fsk-visitor-vpar-defaults-step4 * https://github.com/pnkfelix/rust/commits/fsk-visitor-vpar-defaults-step5 * Note that between step 4 and step 5 there is just a single commit, but its a doozy because its the only case where my mechanical transformation did not apply, and thus more serious rewriting was necessary. See commit pnkfelix@da902b2ff3b1e0bee9fc63cf00c449cceea8abf7
This commit is contained in:
commit
77739a7084
8 changed files with 534 additions and 399 deletions
|
|
@ -39,7 +39,8 @@ use syntax::attr;
|
|||
use syntax::attr::AttrMetaMethods;
|
||||
use syntax::diagnostic::span_handler;
|
||||
use syntax::parse::token::special_idents;
|
||||
use syntax::{ast_util, oldvisit};
|
||||
use syntax::ast_util;
|
||||
use syntax::visit;
|
||||
use syntax::parse::token;
|
||||
use syntax;
|
||||
use writer = extra::ebml::writer;
|
||||
|
|
@ -1184,6 +1185,74 @@ fn encode_info_for_foreign_item(ecx: &EncodeContext,
|
|||
ebml_w.end_tag();
|
||||
}
|
||||
|
||||
fn my_visit_expr(_e:@expr) { }
|
||||
|
||||
fn my_visit_item(i:@item, items: ast_map::map, ebml_w:&writer::Encoder,
|
||||
ecx_ptr:*int, index: @mut ~[entry<i64>]) {
|
||||
match items.get_copy(&i.id) {
|
||||
ast_map::node_item(_, pt) => {
|
||||
let mut ebml_w = ebml_w.clone();
|
||||
// See above
|
||||
let ecx : &EncodeContext = unsafe { cast::transmute(ecx_ptr) };
|
||||
encode_info_for_item(ecx, &mut ebml_w, i, index, *pt);
|
||||
}
|
||||
_ => fail!("bad item")
|
||||
}
|
||||
}
|
||||
|
||||
fn my_visit_foreign_item(ni:@foreign_item, items: ast_map::map, ebml_w:&writer::Encoder,
|
||||
ecx_ptr:*int, index: @mut ~[entry<i64>]) {
|
||||
match items.get_copy(&ni.id) {
|
||||
ast_map::node_foreign_item(_, abi, _, pt) => {
|
||||
debug!("writing foreign item %s::%s",
|
||||
ast_map::path_to_str(
|
||||
*pt,
|
||||
token::get_ident_interner()),
|
||||
token::ident_to_str(&ni.ident));
|
||||
|
||||
let mut ebml_w = ebml_w.clone();
|
||||
// See above
|
||||
let ecx : &EncodeContext = unsafe { cast::transmute(ecx_ptr) };
|
||||
encode_info_for_foreign_item(ecx,
|
||||
&mut ebml_w,
|
||||
ni,
|
||||
index,
|
||||
pt,
|
||||
abi);
|
||||
}
|
||||
// case for separate item and foreign-item tables
|
||||
_ => fail!("bad foreign item")
|
||||
}
|
||||
}
|
||||
|
||||
struct EncodeVisitor {
|
||||
ebml_w_for_visit_item: writer::Encoder,
|
||||
ebml_w_for_visit_foreign_item: writer::Encoder,
|
||||
ecx_ptr:*int,
|
||||
items: ast_map::map,
|
||||
index: @mut ~[entry<i64>],
|
||||
}
|
||||
|
||||
impl visit::Visitor<()> for EncodeVisitor {
|
||||
fn visit_expr(&mut self, ex:@expr, _:()) { my_visit_expr(ex); }
|
||||
fn visit_item(&mut self, i:@item, _:()) {
|
||||
visit::walk_item(self, i, ());
|
||||
my_visit_item(i,
|
||||
self.items,
|
||||
&self.ebml_w_for_visit_item,
|
||||
self.ecx_ptr,
|
||||
self.index);
|
||||
}
|
||||
fn visit_foreign_item(&mut self, ni:@foreign_item, _:()) {
|
||||
visit::walk_foreign_item(self, ni, ());
|
||||
my_visit_foreign_item(ni,
|
||||
self.items,
|
||||
&self.ebml_w_for_visit_foreign_item,
|
||||
self.ecx_ptr,
|
||||
self.index);
|
||||
}
|
||||
}
|
||||
|
||||
fn encode_info_for_items(ecx: &EncodeContext,
|
||||
ebml_w: &mut writer::Encoder,
|
||||
crate: &Crate)
|
||||
|
|
@ -1201,54 +1270,17 @@ fn encode_info_for_items(ecx: &EncodeContext,
|
|||
let items = ecx.tcx.items;
|
||||
|
||||
// See comment in `encode_side_tables_for_ii` in astencode
|
||||
let ecx_ptr : *() = unsafe { cast::transmute(ecx) };
|
||||
let ecx_ptr : *int = unsafe { cast::transmute(ecx) };
|
||||
let mut visitor = EncodeVisitor {
|
||||
index: index,
|
||||
items: items,
|
||||
ecx_ptr: ecx_ptr,
|
||||
ebml_w_for_visit_item: (*ebml_w).clone(),
|
||||
ebml_w_for_visit_foreign_item: (*ebml_w).clone(),
|
||||
};
|
||||
|
||||
oldvisit::visit_crate(crate, ((), oldvisit::mk_vt(@oldvisit::Visitor {
|
||||
visit_expr: |_e, (_cx, _v)| { },
|
||||
visit_item: {
|
||||
let ebml_w = (*ebml_w).clone();
|
||||
|i, (cx, v)| {
|
||||
oldvisit::visit_item(i, (cx, v));
|
||||
match items.get_copy(&i.id) {
|
||||
ast_map::node_item(_, pt) => {
|
||||
let mut ebml_w = ebml_w.clone();
|
||||
// See above
|
||||
let ecx : &EncodeContext = unsafe { cast::transmute(ecx_ptr) };
|
||||
encode_info_for_item(ecx, &mut ebml_w, i, index, *pt);
|
||||
}
|
||||
_ => fail!("bad item")
|
||||
}
|
||||
}
|
||||
},
|
||||
visit_foreign_item: {
|
||||
let ebml_w = (*ebml_w).clone();
|
||||
|ni, (cx, v)| {
|
||||
oldvisit::visit_foreign_item(ni, (cx, v));
|
||||
match items.get_copy(&ni.id) {
|
||||
ast_map::node_foreign_item(_, abi, _, pt) => {
|
||||
debug!("writing foreign item %s::%s",
|
||||
ast_map::path_to_str(
|
||||
*pt,
|
||||
token::get_ident_interner()),
|
||||
token::ident_to_str(&ni.ident));
|
||||
visit::walk_crate(&mut visitor, crate, ());
|
||||
|
||||
let mut ebml_w = ebml_w.clone();
|
||||
// See above
|
||||
let ecx : &EncodeContext = unsafe { cast::transmute(ecx_ptr) };
|
||||
encode_info_for_foreign_item(ecx,
|
||||
&mut ebml_w,
|
||||
ni,
|
||||
index,
|
||||
pt,
|
||||
abi);
|
||||
}
|
||||
// case for separate item and foreign-item tables
|
||||
_ => fail!("bad foreign item")
|
||||
}
|
||||
}
|
||||
},
|
||||
..*oldvisit::default_visitor()
|
||||
})));
|
||||
ebml_w.end_tag();
|
||||
return /*bad*/(*index).clone();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,9 @@ use syntax::ast;
|
|||
use syntax::ast_util::id_range;
|
||||
use syntax::codemap::span;
|
||||
use syntax::print::pprust;
|
||||
use syntax::oldvisit;
|
||||
use syntax::visit;
|
||||
use syntax::visit::Visitor;
|
||||
use syntax::ast::{expr, fn_kind, fn_decl, Block, NodeId, stmt, pat, Local};
|
||||
|
||||
mod lifetime;
|
||||
mod restrictions;
|
||||
|
|
@ -72,6 +74,30 @@ struct GatherLoanCtxt {
|
|||
repeating_ids: ~[ast::NodeId]
|
||||
}
|
||||
|
||||
struct GatherLoanVisitor;
|
||||
|
||||
impl visit::Visitor<@mut GatherLoanCtxt> for GatherLoanVisitor {
|
||||
fn visit_expr(&mut self, ex:@expr, e:@mut GatherLoanCtxt) {
|
||||
gather_loans_in_expr(self, ex, e);
|
||||
}
|
||||
fn visit_block(&mut self, b:&Block, e:@mut GatherLoanCtxt) {
|
||||
gather_loans_in_block(self, b, e);
|
||||
}
|
||||
fn visit_fn(&mut self, fk:&fn_kind, fd:&fn_decl, b:&Block,
|
||||
s:span, n:NodeId, e:@mut GatherLoanCtxt) {
|
||||
gather_loans_in_fn(self, fk, fd, b, s, n, e);
|
||||
}
|
||||
fn visit_stmt(&mut self, s:@stmt, e:@mut GatherLoanCtxt) {
|
||||
add_stmt_to_map(self, s, e);
|
||||
}
|
||||
fn visit_pat(&mut self, p:@pat, e:@mut GatherLoanCtxt) {
|
||||
add_pat_to_id_range(self, p, e);
|
||||
}
|
||||
fn visit_local(&mut self, l:@Local, e:@mut GatherLoanCtxt) {
|
||||
gather_loans_in_local(self, l, e);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn gather_loans(bccx: @BorrowckCtxt,
|
||||
decl: &ast::fn_decl,
|
||||
body: &ast::Block)
|
||||
|
|
@ -85,64 +111,57 @@ pub fn gather_loans(bccx: @BorrowckCtxt,
|
|||
move_data: @mut MoveData::new()
|
||||
};
|
||||
glcx.gather_fn_arg_patterns(decl, body);
|
||||
let v = oldvisit::mk_vt(@oldvisit::Visitor {
|
||||
visit_expr: gather_loans_in_expr,
|
||||
visit_block: gather_loans_in_block,
|
||||
visit_fn: gather_loans_in_fn,
|
||||
visit_stmt: add_stmt_to_map,
|
||||
visit_pat: add_pat_to_id_range,
|
||||
visit_local: gather_loans_in_local,
|
||||
.. *oldvisit::default_visitor()
|
||||
});
|
||||
(v.visit_block)(body, (glcx, v));
|
||||
|
||||
let mut v = GatherLoanVisitor;
|
||||
v.visit_block(body, glcx);
|
||||
return (glcx.id_range, glcx.all_loans, glcx.move_data);
|
||||
}
|
||||
|
||||
fn add_pat_to_id_range(p: @ast::pat,
|
||||
(this, v): (@mut GatherLoanCtxt,
|
||||
oldvisit::vt<@mut GatherLoanCtxt>)) {
|
||||
fn add_pat_to_id_range(v: &mut GatherLoanVisitor,
|
||||
p: @ast::pat,
|
||||
this: @mut GatherLoanCtxt) {
|
||||
// NB: This visitor function just adds the pat ids into the id
|
||||
// range. We gather loans that occur in patterns using the
|
||||
// `gather_pat()` method below. Eventually these two should be
|
||||
// brought together.
|
||||
this.id_range.add(p.id);
|
||||
oldvisit::visit_pat(p, (this, v));
|
||||
visit::walk_pat(v, p, this);
|
||||
}
|
||||
|
||||
fn gather_loans_in_fn(fk: &oldvisit::fn_kind,
|
||||
fn gather_loans_in_fn(v: &mut GatherLoanVisitor,
|
||||
fk: &fn_kind,
|
||||
decl: &ast::fn_decl,
|
||||
body: &ast::Block,
|
||||
sp: span,
|
||||
id: ast::NodeId,
|
||||
(this, v): (@mut GatherLoanCtxt,
|
||||
oldvisit::vt<@mut GatherLoanCtxt>)) {
|
||||
this: @mut GatherLoanCtxt) {
|
||||
match fk {
|
||||
// Do not visit items here, the outer loop in borrowck/mod
|
||||
// will visit them for us in turn.
|
||||
&oldvisit::fk_item_fn(*) | &oldvisit::fk_method(*) => {
|
||||
&visit::fk_item_fn(*) | &visit::fk_method(*) => {
|
||||
return;
|
||||
}
|
||||
|
||||
// Visit closures as part of the containing item.
|
||||
&oldvisit::fk_anon(*) | &oldvisit::fk_fn_block(*) => {
|
||||
&visit::fk_anon(*) | &visit::fk_fn_block(*) => {
|
||||
this.push_repeating_id(body.id);
|
||||
oldvisit::visit_fn(fk, decl, body, sp, id, (this, v));
|
||||
visit::walk_fn(v, fk, decl, body, sp, id, this);
|
||||
this.pop_repeating_id(body.id);
|
||||
this.gather_fn_arg_patterns(decl, body);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn gather_loans_in_block(blk: &ast::Block,
|
||||
(this, vt): (@mut GatherLoanCtxt,
|
||||
oldvisit::vt<@mut GatherLoanCtxt>)) {
|
||||
fn gather_loans_in_block(v: &mut GatherLoanVisitor,
|
||||
blk: &ast::Block,
|
||||
this: @mut GatherLoanCtxt) {
|
||||
this.id_range.add(blk.id);
|
||||
oldvisit::visit_block(blk, (this, vt));
|
||||
visit::walk_block(v, blk, this);
|
||||
}
|
||||
|
||||
fn gather_loans_in_local(local: @ast::Local,
|
||||
(this, vt): (@mut GatherLoanCtxt,
|
||||
oldvisit::vt<@mut GatherLoanCtxt>)) {
|
||||
fn gather_loans_in_local(v: &mut GatherLoanVisitor,
|
||||
local: @ast::Local,
|
||||
this: @mut GatherLoanCtxt) {
|
||||
match local.init {
|
||||
None => {
|
||||
// Variable declarations without initializers are considered "moves":
|
||||
|
|
@ -173,12 +192,13 @@ fn gather_loans_in_local(local: @ast::Local,
|
|||
}
|
||||
}
|
||||
|
||||
oldvisit::visit_local(local, (this, vt));
|
||||
visit::walk_local(v, local, this);
|
||||
}
|
||||
|
||||
fn gather_loans_in_expr(ex: @ast::expr,
|
||||
(this, vt): (@mut GatherLoanCtxt,
|
||||
oldvisit::vt<@mut GatherLoanCtxt>)) {
|
||||
|
||||
fn gather_loans_in_expr(v: &mut GatherLoanVisitor,
|
||||
ex: @ast::expr,
|
||||
this: @mut GatherLoanCtxt) {
|
||||
let bccx = this.bccx;
|
||||
let tcx = bccx.tcx;
|
||||
|
||||
|
|
@ -218,7 +238,7 @@ fn gather_loans_in_expr(ex: @ast::expr,
|
|||
// for the lifetime `scope_r` of the resulting ptr:
|
||||
let scope_r = ty_region(tcx, ex.span, ty::expr_ty(tcx, ex));
|
||||
this.guarantee_valid(ex.id, ex.span, base_cmt, mutbl, scope_r);
|
||||
oldvisit::visit_expr(ex, (this, vt));
|
||||
visit::walk_expr(v, ex, this);
|
||||
}
|
||||
|
||||
ast::expr_assign(l, _) | ast::expr_assign_op(_, _, l, _) => {
|
||||
|
|
@ -235,7 +255,7 @@ fn gather_loans_in_expr(ex: @ast::expr,
|
|||
// with moves etc, just ignore.
|
||||
}
|
||||
}
|
||||
oldvisit::visit_expr(ex, (this, vt));
|
||||
visit::walk_expr(v, ex, this);
|
||||
}
|
||||
|
||||
ast::expr_match(ex_v, ref arms) => {
|
||||
|
|
@ -245,7 +265,7 @@ fn gather_loans_in_expr(ex: @ast::expr,
|
|||
this.gather_pat(cmt, *pat, Some((arm.body.id, ex.id)));
|
||||
}
|
||||
}
|
||||
oldvisit::visit_expr(ex, (this, vt));
|
||||
visit::walk_expr(v, ex, this);
|
||||
}
|
||||
|
||||
ast::expr_index(_, _, arg) |
|
||||
|
|
@ -259,36 +279,36 @@ fn gather_loans_in_expr(ex: @ast::expr,
|
|||
let scope_r = ty::re_scope(ex.id);
|
||||
let arg_cmt = this.bccx.cat_expr(arg);
|
||||
this.guarantee_valid(arg.id, arg.span, arg_cmt, m_imm, scope_r);
|
||||
oldvisit::visit_expr(ex, (this, vt));
|
||||
visit::walk_expr(v, ex, this);
|
||||
}
|
||||
|
||||
// see explanation attached to the `root_ub` field:
|
||||
ast::expr_while(cond, ref body) => {
|
||||
// during the condition, can only root for the condition
|
||||
this.push_repeating_id(cond.id);
|
||||
(vt.visit_expr)(cond, (this, vt));
|
||||
v.visit_expr(cond, this);
|
||||
this.pop_repeating_id(cond.id);
|
||||
|
||||
// during body, can only root for the body
|
||||
this.push_repeating_id(body.id);
|
||||
(vt.visit_block)(body, (this, vt));
|
||||
v.visit_block(body, this);
|
||||
this.pop_repeating_id(body.id);
|
||||
}
|
||||
|
||||
// see explanation attached to the `root_ub` field:
|
||||
ast::expr_loop(ref body, _) => {
|
||||
this.push_repeating_id(body.id);
|
||||
oldvisit::visit_expr(ex, (this, vt));
|
||||
visit::walk_expr(v, ex, this);
|
||||
this.pop_repeating_id(body.id);
|
||||
}
|
||||
|
||||
ast::expr_fn_block(*) => {
|
||||
gather_moves::gather_captures(this.bccx, this.move_data, ex);
|
||||
oldvisit::visit_expr(ex, (this, vt));
|
||||
visit::walk_expr(v, ex, this);
|
||||
}
|
||||
|
||||
_ => {
|
||||
oldvisit::visit_expr(ex, (this, vt));
|
||||
visit::walk_expr(v, ex, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -770,14 +790,14 @@ impl GatherLoanCtxt {
|
|||
|
||||
// Setting up info that preserve needs.
|
||||
// This is just the most convenient place to do it.
|
||||
fn add_stmt_to_map(stmt: @ast::stmt,
|
||||
(this, vt): (@mut GatherLoanCtxt,
|
||||
oldvisit::vt<@mut GatherLoanCtxt>)) {
|
||||
fn add_stmt_to_map(v: &mut GatherLoanVisitor,
|
||||
stmt: @ast::stmt,
|
||||
this: @mut GatherLoanCtxt) {
|
||||
match stmt.node {
|
||||
ast::stmt_expr(_, id) | ast::stmt_semi(_, id) => {
|
||||
this.bccx.stmt_map.insert(id);
|
||||
}
|
||||
_ => ()
|
||||
}
|
||||
oldvisit::visit_stmt(stmt, (this, vt));
|
||||
visit::walk_stmt(v, stmt, this);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,9 +26,11 @@ use std::ops::{BitOr, BitAnd};
|
|||
use std::result::{Result};
|
||||
use syntax::ast;
|
||||
use syntax::ast_map;
|
||||
use syntax::oldvisit;
|
||||
use syntax::codemap::span;
|
||||
use syntax::parse::token;
|
||||
use syntax::visit;
|
||||
use syntax::visit::{Visitor,fn_kind};
|
||||
use syntax::ast::{fn_decl,Block,NodeId};
|
||||
|
||||
macro_rules! if_ok(
|
||||
($inp: expr) => (
|
||||
|
|
@ -59,6 +61,15 @@ impl Clone for LoanDataFlowOperator {
|
|||
|
||||
pub type LoanDataFlow = DataFlowContext<LoanDataFlowOperator>;
|
||||
|
||||
struct BorrowckVisitor;
|
||||
|
||||
impl Visitor<@BorrowckCtxt> for BorrowckVisitor {
|
||||
fn visit_fn(&mut self, fk:&fn_kind, fd:&fn_decl,
|
||||
b:&Block, s:span, n:NodeId, e:@BorrowckCtxt) {
|
||||
borrowck_fn(self, fk, fd, b, s, n, e);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn check_crate(
|
||||
tcx: ty::ctxt,
|
||||
method_map: typeck::method_map,
|
||||
|
|
@ -86,9 +97,8 @@ pub fn check_crate(
|
|||
}
|
||||
};
|
||||
|
||||
let v = oldvisit::mk_vt(@oldvisit::Visitor {visit_fn: borrowck_fn,
|
||||
..*oldvisit::default_visitor()});
|
||||
oldvisit::visit_crate(crate, (bccx, v));
|
||||
let mut v = BorrowckVisitor;
|
||||
visit::walk_crate(&mut v, crate, bccx);
|
||||
|
||||
if tcx.sess.borrowck_stats() {
|
||||
io::println("--- borrowck stats ---");
|
||||
|
|
@ -113,21 +123,21 @@ pub fn check_crate(
|
|||
}
|
||||
}
|
||||
|
||||
fn borrowck_fn(fk: &oldvisit::fn_kind,
|
||||
fn borrowck_fn(v: &mut BorrowckVisitor,
|
||||
fk: &visit::fn_kind,
|
||||
decl: &ast::fn_decl,
|
||||
body: &ast::Block,
|
||||
sp: span,
|
||||
id: ast::NodeId,
|
||||
(this, v): (@BorrowckCtxt,
|
||||
oldvisit::vt<@BorrowckCtxt>)) {
|
||||
this: @BorrowckCtxt) {
|
||||
match fk {
|
||||
&oldvisit::fk_anon(*) |
|
||||
&oldvisit::fk_fn_block(*) => {
|
||||
&visit::fk_anon(*) |
|
||||
&visit::fk_fn_block(*) => {
|
||||
// Closures are checked as part of their containing fn item.
|
||||
}
|
||||
|
||||
&oldvisit::fk_item_fn(*) |
|
||||
&oldvisit::fk_method(*) => {
|
||||
&visit::fk_item_fn(*) |
|
||||
&visit::fk_method(*) => {
|
||||
debug!("borrowck_fn(id=%?)", id);
|
||||
|
||||
// Check the body of fn items.
|
||||
|
|
@ -156,7 +166,7 @@ fn borrowck_fn(fk: &oldvisit::fn_kind,
|
|||
}
|
||||
}
|
||||
|
||||
oldvisit::visit_fn(fk, decl, body, sp, id, (this, v));
|
||||
visit::walk_fn(v, fk, decl, body, sp, id, this);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -480,6 +480,7 @@ impl Context {
|
|||
(orig.visit_item)(it, (self, stopping));
|
||||
}
|
||||
NewVisitor(new_visitor) => {
|
||||
let mut new_visitor = new_visitor;
|
||||
new_visitor.visit_item(it, ());
|
||||
}
|
||||
}
|
||||
|
|
@ -492,7 +493,8 @@ impl Context {
|
|||
oldvisit::visit_crate(c, (self, stopping))
|
||||
}
|
||||
NewVisitor(new_visitor) => {
|
||||
visit::visit_crate(new_visitor, c, ())
|
||||
let mut new_visitor = new_visitor;
|
||||
visit::walk_crate(&mut new_visitor, c, ())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -518,6 +520,7 @@ impl Context {
|
|||
let fk = visit::fk_method(m.ident,
|
||||
&m.generics,
|
||||
m);
|
||||
let mut new_visitor = new_visitor;
|
||||
new_visitor.visit_fn(&fk,
|
||||
&m.decl,
|
||||
&m.body,
|
||||
|
|
|
|||
|
|
@ -89,11 +89,11 @@ pub struct Ctx {
|
|||
}
|
||||
|
||||
impl Ctx {
|
||||
fn extend(@mut self, elt: ident) -> @path {
|
||||
fn extend(&self, elt: ident) -> @path {
|
||||
@vec::append(self.path.clone(), [path_name(elt)])
|
||||
}
|
||||
|
||||
fn map_method(@mut self,
|
||||
fn map_method(&mut self,
|
||||
impl_did: def_id,
|
||||
impl_path: @path,
|
||||
m: @method,
|
||||
|
|
@ -107,7 +107,7 @@ impl Ctx {
|
|||
self.map.insert(m.self_id, node_local(special_idents::self_));
|
||||
}
|
||||
|
||||
fn map_struct_def(@mut self,
|
||||
fn map_struct_def(&mut self,
|
||||
struct_def: @ast::struct_def,
|
||||
parent_node: ast_node,
|
||||
ident: ast::ident) {
|
||||
|
|
@ -130,7 +130,7 @@ impl Ctx {
|
|||
}
|
||||
}
|
||||
|
||||
fn map_expr(@mut self, ex: @expr) {
|
||||
fn map_expr(&mut self, ex: @expr) {
|
||||
self.map.insert(ex.id, node_expr(ex));
|
||||
|
||||
// Expressions which are or might be calls:
|
||||
|
|
@ -141,10 +141,10 @@ impl Ctx {
|
|||
}
|
||||
}
|
||||
|
||||
visit::visit_expr(self as @mut Visitor<()>, ex, ());
|
||||
visit::walk_expr(self, ex, ());
|
||||
}
|
||||
|
||||
fn map_fn(@mut self,
|
||||
fn map_fn(&mut self,
|
||||
fk: &visit::fn_kind,
|
||||
decl: &fn_decl,
|
||||
body: &Block,
|
||||
|
|
@ -153,21 +153,21 @@ impl Ctx {
|
|||
for a in decl.inputs.iter() {
|
||||
self.map.insert(a.id, node_arg);
|
||||
}
|
||||
visit::visit_fn(self as @mut Visitor<()>, fk, decl, body, sp, id, ());
|
||||
visit::walk_fn(self, fk, decl, body, sp, id, ());
|
||||
}
|
||||
|
||||
fn map_stmt(@mut self, stmt: @stmt) {
|
||||
fn map_stmt(&mut self, stmt: @stmt) {
|
||||
self.map.insert(stmt_id(stmt), node_stmt(stmt));
|
||||
visit::visit_stmt(self as @mut Visitor<()>, stmt, ());
|
||||
visit::walk_stmt(self, stmt, ());
|
||||
}
|
||||
|
||||
fn map_block(@mut self, b: &Block) {
|
||||
fn map_block(&mut self, b: &Block) {
|
||||
// clone is FIXME #2543
|
||||
self.map.insert(b.id, node_block((*b).clone()));
|
||||
visit::visit_block(self as @mut Visitor<()>, b, ());
|
||||
visit::walk_block(self, b, ());
|
||||
}
|
||||
|
||||
fn map_pat(@mut self, pat: @pat) {
|
||||
fn map_pat(&mut self, pat: @pat) {
|
||||
match pat.node {
|
||||
pat_ident(_, ref path, _) => {
|
||||
// Note: this is at least *potentially* a pattern...
|
||||
|
|
@ -177,12 +177,12 @@ impl Ctx {
|
|||
_ => ()
|
||||
}
|
||||
|
||||
visit::visit_pat(self as @mut Visitor<()>, pat, ());
|
||||
visit::walk_pat(self, pat, ());
|
||||
}
|
||||
}
|
||||
|
||||
impl Visitor<()> for Ctx {
|
||||
fn visit_item(@mut self, i: @item, _: ()) {
|
||||
fn visit_item(&mut self, i: @item, _: ()) {
|
||||
// clone is FIXME #2543
|
||||
let item_path = @self.path.clone();
|
||||
self.map.insert(i.id, node_item(i, item_path));
|
||||
|
|
@ -190,7 +190,8 @@ impl Visitor<()> for Ctx {
|
|||
item_impl(_, _, _, ref ms) => {
|
||||
let impl_did = ast_util::local_def(i.id);
|
||||
for m in ms.iter() {
|
||||
self.map_method(impl_did, self.extend(i.ident), *m, false)
|
||||
let extended = { self.extend(i.ident) };
|
||||
self.map_method(impl_did, extended, *m, false)
|
||||
}
|
||||
}
|
||||
item_enum(ref enum_definition, _) => {
|
||||
|
|
@ -254,24 +255,24 @@ impl Visitor<()> for Ctx {
|
|||
}
|
||||
_ => self.path.push(path_name(i.ident))
|
||||
}
|
||||
visit::visit_item(self as @mut Visitor<()>, i, ());
|
||||
visit::walk_item(self, i, ());
|
||||
self.path.pop();
|
||||
}
|
||||
|
||||
fn visit_pat(@mut self, pat: @pat, _: ()) {
|
||||
fn visit_pat(&mut self, pat: @pat, _: ()) {
|
||||
self.map_pat(pat);
|
||||
visit::visit_pat(self as @mut Visitor<()>, pat, ())
|
||||
visit::walk_pat(self, pat, ())
|
||||
}
|
||||
|
||||
fn visit_expr(@mut self, expr: @expr, _: ()) {
|
||||
fn visit_expr(&mut self, expr: @expr, _: ()) {
|
||||
self.map_expr(expr)
|
||||
}
|
||||
|
||||
fn visit_stmt(@mut self, stmt: @stmt, _: ()) {
|
||||
fn visit_stmt(&mut self, stmt: @stmt, _: ()) {
|
||||
self.map_stmt(stmt)
|
||||
}
|
||||
|
||||
fn visit_fn(@mut self,
|
||||
fn visit_fn(&mut self,
|
||||
function_kind: &fn_kind,
|
||||
function_declaration: &fn_decl,
|
||||
block: &Block,
|
||||
|
|
@ -281,56 +282,56 @@ impl Visitor<()> for Ctx {
|
|||
self.map_fn(function_kind, function_declaration, block, span, node_id)
|
||||
}
|
||||
|
||||
fn visit_block(@mut self, block: &Block, _: ()) {
|
||||
fn visit_block(&mut self, block: &Block, _: ()) {
|
||||
self.map_block(block)
|
||||
}
|
||||
|
||||
// XXX: Methods below can become default methods.
|
||||
|
||||
fn visit_mod(@mut self, module: &_mod, _: span, _: NodeId, _: ()) {
|
||||
visit::visit_mod(self as @mut Visitor<()>, module, ())
|
||||
fn visit_mod(&mut self, module: &_mod, _: span, _: NodeId, _: ()) {
|
||||
visit::walk_mod(self, module, ())
|
||||
}
|
||||
|
||||
fn visit_view_item(@mut self, view_item: &view_item, _: ()) {
|
||||
visit::visit_view_item(self as @mut Visitor<()>, view_item, ())
|
||||
fn visit_view_item(&mut self, view_item: &view_item, _: ()) {
|
||||
visit::walk_view_item(self, view_item, ())
|
||||
}
|
||||
|
||||
fn visit_foreign_item(@mut self, foreign_item: @foreign_item, _: ()) {
|
||||
visit::visit_foreign_item(self as @mut Visitor<()>, foreign_item, ())
|
||||
fn visit_foreign_item(&mut self, foreign_item: @foreign_item, _: ()) {
|
||||
visit::walk_foreign_item(self, foreign_item, ())
|
||||
}
|
||||
|
||||
fn visit_local(@mut self, local: @Local, _: ()) {
|
||||
visit::visit_local(self as @mut Visitor<()>, local, ())
|
||||
fn visit_local(&mut self, local: @Local, _: ()) {
|
||||
visit::walk_local(self, local, ())
|
||||
}
|
||||
|
||||
fn visit_arm(@mut self, arm: &arm, _: ()) {
|
||||
visit::visit_arm(self as @mut Visitor<()>, arm, ())
|
||||
fn visit_arm(&mut self, arm: &arm, _: ()) {
|
||||
visit::walk_arm(self, arm, ())
|
||||
}
|
||||
|
||||
fn visit_decl(@mut self, decl: @decl, _: ()) {
|
||||
visit::visit_decl(self as @mut Visitor<()>, decl, ())
|
||||
fn visit_decl(&mut self, decl: @decl, _: ()) {
|
||||
visit::walk_decl(self, decl, ())
|
||||
}
|
||||
|
||||
fn visit_expr_post(@mut self, _: @expr, _: ()) {
|
||||
fn visit_expr_post(&mut self, _: @expr, _: ()) {
|
||||
// Empty!
|
||||
}
|
||||
|
||||
fn visit_ty(@mut self, typ: &Ty, _: ()) {
|
||||
visit::visit_ty(self as @mut Visitor<()>, typ, ())
|
||||
fn visit_ty(&mut self, typ: &Ty, _: ()) {
|
||||
visit::walk_ty(self, typ, ())
|
||||
}
|
||||
|
||||
fn visit_generics(@mut self, generics: &Generics, _: ()) {
|
||||
visit::visit_generics(self as @mut Visitor<()>, generics, ())
|
||||
fn visit_generics(&mut self, generics: &Generics, _: ()) {
|
||||
visit::walk_generics(self, generics, ())
|
||||
}
|
||||
|
||||
fn visit_fn(@mut self,
|
||||
fn visit_fn(&mut self,
|
||||
function_kind: &fn_kind,
|
||||
function_declaration: &fn_decl,
|
||||
block: &Block,
|
||||
span: span,
|
||||
node_id: NodeId,
|
||||
_: ()) {
|
||||
visit::visit_fn(self as @mut Visitor<()>,
|
||||
visit::walk_fn(self,
|
||||
function_kind,
|
||||
function_declaration,
|
||||
block,
|
||||
|
|
@ -339,21 +340,21 @@ impl Visitor<()> for Ctx {
|
|||
())
|
||||
}
|
||||
|
||||
fn visit_ty_method(@mut self, ty_method: &TypeMethod, _: ()) {
|
||||
visit::visit_ty_method(self as @mut Visitor<()>, ty_method, ())
|
||||
fn visit_ty_method(&mut self, ty_method: &TypeMethod, _: ()) {
|
||||
visit::walk_ty_method(self, ty_method, ())
|
||||
}
|
||||
|
||||
fn visit_trait_method(@mut self, trait_method: &trait_method, _: ()) {
|
||||
visit::visit_trait_method(self as @mut Visitor<()>, trait_method, ())
|
||||
fn visit_trait_method(&mut self, trait_method: &trait_method, _: ()) {
|
||||
visit::walk_trait_method(self, trait_method, ())
|
||||
}
|
||||
|
||||
fn visit_struct_def(@mut self,
|
||||
fn visit_struct_def(&mut self,
|
||||
struct_def: @struct_def,
|
||||
ident: ident,
|
||||
generics: &Generics,
|
||||
node_id: NodeId,
|
||||
_: ()) {
|
||||
visit::visit_struct_def(self as @mut Visitor<()>,
|
||||
visit::walk_struct_def(self,
|
||||
struct_def,
|
||||
ident,
|
||||
generics,
|
||||
|
|
@ -361,8 +362,8 @@ impl Visitor<()> for Ctx {
|
|||
())
|
||||
}
|
||||
|
||||
fn visit_struct_field(@mut self, struct_field: @struct_field, _: ()) {
|
||||
visit::visit_struct_field(self as @mut Visitor<()>, struct_field, ())
|
||||
fn visit_struct_field(&mut self, struct_field: @struct_field, _: ()) {
|
||||
visit::walk_struct_field(self, struct_field, ())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -372,7 +373,7 @@ pub fn map_crate(diag: @mut span_handler, c: &Crate) -> map {
|
|||
path: ~[],
|
||||
diag: diag,
|
||||
};
|
||||
visit::visit_crate(cx as @mut Visitor<()>, c, ());
|
||||
visit::walk_crate(cx, c, ());
|
||||
cx.map
|
||||
}
|
||||
|
||||
|
|
@ -409,7 +410,7 @@ pub fn map_decoded_item(diag: @mut span_handler,
|
|||
}
|
||||
|
||||
// visit the item / method contents and add those to the map:
|
||||
ii.accept((), cx as @mut Visitor<()>);
|
||||
ii.accept((), cx);
|
||||
}
|
||||
|
||||
pub fn node_id_to_str(map: map, id: NodeId, itr: @ident_interner) -> ~str {
|
||||
|
|
|
|||
|
|
@ -298,7 +298,7 @@ pub fn struct_field_visibility(field: ast::struct_field) -> visibility {
|
|||
pub trait inlined_item_utils {
|
||||
fn ident(&self) -> ident;
|
||||
fn id(&self) -> ast::NodeId;
|
||||
fn accept<E: Clone>(&self, e: E, v: @mut Visitor<E>);
|
||||
fn accept<E: Clone, V:Visitor<E>>(&self, e: E, v: &mut V);
|
||||
}
|
||||
|
||||
impl inlined_item_utils for inlined_item {
|
||||
|
|
@ -318,11 +318,11 @@ impl inlined_item_utils for inlined_item {
|
|||
}
|
||||
}
|
||||
|
||||
fn accept<E: Clone>(&self, e: E, v: @mut Visitor<E>) {
|
||||
fn accept<E: Clone, V:Visitor<E>>(&self, e: E, v: &mut V) {
|
||||
match *self {
|
||||
ii_item(i) => v.visit_item(i, e),
|
||||
ii_foreign(i) => v.visit_foreign_item(i, e),
|
||||
ii_method(_, _, m) => visit::visit_method_helper(v, m, e),
|
||||
ii_method(_, _, m) => visit::walk_method_helper(v, m, e),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -390,14 +390,24 @@ impl id_range {
|
|||
}
|
||||
}
|
||||
|
||||
struct IdVisitor {
|
||||
pub fn id_visitor(vfn: @fn(NodeId), pass_through_items: bool)
|
||||
-> @mut Visitor<()> {
|
||||
let visitor = @mut IdVisitor {
|
||||
visit_callback: vfn,
|
||||
pass_through_items: pass_through_items,
|
||||
visited_outermost: false,
|
||||
};
|
||||
visitor as @mut Visitor<()>
|
||||
}
|
||||
|
||||
pub struct IdVisitor {
|
||||
visit_callback: @fn(NodeId),
|
||||
pass_through_items: bool,
|
||||
visited_outermost: bool,
|
||||
}
|
||||
|
||||
impl IdVisitor {
|
||||
fn visit_generics_helper(@mut self, generics: &Generics) {
|
||||
fn visit_generics_helper(&self, generics: &Generics) {
|
||||
for type_parameter in generics.ty_params.iter() {
|
||||
(self.visit_callback)(type_parameter.id)
|
||||
}
|
||||
|
|
@ -408,16 +418,16 @@ impl IdVisitor {
|
|||
}
|
||||
|
||||
impl Visitor<()> for IdVisitor {
|
||||
fn visit_mod(@mut self,
|
||||
fn visit_mod(&mut self,
|
||||
module: &_mod,
|
||||
_span: span,
|
||||
node_id: NodeId,
|
||||
env: ()) {
|
||||
(self.visit_callback)(node_id);
|
||||
visit::visit_mod(self as @mut Visitor<()>, module, env)
|
||||
visit::walk_mod(self, module, env)
|
||||
}
|
||||
|
||||
fn visit_view_item(@mut self, view_item: &view_item, env: ()) {
|
||||
fn visit_view_item(&mut self, view_item: &view_item, env: ()) {
|
||||
match view_item.node {
|
||||
view_item_extern_mod(_, _, _, node_id) => {
|
||||
(self.visit_callback)(node_id)
|
||||
|
|
@ -439,15 +449,15 @@ impl Visitor<()> for IdVisitor {
|
|||
}
|
||||
}
|
||||
}
|
||||
visit::visit_view_item(self as @mut Visitor<()>, view_item, env)
|
||||
visit::walk_view_item(self, view_item, env)
|
||||
}
|
||||
|
||||
fn visit_foreign_item(@mut self, foreign_item: @foreign_item, env: ()) {
|
||||
fn visit_foreign_item(&mut self, foreign_item: @foreign_item, env: ()) {
|
||||
(self.visit_callback)(foreign_item.id);
|
||||
visit::visit_foreign_item(self as @mut Visitor<()>, foreign_item, env)
|
||||
visit::walk_foreign_item(self, foreign_item, env)
|
||||
}
|
||||
|
||||
fn visit_item(@mut self, item: @item, env: ()) {
|
||||
fn visit_item(&mut self, item: @item, env: ()) {
|
||||
if !self.pass_through_items {
|
||||
if self.visited_outermost {
|
||||
return
|
||||
|
|
@ -466,42 +476,42 @@ impl Visitor<()> for IdVisitor {
|
|||
_ => {}
|
||||
}
|
||||
|
||||
visit::visit_item(self as @mut Visitor<()>, item, env);
|
||||
visit::walk_item(self, item, env);
|
||||
|
||||
self.visited_outermost = false
|
||||
}
|
||||
|
||||
fn visit_local(@mut self, local: @Local, env: ()) {
|
||||
fn visit_local(&mut self, local: @Local, env: ()) {
|
||||
(self.visit_callback)(local.id);
|
||||
visit::visit_local(self as @mut Visitor<()>, local, env)
|
||||
visit::walk_local(self, local, env)
|
||||
}
|
||||
|
||||
fn visit_block(@mut self, block: &Block, env: ()) {
|
||||
fn visit_block(&mut self, block: &Block, env: ()) {
|
||||
(self.visit_callback)(block.id);
|
||||
visit::visit_block(self as @mut Visitor<()>, block, env)
|
||||
visit::walk_block(self, block, env)
|
||||
}
|
||||
|
||||
fn visit_stmt(@mut self, statement: @stmt, env: ()) {
|
||||
fn visit_stmt(&mut self, statement: @stmt, env: ()) {
|
||||
(self.visit_callback)(ast_util::stmt_id(statement));
|
||||
visit::visit_stmt(self as @mut Visitor<()>, statement, env)
|
||||
visit::walk_stmt(self, statement, env)
|
||||
}
|
||||
|
||||
// XXX: Default
|
||||
fn visit_arm(@mut self, arm: &arm, env: ()) {
|
||||
visit::visit_arm(self as @mut Visitor<()>, arm, env)
|
||||
fn visit_arm(&mut self, arm: &arm, env: ()) {
|
||||
visit::walk_arm(self, arm, env)
|
||||
}
|
||||
|
||||
fn visit_pat(@mut self, pattern: @pat, env: ()) {
|
||||
fn visit_pat(&mut self, pattern: @pat, env: ()) {
|
||||
(self.visit_callback)(pattern.id);
|
||||
visit::visit_pat(self as @mut Visitor<()>, pattern, env)
|
||||
visit::walk_pat(self, pattern, env)
|
||||
}
|
||||
|
||||
// XXX: Default
|
||||
fn visit_decl(@mut self, declaration: @decl, env: ()) {
|
||||
visit::visit_decl(self as @mut Visitor<()>, declaration, env)
|
||||
fn visit_decl(&mut self, declaration: @decl, env: ()) {
|
||||
visit::walk_decl(self, declaration, env)
|
||||
}
|
||||
|
||||
fn visit_expr(@mut self, expression: @expr, env: ()) {
|
||||
fn visit_expr(&mut self, expression: @expr, env: ()) {
|
||||
{
|
||||
let optional_callee_id = expression.get_callee_id();
|
||||
for callee_id in optional_callee_id.iter() {
|
||||
|
|
@ -509,29 +519,29 @@ impl Visitor<()> for IdVisitor {
|
|||
}
|
||||
}
|
||||
(self.visit_callback)(expression.id);
|
||||
visit::visit_expr(self as @mut Visitor<()>, expression, env)
|
||||
visit::walk_expr(self, expression, env)
|
||||
}
|
||||
|
||||
// XXX: Default
|
||||
fn visit_expr_post(@mut self, _: @expr, _: ()) {
|
||||
fn visit_expr_post(&mut self, _: @expr, _: ()) {
|
||||
// Empty!
|
||||
}
|
||||
|
||||
fn visit_ty(@mut self, typ: &Ty, env: ()) {
|
||||
fn visit_ty(&mut self, typ: &Ty, env: ()) {
|
||||
(self.visit_callback)(typ.id);
|
||||
match typ.node {
|
||||
ty_path(_, _, id) => (self.visit_callback)(id),
|
||||
_ => {}
|
||||
}
|
||||
visit::visit_ty(self as @mut Visitor<()>, typ, env)
|
||||
visit::walk_ty(self, typ, env)
|
||||
}
|
||||
|
||||
fn visit_generics(@mut self, generics: &Generics, env: ()) {
|
||||
fn visit_generics(&mut self, generics: &Generics, env: ()) {
|
||||
self.visit_generics_helper(generics);
|
||||
visit::visit_generics(self as @mut Visitor<()>, generics, env)
|
||||
visit::walk_generics(self, generics, env)
|
||||
}
|
||||
|
||||
fn visit_fn(@mut self,
|
||||
fn visit_fn(&mut self,
|
||||
function_kind: &visit::fn_kind,
|
||||
function_declaration: &fn_decl,
|
||||
block: &Block,
|
||||
|
|
@ -563,7 +573,7 @@ impl Visitor<()> for IdVisitor {
|
|||
(self.visit_callback)(argument.id)
|
||||
}
|
||||
|
||||
visit::visit_fn(self as @mut Visitor<()>,
|
||||
visit::walk_fn(self,
|
||||
function_kind,
|
||||
function_declaration,
|
||||
block,
|
||||
|
|
@ -580,23 +590,23 @@ impl Visitor<()> for IdVisitor {
|
|||
}
|
||||
|
||||
// XXX: Default
|
||||
fn visit_ty_method(@mut self, type_method: &TypeMethod, env: ()) {
|
||||
visit::visit_ty_method(self as @mut Visitor<()>, type_method, env)
|
||||
fn visit_ty_method(&mut self, type_method: &TypeMethod, env: ()) {
|
||||
visit::walk_ty_method(self, type_method, env)
|
||||
}
|
||||
|
||||
// XXX: Default
|
||||
fn visit_trait_method(@mut self, trait_method: &trait_method, env: ()) {
|
||||
visit::visit_trait_method(self as @mut Visitor<()>, trait_method, env)
|
||||
fn visit_trait_method(&mut self, trait_method: &trait_method, env: ()) {
|
||||
visit::walk_trait_method(self, trait_method, env)
|
||||
}
|
||||
|
||||
// XXX: Default
|
||||
fn visit_struct_def(@mut self,
|
||||
fn visit_struct_def(&mut self,
|
||||
struct_definition: @struct_def,
|
||||
identifier: ident,
|
||||
generics: &Generics,
|
||||
node_id: NodeId,
|
||||
env: ()) {
|
||||
visit::visit_struct_def(self as @mut Visitor<()>,
|
||||
visit::walk_struct_def(self,
|
||||
struct_definition,
|
||||
identifier,
|
||||
generics,
|
||||
|
|
@ -604,24 +614,19 @@ impl Visitor<()> for IdVisitor {
|
|||
env)
|
||||
}
|
||||
|
||||
fn visit_struct_field(@mut self, struct_field: @struct_field, env: ()) {
|
||||
fn visit_struct_field(&mut self, struct_field: @struct_field, env: ()) {
|
||||
(self.visit_callback)(struct_field.node.id);
|
||||
visit::visit_struct_field(self as @mut Visitor<()>, struct_field, env)
|
||||
visit::walk_struct_field(self, struct_field, env)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn id_visitor(vfn: @fn(NodeId), pass_through_items: bool)
|
||||
-> @mut Visitor<()> {
|
||||
let visitor = @mut IdVisitor {
|
||||
pub fn visit_ids_for_inlined_item(item: &inlined_item, vfn: @fn(NodeId)) {
|
||||
let mut id_visitor = IdVisitor {
|
||||
visit_callback: vfn,
|
||||
pass_through_items: pass_through_items,
|
||||
pass_through_items: true,
|
||||
visited_outermost: false,
|
||||
};
|
||||
visitor as @mut Visitor<()>
|
||||
}
|
||||
|
||||
pub fn visit_ids_for_inlined_item(item: &inlined_item, vfn: @fn(NodeId)) {
|
||||
item.accept((), id_visitor(|id| vfn(id), true));
|
||||
item.accept((), &mut id_visitor);
|
||||
}
|
||||
|
||||
pub fn compute_id_range(visit_ids_fn: &fn(@fn(NodeId))) -> id_range {
|
||||
|
|
@ -680,49 +685,49 @@ struct EachViewItemData {
|
|||
}
|
||||
|
||||
impl SimpleVisitor for EachViewItemData {
|
||||
fn visit_mod(@mut self, _: &_mod, _: span, _: NodeId) {
|
||||
fn visit_mod(&mut self, _: &_mod, _: span, _: NodeId) {
|
||||
// XXX: Default method.
|
||||
}
|
||||
fn visit_view_item(@mut self, view_item: &view_item) {
|
||||
fn visit_view_item(&mut self, view_item: &view_item) {
|
||||
let _ = (self.callback)(view_item);
|
||||
}
|
||||
fn visit_foreign_item(@mut self, _: @foreign_item) {
|
||||
fn visit_foreign_item(&mut self, _: @foreign_item) {
|
||||
// XXX: Default method.
|
||||
}
|
||||
fn visit_item(@mut self, _: @item) {
|
||||
fn visit_item(&mut self, _: @item) {
|
||||
// XXX: Default method.
|
||||
}
|
||||
fn visit_local(@mut self, _: @Local) {
|
||||
fn visit_local(&mut self, _: @Local) {
|
||||
// XXX: Default method.
|
||||
}
|
||||
fn visit_block(@mut self, _: &Block) {
|
||||
fn visit_block(&mut self, _: &Block) {
|
||||
// XXX: Default method.
|
||||
}
|
||||
fn visit_stmt(@mut self, _: @stmt) {
|
||||
fn visit_stmt(&mut self, _: @stmt) {
|
||||
// XXX: Default method.
|
||||
}
|
||||
fn visit_arm(@mut self, _: &arm) {
|
||||
fn visit_arm(&mut self, _: &arm) {
|
||||
// XXX: Default method.
|
||||
}
|
||||
fn visit_pat(@mut self, _: @pat) {
|
||||
fn visit_pat(&mut self, _: @pat) {
|
||||
// XXX: Default method.
|
||||
}
|
||||
fn visit_decl(@mut self, _: @decl) {
|
||||
fn visit_decl(&mut self, _: @decl) {
|
||||
// XXX: Default method.
|
||||
}
|
||||
fn visit_expr(@mut self, _: @expr) {
|
||||
fn visit_expr(&mut self, _: @expr) {
|
||||
// XXX: Default method.
|
||||
}
|
||||
fn visit_expr_post(@mut self, _: @expr) {
|
||||
fn visit_expr_post(&mut self, _: @expr) {
|
||||
// XXX: Default method.
|
||||
}
|
||||
fn visit_ty(@mut self, _: &Ty) {
|
||||
fn visit_ty(&mut self, _: &Ty) {
|
||||
// XXX: Default method.
|
||||
}
|
||||
fn visit_generics(@mut self, _: &Generics) {
|
||||
fn visit_generics(&mut self, _: &Generics) {
|
||||
// XXX: Default method.
|
||||
}
|
||||
fn visit_fn(@mut self,
|
||||
fn visit_fn(&mut self,
|
||||
_: &visit::fn_kind,
|
||||
_: &fn_decl,
|
||||
_: &Block,
|
||||
|
|
@ -730,23 +735,23 @@ impl SimpleVisitor for EachViewItemData {
|
|||
_: NodeId) {
|
||||
// XXX: Default method.
|
||||
}
|
||||
fn visit_ty_method(@mut self, _: &TypeMethod) {
|
||||
fn visit_ty_method(&mut self, _: &TypeMethod) {
|
||||
// XXX: Default method.
|
||||
}
|
||||
fn visit_trait_method(@mut self, _: &trait_method) {
|
||||
fn visit_trait_method(&mut self, _: &trait_method) {
|
||||
// XXX: Default method.
|
||||
}
|
||||
fn visit_struct_def(@mut self,
|
||||
fn visit_struct_def(&mut self,
|
||||
_: @struct_def,
|
||||
_: ident,
|
||||
_: &Generics,
|
||||
_: NodeId) {
|
||||
// XXX: Default method.
|
||||
}
|
||||
fn visit_struct_field(@mut self, _: @struct_field) {
|
||||
fn visit_struct_field(&mut self, _: @struct_field) {
|
||||
// XXX: Default method.
|
||||
}
|
||||
fn visit_struct_method(@mut self, _: @method) {
|
||||
fn visit_struct_method(&mut self, _: @method) {
|
||||
// XXX: Default method.
|
||||
}
|
||||
}
|
||||
|
|
@ -759,7 +764,7 @@ impl EachViewItem for ast::Crate {
|
|||
let visitor = @mut SimpleVisitorVisitor {
|
||||
simple_visitor: data as @mut SimpleVisitor,
|
||||
};
|
||||
visit::visit_crate(visitor as @mut Visitor<()>, self, ());
|
||||
visit::walk_crate(visitor, self, ());
|
||||
true
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -522,7 +522,7 @@ struct NewNameFinderContext {
|
|||
}
|
||||
|
||||
impl Visitor<()> for NewNameFinderContext {
|
||||
fn visit_pat(@mut self, pattern: @ast::pat, _: ()) {
|
||||
fn visit_pat(&mut self, pattern: @ast::pat, _: ()) {
|
||||
match *pattern {
|
||||
// we found a pat_ident!
|
||||
ast::pat {
|
||||
|
|
@ -548,74 +548,74 @@ impl Visitor<()> for NewNameFinderContext {
|
|||
}
|
||||
}
|
||||
// use the default traversal for non-pat_idents
|
||||
_ => visit::visit_pat(self as @mut Visitor<()>, pattern, ())
|
||||
_ => visit::walk_pat(self, pattern, ())
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: Methods below can become default methods.
|
||||
|
||||
fn visit_mod(@mut self, module: &ast::_mod, _: span, _: NodeId, _: ()) {
|
||||
visit::visit_mod(self as @mut Visitor<()>, module, ())
|
||||
fn visit_mod(&mut self, module: &ast::_mod, _: span, _: NodeId, _: ()) {
|
||||
visit::walk_mod(self, module, ())
|
||||
}
|
||||
|
||||
fn visit_view_item(@mut self, view_item: &ast::view_item, _: ()) {
|
||||
visit::visit_view_item(self as @mut Visitor<()>, view_item, ())
|
||||
fn visit_view_item(&mut self, view_item: &ast::view_item, _: ()) {
|
||||
visit::walk_view_item(self, view_item, ())
|
||||
}
|
||||
|
||||
fn visit_item(@mut self, item: @ast::item, _: ()) {
|
||||
visit::visit_item(self as @mut Visitor<()>, item, ())
|
||||
fn visit_item(&mut self, item: @ast::item, _: ()) {
|
||||
visit::walk_item(self, item, ())
|
||||
}
|
||||
|
||||
fn visit_foreign_item(@mut self,
|
||||
fn visit_foreign_item(&mut self,
|
||||
foreign_item: @ast::foreign_item,
|
||||
_: ()) {
|
||||
visit::visit_foreign_item(self as @mut Visitor<()>, foreign_item, ())
|
||||
visit::walk_foreign_item(self, foreign_item, ())
|
||||
}
|
||||
|
||||
fn visit_local(@mut self, local: @ast::Local, _: ()) {
|
||||
visit::visit_local(self as @mut Visitor<()>, local, ())
|
||||
fn visit_local(&mut self, local: @ast::Local, _: ()) {
|
||||
visit::walk_local(self, local, ())
|
||||
}
|
||||
|
||||
fn visit_block(@mut self, block: &ast::Block, _: ()) {
|
||||
visit::visit_block(self as @mut Visitor<()>, block, ())
|
||||
fn visit_block(&mut self, block: &ast::Block, _: ()) {
|
||||
visit::walk_block(self, block, ())
|
||||
}
|
||||
|
||||
fn visit_stmt(@mut self, stmt: @ast::stmt, _: ()) {
|
||||
visit::visit_stmt(self as @mut Visitor<()>, stmt, ())
|
||||
fn visit_stmt(&mut self, stmt: @ast::stmt, _: ()) {
|
||||
visit::walk_stmt(self, stmt, ())
|
||||
}
|
||||
|
||||
fn visit_arm(@mut self, arm: &ast::arm, _: ()) {
|
||||
visit::visit_arm(self as @mut Visitor<()>, arm, ())
|
||||
fn visit_arm(&mut self, arm: &ast::arm, _: ()) {
|
||||
visit::walk_arm(self, arm, ())
|
||||
}
|
||||
|
||||
fn visit_decl(@mut self, decl: @ast::decl, _: ()) {
|
||||
visit::visit_decl(self as @mut Visitor<()>, decl, ())
|
||||
fn visit_decl(&mut self, decl: @ast::decl, _: ()) {
|
||||
visit::walk_decl(self, decl, ())
|
||||
}
|
||||
|
||||
fn visit_expr(@mut self, expr: @ast::expr, _: ()) {
|
||||
visit::visit_expr(self as @mut Visitor<()>, expr, ())
|
||||
fn visit_expr(&mut self, expr: @ast::expr, _: ()) {
|
||||
visit::walk_expr(self, expr, ())
|
||||
}
|
||||
|
||||
fn visit_expr_post(@mut self, _: @ast::expr, _: ()) {
|
||||
fn visit_expr_post(&mut self, _: @ast::expr, _: ()) {
|
||||
// Empty!
|
||||
}
|
||||
|
||||
fn visit_ty(@mut self, typ: &ast::Ty, _: ()) {
|
||||
visit::visit_ty(self as @mut Visitor<()>, typ, ())
|
||||
fn visit_ty(&mut self, typ: &ast::Ty, _: ()) {
|
||||
visit::walk_ty(self, typ, ())
|
||||
}
|
||||
|
||||
fn visit_generics(@mut self, generics: &ast::Generics, _: ()) {
|
||||
visit::visit_generics(self as @mut Visitor<()>, generics, ())
|
||||
fn visit_generics(&mut self, generics: &ast::Generics, _: ()) {
|
||||
visit::walk_generics(self, generics, ())
|
||||
}
|
||||
|
||||
fn visit_fn(@mut self,
|
||||
fn visit_fn(&mut self,
|
||||
function_kind: &visit::fn_kind,
|
||||
function_declaration: &ast::fn_decl,
|
||||
block: &ast::Block,
|
||||
span: span,
|
||||
node_id: NodeId,
|
||||
_: ()) {
|
||||
visit::visit_fn(self as @mut Visitor<()>,
|
||||
visit::walk_fn(self,
|
||||
function_kind,
|
||||
function_declaration,
|
||||
block,
|
||||
|
|
@ -624,23 +624,23 @@ impl Visitor<()> for NewNameFinderContext {
|
|||
())
|
||||
}
|
||||
|
||||
fn visit_ty_method(@mut self, ty_method: &ast::TypeMethod, _: ()) {
|
||||
visit::visit_ty_method(self as @mut Visitor<()>, ty_method, ())
|
||||
fn visit_ty_method(&mut self, ty_method: &ast::TypeMethod, _: ()) {
|
||||
visit::walk_ty_method(self, ty_method, ())
|
||||
}
|
||||
|
||||
fn visit_trait_method(@mut self,
|
||||
fn visit_trait_method(&mut self,
|
||||
trait_method: &ast::trait_method,
|
||||
_: ()) {
|
||||
visit::visit_trait_method(self as @mut Visitor<()>, trait_method, ())
|
||||
visit::walk_trait_method(self, trait_method, ())
|
||||
}
|
||||
|
||||
fn visit_struct_def(@mut self,
|
||||
fn visit_struct_def(&mut self,
|
||||
struct_def: @ast::struct_def,
|
||||
ident: ident,
|
||||
generics: &ast::Generics,
|
||||
node_id: NodeId,
|
||||
_: ()) {
|
||||
visit::visit_struct_def(self as @mut Visitor<()>,
|
||||
visit::walk_struct_def(self,
|
||||
struct_def,
|
||||
ident,
|
||||
generics,
|
||||
|
|
@ -648,10 +648,10 @@ impl Visitor<()> for NewNameFinderContext {
|
|||
())
|
||||
}
|
||||
|
||||
fn visit_struct_field(@mut self,
|
||||
fn visit_struct_field(&mut self,
|
||||
struct_field: @ast::struct_field,
|
||||
_: ()) {
|
||||
visit::visit_struct_field(self as @mut Visitor<()>, struct_field, ())
|
||||
visit::walk_struct_field(self, struct_field, ())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -66,33 +66,97 @@ pub fn generics_of_fn(fk: &fn_kind) -> Generics {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait Visitor<E> {
|
||||
fn visit_mod(@mut self, &_mod, span, NodeId, E);
|
||||
fn visit_view_item(@mut self, &view_item, E);
|
||||
fn visit_foreign_item(@mut self, @foreign_item, E);
|
||||
fn visit_item(@mut self, @item, E);
|
||||
fn visit_local(@mut self, @Local, E);
|
||||
fn visit_block(@mut self, &Block, E);
|
||||
fn visit_stmt(@mut self, @stmt, E);
|
||||
fn visit_arm(@mut self, &arm, E);
|
||||
fn visit_pat(@mut self, @pat, E);
|
||||
fn visit_decl(@mut self, @decl, E);
|
||||
fn visit_expr(@mut self, @expr, E);
|
||||
fn visit_expr_post(@mut self, @expr, E);
|
||||
fn visit_ty(@mut self, &Ty, E);
|
||||
fn visit_generics(@mut self, &Generics, E);
|
||||
fn visit_fn(@mut self, &fn_kind, &fn_decl, &Block, span, NodeId, E);
|
||||
fn visit_ty_method(@mut self, &TypeMethod, E);
|
||||
fn visit_trait_method(@mut self, &trait_method, E);
|
||||
fn visit_struct_def(@mut self, @struct_def, ident, &Generics, NodeId, E);
|
||||
fn visit_struct_field(@mut self, @struct_field, E);
|
||||
pub trait Visitor<E:Clone> {
|
||||
fn visit_mod(&mut self, m:&_mod, _s:span, _n:NodeId, e:E) { walk_mod(self, m, e) }
|
||||
fn visit_view_item(&mut self, i:&view_item, e:E) { walk_view_item(self, i, e) }
|
||||
fn visit_foreign_item(&mut self, i:@foreign_item, e:E) { walk_foreign_item(self, i, e) }
|
||||
fn visit_item(&mut self, i:@item, e:E) { walk_item(self, i, e) }
|
||||
fn visit_local(&mut self, l:@Local, e:E) { walk_local(self, l, e) }
|
||||
fn visit_block(&mut self, b:&Block, e:E) { walk_block(self, b, e) }
|
||||
fn visit_stmt(&mut self, s:@stmt, e:E) { walk_stmt(self, s, e) }
|
||||
fn visit_arm(&mut self, a:&arm, e:E) { walk_arm(self, a, e) }
|
||||
fn visit_pat(&mut self, p:@pat, e:E) { walk_pat(self, p, e) }
|
||||
fn visit_decl(&mut self, d:@decl, e:E) { walk_decl(self, d, e) }
|
||||
fn visit_expr(&mut self, ex:@expr, e:E) { walk_expr(self, ex, e) }
|
||||
fn visit_expr_post(&mut self, _ex:@expr, _e:E) { }
|
||||
fn visit_ty(&mut self, _t:&Ty, _e:E) { }
|
||||
fn visit_generics(&mut self, g:&Generics, e:E) { walk_generics(self, g, e) }
|
||||
fn visit_fn(&mut self, fk:&fn_kind, fd:&fn_decl, b:&Block, s:span, n:NodeId, e:E) {
|
||||
walk_fn(self, fk, fd, b, s, n , e)
|
||||
}
|
||||
fn visit_ty_method(&mut self, t:&TypeMethod, e:E) { walk_ty_method(self, t, e) }
|
||||
fn visit_trait_method(&mut self, t:&trait_method, e:E) { walk_trait_method(self, t, e) }
|
||||
fn visit_struct_def(&mut self, s:@struct_def, i:ident, g:&Generics, n:NodeId, e:E) {
|
||||
walk_struct_def(self, s, i, g, n, e)
|
||||
}
|
||||
fn visit_struct_field(&mut self, s:@struct_field, e:E) { walk_struct_field(self, s, e) }
|
||||
}
|
||||
|
||||
pub fn visit_crate<E:Clone>(visitor: @mut Visitor<E>, crate: &Crate, env: E) {
|
||||
impl<E:Clone> Visitor<E> for @mut Visitor<E> {
|
||||
fn visit_mod(&mut self, a:&_mod, b:span, c:NodeId, e:E) {
|
||||
(*self).visit_mod(a, b, c, e)
|
||||
}
|
||||
fn visit_view_item(&mut self, a:&view_item, e:E) {
|
||||
(*self).visit_view_item(a, e)
|
||||
}
|
||||
fn visit_foreign_item(&mut self, a:@foreign_item, e:E) {
|
||||
(*self).visit_foreign_item(a, e)
|
||||
}
|
||||
fn visit_item(&mut self, a:@item, e:E) {
|
||||
(*self).visit_item(a, e)
|
||||
}
|
||||
fn visit_local(&mut self, a:@Local, e:E) {
|
||||
(*self).visit_local(a, e)
|
||||
}
|
||||
fn visit_block(&mut self, a:&Block, e:E) {
|
||||
(*self).visit_block(a, e)
|
||||
}
|
||||
fn visit_stmt(&mut self, a:@stmt, e:E) {
|
||||
(*self).visit_stmt(a, e)
|
||||
}
|
||||
fn visit_arm(&mut self, a:&arm, e:E) {
|
||||
(*self).visit_arm(a, e)
|
||||
}
|
||||
fn visit_pat(&mut self, a:@pat, e:E) {
|
||||
(*self).visit_pat(a, e)
|
||||
}
|
||||
fn visit_decl(&mut self, a:@decl, e:E) {
|
||||
(*self).visit_decl(a, e)
|
||||
}
|
||||
fn visit_expr(&mut self, a:@expr, e:E) {
|
||||
(*self).visit_expr(a, e)
|
||||
}
|
||||
fn visit_expr_post(&mut self, a:@expr, e:E) {
|
||||
(*self).visit_expr_post(a, e)
|
||||
}
|
||||
fn visit_ty(&mut self, a:&Ty, e:E) {
|
||||
(*self).visit_ty(a, e)
|
||||
}
|
||||
fn visit_generics(&mut self, a:&Generics, e:E) {
|
||||
(*self).visit_generics(a, e)
|
||||
}
|
||||
fn visit_fn(&mut self, a:&fn_kind, b:&fn_decl, c:&Block, d:span, f:NodeId, e:E) {
|
||||
(*self).visit_fn(a, b, c, d, f, e)
|
||||
}
|
||||
fn visit_ty_method(&mut self, a:&TypeMethod, e:E) {
|
||||
(*self).visit_ty_method(a, e)
|
||||
}
|
||||
fn visit_trait_method(&mut self, a:&trait_method, e:E) {
|
||||
(*self).visit_trait_method(a, e)
|
||||
}
|
||||
fn visit_struct_def(&mut self, a:@struct_def, b:ident, c:&Generics, d:NodeId, e:E) {
|
||||
(*self).visit_struct_def(a, b, c, d, e)
|
||||
}
|
||||
fn visit_struct_field(&mut self, a:@struct_field, e:E) {
|
||||
(*self).visit_struct_field(a, e)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn walk_crate<E:Clone, V:Visitor<E>>(visitor: &mut V, crate: &Crate, env: E) {
|
||||
visitor.visit_mod(&crate.module, crate.span, CRATE_NODE_ID, env)
|
||||
}
|
||||
|
||||
pub fn visit_mod<E:Clone>(visitor: @mut Visitor<E>, module: &_mod, env: E) {
|
||||
pub fn walk_mod<E:Clone, V:Visitor<E>>(visitor: &mut V, module: &_mod, env: E) {
|
||||
for view_item in module.view_items.iter() {
|
||||
visitor.visit_view_item(view_item, env.clone())
|
||||
}
|
||||
|
|
@ -101,11 +165,11 @@ pub fn visit_mod<E:Clone>(visitor: @mut Visitor<E>, module: &_mod, env: E) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn visit_view_item<E:Clone>(_: @mut Visitor<E>, _: &view_item, _: E) {
|
||||
pub fn walk_view_item<E:Clone, V:Visitor<E>>(_: &mut V, _: &view_item, _: E) {
|
||||
// Empty!
|
||||
}
|
||||
|
||||
pub fn visit_local<E:Clone>(visitor: @mut Visitor<E>, local: &Local, env: E) {
|
||||
pub fn walk_local<E:Clone, V:Visitor<E>>(visitor: &mut V, local: &Local, env: E) {
|
||||
visitor.visit_pat(local.pat, env.clone());
|
||||
visitor.visit_ty(&local.ty, env.clone());
|
||||
match local.init {
|
||||
|
|
@ -114,13 +178,13 @@ pub fn visit_local<E:Clone>(visitor: @mut Visitor<E>, local: &Local, env: E) {
|
|||
}
|
||||
}
|
||||
|
||||
fn visit_trait_ref<E:Clone>(visitor: @mut Visitor<E>,
|
||||
fn walk_trait_ref<E:Clone, V:Visitor<E>>(visitor: &mut V,
|
||||
trait_ref: &ast::trait_ref,
|
||||
env: E) {
|
||||
visit_path(visitor, &trait_ref.path, env)
|
||||
walk_path(visitor, &trait_ref.path, env)
|
||||
}
|
||||
|
||||
pub fn visit_item<E:Clone>(visitor: @mut Visitor<E>, item: &item, env: E) {
|
||||
pub fn walk_item<E:Clone, V:Visitor<E>>(visitor: &mut V, item: &item, env: E) {
|
||||
match item.node {
|
||||
item_static(ref typ, _, expr) => {
|
||||
visitor.visit_ty(typ, env.clone());
|
||||
|
|
@ -151,7 +215,7 @@ pub fn visit_item<E:Clone>(visitor: @mut Visitor<E>, item: &item, env: E) {
|
|||
}
|
||||
item_enum(ref enum_definition, ref type_parameters) => {
|
||||
visitor.visit_generics(type_parameters, env.clone());
|
||||
visit_enum_def(visitor, enum_definition, type_parameters, env)
|
||||
walk_enum_def(visitor, enum_definition, type_parameters, env)
|
||||
}
|
||||
item_impl(ref type_parameters,
|
||||
ref trait_references,
|
||||
|
|
@ -159,11 +223,11 @@ pub fn visit_item<E:Clone>(visitor: @mut Visitor<E>, item: &item, env: E) {
|
|||
ref methods) => {
|
||||
visitor.visit_generics(type_parameters, env.clone());
|
||||
for trait_reference in trait_references.iter() {
|
||||
visit_trait_ref(visitor, trait_reference, env.clone())
|
||||
walk_trait_ref(visitor, trait_reference, env.clone())
|
||||
}
|
||||
visitor.visit_ty(typ, env.clone());
|
||||
for method in methods.iter() {
|
||||
visit_method_helper(visitor, *method, env.clone())
|
||||
walk_method_helper(visitor, *method, env.clone())
|
||||
}
|
||||
}
|
||||
item_struct(struct_definition, ref generics) => {
|
||||
|
|
@ -177,17 +241,17 @@ pub fn visit_item<E:Clone>(visitor: @mut Visitor<E>, item: &item, env: E) {
|
|||
item_trait(ref generics, ref trait_paths, ref methods) => {
|
||||
visitor.visit_generics(generics, env.clone());
|
||||
for trait_path in trait_paths.iter() {
|
||||
visit_path(visitor, &trait_path.path, env.clone())
|
||||
walk_path(visitor, &trait_path.path, env.clone())
|
||||
}
|
||||
for method in methods.iter() {
|
||||
visitor.visit_trait_method(method, env.clone())
|
||||
}
|
||||
}
|
||||
item_mac(ref macro) => visit_mac(visitor, macro, env),
|
||||
item_mac(ref macro) => walk_mac(visitor, macro, env),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn visit_enum_def<E:Clone>(visitor: @mut Visitor<E>,
|
||||
pub fn walk_enum_def<E:Clone, V:Visitor<E>>(visitor: &mut V,
|
||||
enum_definition: &ast::enum_def,
|
||||
generics: &Generics,
|
||||
env: E) {
|
||||
|
|
@ -209,11 +273,11 @@ pub fn visit_enum_def<E:Clone>(visitor: @mut Visitor<E>,
|
|||
}
|
||||
}
|
||||
|
||||
pub fn skip_ty<E>(_: @mut Visitor<E>, _: &Ty, _: E) {
|
||||
pub fn skip_ty<E, V:Visitor<E>>(_: &mut V, _: &Ty, _: E) {
|
||||
// Empty!
|
||||
}
|
||||
|
||||
pub fn visit_ty<E:Clone>(visitor: @mut Visitor<E>, typ: &Ty, env: E) {
|
||||
pub fn walk_ty<E:Clone, V:Visitor<E>>(visitor: &mut V, typ: &Ty, env: E) {
|
||||
match typ.node {
|
||||
ty_box(ref mutable_type) | ty_uniq(ref mutable_type) |
|
||||
ty_vec(ref mutable_type) | ty_ptr(ref mutable_type) |
|
||||
|
|
@ -231,7 +295,7 @@ pub fn visit_ty<E:Clone>(visitor: @mut Visitor<E>, typ: &Ty, env: E) {
|
|||
}
|
||||
visitor.visit_ty(&function_declaration.decl.output, env.clone());
|
||||
for bounds in function_declaration.bounds.iter() {
|
||||
visit_ty_param_bounds(visitor, bounds, env.clone())
|
||||
walk_ty_param_bounds(visitor, bounds, env.clone())
|
||||
}
|
||||
}
|
||||
ty_bare_fn(ref function_declaration) => {
|
||||
|
|
@ -241,9 +305,9 @@ pub fn visit_ty<E:Clone>(visitor: @mut Visitor<E>, typ: &Ty, env: E) {
|
|||
visitor.visit_ty(&function_declaration.decl.output, env.clone())
|
||||
}
|
||||
ty_path(ref path, ref bounds, _) => {
|
||||
visit_path(visitor, path, env.clone());
|
||||
walk_path(visitor, path, env.clone());
|
||||
for bounds in bounds.iter() {
|
||||
visit_ty_param_bounds(visitor, bounds, env.clone())
|
||||
walk_ty_param_bounds(visitor, bounds, env.clone())
|
||||
}
|
||||
}
|
||||
ty_fixed_length_vec(ref mutable_type, expression) => {
|
||||
|
|
@ -254,16 +318,16 @@ pub fn visit_ty<E:Clone>(visitor: @mut Visitor<E>, typ: &Ty, env: E) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn visit_path<E:Clone>(visitor: @mut Visitor<E>, path: &Path, env: E) {
|
||||
pub fn walk_path<E:Clone, V:Visitor<E>>(visitor: &mut V, path: &Path, env: E) {
|
||||
for typ in path.types.iter() {
|
||||
visitor.visit_ty(typ, env.clone())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn visit_pat<E:Clone>(visitor: @mut Visitor<E>, pattern: &pat, env: E) {
|
||||
pub fn walk_pat<E:Clone, V:Visitor<E>>(visitor: &mut V, pattern: &pat, env: E) {
|
||||
match pattern.node {
|
||||
pat_enum(ref path, ref children) => {
|
||||
visit_path(visitor, path, env.clone());
|
||||
walk_path(visitor, path, env.clone());
|
||||
for children in children.iter() {
|
||||
for child in children.iter() {
|
||||
visitor.visit_pat(*child, env.clone())
|
||||
|
|
@ -271,7 +335,7 @@ pub fn visit_pat<E:Clone>(visitor: @mut Visitor<E>, pattern: &pat, env: E) {
|
|||
}
|
||||
}
|
||||
pat_struct(ref path, ref fields, _) => {
|
||||
visit_path(visitor, path, env.clone());
|
||||
walk_path(visitor, path, env.clone());
|
||||
for field in fields.iter() {
|
||||
visitor.visit_pat(field.pat, env.clone())
|
||||
}
|
||||
|
|
@ -287,7 +351,7 @@ pub fn visit_pat<E:Clone>(visitor: @mut Visitor<E>, pattern: &pat, env: E) {
|
|||
visitor.visit_pat(subpattern, env)
|
||||
}
|
||||
pat_ident(_, ref path, ref optional_subpattern) => {
|
||||
visit_path(visitor, path, env.clone());
|
||||
walk_path(visitor, path, env.clone());
|
||||
match *optional_subpattern {
|
||||
None => {}
|
||||
Some(subpattern) => visitor.visit_pat(subpattern, env),
|
||||
|
|
@ -313,40 +377,40 @@ pub fn visit_pat<E:Clone>(visitor: @mut Visitor<E>, pattern: &pat, env: E) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn visit_foreign_item<E:Clone>(visitor: @mut Visitor<E>,
|
||||
pub fn walk_foreign_item<E:Clone, V:Visitor<E>>(visitor: &mut V,
|
||||
foreign_item: &foreign_item,
|
||||
env: E) {
|
||||
match foreign_item.node {
|
||||
foreign_item_fn(ref function_declaration, ref generics) => {
|
||||
visit_fn_decl(visitor, function_declaration, env.clone());
|
||||
walk_fn_decl(visitor, function_declaration, env.clone());
|
||||
visitor.visit_generics(generics, env)
|
||||
}
|
||||
foreign_item_static(ref typ, _) => visitor.visit_ty(typ, env),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn visit_ty_param_bounds<E:Clone>(visitor: @mut Visitor<E>,
|
||||
pub fn walk_ty_param_bounds<E:Clone, V:Visitor<E>>(visitor: &mut V,
|
||||
bounds: &OptVec<TyParamBound>,
|
||||
env: E) {
|
||||
for bound in bounds.iter() {
|
||||
match *bound {
|
||||
TraitTyParamBound(ref typ) => {
|
||||
visit_trait_ref(visitor, typ, env.clone())
|
||||
walk_trait_ref(visitor, typ, env.clone())
|
||||
}
|
||||
RegionTyParamBound => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn visit_generics<E:Clone>(visitor: @mut Visitor<E>,
|
||||
pub fn walk_generics<E:Clone, V:Visitor<E>>(visitor: &mut V,
|
||||
generics: &Generics,
|
||||
env: E) {
|
||||
for type_parameter in generics.ty_params.iter() {
|
||||
visit_ty_param_bounds(visitor, &type_parameter.bounds, env.clone())
|
||||
walk_ty_param_bounds(visitor, &type_parameter.bounds, env.clone())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn visit_fn_decl<E:Clone>(visitor: @mut Visitor<E>,
|
||||
pub fn walk_fn_decl<E:Clone, V:Visitor<E>>(visitor: &mut V,
|
||||
function_declaration: &fn_decl,
|
||||
env: E) {
|
||||
for argument in function_declaration.inputs.iter() {
|
||||
|
|
@ -360,7 +424,7 @@ pub fn visit_fn_decl<E:Clone>(visitor: @mut Visitor<E>,
|
|||
// visit_fn() and check for fk_method(). I named this visit_method_helper()
|
||||
// because it is not a default impl of any method, though I doubt that really
|
||||
// clarifies anything. - Niko
|
||||
pub fn visit_method_helper<E:Clone>(visitor: @mut Visitor<E>,
|
||||
pub fn walk_method_helper<E:Clone, V:Visitor<E>>(visitor: &mut V,
|
||||
method: &method,
|
||||
env: E) {
|
||||
visitor.visit_fn(&fk_method(method.ident, &method.generics, method),
|
||||
|
|
@ -371,20 +435,20 @@ pub fn visit_method_helper<E:Clone>(visitor: @mut Visitor<E>,
|
|||
env)
|
||||
}
|
||||
|
||||
pub fn visit_fn<E:Clone>(visitor: @mut Visitor<E>,
|
||||
pub fn walk_fn<E:Clone, V:Visitor<E>>(visitor: &mut V,
|
||||
function_kind: &fn_kind,
|
||||
function_declaration: &fn_decl,
|
||||
function_body: &Block,
|
||||
_: span,
|
||||
_: NodeId,
|
||||
env: E) {
|
||||
visit_fn_decl(visitor, function_declaration, env.clone());
|
||||
walk_fn_decl(visitor, function_declaration, env.clone());
|
||||
let generics = generics_of_fn(function_kind);
|
||||
visitor.visit_generics(&generics, env.clone());
|
||||
visitor.visit_block(function_body, env)
|
||||
}
|
||||
|
||||
pub fn visit_ty_method<E:Clone>(visitor: @mut Visitor<E>,
|
||||
pub fn walk_ty_method<E:Clone, V:Visitor<E>>(visitor: &mut V,
|
||||
method_type: &TypeMethod,
|
||||
env: E) {
|
||||
for argument_type in method_type.decl.inputs.iter() {
|
||||
|
|
@ -394,18 +458,18 @@ pub fn visit_ty_method<E:Clone>(visitor: @mut Visitor<E>,
|
|||
visitor.visit_ty(&method_type.decl.output, env.clone())
|
||||
}
|
||||
|
||||
pub fn visit_trait_method<E:Clone>(visitor: @mut Visitor<E>,
|
||||
pub fn walk_trait_method<E:Clone, V:Visitor<E>>(visitor: &mut V,
|
||||
trait_method: &trait_method,
|
||||
env: E) {
|
||||
match *trait_method {
|
||||
required(ref method_type) => {
|
||||
visitor.visit_ty_method(method_type, env)
|
||||
}
|
||||
provided(method) => visit_method_helper(visitor, method, env),
|
||||
provided(method) => walk_method_helper(visitor, method, env),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn visit_struct_def<E:Clone>(visitor: @mut Visitor<E>,
|
||||
pub fn walk_struct_def<E:Clone, V:Visitor<E>>(visitor: &mut V,
|
||||
struct_definition: @struct_def,
|
||||
_: ast::ident,
|
||||
_: &Generics,
|
||||
|
|
@ -416,40 +480,40 @@ pub fn visit_struct_def<E:Clone>(visitor: @mut Visitor<E>,
|
|||
}
|
||||
}
|
||||
|
||||
pub fn visit_struct_field<E:Clone>(visitor: @mut Visitor<E>,
|
||||
pub fn walk_struct_field<E:Clone, V:Visitor<E>>(visitor: &mut V,
|
||||
struct_field: &struct_field,
|
||||
env: E) {
|
||||
visitor.visit_ty(&struct_field.node.ty, env)
|
||||
}
|
||||
|
||||
pub fn visit_block<E:Clone>(visitor: @mut Visitor<E>, block: &Block, env: E) {
|
||||
pub fn walk_block<E:Clone, V:Visitor<E>>(visitor: &mut V, block: &Block, env: E) {
|
||||
for view_item in block.view_items.iter() {
|
||||
visitor.visit_view_item(view_item, env.clone())
|
||||
}
|
||||
for statement in block.stmts.iter() {
|
||||
visitor.visit_stmt(*statement, env.clone())
|
||||
}
|
||||
visit_expr_opt(visitor, block.expr, env)
|
||||
walk_expr_opt(visitor, block.expr, env)
|
||||
}
|
||||
|
||||
pub fn visit_stmt<E>(visitor: @mut Visitor<E>, statement: &stmt, env: E) {
|
||||
pub fn walk_stmt<E:Clone, V:Visitor<E>>(visitor: &mut V, statement: &stmt, env: E) {
|
||||
match statement.node {
|
||||
stmt_decl(declaration, _) => visitor.visit_decl(declaration, env),
|
||||
stmt_expr(expression, _) | stmt_semi(expression, _) => {
|
||||
visitor.visit_expr(expression, env)
|
||||
}
|
||||
stmt_mac(ref macro, _) => visit_mac(visitor, macro, env),
|
||||
stmt_mac(ref macro, _) => walk_mac(visitor, macro, env),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn visit_decl<E:Clone>(visitor: @mut Visitor<E>, declaration: &decl, env: E) {
|
||||
pub fn walk_decl<E:Clone, V:Visitor<E>>(visitor: &mut V, declaration: &decl, env: E) {
|
||||
match declaration.node {
|
||||
decl_local(ref local) => visitor.visit_local(*local, env),
|
||||
decl_item(item) => visitor.visit_item(item, env),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn visit_expr_opt<E>(visitor: @mut Visitor<E>,
|
||||
pub fn walk_expr_opt<E:Clone, V:Visitor<E>>(visitor: &mut V,
|
||||
optional_expression: Option<@expr>,
|
||||
env: E) {
|
||||
match optional_expression {
|
||||
|
|
@ -458,7 +522,7 @@ pub fn visit_expr_opt<E>(visitor: @mut Visitor<E>,
|
|||
}
|
||||
}
|
||||
|
||||
pub fn visit_exprs<E:Clone>(visitor: @mut Visitor<E>,
|
||||
pub fn walk_exprs<E:Clone, V:Visitor<E>>(visitor: &mut V,
|
||||
expressions: &[@expr],
|
||||
env: E) {
|
||||
for expression in expressions.iter() {
|
||||
|
|
@ -466,28 +530,28 @@ pub fn visit_exprs<E:Clone>(visitor: @mut Visitor<E>,
|
|||
}
|
||||
}
|
||||
|
||||
pub fn visit_mac<E>(_: @mut Visitor<E>, _: &mac, _: E) {
|
||||
pub fn walk_mac<E, V:Visitor<E>>(_: &mut V, _: &mac, _: E) {
|
||||
// Empty!
|
||||
}
|
||||
|
||||
pub fn visit_expr<E:Clone>(visitor: @mut Visitor<E>, expression: @expr, env: E) {
|
||||
pub fn walk_expr<E:Clone, V:Visitor<E>>(visitor: &mut V, expression: @expr, env: E) {
|
||||
match expression.node {
|
||||
expr_vstore(subexpression, _) => {
|
||||
visitor.visit_expr(subexpression, env.clone())
|
||||
}
|
||||
expr_vec(ref subexpressions, _) => {
|
||||
visit_exprs(visitor, *subexpressions, env.clone())
|
||||
walk_exprs(visitor, *subexpressions, env.clone())
|
||||
}
|
||||
expr_repeat(element, count, _) => {
|
||||
visitor.visit_expr(element, env.clone());
|
||||
visitor.visit_expr(count, env.clone())
|
||||
}
|
||||
expr_struct(ref path, ref fields, optional_base) => {
|
||||
visit_path(visitor, path, env.clone());
|
||||
walk_path(visitor, path, env.clone());
|
||||
for field in fields.iter() {
|
||||
visitor.visit_expr(field.expr, env.clone())
|
||||
}
|
||||
visit_expr_opt(visitor, optional_base, env.clone())
|
||||
walk_expr_opt(visitor, optional_base, env.clone())
|
||||
}
|
||||
expr_tup(ref subexpressions) => {
|
||||
for subexpression in subexpressions.iter() {
|
||||
|
|
@ -501,7 +565,7 @@ pub fn visit_expr<E:Clone>(visitor: @mut Visitor<E>, expression: @expr, env: E)
|
|||
visitor.visit_expr(callee_expression, env.clone())
|
||||
}
|
||||
expr_method_call(_, callee, _, ref types, ref arguments, _) => {
|
||||
visit_exprs(visitor, *arguments, env.clone());
|
||||
walk_exprs(visitor, *arguments, env.clone());
|
||||
for typ in types.iter() {
|
||||
visitor.visit_ty(typ, env.clone())
|
||||
}
|
||||
|
|
@ -524,7 +588,7 @@ pub fn visit_expr<E:Clone>(visitor: @mut Visitor<E>, expression: @expr, env: E)
|
|||
expr_if(head_expression, ref if_block, optional_else) => {
|
||||
visitor.visit_expr(head_expression, env.clone());
|
||||
visitor.visit_block(if_block, env.clone());
|
||||
visit_expr_opt(visitor, optional_else, env.clone())
|
||||
walk_expr_opt(visitor, optional_else, env.clone())
|
||||
}
|
||||
expr_while(subexpression, ref block) => {
|
||||
visitor.visit_expr(subexpression, env.clone());
|
||||
|
|
@ -569,16 +633,16 @@ pub fn visit_expr<E:Clone>(visitor: @mut Visitor<E>, expression: @expr, env: E)
|
|||
visitor.visit_expr(main_expression, env.clone());
|
||||
visitor.visit_expr(index_expression, env.clone())
|
||||
}
|
||||
expr_path(ref path) => visit_path(visitor, path, env.clone()),
|
||||
expr_path(ref path) => walk_path(visitor, path, env.clone()),
|
||||
expr_self | expr_break(_) | expr_again(_) => {}
|
||||
expr_ret(optional_expression) => {
|
||||
visit_expr_opt(visitor, optional_expression, env.clone())
|
||||
walk_expr_opt(visitor, optional_expression, env.clone())
|
||||
}
|
||||
expr_log(level, subexpression) => {
|
||||
visitor.visit_expr(level, env.clone());
|
||||
visitor.visit_expr(subexpression, env.clone());
|
||||
}
|
||||
expr_mac(ref macro) => visit_mac(visitor, macro, env.clone()),
|
||||
expr_mac(ref macro) => walk_mac(visitor, macro, env.clone()),
|
||||
expr_paren(subexpression) => {
|
||||
visitor.visit_expr(subexpression, env.clone())
|
||||
}
|
||||
|
|
@ -595,11 +659,11 @@ pub fn visit_expr<E:Clone>(visitor: @mut Visitor<E>, expression: @expr, env: E)
|
|||
visitor.visit_expr_post(expression, env.clone())
|
||||
}
|
||||
|
||||
pub fn visit_arm<E:Clone>(visitor: @mut Visitor<E>, arm: &arm, env: E) {
|
||||
pub fn walk_arm<E:Clone, V:Visitor<E>>(visitor: &mut V, arm: &arm, env: E) {
|
||||
for pattern in arm.pats.iter() {
|
||||
visitor.visit_pat(*pattern, env.clone())
|
||||
}
|
||||
visit_expr_opt(visitor, arm.guard, env.clone());
|
||||
walk_expr_opt(visitor, arm.guard, env.clone());
|
||||
visitor.visit_block(&arm.body, env)
|
||||
}
|
||||
|
||||
|
|
@ -607,26 +671,26 @@ pub fn visit_arm<E:Clone>(visitor: @mut Visitor<E>, arm: &arm, env: E) {
|
|||
// calls the given functions on the nodes.
|
||||
|
||||
pub trait SimpleVisitor {
|
||||
fn visit_mod(@mut self, &_mod, span, NodeId);
|
||||
fn visit_view_item(@mut self, &view_item);
|
||||
fn visit_foreign_item(@mut self, @foreign_item);
|
||||
fn visit_item(@mut self, @item);
|
||||
fn visit_local(@mut self, @Local);
|
||||
fn visit_block(@mut self, &Block);
|
||||
fn visit_stmt(@mut self, @stmt);
|
||||
fn visit_arm(@mut self, &arm);
|
||||
fn visit_pat(@mut self, @pat);
|
||||
fn visit_decl(@mut self, @decl);
|
||||
fn visit_expr(@mut self, @expr);
|
||||
fn visit_expr_post(@mut self, @expr);
|
||||
fn visit_ty(@mut self, &Ty);
|
||||
fn visit_generics(@mut self, &Generics);
|
||||
fn visit_fn(@mut self, &fn_kind, &fn_decl, &Block, span, NodeId);
|
||||
fn visit_ty_method(@mut self, &TypeMethod);
|
||||
fn visit_trait_method(@mut self, &trait_method);
|
||||
fn visit_struct_def(@mut self, @struct_def, ident, &Generics, NodeId);
|
||||
fn visit_struct_field(@mut self, @struct_field);
|
||||
fn visit_struct_method(@mut self, @method);
|
||||
fn visit_mod(&mut self, &_mod, span, NodeId);
|
||||
fn visit_view_item(&mut self, &view_item);
|
||||
fn visit_foreign_item(&mut self, @foreign_item);
|
||||
fn visit_item(&mut self, @item);
|
||||
fn visit_local(&mut self, @Local);
|
||||
fn visit_block(&mut self, &Block);
|
||||
fn visit_stmt(&mut self, @stmt);
|
||||
fn visit_arm(&mut self, &arm);
|
||||
fn visit_pat(&mut self, @pat);
|
||||
fn visit_decl(&mut self, @decl);
|
||||
fn visit_expr(&mut self, @expr);
|
||||
fn visit_expr_post(&mut self, @expr);
|
||||
fn visit_ty(&mut self, &Ty);
|
||||
fn visit_generics(&mut self, &Generics);
|
||||
fn visit_fn(&mut self, &fn_kind, &fn_decl, &Block, span, NodeId);
|
||||
fn visit_ty_method(&mut self, &TypeMethod);
|
||||
fn visit_trait_method(&mut self, &trait_method);
|
||||
fn visit_struct_def(&mut self, @struct_def, ident, &Generics, NodeId);
|
||||
fn visit_struct_field(&mut self, @struct_field);
|
||||
fn visit_struct_method(&mut self, @method);
|
||||
}
|
||||
|
||||
pub struct SimpleVisitorVisitor {
|
||||
|
|
@ -634,66 +698,66 @@ pub struct SimpleVisitorVisitor {
|
|||
}
|
||||
|
||||
impl Visitor<()> for SimpleVisitorVisitor {
|
||||
fn visit_mod(@mut self,
|
||||
fn visit_mod(&mut self,
|
||||
module: &_mod,
|
||||
span: span,
|
||||
node_id: NodeId,
|
||||
env: ()) {
|
||||
self.simple_visitor.visit_mod(module, span, node_id);
|
||||
visit_mod(self as @mut Visitor<()>, module, env)
|
||||
walk_mod(self, module, env)
|
||||
}
|
||||
fn visit_view_item(@mut self, view_item: &view_item, env: ()) {
|
||||
fn visit_view_item(&mut self, view_item: &view_item, env: ()) {
|
||||
self.simple_visitor.visit_view_item(view_item);
|
||||
visit_view_item(self as @mut Visitor<()>, view_item, env)
|
||||
walk_view_item(self, view_item, env)
|
||||
}
|
||||
fn visit_foreign_item(@mut self, foreign_item: @foreign_item, env: ()) {
|
||||
fn visit_foreign_item(&mut self, foreign_item: @foreign_item, env: ()) {
|
||||
self.simple_visitor.visit_foreign_item(foreign_item);
|
||||
visit_foreign_item(self as @mut Visitor<()>, foreign_item, env)
|
||||
walk_foreign_item(self, foreign_item, env)
|
||||
}
|
||||
fn visit_item(@mut self, item: @item, env: ()) {
|
||||
fn visit_item(&mut self, item: @item, env: ()) {
|
||||
self.simple_visitor.visit_item(item);
|
||||
visit_item(self as @mut Visitor<()>, item, env)
|
||||
walk_item(self, item, env)
|
||||
}
|
||||
fn visit_local(@mut self, local: @Local, env: ()) {
|
||||
fn visit_local(&mut self, local: @Local, env: ()) {
|
||||
self.simple_visitor.visit_local(local);
|
||||
visit_local(self as @mut Visitor<()>, local, env)
|
||||
walk_local(self, local, env)
|
||||
}
|
||||
fn visit_block(@mut self, block: &Block, env: ()) {
|
||||
fn visit_block(&mut self, block: &Block, env: ()) {
|
||||
self.simple_visitor.visit_block(block);
|
||||
visit_block(self as @mut Visitor<()>, block, env)
|
||||
walk_block(self, block, env)
|
||||
}
|
||||
fn visit_stmt(@mut self, statement: @stmt, env: ()) {
|
||||
fn visit_stmt(&mut self, statement: @stmt, env: ()) {
|
||||
self.simple_visitor.visit_stmt(statement);
|
||||
visit_stmt(self as @mut Visitor<()>, statement, env)
|
||||
walk_stmt(self, statement, env)
|
||||
}
|
||||
fn visit_arm(@mut self, arm: &arm, env: ()) {
|
||||
fn visit_arm(&mut self, arm: &arm, env: ()) {
|
||||
self.simple_visitor.visit_arm(arm);
|
||||
visit_arm(self as @mut Visitor<()>, arm, env)
|
||||
walk_arm(self, arm, env)
|
||||
}
|
||||
fn visit_pat(@mut self, pattern: @pat, env: ()) {
|
||||
fn visit_pat(&mut self, pattern: @pat, env: ()) {
|
||||
self.simple_visitor.visit_pat(pattern);
|
||||
visit_pat(self as @mut Visitor<()>, pattern, env)
|
||||
walk_pat(self, pattern, env)
|
||||
}
|
||||
fn visit_decl(@mut self, declaration: @decl, env: ()) {
|
||||
fn visit_decl(&mut self, declaration: @decl, env: ()) {
|
||||
self.simple_visitor.visit_decl(declaration);
|
||||
visit_decl(self as @mut Visitor<()>, declaration, env)
|
||||
walk_decl(self, declaration, env)
|
||||
}
|
||||
fn visit_expr(@mut self, expression: @expr, env: ()) {
|
||||
fn visit_expr(&mut self, expression: @expr, env: ()) {
|
||||
self.simple_visitor.visit_expr(expression);
|
||||
visit_expr(self as @mut Visitor<()>, expression, env)
|
||||
walk_expr(self, expression, env)
|
||||
}
|
||||
fn visit_expr_post(@mut self, expression: @expr, _: ()) {
|
||||
fn visit_expr_post(&mut self, expression: @expr, _: ()) {
|
||||
self.simple_visitor.visit_expr_post(expression)
|
||||
}
|
||||
fn visit_ty(@mut self, typ: &Ty, env: ()) {
|
||||
fn visit_ty(&mut self, typ: &Ty, env: ()) {
|
||||
self.simple_visitor.visit_ty(typ);
|
||||
visit_ty(self as @mut Visitor<()>, typ, env)
|
||||
walk_ty(self, typ, env)
|
||||
}
|
||||
fn visit_generics(@mut self, generics: &Generics, env: ()) {
|
||||
fn visit_generics(&mut self, generics: &Generics, env: ()) {
|
||||
self.simple_visitor.visit_generics(generics);
|
||||
visit_generics(self as @mut Visitor<()>, generics, env)
|
||||
walk_generics(self, generics, env)
|
||||
}
|
||||
fn visit_fn(@mut self,
|
||||
fn visit_fn(&mut self,
|
||||
function_kind: &fn_kind,
|
||||
function_declaration: &fn_decl,
|
||||
block: &Block,
|
||||
|
|
@ -705,7 +769,7 @@ impl Visitor<()> for SimpleVisitorVisitor {
|
|||
block,
|
||||
span,
|
||||
node_id);
|
||||
visit_fn(self as @mut Visitor<()>,
|
||||
walk_fn(self,
|
||||
function_kind,
|
||||
function_declaration,
|
||||
block,
|
||||
|
|
@ -713,15 +777,15 @@ impl Visitor<()> for SimpleVisitorVisitor {
|
|||
node_id,
|
||||
env)
|
||||
}
|
||||
fn visit_ty_method(@mut self, method_type: &TypeMethod, env: ()) {
|
||||
fn visit_ty_method(&mut self, method_type: &TypeMethod, env: ()) {
|
||||
self.simple_visitor.visit_ty_method(method_type);
|
||||
visit_ty_method(self as @mut Visitor<()>, method_type, env)
|
||||
walk_ty_method(self, method_type, env)
|
||||
}
|
||||
fn visit_trait_method(@mut self, trait_method: &trait_method, env: ()) {
|
||||
fn visit_trait_method(&mut self, trait_method: &trait_method, env: ()) {
|
||||
self.simple_visitor.visit_trait_method(trait_method);
|
||||
visit_trait_method(self as @mut Visitor<()>, trait_method, env)
|
||||
walk_trait_method(self, trait_method, env)
|
||||
}
|
||||
fn visit_struct_def(@mut self,
|
||||
fn visit_struct_def(&mut self,
|
||||
struct_definition: @struct_def,
|
||||
identifier: ident,
|
||||
generics: &Generics,
|
||||
|
|
@ -731,16 +795,16 @@ impl Visitor<()> for SimpleVisitorVisitor {
|
|||
identifier,
|
||||
generics,
|
||||
node_id);
|
||||
visit_struct_def(self as @mut Visitor<()>,
|
||||
walk_struct_def(self,
|
||||
struct_definition,
|
||||
identifier,
|
||||
generics,
|
||||
node_id,
|
||||
env)
|
||||
}
|
||||
fn visit_struct_field(@mut self, struct_field: @struct_field, env: ()) {
|
||||
fn visit_struct_field(&mut self, struct_field: @struct_field, env: ()) {
|
||||
self.simple_visitor.visit_struct_field(struct_field);
|
||||
visit_struct_field(self as @mut Visitor<()>, struct_field, env)
|
||||
walk_struct_field(self, struct_field, env)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue