auto merge of #11146 : sfackler/rust/cleanup, r=alexcrichton
I also deleted a test which has apparently not been needed for a very long time.
This commit is contained in:
commit
d975060de6
@ -838,7 +838,7 @@ fn link_rlib(sess: Session,
|
||||
out_filename: &Path) -> Archive {
|
||||
let mut a = Archive::create(sess, out_filename, obj_filename);
|
||||
|
||||
for &(ref l, kind) in cstore::get_used_libraries(sess.cstore).iter() {
|
||||
for &(ref l, kind) in sess.cstore.get_used_libraries().iter() {
|
||||
match kind {
|
||||
cstore::NativeStatic => {
|
||||
a.add_native_library(l.as_slice());
|
||||
@ -912,9 +912,9 @@ fn link_staticlib(sess: Session, obj_filename: &Path, out_filename: &Path) {
|
||||
let mut a = link_rlib(sess, None, obj_filename, out_filename);
|
||||
a.add_native_library("morestack");
|
||||
|
||||
let crates = cstore::get_used_crates(sess.cstore, cstore::RequireStatic);
|
||||
let crates = sess.cstore.get_used_crates(cstore::RequireStatic);
|
||||
for &(cnum, ref path) in crates.iter() {
|
||||
let name = cstore::get_crate_data(sess.cstore, cnum).name;
|
||||
let name = sess.cstore.get_crate_data(cnum).name;
|
||||
let p = match *path {
|
||||
Some(ref p) => p.clone(), None => {
|
||||
sess.err(format!("could not find rlib for: `{}`", name));
|
||||
@ -1072,7 +1072,7 @@ fn link_args(sess: Session,
|
||||
// Finally add all the linker arguments provided on the command line along
|
||||
// with any #[link_args] attributes found inside the crate
|
||||
args.push_all(sess.opts.linker_args);
|
||||
for arg in cstore::get_used_link_args(sess.cstore).iter() {
|
||||
for arg in sess.cstore.get_used_link_args().iter() {
|
||||
args.push(arg.clone());
|
||||
}
|
||||
return args;
|
||||
@ -1101,7 +1101,7 @@ fn add_local_native_libraries(args: &mut ~[~str], sess: Session) {
|
||||
args.push("-L" + path.as_str().unwrap().to_owned());
|
||||
}
|
||||
|
||||
for &(ref l, kind) in cstore::get_used_libraries(sess.cstore).iter() {
|
||||
for &(ref l, kind) in sess.cstore.get_used_libraries().iter() {
|
||||
match kind {
|
||||
cstore::NativeUnknown | cstore::NativeStatic => {
|
||||
args.push("-l" + *l);
|
||||
@ -1143,7 +1143,7 @@ fn add_upstream_rust_crates(args: &mut ~[~str], sess: Session,
|
||||
// all dynamic libaries require dynamic dependencies (see above), so
|
||||
// it's satisfactory to include either all static libraries or all
|
||||
// dynamic libraries.
|
||||
let crates = cstore::get_used_crates(cstore, cstore::RequireStatic);
|
||||
let crates = cstore.get_used_crates(cstore::RequireStatic);
|
||||
if crates.iter().all(|&(_, ref p)| p.is_some()) {
|
||||
for (cnum, path) in crates.move_iter() {
|
||||
let cratepath = path.unwrap();
|
||||
@ -1163,7 +1163,7 @@ fn add_upstream_rust_crates(args: &mut ~[~str], sess: Session,
|
||||
// If we're not doing LTO, then our job is simply to just link
|
||||
// against the archive.
|
||||
if sess.lto() {
|
||||
let name = cstore::get_crate_data(sess.cstore, cnum).name;
|
||||
let name = sess.cstore.get_crate_data(cnum).name;
|
||||
time(sess.time_passes(), format!("altering {}.rlib", name),
|
||||
(), |()| {
|
||||
let dst = tmpdir.join(cratepath.filename().unwrap());
|
||||
@ -1196,13 +1196,13 @@ fn add_upstream_rust_crates(args: &mut ~[~str], sess: Session,
|
||||
// this case is the fallback
|
||||
// * If an executable is being created, and one of the inputs is missing as
|
||||
// a static library, then this is the fallback case.
|
||||
let crates = cstore::get_used_crates(cstore, cstore::RequireDynamic);
|
||||
let crates = cstore.get_used_crates(cstore::RequireDynamic);
|
||||
for &(cnum, ref path) in crates.iter() {
|
||||
let cratepath = match *path {
|
||||
Some(ref p) => p.clone(),
|
||||
None => {
|
||||
sess.err(format!("could not find dynamic library for: `{}`",
|
||||
cstore::get_crate_data(sess.cstore, cnum).name));
|
||||
sess.cstore.get_crate_data(cnum).name));
|
||||
return
|
||||
}
|
||||
};
|
||||
@ -1235,7 +1235,7 @@ fn add_upstream_rust_crates(args: &mut ~[~str], sess: Session,
|
||||
// also be resolved in the target crate.
|
||||
fn add_upstream_native_libraries(args: &mut ~[~str], sess: Session) {
|
||||
let cstore = sess.cstore;
|
||||
cstore::iter_crate_data(cstore, |cnum, _| {
|
||||
cstore.iter_crate_data(|cnum, _| {
|
||||
let libs = csearch::get_native_libraries(cstore, cnum);
|
||||
for &(kind, ref lib) in libs.iter() {
|
||||
match kind {
|
||||
|
@ -33,9 +33,9 @@ pub fn run(sess: session::Session, llmod: ModuleRef,
|
||||
// For each of our upstream dependencies, find the corresponding rlib and
|
||||
// load the bitcode from the archive. Then merge it into the current LLVM
|
||||
// module that we've got.
|
||||
let crates = cstore::get_used_crates(sess.cstore, cstore::RequireStatic);
|
||||
let crates = sess.cstore.get_used_crates(cstore::RequireStatic);
|
||||
for (cnum, path) in crates.move_iter() {
|
||||
let name = cstore::get_crate_data(sess.cstore, cnum).name;
|
||||
let name = sess.cstore.get_crate_data(cnum).name;
|
||||
let path = match path {
|
||||
Some(p) => p,
|
||||
None => {
|
||||
|
@ -41,7 +41,7 @@ pub fn get_rpath_flags(sess: session::Session, out_filename: &Path) -> ~[~str] {
|
||||
|
||||
let sysroot = sess.filesearch.sysroot();
|
||||
let output = out_filename;
|
||||
let libs = cstore::get_used_crates(sess.cstore, cstore::RequireDynamic);
|
||||
let libs = sess.cstore.get_used_crates(cstore::RequireDynamic);
|
||||
let libs = libs.move_iter().filter_map(|(_, l)| l.map(|p| p.clone())).collect();
|
||||
// We don't currently rpath extern libraries, but we know
|
||||
// where rustrt is and we know every rust program needs it
|
||||
|
@ -18,7 +18,8 @@ use front;
|
||||
use lib::llvm::llvm;
|
||||
use lib::llvm::{ContextRef, ModuleRef};
|
||||
use metadata::common::LinkMeta;
|
||||
use metadata::{creader, cstore, filesearch};
|
||||
use metadata::{creader, filesearch};
|
||||
use metadata::cstore::CStore;
|
||||
use metadata;
|
||||
use middle::{trans, freevars, kind, ty, typeck, lint, astencode, reachable};
|
||||
use middle;
|
||||
@ -853,7 +854,7 @@ pub fn build_session_(sopts: @session::options,
|
||||
let target_cfg = build_target_config(sopts, demitter);
|
||||
let p_s = parse::new_parse_sess_special_handler(span_diagnostic_handler,
|
||||
cm);
|
||||
let cstore = @mut cstore::mk_cstore(token::get_ident_interner());
|
||||
let cstore = @mut CStore::new(token::get_ident_interner());
|
||||
let filesearch = filesearch::mk_filesearch(
|
||||
&sopts.maybe_sysroot,
|
||||
sopts.target_triple,
|
||||
|
@ -114,7 +114,7 @@ fn visit_crate(e: &Env, c: &ast::Crate) {
|
||||
for a in c.attrs.iter().filter(|m| "link_args" == m.name()) {
|
||||
match a.value_str() {
|
||||
Some(ref linkarg) => {
|
||||
cstore::add_used_link_args(cstore, *linkarg);
|
||||
cstore.add_used_link_args(*linkarg);
|
||||
}
|
||||
None => {/* fallthrough */ }
|
||||
}
|
||||
@ -149,7 +149,7 @@ fn visit_view_item(e: @mut Env, i: &ast::view_item) {
|
||||
version,
|
||||
@"",
|
||||
i.span);
|
||||
cstore::add_extern_mod_stmt_cnum(e.sess.cstore, id, cnum);
|
||||
e.sess.cstore.add_extern_mod_stmt_cnum(id, cnum);
|
||||
}
|
||||
_ => ()
|
||||
}
|
||||
@ -170,7 +170,7 @@ fn visit_item(e: &Env, i: @ast::item) {
|
||||
for m in link_args.iter() {
|
||||
match m.value_str() {
|
||||
Some(linkarg) => {
|
||||
cstore::add_used_link_args(cstore, linkarg);
|
||||
cstore.add_used_link_args(linkarg);
|
||||
}
|
||||
None => { /* fallthrough */ }
|
||||
}
|
||||
@ -222,7 +222,7 @@ fn visit_item(e: &Env, i: @ast::item) {
|
||||
if n.is_empty() {
|
||||
e.sess.span_err(m.span, "#[link(name = \"\")] given with empty name");
|
||||
} else {
|
||||
cstore::add_used_library(cstore, n.to_owned(), kind);
|
||||
cstore.add_used_library(n.to_owned(), kind);
|
||||
}
|
||||
}
|
||||
None => {}
|
||||
@ -296,8 +296,8 @@ fn resolve_crate(e: @mut Env,
|
||||
};
|
||||
|
||||
let cstore = e.sess.cstore;
|
||||
cstore::set_crate_data(cstore, cnum, cmeta);
|
||||
cstore::add_used_crate_source(cstore, cstore::CrateSource {
|
||||
cstore.set_crate_data(cnum, cmeta);
|
||||
cstore.add_used_crate_source(cstore::CrateSource {
|
||||
dylib: dylib,
|
||||
rlib: rlib,
|
||||
cnum: cnum,
|
||||
|
@ -31,13 +31,13 @@ pub struct StaticMethodInfo {
|
||||
}
|
||||
|
||||
pub fn get_symbol(cstore: @mut cstore::CStore, def: ast::DefId) -> ~str {
|
||||
let cdata = cstore::get_crate_data(cstore, def.crate).data();
|
||||
let cdata = cstore.get_crate_data(def.crate).data();
|
||||
return decoder::get_symbol(cdata, def.node);
|
||||
}
|
||||
|
||||
pub fn get_type_param_count(cstore: @mut cstore::CStore, def: ast::DefId)
|
||||
-> uint {
|
||||
let cdata = cstore::get_crate_data(cstore, def.crate).data();
|
||||
let cdata = cstore.get_crate_data(def.crate).data();
|
||||
return decoder::get_type_param_count(cdata, def.node);
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@ pub fn each_lang_item(cstore: @mut cstore::CStore,
|
||||
cnum: ast::CrateNum,
|
||||
f: |ast::NodeId, uint| -> bool)
|
||||
-> bool {
|
||||
let crate_data = cstore::get_crate_data(cstore, cnum);
|
||||
let crate_data = cstore.get_crate_data(cnum);
|
||||
decoder::each_lang_item(crate_data, f)
|
||||
}
|
||||
|
||||
@ -56,9 +56,9 @@ pub fn each_child_of_item(cstore: @mut cstore::CStore,
|
||||
callback: |decoder::DefLike,
|
||||
ast::Ident,
|
||||
ast::visibility|) {
|
||||
let crate_data = cstore::get_crate_data(cstore, def_id.crate);
|
||||
let crate_data = cstore.get_crate_data(def_id.crate);
|
||||
let get_crate_data: decoder::GetCrateDataCb = |cnum| {
|
||||
cstore::get_crate_data(cstore, cnum)
|
||||
cstore.get_crate_data(cnum)
|
||||
};
|
||||
decoder::each_child_of_item(cstore.intr,
|
||||
crate_data,
|
||||
@ -73,9 +73,9 @@ pub fn each_top_level_item_of_crate(cstore: @mut cstore::CStore,
|
||||
callback: |decoder::DefLike,
|
||||
ast::Ident,
|
||||
ast::visibility|) {
|
||||
let crate_data = cstore::get_crate_data(cstore, cnum);
|
||||
let crate_data = cstore.get_crate_data(cnum);
|
||||
let get_crate_data: decoder::GetCrateDataCb = |cnum| {
|
||||
cstore::get_crate_data(cstore, cnum)
|
||||
cstore.get_crate_data(cnum)
|
||||
};
|
||||
decoder::each_top_level_item_of_crate(cstore.intr,
|
||||
crate_data,
|
||||
@ -85,7 +85,7 @@ pub fn each_top_level_item_of_crate(cstore: @mut cstore::CStore,
|
||||
|
||||
pub fn get_item_path(tcx: ty::ctxt, def: ast::DefId) -> ast_map::path {
|
||||
let cstore = tcx.cstore;
|
||||
let cdata = cstore::get_crate_data(cstore, def.crate);
|
||||
let cdata = cstore.get_crate_data(def.crate);
|
||||
let path = decoder::get_item_path(cdata, def.node);
|
||||
|
||||
// FIXME #1920: This path is not always correct if the crate is not linked
|
||||
@ -107,7 +107,7 @@ pub fn maybe_get_item_ast(tcx: ty::ctxt, def: ast::DefId,
|
||||
decode_inlined_item: decoder::decode_inlined_item)
|
||||
-> found_ast {
|
||||
let cstore = tcx.cstore;
|
||||
let cdata = cstore::get_crate_data(cstore, def.crate);
|
||||
let cdata = cstore.get_crate_data(def.crate);
|
||||
decoder::maybe_get_item_ast(cdata, tcx, def.node,
|
||||
decode_inlined_item)
|
||||
}
|
||||
@ -115,19 +115,19 @@ pub fn maybe_get_item_ast(tcx: ty::ctxt, def: ast::DefId,
|
||||
pub fn get_enum_variants(tcx: ty::ctxt, def: ast::DefId)
|
||||
-> ~[@ty::VariantInfo] {
|
||||
let cstore = tcx.cstore;
|
||||
let cdata = cstore::get_crate_data(cstore, def.crate);
|
||||
let cdata = cstore.get_crate_data(def.crate);
|
||||
return decoder::get_enum_variants(cstore.intr, cdata, def.node, tcx)
|
||||
}
|
||||
|
||||
/// Returns information about the given implementation.
|
||||
pub fn get_impl(tcx: ty::ctxt, impl_def_id: ast::DefId)
|
||||
-> ty::Impl {
|
||||
let cdata = cstore::get_crate_data(tcx.cstore, impl_def_id.crate);
|
||||
let cdata = tcx.cstore.get_crate_data(impl_def_id.crate);
|
||||
decoder::get_impl(tcx.cstore.intr, cdata, impl_def_id.node, tcx)
|
||||
}
|
||||
|
||||
pub fn get_method(tcx: ty::ctxt, def: ast::DefId) -> ty::Method {
|
||||
let cdata = cstore::get_crate_data(tcx.cstore, def.crate);
|
||||
let cdata = tcx.cstore.get_crate_data(def.crate);
|
||||
decoder::get_method(tcx.cstore.intr, cdata, def.node, tcx)
|
||||
}
|
||||
|
||||
@ -135,19 +135,19 @@ pub fn get_method_name_and_explicit_self(cstore: @mut cstore::CStore,
|
||||
def: ast::DefId)
|
||||
-> (ast::Ident, ast::explicit_self_)
|
||||
{
|
||||
let cdata = cstore::get_crate_data(cstore, def.crate);
|
||||
let cdata = cstore.get_crate_data(def.crate);
|
||||
decoder::get_method_name_and_explicit_self(cstore.intr, cdata, def.node)
|
||||
}
|
||||
|
||||
pub fn get_trait_method_def_ids(cstore: @mut cstore::CStore,
|
||||
def: ast::DefId) -> ~[ast::DefId] {
|
||||
let cdata = cstore::get_crate_data(cstore, def.crate);
|
||||
let cdata = cstore.get_crate_data(def.crate);
|
||||
decoder::get_trait_method_def_ids(cdata, def.node)
|
||||
}
|
||||
|
||||
pub fn get_item_variances(cstore: @mut cstore::CStore,
|
||||
def: ast::DefId) -> ty::ItemVariances {
|
||||
let cdata = cstore::get_crate_data(cstore, def.crate);
|
||||
let cdata = cstore.get_crate_data(def.crate);
|
||||
decoder::get_item_variances(cdata, def.node)
|
||||
}
|
||||
|
||||
@ -155,40 +155,40 @@ pub fn get_provided_trait_methods(tcx: ty::ctxt,
|
||||
def: ast::DefId)
|
||||
-> ~[@ty::Method] {
|
||||
let cstore = tcx.cstore;
|
||||
let cdata = cstore::get_crate_data(cstore, def.crate);
|
||||
let cdata = cstore.get_crate_data(def.crate);
|
||||
decoder::get_provided_trait_methods(cstore.intr, cdata, def.node, tcx)
|
||||
}
|
||||
|
||||
pub fn get_supertraits(tcx: ty::ctxt, def: ast::DefId) -> ~[@ty::TraitRef] {
|
||||
let cstore = tcx.cstore;
|
||||
let cdata = cstore::get_crate_data(cstore, def.crate);
|
||||
let cdata = cstore.get_crate_data(def.crate);
|
||||
decoder::get_supertraits(cdata, def.node, tcx)
|
||||
}
|
||||
|
||||
pub fn get_type_name_if_impl(cstore: @mut cstore::CStore, def: ast::DefId)
|
||||
-> Option<ast::Ident> {
|
||||
let cdata = cstore::get_crate_data(cstore, def.crate);
|
||||
let cdata = cstore.get_crate_data(def.crate);
|
||||
decoder::get_type_name_if_impl(cdata, def.node)
|
||||
}
|
||||
|
||||
pub fn get_static_methods_if_impl(cstore: @mut cstore::CStore,
|
||||
def: ast::DefId)
|
||||
-> Option<~[StaticMethodInfo]> {
|
||||
let cdata = cstore::get_crate_data(cstore, def.crate);
|
||||
let cdata = cstore.get_crate_data(def.crate);
|
||||
decoder::get_static_methods_if_impl(cstore.intr, cdata, def.node)
|
||||
}
|
||||
|
||||
pub fn get_item_attrs(cstore: @mut cstore::CStore,
|
||||
def_id: ast::DefId,
|
||||
f: |~[@ast::MetaItem]|) {
|
||||
let cdata = cstore::get_crate_data(cstore, def_id.crate);
|
||||
let cdata = cstore.get_crate_data(def_id.crate);
|
||||
decoder::get_item_attrs(cdata, def_id.node, f)
|
||||
}
|
||||
|
||||
pub fn get_struct_fields(cstore: @mut cstore::CStore,
|
||||
def: ast::DefId)
|
||||
-> ~[ty::field_ty] {
|
||||
let cdata = cstore::get_crate_data(cstore, def.crate);
|
||||
let cdata = cstore.get_crate_data(def.crate);
|
||||
decoder::get_struct_fields(cstore.intr, cdata, def.node)
|
||||
}
|
||||
|
||||
@ -196,20 +196,20 @@ pub fn get_type(tcx: ty::ctxt,
|
||||
def: ast::DefId)
|
||||
-> ty::ty_param_bounds_and_ty {
|
||||
let cstore = tcx.cstore;
|
||||
let cdata = cstore::get_crate_data(cstore, def.crate);
|
||||
let cdata = cstore.get_crate_data(def.crate);
|
||||
decoder::get_type(cdata, def.node, tcx)
|
||||
}
|
||||
|
||||
pub fn get_trait_def(tcx: ty::ctxt, def: ast::DefId) -> ty::TraitDef {
|
||||
let cstore = tcx.cstore;
|
||||
let cdata = cstore::get_crate_data(cstore, def.crate);
|
||||
let cdata = cstore.get_crate_data(def.crate);
|
||||
decoder::get_trait_def(cdata, def.node, tcx)
|
||||
}
|
||||
|
||||
pub fn get_field_type(tcx: ty::ctxt, class_id: ast::DefId,
|
||||
def: ast::DefId) -> ty::ty_param_bounds_and_ty {
|
||||
let cstore = tcx.cstore;
|
||||
let cdata = cstore::get_crate_data(cstore, class_id.crate);
|
||||
let cdata = cstore.get_crate_data(class_id.crate);
|
||||
let all_items = reader::get_doc(reader::Doc(cdata.data()), tag_items);
|
||||
debug!("Looking up {:?}", class_id);
|
||||
let class_doc = expect(tcx.diag,
|
||||
@ -235,7 +235,7 @@ pub fn get_field_type(tcx: ty::ctxt, class_id: ast::DefId,
|
||||
pub fn get_impl_trait(tcx: ty::ctxt,
|
||||
def: ast::DefId) -> Option<@ty::TraitRef> {
|
||||
let cstore = tcx.cstore;
|
||||
let cdata = cstore::get_crate_data(cstore, def.crate);
|
||||
let cdata = cstore.get_crate_data(def.crate);
|
||||
decoder::get_impl_trait(cdata, def.node, tcx)
|
||||
}
|
||||
|
||||
@ -243,7 +243,7 @@ pub fn get_impl_trait(tcx: ty::ctxt,
|
||||
pub fn get_impl_vtables(tcx: ty::ctxt,
|
||||
def: ast::DefId) -> typeck::impl_res {
|
||||
let cstore = tcx.cstore;
|
||||
let cdata = cstore::get_crate_data(cstore, def.crate);
|
||||
let cdata = cstore.get_crate_data(def.crate);
|
||||
decoder::get_impl_vtables(cdata, def.node, tcx)
|
||||
}
|
||||
|
||||
@ -251,42 +251,42 @@ pub fn get_impl_method(cstore: @mut cstore::CStore,
|
||||
def: ast::DefId,
|
||||
mname: ast::Ident)
|
||||
-> Option<ast::DefId> {
|
||||
let cdata = cstore::get_crate_data(cstore, def.crate);
|
||||
let cdata = cstore.get_crate_data(def.crate);
|
||||
decoder::get_impl_method(cstore.intr, cdata, def.node, mname)
|
||||
}
|
||||
|
||||
pub fn get_item_visibility(cstore: @mut cstore::CStore,
|
||||
def_id: ast::DefId)
|
||||
-> ast::visibility {
|
||||
let cdata = cstore::get_crate_data(cstore, def_id.crate);
|
||||
let cdata = cstore.get_crate_data(def_id.crate);
|
||||
decoder::get_item_visibility(cdata, def_id.node)
|
||||
}
|
||||
|
||||
pub fn get_native_libraries(cstore: @mut cstore::CStore,
|
||||
crate_num: ast::CrateNum)
|
||||
-> ~[(cstore::NativeLibaryKind, ~str)] {
|
||||
let cdata = cstore::get_crate_data(cstore, crate_num);
|
||||
let cdata = cstore.get_crate_data(crate_num);
|
||||
decoder::get_native_libraries(cdata)
|
||||
}
|
||||
|
||||
pub fn each_impl(cstore: @mut cstore::CStore,
|
||||
crate_num: ast::CrateNum,
|
||||
callback: |ast::DefId|) {
|
||||
let cdata = cstore::get_crate_data(cstore, crate_num);
|
||||
let cdata = cstore.get_crate_data(crate_num);
|
||||
decoder::each_impl(cdata, callback)
|
||||
}
|
||||
|
||||
pub fn each_implementation_for_type(cstore: @mut cstore::CStore,
|
||||
def_id: ast::DefId,
|
||||
callback: |ast::DefId|) {
|
||||
let cdata = cstore::get_crate_data(cstore, def_id.crate);
|
||||
let cdata = cstore.get_crate_data(def_id.crate);
|
||||
decoder::each_implementation_for_type(cdata, def_id.node, callback)
|
||||
}
|
||||
|
||||
pub fn each_implementation_for_trait(cstore: @mut cstore::CStore,
|
||||
def_id: ast::DefId,
|
||||
callback: |ast::DefId|) {
|
||||
let cdata = cstore::get_crate_data(cstore, def_id.crate);
|
||||
let cdata = cstore.get_crate_data(def_id.crate);
|
||||
decoder::each_implementation_for_trait(cdata, def_id.node, callback)
|
||||
}
|
||||
|
||||
@ -297,7 +297,7 @@ pub fn get_trait_of_method(cstore: @mut cstore::CStore,
|
||||
def_id: ast::DefId,
|
||||
tcx: ty::ctxt)
|
||||
-> Option<ast::DefId> {
|
||||
let cdata = cstore::get_crate_data(cstore, def_id.crate);
|
||||
let cdata = cstore.get_crate_data(def_id.crate);
|
||||
decoder::get_trait_of_method(cdata, def_id.node, tcx)
|
||||
}
|
||||
|
||||
|
@ -12,8 +12,6 @@
|
||||
// The crate store - a central repo for information collected about external
|
||||
// crates and libraries
|
||||
|
||||
|
||||
use metadata::cstore;
|
||||
use metadata::decoder;
|
||||
use metadata::loader;
|
||||
|
||||
@ -73,104 +71,126 @@ pub struct CStore {
|
||||
// Map from NodeId's of local extern mod statements to crate numbers
|
||||
type extern_mod_crate_map = HashMap<ast::NodeId, ast::CrateNum>;
|
||||
|
||||
pub fn mk_cstore(intr: @ident_interner) -> CStore {
|
||||
return CStore {
|
||||
metas: HashMap::new(),
|
||||
extern_mod_crate_map: HashMap::new(),
|
||||
used_crate_sources: ~[],
|
||||
used_libraries: ~[],
|
||||
used_link_args: ~[],
|
||||
intr: intr
|
||||
};
|
||||
}
|
||||
|
||||
pub fn get_crate_data(cstore: &CStore, cnum: ast::CrateNum)
|
||||
-> @crate_metadata {
|
||||
return *cstore.metas.get(&cnum);
|
||||
}
|
||||
|
||||
pub fn get_crate_hash(cstore: &CStore, cnum: ast::CrateNum) -> @str {
|
||||
let cdata = get_crate_data(cstore, cnum);
|
||||
decoder::get_crate_hash(cdata.data())
|
||||
}
|
||||
|
||||
pub fn get_crate_vers(cstore: &CStore, cnum: ast::CrateNum) -> @str {
|
||||
let cdata = get_crate_data(cstore, cnum);
|
||||
decoder::get_crate_vers(cdata.data())
|
||||
}
|
||||
|
||||
pub fn set_crate_data(cstore: &mut CStore,
|
||||
cnum: ast::CrateNum,
|
||||
data: @crate_metadata) {
|
||||
cstore.metas.insert(cnum, data);
|
||||
}
|
||||
|
||||
pub fn have_crate_data(cstore: &CStore, cnum: ast::CrateNum) -> bool {
|
||||
cstore.metas.contains_key(&cnum)
|
||||
}
|
||||
|
||||
pub fn iter_crate_data(cstore: &CStore, i: |ast::CrateNum, @crate_metadata|) {
|
||||
for (&k, &v) in cstore.metas.iter() {
|
||||
i(k, v);
|
||||
impl CStore {
|
||||
pub fn new(intr: @ident_interner) -> CStore {
|
||||
CStore {
|
||||
metas: HashMap::new(),
|
||||
extern_mod_crate_map: HashMap::new(),
|
||||
used_crate_sources: ~[],
|
||||
used_libraries: ~[],
|
||||
used_link_args: ~[],
|
||||
intr: intr
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_used_crate_source(cstore: &mut CStore, src: CrateSource) {
|
||||
if !cstore.used_crate_sources.contains(&src) {
|
||||
cstore.used_crate_sources.push(src);
|
||||
pub fn get_crate_data(&self, cnum: ast::CrateNum) -> @crate_metadata {
|
||||
*self.metas.get(&cnum)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_used_crate_sources<'a>(cstore: &'a CStore) -> &'a [CrateSource] {
|
||||
cstore.used_crate_sources.as_slice()
|
||||
}
|
||||
|
||||
pub fn get_used_crates(cstore: &CStore, prefer: LinkagePreference)
|
||||
-> ~[(ast::CrateNum, Option<Path>)]
|
||||
{
|
||||
let mut ret = ~[];
|
||||
for src in cstore.used_crate_sources.iter() {
|
||||
ret.push((src.cnum, match prefer {
|
||||
RequireDynamic => src.dylib.clone(),
|
||||
RequireStatic => src.rlib.clone(),
|
||||
}));
|
||||
pub fn get_crate_hash(&self, cnum: ast::CrateNum) -> @str {
|
||||
let cdata = self.get_crate_data(cnum);
|
||||
decoder::get_crate_hash(cdata.data())
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
pub fn add_used_library(cstore: &mut CStore,
|
||||
lib: ~str, kind: NativeLibaryKind) -> bool {
|
||||
assert!(!lib.is_empty());
|
||||
|
||||
if cstore.used_libraries.iter().any(|&(ref x, _)| x == &lib) { return false; }
|
||||
cstore.used_libraries.push((lib, kind));
|
||||
true
|
||||
}
|
||||
|
||||
pub fn get_used_libraries<'a>(cstore: &'a CStore) -> &'a [(~str, NativeLibaryKind)] {
|
||||
cstore.used_libraries.as_slice()
|
||||
}
|
||||
|
||||
pub fn add_used_link_args(cstore: &mut CStore, args: &str) {
|
||||
for s in args.split(' ') {
|
||||
cstore.used_link_args.push(s.to_owned());
|
||||
pub fn get_crate_vers(&self, cnum: ast::CrateNum) -> @str {
|
||||
let cdata = self.get_crate_data(cnum);
|
||||
decoder::get_crate_vers(cdata.data())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_used_link_args<'a>(cstore: &'a CStore) -> &'a [~str] {
|
||||
cstore.used_link_args.as_slice()
|
||||
}
|
||||
pub fn set_crate_data(&mut self, cnum: ast::CrateNum, data: @crate_metadata) {
|
||||
self.metas.insert(cnum, data);
|
||||
}
|
||||
|
||||
pub fn add_extern_mod_stmt_cnum(cstore: &mut CStore,
|
||||
emod_id: ast::NodeId,
|
||||
cnum: ast::CrateNum) {
|
||||
cstore.extern_mod_crate_map.insert(emod_id, cnum);
|
||||
}
|
||||
pub fn have_crate_data(&self, cnum: ast::CrateNum) -> bool {
|
||||
self.metas.contains_key(&cnum)
|
||||
}
|
||||
|
||||
pub fn find_extern_mod_stmt_cnum(cstore: &CStore,
|
||||
emod_id: ast::NodeId)
|
||||
-> Option<ast::CrateNum> {
|
||||
cstore.extern_mod_crate_map.find(&emod_id).map(|x| *x)
|
||||
pub fn iter_crate_data(&self, i: |ast::CrateNum, @crate_metadata|) {
|
||||
for (&k, &v) in self.metas.iter() {
|
||||
i(k, v);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_used_crate_source(&mut self, src: CrateSource) {
|
||||
if !self.used_crate_sources.contains(&src) {
|
||||
self.used_crate_sources.push(src);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_used_crate_sources<'a>(&'a self) -> &'a [CrateSource] {
|
||||
self.used_crate_sources.as_slice()
|
||||
}
|
||||
|
||||
pub fn get_used_crates(&self, prefer: LinkagePreference)
|
||||
-> ~[(ast::CrateNum, Option<Path>)] {
|
||||
self.used_crate_sources.iter()
|
||||
.map(|src| (src.cnum, match prefer {
|
||||
RequireDynamic => src.dylib.clone(),
|
||||
RequireStatic => src.rlib.clone(),
|
||||
}))
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn add_used_library(&mut self, lib: ~str, kind: NativeLibaryKind) -> bool {
|
||||
assert!(!lib.is_empty());
|
||||
if self.used_libraries.iter().any(|&(ref x, _)| x == &lib) {
|
||||
return false;
|
||||
}
|
||||
self.used_libraries.push((lib, kind));
|
||||
true
|
||||
}
|
||||
|
||||
pub fn get_used_libraries<'a>(&'a self) -> &'a [(~str, NativeLibaryKind)] {
|
||||
self.used_libraries.as_slice()
|
||||
}
|
||||
|
||||
pub fn add_used_link_args(&mut self, args: &str) {
|
||||
for s in args.split(' ') {
|
||||
self.used_link_args.push(s.to_owned());
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_used_link_args<'a>(&'a self) -> &'a [~str] {
|
||||
self.used_link_args.as_slice()
|
||||
}
|
||||
|
||||
pub fn add_extern_mod_stmt_cnum(&mut self,
|
||||
emod_id: ast::NodeId,
|
||||
cnum: ast::CrateNum) {
|
||||
self.extern_mod_crate_map.insert(emod_id, cnum);
|
||||
}
|
||||
|
||||
pub fn find_extern_mod_stmt_cnum(&self, emod_id: ast::NodeId)
|
||||
-> Option<ast::CrateNum> {
|
||||
self.extern_mod_crate_map.find(&emod_id).map(|x| *x)
|
||||
}
|
||||
|
||||
// returns hashes of crates directly used by this crate. Hashes are sorted by
|
||||
// (crate name, crate version, crate hash) in lexicographic order (not semver)
|
||||
pub fn get_dep_hashes(&self) -> ~[@str] {
|
||||
let mut result = ~[];
|
||||
|
||||
for (_, &cnum) in self.extern_mod_crate_map.iter() {
|
||||
let cdata = self.get_crate_data(cnum);
|
||||
let hash = decoder::get_crate_hash(cdata.data());
|
||||
let vers = decoder::get_crate_vers(cdata.data());
|
||||
debug!("Add hash[{}]: {} {}", cdata.name, vers, hash);
|
||||
result.push(crate_hash {
|
||||
name: cdata.name,
|
||||
vers: vers,
|
||||
hash: hash
|
||||
});
|
||||
}
|
||||
|
||||
result.sort();
|
||||
|
||||
debug!("sorted:");
|
||||
for x in result.iter() {
|
||||
debug!(" hash[{}]: {}", x.name, x.hash);
|
||||
}
|
||||
|
||||
result.map(|ch| ch.hash)
|
||||
}
|
||||
}
|
||||
|
||||
#[deriving(Clone, TotalEq, TotalOrd)]
|
||||
@ -180,33 +200,6 @@ struct crate_hash {
|
||||
hash: @str,
|
||||
}
|
||||
|
||||
// returns hashes of crates directly used by this crate. Hashes are sorted by
|
||||
// (crate name, crate version, crate hash) in lexicographic order (not semver)
|
||||
pub fn get_dep_hashes(cstore: &CStore) -> ~[@str] {
|
||||
let mut result = ~[];
|
||||
|
||||
for (_, &cnum) in cstore.extern_mod_crate_map.iter() {
|
||||
let cdata = cstore::get_crate_data(cstore, cnum);
|
||||
let hash = decoder::get_crate_hash(cdata.data());
|
||||
let vers = decoder::get_crate_vers(cdata.data());
|
||||
debug!("Add hash[{}]: {} {}", cdata.name, vers, hash);
|
||||
result.push(crate_hash {
|
||||
name: cdata.name,
|
||||
vers: vers,
|
||||
hash: hash
|
||||
});
|
||||
}
|
||||
|
||||
result.sort();
|
||||
|
||||
debug!("sorted:");
|
||||
for x in result.iter() {
|
||||
debug!(" hash[{}]: {}", x.name, x.hash);
|
||||
}
|
||||
|
||||
result.map(|ch| ch.hash)
|
||||
}
|
||||
|
||||
impl crate_metadata {
|
||||
pub fn data<'a>(&'a self) -> &'a [u8] { self.data.as_slice() }
|
||||
}
|
||||
|
@ -1522,7 +1522,7 @@ fn encode_crate_deps(ecx: &EncodeContext,
|
||||
|
||||
// Pull the cnums and name,vers,hash out of cstore
|
||||
let mut deps = ~[];
|
||||
cstore::iter_crate_data(cstore, |key, val| {
|
||||
cstore.iter_crate_data(|key, val| {
|
||||
let dep = decoder::CrateDep {cnum: key,
|
||||
name: ecx.tcx.sess.ident_of(val.name),
|
||||
vers: decoder::get_crate_vers(val.data()),
|
||||
@ -1588,7 +1588,7 @@ fn encode_lang_items(ecx: &EncodeContext, ebml_w: &mut writer::Encoder) {
|
||||
fn encode_native_libraries(ecx: &EncodeContext, ebml_w: &mut writer::Encoder) {
|
||||
ebml_w.start_tag(tag_native_libraries);
|
||||
|
||||
for &(ref lib, kind) in cstore::get_used_libraries(ecx.cstore).iter() {
|
||||
for &(ref lib, kind) in ecx.cstore.get_used_libraries().iter() {
|
||||
match kind {
|
||||
cstore::NativeStatic => {} // these libraries are not propagated
|
||||
cstore::NativeFramework | cstore::NativeUnknown => {
|
||||
|
@ -22,7 +22,6 @@
|
||||
|
||||
use driver::session::Session;
|
||||
use metadata::csearch::each_lang_item;
|
||||
use metadata::cstore::iter_crate_data;
|
||||
use middle::ty::{BuiltinBound, BoundFreeze, BoundPod, BoundSend, BoundSized};
|
||||
use syntax::ast;
|
||||
use syntax::ast_util::local_def;
|
||||
@ -165,7 +164,7 @@ impl LanguageItemCollector {
|
||||
|
||||
pub fn collect_external_language_items(&mut self) {
|
||||
let crate_store = self.session.cstore;
|
||||
iter_crate_data(crate_store, |crate_number, _crate_metadata| {
|
||||
crate_store.iter_crate_data(|crate_number, _crate_metadata| {
|
||||
each_lang_item(crate_store, crate_number, |node_id, item_index| {
|
||||
let def_id = ast::DefId { crate: crate_number, node: node_id };
|
||||
self.collect_item(item_index, def_id);
|
||||
|
@ -10,12 +10,7 @@
|
||||
|
||||
|
||||
use driver::session::Session;
|
||||
use metadata::csearch::get_trait_method_def_ids;
|
||||
use metadata::csearch::get_method_name_and_explicit_self;
|
||||
use metadata::csearch::get_static_methods_if_impl;
|
||||
use metadata::csearch::{get_type_name_if_impl, get_struct_fields};
|
||||
use metadata::csearch;
|
||||
use metadata::cstore::find_extern_mod_stmt_cnum;
|
||||
use metadata::decoder::{DefLike, DlDef, DlField, DlImpl};
|
||||
use middle::lang_items::LanguageItems;
|
||||
use middle::lint::{unnecessary_qualification, unused_imports};
|
||||
@ -1498,8 +1493,7 @@ impl Resolver {
|
||||
|
||||
view_item_extern_mod(name, _, _, node_id) => {
|
||||
// n.b. we don't need to look at the path option here, because cstore already did
|
||||
match find_extern_mod_stmt_cnum(self.session.cstore,
|
||||
node_id) {
|
||||
match self.session.cstore.find_extern_mod_stmt_cnum(node_id) {
|
||||
Some(crate_id) => {
|
||||
let def_id = DefId { crate: crate_id, node: 0 };
|
||||
self.external_exports.insert(def_id);
|
||||
@ -1662,12 +1656,12 @@ impl Resolver {
|
||||
// to the trait info.
|
||||
|
||||
let method_def_ids =
|
||||
get_trait_method_def_ids(self.session.cstore, def_id);
|
||||
csearch::get_trait_method_def_ids(self.session.cstore, def_id);
|
||||
let mut interned_method_names = HashSet::new();
|
||||
for &method_def_id in method_def_ids.iter() {
|
||||
let (method_name, explicit_self) =
|
||||
get_method_name_and_explicit_self(self.session.cstore,
|
||||
method_def_id);
|
||||
csearch::get_method_name_and_explicit_self(self.session.cstore,
|
||||
method_def_id);
|
||||
|
||||
debug!("(building reduced graph for \
|
||||
external crate) ... adding \
|
||||
@ -1714,7 +1708,7 @@ impl Resolver {
|
||||
crate) building type and value for {}",
|
||||
final_ident);
|
||||
child_name_bindings.define_type(def, dummy_sp(), is_public);
|
||||
if get_struct_fields(self.session.cstore, def_id).len() == 0 {
|
||||
if csearch::get_struct_fields(self.session.cstore, def_id).len() == 0 {
|
||||
child_name_bindings.define_value(def, dummy_sp(), is_public);
|
||||
}
|
||||
self.structs.insert(def_id);
|
||||
@ -1776,12 +1770,11 @@ impl Resolver {
|
||||
}
|
||||
DlImpl(def) => {
|
||||
// We only process static methods of impls here.
|
||||
match get_type_name_if_impl(self.session.cstore, def) {
|
||||
match csearch::get_type_name_if_impl(self.session.cstore, def) {
|
||||
None => {}
|
||||
Some(final_ident) => {
|
||||
let static_methods_opt =
|
||||
get_static_methods_if_impl(self.session.cstore,
|
||||
def);
|
||||
csearch::get_static_methods_if_impl(self.session.cstore, def);
|
||||
match static_methods_opt {
|
||||
Some(ref static_methods) if
|
||||
static_methods.len() >= 1 => {
|
||||
|
@ -33,7 +33,7 @@ use lib::llvm::{ModuleRef, ValueRef, BasicBlockRef};
|
||||
use lib::llvm::{llvm, True};
|
||||
use lib;
|
||||
use metadata::common::LinkMeta;
|
||||
use metadata::{csearch, cstore, encoder};
|
||||
use metadata::{csearch, encoder};
|
||||
use middle::astencode;
|
||||
use middle::lang_items::{LangItem, ExchangeMallocFnLangItem, StartFnLangItem};
|
||||
use middle::lang_items::{MallocFnLangItem, ClosureExchangeMallocFnLangItem};
|
||||
@ -2945,7 +2945,7 @@ pub fn decl_crate_map(sess: session::Session, mapmeta: LinkMeta,
|
||||
let int_type = Type::int(targ_cfg.arch);
|
||||
let mut n_subcrates = 1;
|
||||
let cstore = sess.cstore;
|
||||
while cstore::have_crate_data(cstore, n_subcrates) { n_subcrates += 1; }
|
||||
while cstore.have_crate_data(n_subcrates) { n_subcrates += 1; }
|
||||
let is_top = !*sess.building_library || sess.gen_crate_map();
|
||||
let sym_name = if is_top {
|
||||
~"_rust_crate_map_toplevel"
|
||||
@ -2981,11 +2981,11 @@ pub fn fill_crate_map(ccx: @mut CrateContext, map: ValueRef) {
|
||||
let mut subcrates: ~[ValueRef] = ~[];
|
||||
let mut i = 1;
|
||||
let cstore = ccx.sess.cstore;
|
||||
while cstore::have_crate_data(cstore, i) {
|
||||
let cdata = cstore::get_crate_data(cstore, i);
|
||||
while cstore.have_crate_data(i) {
|
||||
let cdata = cstore.get_crate_data(i);
|
||||
let nm = symname(ccx.sess, format!("_rust_crate_map_{}", cdata.name),
|
||||
cstore::get_crate_hash(cstore, i),
|
||||
cstore::get_crate_vers(cstore, i));
|
||||
cstore.get_crate_hash(i),
|
||||
cstore.get_crate_vers(i));
|
||||
let cr = nm.with_c_str(|buf| {
|
||||
unsafe {
|
||||
llvm::LLVMAddGlobal(ccx.llmod, ccx.int_type.to_ref(), buf)
|
||||
|
@ -119,7 +119,6 @@ use back::link;
|
||||
use lib::llvm::{ValueRef, llvm, SetLinkage, False};
|
||||
use lib;
|
||||
use metadata::csearch;
|
||||
use metadata::cstore;
|
||||
use middle::trans::_match;
|
||||
use middle::trans::adt;
|
||||
use middle::trans::asm;
|
||||
@ -1796,7 +1795,7 @@ pub fn trans_log_level(bcx: @mut Block) -> DatumBlock {
|
||||
let (modpath, modname) = {
|
||||
let srccrate = match ccx.external_srcs.find(&bcx.fcx.id) {
|
||||
Some(&src) => {
|
||||
cstore::get_crate_data(ccx.sess.cstore, src.crate).name
|
||||
ccx.sess.cstore.get_crate_data(src.crate).name
|
||||
}
|
||||
None => ccx.link_meta.pkgid.name.to_managed(),
|
||||
};
|
||||
|
@ -4607,7 +4607,6 @@ pub fn trait_method_of_method(tcx: ctxt,
|
||||
/// context it's calculated within. This is used by the `type_id` intrinsic.
|
||||
pub fn hash_crate_independent(tcx: ctxt, t: t, local_hash: @str) -> u64 {
|
||||
use std::hash::{SipState, Streaming};
|
||||
use metadata::cstore;
|
||||
|
||||
let mut hash = SipState::new(0, 0);
|
||||
let region = |_hash: &mut SipState, r: Region| {
|
||||
@ -4639,7 +4638,7 @@ pub fn hash_crate_independent(tcx: ctxt, t: t, local_hash: @str) -> u64 {
|
||||
let h = if ast_util::is_local(did) {
|
||||
local_hash
|
||||
} else {
|
||||
cstore::get_crate_hash(tcx.sess.cstore, did.crate)
|
||||
tcx.sess.cstore.get_crate_hash(did.crate)
|
||||
};
|
||||
hash.input(h.as_bytes());
|
||||
iter(hash, &did.node);
|
||||
|
@ -17,7 +17,6 @@
|
||||
|
||||
use metadata::csearch::{each_impl, get_impl_trait};
|
||||
use metadata::csearch;
|
||||
use metadata::cstore::iter_crate_data;
|
||||
use middle::ty::get;
|
||||
use middle::ty::{ImplContainer, lookup_item_type, subst};
|
||||
use middle::ty::{substs, t, ty_bool, ty_char, ty_bot, ty_box, ty_enum, ty_err};
|
||||
@ -665,7 +664,7 @@ impl CoherenceChecker {
|
||||
let mut impls_seen = HashSet::new();
|
||||
|
||||
let crate_store = self.crate_context.tcx.sess.cstore;
|
||||
iter_crate_data(crate_store, |crate_number, _crate_metadata| {
|
||||
crate_store.iter_crate_data(|crate_number, _crate_metadata| {
|
||||
each_impl(crate_store, crate_number, |def_id| {
|
||||
assert_eq!(crate_number, def_id.crate);
|
||||
self.add_external_impl(&mut impls_seen, def_id)
|
||||
|
@ -77,7 +77,7 @@ impl Clean<Crate> for visit_ast::RustdocVisitor {
|
||||
let cx = local_data::get(super::ctxtkey, |x| *x.unwrap());
|
||||
|
||||
let mut externs = HashMap::new();
|
||||
cstore::iter_crate_data(cx.sess.cstore, |n, meta| {
|
||||
cx.sess.cstore.iter_crate_data(|n, meta| {
|
||||
externs.insert(n, meta.clean());
|
||||
});
|
||||
|
||||
|
@ -1,62 +0,0 @@
|
||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// xfail-test
|
||||
// fails pretty printing for some reason
|
||||
use syntax;
|
||||
use syntax::diagnostic;
|
||||
use syntax::ast;
|
||||
use syntax::codemap;
|
||||
use syntax::print::pprust;
|
||||
use syntax::parse::parser;
|
||||
|
||||
fn new_parse_sess() -> parser::parse_sess {
|
||||
let cm = codemap::new_codemap();
|
||||
let handler = diagnostic::mk_handler(option::none);
|
||||
let sess = @mut {
|
||||
cm: cm,
|
||||
next_id: 1,
|
||||
span_diagnostic: diagnostic::mk_span_handler(handler, cm),
|
||||
chpos: 0u,
|
||||
byte_pos: 0u
|
||||
};
|
||||
return sess;
|
||||
}
|
||||
|
||||
trait fake_ext_ctxt {
|
||||
fn session() -> fake_session;
|
||||
fn cfg() -> ast::CrateConfig;
|
||||
fn parse_sess() -> parser::parse_sess;
|
||||
}
|
||||
|
||||
type fake_options = {cfg: ast::CrateConfig};
|
||||
|
||||
type fake_session = {opts: @fake_options,
|
||||
parse_sess: parser::parse_sess};
|
||||
|
||||
impl of fake_ext_ctxt for fake_session {
|
||||
fn session() -> fake_session {self}
|
||||
fn cfg() -> ast::CrateConfig { self.opts.cfg }
|
||||
fn parse_sess() -> parser::parse_sess { self.parse_sess }
|
||||
}
|
||||
|
||||
fn mk_ctxt() -> fake_ext_ctxt {
|
||||
let opts : fake_options = {cfg: ~[]};
|
||||
{opts: @opts, parse_sess: new_parse_sess()} as fake_ext_ctxt
|
||||
}
|
||||
|
||||
|
||||
fn main() {
|
||||
let cx = mk_ctxt();
|
||||
let s = quote_expr!(cx, __s);
|
||||
let e = quote_expr!(cx, __e);
|
||||
let f = quote_expr!(cx, $s.foo {|__e| $e});
|
||||
log(error, pprust::expr_to_str(f));
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user