rustc: Remove a bunch of exterior vectors
This commit is contained in:
parent
a716eb28ec
commit
917afa4cc9
18 changed files with 302 additions and 331 deletions
|
|
@ -14,7 +14,6 @@ import back::x86;
|
|||
import util::common;
|
||||
import std::ivec;
|
||||
import std::str;
|
||||
import std::vec;
|
||||
import std::fs;
|
||||
import std::ioivec;
|
||||
import std::option;
|
||||
|
|
@ -47,7 +46,7 @@ fn read_crates(session::session sess,
|
|||
type env =
|
||||
@rec(session::session sess,
|
||||
@hashmap[str, int] crate_cache,
|
||||
vec[str] library_search_paths,
|
||||
str[] library_search_paths,
|
||||
mutable ast::crate_num next_crate_num);
|
||||
|
||||
fn visit_view_item(env e, &@ast::view_item i) {
|
||||
|
|
@ -128,7 +127,7 @@ fn default_native_lib_naming(session::session sess, bool static) ->
|
|||
|
||||
fn find_library_crate(&session::session sess, &ast::ident ident,
|
||||
&(@ast::meta_item)[] metas,
|
||||
&vec[str] library_search_paths)
|
||||
&str[] library_search_paths)
|
||||
-> option::t[tup(str, @u8[])] {
|
||||
|
||||
attr::require_unique_names(sess, metas);
|
||||
|
|
@ -162,7 +161,7 @@ fn find_library_crate(&session::session sess, &ast::ident ident,
|
|||
|
||||
fn find_library_crate_aux(&rec(str prefix, str suffix) nn, str crate_name,
|
||||
&(@ast::meta_item)[] metas,
|
||||
&vec[str] library_search_paths) ->
|
||||
&str[] library_search_paths) ->
|
||||
option::t[tup(str, @u8[])] {
|
||||
let str prefix = nn.prefix + crate_name;
|
||||
// FIXME: we could probably use a 'glob' function in std::fs but it will
|
||||
|
|
@ -220,7 +219,7 @@ fn get_metadata_section(str filename) -> option::t[@u8[]] {
|
|||
|
||||
fn load_library_crate(&session::session sess, span span,
|
||||
&ast::ident ident, &(@ast::meta_item)[] metas,
|
||||
&vec[str] library_search_paths) -> tup(str, @u8[]) {
|
||||
&str[] library_search_paths) -> tup(str, @u8[]) {
|
||||
|
||||
alt (find_library_crate(sess, ident, metas, library_search_paths)) {
|
||||
case (some(?t)) {
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ fn get_type_param_count(&cstore::cstore cstore, &ast::def_id def) -> uint {
|
|||
}
|
||||
|
||||
fn lookup_defs(&cstore::cstore cstore, ast::crate_num cnum,
|
||||
vec[ast::ident] path) -> vec[ast::def] {
|
||||
&ast::ident[] path) -> ast::def[] {
|
||||
auto cdata = cstore::get_crate_data(cstore, cnum).data;
|
||||
ret decoder::lookup_defs(cdata, cnum, path);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
// The crate store - a central repo for information collected about external
|
||||
// crates and libraries
|
||||
|
||||
import std::ivec;
|
||||
import std::map;
|
||||
import std::vec;
|
||||
import std::str;
|
||||
import syntax::ast;
|
||||
|
||||
|
|
@ -42,9 +42,9 @@ tag cstore {
|
|||
|
||||
type cstore_private = @rec(map::hashmap[ast::crate_num, crate_metadata] metas,
|
||||
use_crate_map use_crate_map,
|
||||
mutable vec[str] used_crate_files,
|
||||
mutable vec[str] used_libraries,
|
||||
mutable vec[str] used_link_args);
|
||||
mutable str[] used_crate_files,
|
||||
mutable str[] used_libraries,
|
||||
mutable str[] used_link_args);
|
||||
|
||||
// Map from node_id's of local use statements to crate numbers
|
||||
type use_crate_map = map::hashmap[ast::node_id, ast::crate_num];
|
||||
|
|
@ -61,9 +61,9 @@ fn mk_cstore() -> cstore {
|
|||
auto crate_map = map::new_int_hash[ast::crate_num]();
|
||||
ret private(@rec(metas = meta_cache,
|
||||
use_crate_map = crate_map,
|
||||
mutable used_crate_files = [],
|
||||
mutable used_libraries = [],
|
||||
mutable used_link_args = []));
|
||||
mutable used_crate_files = ~[],
|
||||
mutable used_libraries = ~[],
|
||||
mutable used_link_args = ~[]));
|
||||
}
|
||||
|
||||
fn get_crate_data(&cstore cstore, ast::crate_num cnum) -> crate_metadata {
|
||||
|
|
@ -86,35 +86,39 @@ iter iter_crate_data(&cstore cstore) -> @tup(ast::crate_num, crate_metadata) {
|
|||
}
|
||||
|
||||
fn add_used_crate_file(&cstore cstore, &str lib) {
|
||||
if (!vec::member(lib, p(cstore).used_crate_files)) {
|
||||
p(cstore).used_crate_files += [lib];
|
||||
if (!ivec::member(lib, p(cstore).used_crate_files)) {
|
||||
p(cstore).used_crate_files += ~[lib];
|
||||
}
|
||||
}
|
||||
|
||||
fn get_used_crate_files(&cstore cstore) -> vec[str] {
|
||||
fn get_used_crate_files(&cstore cstore) -> str[] {
|
||||
ret p(cstore).used_crate_files;
|
||||
}
|
||||
|
||||
fn add_used_library(&cstore cstore, &str lib) -> bool {
|
||||
if (lib == "") { ret false; }
|
||||
|
||||
if (vec::member(lib, p(cstore).used_libraries)) {
|
||||
if (ivec::member(lib, p(cstore).used_libraries)) {
|
||||
ret false;
|
||||
}
|
||||
|
||||
p(cstore).used_libraries += [lib];
|
||||
p(cstore).used_libraries += ~[lib];
|
||||
ret true;
|
||||
}
|
||||
|
||||
fn get_used_libraries(&cstore cstore) -> vec[str] {
|
||||
fn get_used_libraries(&cstore cstore) -> str[] {
|
||||
ret p(cstore).used_libraries;
|
||||
}
|
||||
|
||||
fn add_used_link_args(&cstore cstore, &str args) {
|
||||
p(cstore).used_link_args += str::split(args, ' ' as u8);
|
||||
auto used_link_args_vec = str::split(args, ' ' as u8);
|
||||
// TODO: Remove this vec->ivec conversion.
|
||||
for (str ula in used_link_args_vec) {
|
||||
p(cstore).used_link_args += ~[ula];
|
||||
}
|
||||
}
|
||||
|
||||
fn get_used_link_args(&cstore cstore) -> vec[str] {
|
||||
fn get_used_link_args(&cstore cstore) -> str[] {
|
||||
ret p(cstore).used_link_args;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
import std::ebmlivec;
|
||||
import std::ivec;
|
||||
import std::option;
|
||||
import std::vec;
|
||||
import std::str;
|
||||
import std::ioivec;
|
||||
import std::map::hashmap;
|
||||
|
|
@ -125,38 +124,38 @@ fn item_ty_param_count(&ebmlivec::doc item) -> uint {
|
|||
}
|
||||
|
||||
fn tag_variant_ids(&ebmlivec::doc item,
|
||||
ast::crate_num this_cnum) -> vec[ast::def_id] {
|
||||
let vec[ast::def_id] ids = [];
|
||||
ast::crate_num this_cnum) -> ast::def_id[] {
|
||||
let ast::def_id[] ids = ~[];
|
||||
auto v = tag_items_data_item_variant;
|
||||
for each (ebmlivec::doc p in ebmlivec::tagged_docs(item, v)) {
|
||||
auto ext = parse_def_id(ebmlivec::doc_data(p));
|
||||
vec::push[ast::def_id](ids, tup(this_cnum, ext._1));
|
||||
ids += ~[tup(this_cnum, ext._1)];
|
||||
}
|
||||
ret ids;
|
||||
}
|
||||
|
||||
// Given a path and serialized crate metadata, returns the ID of the
|
||||
// definition the path refers to.
|
||||
fn resolve_path(vec[ast::ident] path, @u8[] data) -> vec[ast::def_id] {
|
||||
fn resolve_path(&ast::ident[] path, @u8[] data) -> ast::def_id[] {
|
||||
fn eq_item(&u8[] data, str s) -> bool {
|
||||
ret str::eq(str::unsafe_from_bytes_ivec(data), s);
|
||||
}
|
||||
auto s = str::connect(path, "::");
|
||||
auto s = str::connect_ivec(path, "::");
|
||||
auto md = ebmlivec::new_doc(data);
|
||||
auto paths = ebmlivec::get_doc(md, tag_paths);
|
||||
auto eqer = bind eq_item(_, s);
|
||||
let vec[ast::def_id] result = [];
|
||||
let ast::def_id[] result = ~[];
|
||||
for (ebmlivec::doc doc in lookup_hash(paths, eqer, hash_path(s))) {
|
||||
auto did_doc = ebmlivec::get_doc(doc, tag_def_id);
|
||||
vec::push(result, parse_def_id(ebmlivec::doc_data(did_doc)));
|
||||
result += ~[parse_def_id(ebmlivec::doc_data(did_doc))];
|
||||
}
|
||||
ret result;
|
||||
}
|
||||
|
||||
// Crate metadata queries
|
||||
fn lookup_defs(&@u8[] data, ast::crate_num cnum,
|
||||
vec[ast::ident] path) -> vec[ast::def] {
|
||||
ret vec::map(bind lookup_def(cnum, data, _), resolve_path(path, data));
|
||||
fn lookup_defs(&@u8[] data, ast::crate_num cnum, &ast::ident[] path)
|
||||
-> ast::def[] {
|
||||
ret ivec::map(bind lookup_def(cnum, data, _), resolve_path(path, data));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -352,8 +351,8 @@ fn get_crate_attributes(@u8[] data) -> ast::attribute[] {
|
|||
|
||||
type crate_dep = tup(ast::crate_num, str);
|
||||
|
||||
fn get_crate_deps(@u8[] data) -> vec[crate_dep] {
|
||||
let vec[crate_dep] deps = [];
|
||||
fn get_crate_deps(@u8[] data) -> crate_dep[] {
|
||||
let crate_dep[] deps = ~[];
|
||||
auto cratedoc = ebmlivec::new_doc(data);
|
||||
auto depsdoc = ebmlivec::get_doc(cratedoc, tag_crate_deps);
|
||||
auto crate_num = 1;
|
||||
|
|
@ -361,7 +360,7 @@ fn get_crate_deps(@u8[] data) -> vec[crate_dep] {
|
|||
ebmlivec::tagged_docs(depsdoc, tag_crate_dep)) {
|
||||
auto depname =
|
||||
str::unsafe_from_bytes_ivec(ebmlivec::doc_data(depdoc));
|
||||
deps += [tup(crate_num, depname)];
|
||||
deps += ~[tup(crate_num, depname)];
|
||||
crate_num += 1;
|
||||
}
|
||||
ret deps;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
import std::ivec;
|
||||
import std::str;
|
||||
import std::vec;
|
||||
import std::uint;
|
||||
import std::option;
|
||||
import std::option::none;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue