auto merge of #5470 : sanxiyn/rust/remove-oldmap-2, r=sanxiyn
Referencing #4986.
This commit is contained in:
commit
0b4f2687ce
5 changed files with 38 additions and 33 deletions
|
@ -21,6 +21,7 @@ use metadata::{creader, cstore, filesearch};
|
||||||
use metadata;
|
use metadata;
|
||||||
use middle::{trans, freevars, kind, ty, typeck, lint, astencode};
|
use middle::{trans, freevars, kind, ty, typeck, lint, astencode};
|
||||||
use middle;
|
use middle;
|
||||||
|
use util::common::time;
|
||||||
use util::ppaux;
|
use util::ppaux;
|
||||||
|
|
||||||
use core::int;
|
use core::int;
|
||||||
|
@ -32,7 +33,6 @@ use core::vec;
|
||||||
use std::getopts::groups::{optopt, optmulti, optflag, optflagopt, getopts};
|
use std::getopts::groups::{optopt, optmulti, optflag, optflagopt, getopts};
|
||||||
use std::getopts::{opt_present};
|
use std::getopts::{opt_present};
|
||||||
use std::getopts;
|
use std::getopts;
|
||||||
use std;
|
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax::attr;
|
use syntax::attr;
|
||||||
use syntax::codemap;
|
use syntax::codemap;
|
||||||
|
@ -161,16 +161,6 @@ pub fn parse_input(sess: Session, +cfg: ast::crate_cfg, input: input)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn time<T>(do_it: bool, what: ~str, thunk: &fn() -> T) -> T {
|
|
||||||
if !do_it { return thunk(); }
|
|
||||||
let start = std::time::precise_time_s();
|
|
||||||
let rv = thunk();
|
|
||||||
let end = std::time::precise_time_s();
|
|
||||||
io::stdout().write_str(fmt!("time: %3.3f s\t%s\n",
|
|
||||||
end - start, what));
|
|
||||||
rv
|
|
||||||
}
|
|
||||||
|
|
||||||
#[deriving_eq]
|
#[deriving_eq]
|
||||||
pub enum compile_upto {
|
pub enum compile_upto {
|
||||||
cu_parse,
|
cu_parse,
|
||||||
|
@ -251,11 +241,9 @@ pub fn compile_rest(sess: Session, cfg: ast::crate_cfg,
|
||||||
let ty_cx = ty::mk_ctxt(sess, def_map, ast_map, freevars,
|
let ty_cx = ty::mk_ctxt(sess, def_map, ast_map, freevars,
|
||||||
region_map, rp_set, lang_items, crate);
|
region_map, rp_set, lang_items, crate);
|
||||||
|
|
||||||
let (method_map, vtable_map) =
|
// passes are timed inside typeck
|
||||||
time(time_passes, ~"typechecking", ||
|
let (method_map, vtable_map) = typeck::check_crate(
|
||||||
typeck::check_crate(ty_cx,
|
ty_cx, trait_map, crate);
|
||||||
trait_map,
|
|
||||||
crate));
|
|
||||||
|
|
||||||
// These next two const passes can probably be merged
|
// These next two const passes can probably be merged
|
||||||
time(time_passes, ~"const marking", ||
|
time(time_passes, ~"const marking", ||
|
||||||
|
|
|
@ -28,7 +28,7 @@ use core::result::{Result, Ok, Err};
|
||||||
use core::result;
|
use core::result;
|
||||||
use core::uint;
|
use core::uint;
|
||||||
use core::vec;
|
use core::vec;
|
||||||
use std::oldmap::HashMap;
|
use core::hashmap::linear::LinearSet;
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax::ast_util;
|
use syntax::ast_util;
|
||||||
use syntax::codemap::span;
|
use syntax::codemap::span;
|
||||||
|
@ -234,14 +234,14 @@ pub fn lookup_vtable(vcx: &VtableContext,
|
||||||
_ => {
|
_ => {
|
||||||
let mut found = ~[];
|
let mut found = ~[];
|
||||||
|
|
||||||
let mut impls_seen = HashMap();
|
let mut impls_seen = LinearSet::new();
|
||||||
|
|
||||||
match vcx.ccx.coherence_info.extension_methods.find(&trait_id) {
|
match vcx.ccx.coherence_info.extension_methods.find(&trait_id) {
|
||||||
None => {
|
None => {
|
||||||
// Nothing found. Continue.
|
// Nothing found. Continue.
|
||||||
}
|
}
|
||||||
Some(implementations) => {
|
Some(implementations) => {
|
||||||
let implementations: &mut ~[@Impl] = implementations;
|
let implementations: &mut ~[@Impl] = *implementations;
|
||||||
// implementations is the list of all impls in scope for
|
// implementations is the list of all impls in scope for
|
||||||
// trait_ty. (Usually, there's just one.)
|
// trait_ty. (Usually, there's just one.)
|
||||||
for uint::range(0, implementations.len()) |i| {
|
for uint::range(0, implementations.len()) |i| {
|
||||||
|
@ -250,10 +250,10 @@ pub fn lookup_vtable(vcx: &VtableContext,
|
||||||
// im is one specific impl of trait_ty.
|
// im is one specific impl of trait_ty.
|
||||||
|
|
||||||
// First, ensure we haven't processed this impl yet.
|
// First, ensure we haven't processed this impl yet.
|
||||||
if impls_seen.contains_key(&im.did) {
|
if impls_seen.contains(&im.did) {
|
||||||
loop;
|
loop;
|
||||||
}
|
}
|
||||||
impls_seen.insert(im.did, ());
|
impls_seen.insert(im.did);
|
||||||
|
|
||||||
// ty::impl_traits gives us the list of all
|
// ty::impl_traits gives us the list of all
|
||||||
// traits that im implements. Again, usually
|
// traits that im implements. Again, usually
|
||||||
|
|
|
@ -56,7 +56,7 @@ use syntax::visit::{visit_mod};
|
||||||
use util::ppaux::ty_to_str;
|
use util::ppaux::ty_to_str;
|
||||||
|
|
||||||
use core::result::Ok;
|
use core::result::Ok;
|
||||||
use core::hashmap::linear::LinearSet;
|
use core::hashmap::linear::{LinearMap, LinearSet};
|
||||||
use core::uint;
|
use core::uint;
|
||||||
use std::oldmap::HashMap;
|
use std::oldmap::HashMap;
|
||||||
|
|
||||||
|
@ -142,18 +142,17 @@ pub fn method_to_MethodInfo(ast_method: @method) -> @MethodInfo {
|
||||||
pub struct CoherenceInfo {
|
pub struct CoherenceInfo {
|
||||||
// Contains implementations of methods that are inherent to a type.
|
// Contains implementations of methods that are inherent to a type.
|
||||||
// Methods in these implementations don't need to be exported.
|
// Methods in these implementations don't need to be exported.
|
||||||
inherent_methods: HashMap<def_id,@mut ~[@Impl]>,
|
inherent_methods: @mut LinearMap<def_id, @mut ~[@Impl]>,
|
||||||
|
|
||||||
// Contains implementations of methods associated with a trait. For these,
|
// Contains implementations of methods associated with a trait. For these,
|
||||||
// the associated trait must be imported at the call site.
|
// the associated trait must be imported at the call site.
|
||||||
extension_methods: HashMap<def_id,@mut ~[@Impl]>,
|
extension_methods: @mut LinearMap<def_id, @mut ~[@Impl]>,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn CoherenceInfo() -> CoherenceInfo {
|
pub fn CoherenceInfo() -> CoherenceInfo {
|
||||||
CoherenceInfo {
|
CoherenceInfo {
|
||||||
inherent_methods: HashMap(),
|
inherent_methods: @mut LinearMap::new(),
|
||||||
extension_methods: HashMap(),
|
extension_methods: @mut LinearMap::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -380,7 +379,7 @@ pub impl CoherenceChecker {
|
||||||
.insert(base_def_id, implementation_list);
|
.insert(base_def_id, implementation_list);
|
||||||
}
|
}
|
||||||
Some(existing_implementation_list) => {
|
Some(existing_implementation_list) => {
|
||||||
implementation_list = existing_implementation_list;
|
implementation_list = *existing_implementation_list;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -397,7 +396,7 @@ pub impl CoherenceChecker {
|
||||||
.insert(trait_id, implementation_list);
|
.insert(trait_id, implementation_list);
|
||||||
}
|
}
|
||||||
Some(existing_implementation_list) => {
|
Some(existing_implementation_list) => {
|
||||||
implementation_list = existing_implementation_list;
|
implementation_list = *existing_implementation_list;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -472,7 +471,7 @@ pub impl CoherenceChecker {
|
||||||
|
|
||||||
match extension_methods.find(&trait_def_id) {
|
match extension_methods.find(&trait_def_id) {
|
||||||
Some(impls) => {
|
Some(impls) => {
|
||||||
let impls: &mut ~[@Impl] = impls;
|
let impls: &mut ~[@Impl] = *impls;
|
||||||
for uint::range(0, impls.len()) |i| {
|
for uint::range(0, impls.len()) |i| {
|
||||||
f(impls[i]);
|
f(impls[i]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,7 @@ use core::prelude::*;
|
||||||
use middle::resolve;
|
use middle::resolve;
|
||||||
use middle::ty::{ty_param_substs_and_ty, vstore_uniq};
|
use middle::ty::{ty_param_substs_and_ty, vstore_uniq};
|
||||||
use middle::ty;
|
use middle::ty;
|
||||||
|
use util::common::time;
|
||||||
use util::ppaux;
|
use util::ppaux;
|
||||||
|
|
||||||
use core::result;
|
use core::result;
|
||||||
|
@ -329,6 +330,7 @@ pub fn check_crate(tcx: ty::ctxt,
|
||||||
trait_map: resolve::TraitMap,
|
trait_map: resolve::TraitMap,
|
||||||
crate: @ast::crate)
|
crate: @ast::crate)
|
||||||
-> (method_map, vtable_map) {
|
-> (method_map, vtable_map) {
|
||||||
|
let time_passes = tcx.sess.time_passes();
|
||||||
let ccx = @mut CrateCtxt {
|
let ccx = @mut CrateCtxt {
|
||||||
trait_map: trait_map,
|
trait_map: trait_map,
|
||||||
method_map: oldmap::HashMap(),
|
method_map: oldmap::HashMap(),
|
||||||
|
@ -336,10 +338,16 @@ pub fn check_crate(tcx: ty::ctxt,
|
||||||
coherence_info: @coherence::CoherenceInfo(),
|
coherence_info: @coherence::CoherenceInfo(),
|
||||||
tcx: tcx
|
tcx: tcx
|
||||||
};
|
};
|
||||||
collect::collect_item_types(ccx, crate);
|
|
||||||
coherence::check_coherence(ccx, crate);
|
|
||||||
|
|
||||||
check::check_item_types(ccx, crate);
|
time(time_passes, ~"type collecting", ||
|
||||||
|
collect::collect_item_types(ccx, crate));
|
||||||
|
|
||||||
|
time(time_passes, ~"method resolution", ||
|
||||||
|
coherence::check_coherence(ccx, crate));
|
||||||
|
|
||||||
|
time(time_passes, ~"type checking", ||
|
||||||
|
check::check_item_types(ccx, crate));
|
||||||
|
|
||||||
check_for_main_fn(ccx);
|
check_for_main_fn(ccx);
|
||||||
tcx.sess.abort_if_errors();
|
tcx.sess.abort_if_errors();
|
||||||
(ccx.method_map, ccx.vtable_map)
|
(ccx.method_map, ccx.vtable_map)
|
||||||
|
|
|
@ -16,6 +16,16 @@ use syntax::visit;
|
||||||
|
|
||||||
use core::str;
|
use core::str;
|
||||||
use std::oldmap::HashMap;
|
use std::oldmap::HashMap;
|
||||||
|
use std;
|
||||||
|
|
||||||
|
pub fn time<T>(do_it: bool, what: ~str, thunk: &fn() -> T) -> T {
|
||||||
|
if !do_it { return thunk(); }
|
||||||
|
let start = std::time::precise_time_s();
|
||||||
|
let rv = thunk();
|
||||||
|
let end = std::time::precise_time_s();
|
||||||
|
io::println(fmt!("time: %3.3f s\t%s", end - start, what));
|
||||||
|
rv
|
||||||
|
}
|
||||||
|
|
||||||
pub fn indent<R>(op: &fn() -> R) -> R {
|
pub fn indent<R>(op: &fn() -> R) -> R {
|
||||||
// Use in conjunction with the log post-processor like `src/etc/indenter`
|
// Use in conjunction with the log post-processor like `src/etc/indenter`
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue