mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-28 15:43:21 +00:00
Switch metadata::encoder to <V:Visitor> trait.
placate make tidy. Remove dead code.
This commit is contained in:
parent
3d83010648
commit
a5a5432f98
@ -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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user