Convert rustc::metadata to istrs. Issue #855
This commit is contained in:
parent
7d70685eef
commit
54691f9a6c
@ -491,9 +491,10 @@ fn main(args: [str]) {
|
|||||||
} else if n_inputs > 1u {
|
} else if n_inputs > 1u {
|
||||||
sess.fatal("Multiple input filenames provided.");
|
sess.fatal("Multiple input filenames provided.");
|
||||||
}
|
}
|
||||||
let ifile = istr::to_estr(match.free[0]);
|
let ifile = match.free[0];
|
||||||
let saved_out_filename: str = "";
|
let saved_out_filename: str = "";
|
||||||
let cfg = build_configuration(sess, binary, ifile);
|
let cfg = build_configuration(sess, binary,
|
||||||
|
istr::to_estr(ifile));
|
||||||
let pretty =
|
let pretty =
|
||||||
option::map::<istr,
|
option::map::<istr,
|
||||||
pp_mode>(bind parse_pretty(sess, _),
|
pp_mode>(bind parse_pretty(sess, _),
|
||||||
@ -501,7 +502,7 @@ fn main(args: [str]) {
|
|||||||
~"normal"));
|
~"normal"));
|
||||||
alt pretty {
|
alt pretty {
|
||||||
some::<pp_mode>(ppm) {
|
some::<pp_mode>(ppm) {
|
||||||
pretty_print_input(sess, cfg, ifile, ppm);
|
pretty_print_input(sess, cfg, istr::to_estr(ifile), ppm);
|
||||||
ret;
|
ret;
|
||||||
}
|
}
|
||||||
none::<pp_mode>. {/* continue */ }
|
none::<pp_mode>. {/* continue */ }
|
||||||
@ -519,8 +520,8 @@ fn main(args: [str]) {
|
|||||||
// have to make up a name
|
// have to make up a name
|
||||||
// We want to toss everything after the final '.'
|
// We want to toss everything after the final '.'
|
||||||
let parts =
|
let parts =
|
||||||
if !input_is_stdin(ifile) {
|
if !input_is_stdin(istr::to_estr(ifile)) {
|
||||||
str::split(ifile, '.' as u8)
|
istr::to_estrs(istr::split(ifile, '.' as u8))
|
||||||
} else { ["default", "rs"] };
|
} else { ["default", "rs"] };
|
||||||
vec::pop(parts);
|
vec::pop(parts);
|
||||||
saved_out_filename = str::connect(parts, ".");
|
saved_out_filename = str::connect(parts, ".");
|
||||||
@ -536,7 +537,7 @@ fn main(args: [str]) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
let ofile = saved_out_filename + "." + suffix;
|
let ofile = saved_out_filename + "." + suffix;
|
||||||
compile_input(sess, cfg, ifile, ofile);
|
compile_input(sess, cfg, istr::to_estr(ifile), ofile);
|
||||||
}
|
}
|
||||||
some(ofile) {
|
some(ofile) {
|
||||||
let ofile = istr::to_estr(ofile);
|
let ofile = istr::to_estr(ofile);
|
||||||
@ -544,7 +545,7 @@ fn main(args: [str]) {
|
|||||||
saved_out_filename = ofile;
|
saved_out_filename = ofile;
|
||||||
let temp_filename =
|
let temp_filename =
|
||||||
if !stop_after_codegen { ofile + ".o" } else { ofile };
|
if !stop_after_codegen { ofile + ".o" } else { ofile };
|
||||||
compile_input(sess, cfg, ifile, temp_filename);
|
compile_input(sess, cfg, istr::to_estr(ifile), temp_filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -596,12 +597,12 @@ fn rmext(filename: &istr) -> istr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let cstore = sess.get_cstore();
|
let cstore = sess.get_cstore();
|
||||||
for cratepath: str in cstore::get_used_crate_files(cstore) {
|
for cratepath: istr in cstore::get_used_crate_files(cstore) {
|
||||||
if str::ends_with(cratepath, ".rlib") {
|
if istr::ends_with(cratepath, ~".rlib") {
|
||||||
gcc_args += [istr::from_estr(cratepath)];
|
gcc_args += [cratepath];
|
||||||
cont;
|
cont;
|
||||||
}
|
}
|
||||||
let cratepath = istr::from_estr(cratepath);
|
let cratepath = cratepath;
|
||||||
let dir = fs::dirname(cratepath);
|
let dir = fs::dirname(cratepath);
|
||||||
if dir != ~"" { gcc_args += [~"-L" + dir]; }
|
if dir != ~"" { gcc_args += [~"-L" + dir]; }
|
||||||
let libarg = unlib(sess.get_targ_cfg(), fs::basename(cratepath));
|
let libarg = unlib(sess.get_targ_cfg(), fs::basename(cratepath));
|
||||||
@ -609,10 +610,10 @@ fn rmext(filename: &istr) -> istr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let ula = cstore::get_used_link_args(cstore);
|
let ula = cstore::get_used_link_args(cstore);
|
||||||
for arg: str in ula { gcc_args += [istr::from_estr(arg)]; }
|
for arg: istr in ula { gcc_args += [arg]; }
|
||||||
|
|
||||||
let used_libs = cstore::get_used_libraries(cstore);
|
let used_libs = cstore::get_used_libraries(cstore);
|
||||||
for l: str in used_libs { gcc_args += [~"-l" + istr::from_estr(l)]; }
|
for l: istr in used_libs { gcc_args += [~"-l" + l]; }
|
||||||
|
|
||||||
if sopts.library {
|
if sopts.library {
|
||||||
gcc_args += [istr::from_estr(lib_cmd)];
|
gcc_args += [istr::from_estr(lib_cmd)];
|
||||||
|
@ -35,7 +35,8 @@ fn read_crates(sess: session::session, crate: &ast::crate) {
|
|||||||
let e =
|
let e =
|
||||||
@{sess: sess,
|
@{sess: sess,
|
||||||
crate_cache: @std::map::new_str_hash::<int>(),
|
crate_cache: @std::map::new_str_hash::<int>(),
|
||||||
library_search_paths: sess.get_opts().library_search_paths,
|
library_search_paths:
|
||||||
|
istr::from_estrs(sess.get_opts().library_search_paths),
|
||||||
mutable next_crate_num: 1};
|
mutable next_crate_num: 1};
|
||||||
let v =
|
let v =
|
||||||
visit::mk_simple_visitor(@{visit_view_item:
|
visit::mk_simple_visitor(@{visit_view_item:
|
||||||
@ -48,7 +49,7 @@ fn read_crates(sess: session::session, crate: &ast::crate) {
|
|||||||
type env =
|
type env =
|
||||||
@{sess: session::session,
|
@{sess: session::session,
|
||||||
crate_cache: @hashmap<istr, int>,
|
crate_cache: @hashmap<istr, int>,
|
||||||
library_search_paths: [str],
|
library_search_paths: [istr],
|
||||||
mutable next_crate_num: ast::crate_num};
|
mutable next_crate_num: ast::crate_num};
|
||||||
|
|
||||||
fn visit_view_item(e: env, i: &@ast::view_item) {
|
fn visit_view_item(e: env, i: &@ast::view_item) {
|
||||||
@ -69,12 +70,12 @@ fn visit_item(e: env, i: &@ast::item) {
|
|||||||
}
|
}
|
||||||
let cstore = e.sess.get_cstore();
|
let cstore = e.sess.get_cstore();
|
||||||
if !cstore::add_used_library(cstore,
|
if !cstore::add_used_library(cstore,
|
||||||
istr::to_estr(m.native_name)) { ret; }
|
m.native_name) { ret; }
|
||||||
for a: ast::attribute in
|
for a: ast::attribute in
|
||||||
attr::find_attrs_by_name(i.attrs, ~"link_args") {
|
attr::find_attrs_by_name(i.attrs, ~"link_args") {
|
||||||
alt attr::get_meta_item_value_str(attr::attr_meta(a)) {
|
alt attr::get_meta_item_value_str(attr::attr_meta(a)) {
|
||||||
some(linkarg) {
|
some(linkarg) {
|
||||||
cstore::add_used_link_args(cstore, istr::to_estr(linkarg));
|
cstore::add_used_link_args(cstore, linkarg);
|
||||||
}
|
}
|
||||||
none. {/* fallthrough */ }
|
none. {/* fallthrough */ }
|
||||||
}
|
}
|
||||||
@ -85,12 +86,12 @@ fn visit_item(e: env, i: &@ast::item) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// A diagnostic function for dumping crate metadata to an output stream
|
// A diagnostic function for dumping crate metadata to an output stream
|
||||||
fn list_file_metadata(path: str, out: io::writer) {
|
fn list_file_metadata(path: &istr, out: io::writer) {
|
||||||
alt get_metadata_section(path) {
|
alt get_metadata_section(path) {
|
||||||
option::some(bytes) { decoder::list_crate_metadata(bytes, out); }
|
option::some(bytes) { decoder::list_crate_metadata(bytes, out); }
|
||||||
option::none. {
|
option::none. {
|
||||||
out.write_str(
|
out.write_str(
|
||||||
istr::from_estr("Could not find metadata in " + path + ".\n"));
|
~"Could not find metadata in " + path + ~".\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -112,18 +113,18 @@ fn metadata_matches(crate_data: &@[u8], metas: &[@ast::meta_item]) -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn default_native_lib_naming(sess: session::session, static: bool) ->
|
fn default_native_lib_naming(sess: session::session, static: bool) ->
|
||||||
{prefix: str, suffix: str} {
|
{prefix: istr, suffix: istr} {
|
||||||
if static { ret {prefix: "lib", suffix: ".rlib"}; }
|
if static { ret {prefix: ~"lib", suffix: ~".rlib"}; }
|
||||||
alt sess.get_targ_cfg().os {
|
alt sess.get_targ_cfg().os {
|
||||||
session::os_win32. { ret {prefix: "", suffix: ".dll"}; }
|
session::os_win32. { ret {prefix: ~"", suffix: ~".dll"}; }
|
||||||
session::os_macos. { ret {prefix: "lib", suffix: ".dylib"}; }
|
session::os_macos. { ret {prefix: ~"lib", suffix: ~".dylib"}; }
|
||||||
session::os_linux. { ret {prefix: "lib", suffix: ".so"}; }
|
session::os_linux. { ret {prefix: ~"lib", suffix: ~".so"}; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_library_crate(sess: &session::session, ident: &ast::ident,
|
fn find_library_crate(sess: &session::session, ident: &ast::ident,
|
||||||
metas: &[@ast::meta_item], library_search_paths: &[str])
|
metas: &[@ast::meta_item], library_search_paths: &[istr])
|
||||||
-> option::t<{ident: str, data: @[u8]}> {
|
-> option::t<{ident: istr, data: @[u8]}> {
|
||||||
|
|
||||||
attr::require_unique_names(sess, metas);
|
attr::require_unique_names(sess, metas);
|
||||||
|
|
||||||
@ -145,37 +146,36 @@ fn find_library_crate(sess: &session::session, ident: &ast::ident,
|
|||||||
|
|
||||||
let nn = default_native_lib_naming(sess, sess.get_opts().static);
|
let nn = default_native_lib_naming(sess, sess.get_opts().static);
|
||||||
let x =
|
let x =
|
||||||
find_library_crate_aux(nn, istr::to_estr(crate_name),
|
find_library_crate_aux(nn, crate_name,
|
||||||
metas, library_search_paths);
|
metas, library_search_paths);
|
||||||
if x != none || sess.get_opts().static { ret x; }
|
if x != none || sess.get_opts().static { ret x; }
|
||||||
let nn2 = default_native_lib_naming(sess, true);
|
let nn2 = default_native_lib_naming(sess, true);
|
||||||
ret find_library_crate_aux(nn2, istr::to_estr(crate_name),
|
ret find_library_crate_aux(nn2, crate_name,
|
||||||
metas, library_search_paths);
|
metas, library_search_paths);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_library_crate_aux(nn: &{prefix: str, suffix: str}, crate_name: str,
|
fn find_library_crate_aux(nn: &{prefix: istr, suffix: istr},
|
||||||
|
crate_name: &istr,
|
||||||
metas: &[@ast::meta_item],
|
metas: &[@ast::meta_item],
|
||||||
library_search_paths: &[str]) ->
|
library_search_paths: &[istr]) ->
|
||||||
option::t<{ident: str, data: @[u8]}> {
|
option::t<{ident: istr, data: @[u8]}> {
|
||||||
let prefix: istr = istr::from_estr(nn.prefix + crate_name);
|
let prefix: istr = nn.prefix + crate_name;
|
||||||
let suffix: istr = istr::from_estr(nn.suffix);
|
let suffix: istr = nn.suffix;
|
||||||
// FIXME: we could probably use a 'glob' function in std::fs but it will
|
// FIXME: we could probably use a 'glob' function in std::fs but it will
|
||||||
// be much easier to write once the unsafe module knows more about FFI
|
// be much easier to write once the unsafe module knows more about FFI
|
||||||
// tricks. Currently the glob(3) interface is a bit more than we can
|
// tricks. Currently the glob(3) interface is a bit more than we can
|
||||||
// stomach from here, and writing a C++ wrapper is more work than just
|
// stomach from here, and writing a C++ wrapper is more work than just
|
||||||
// manually filtering fs::list_dir here.
|
// manually filtering fs::list_dir here.
|
||||||
|
|
||||||
for library_search_path: str in library_search_paths {
|
for library_search_path: istr in library_search_paths {
|
||||||
log #fmt["searching %s", library_search_path];
|
log #fmt["searching %s", istr::to_estr(library_search_path)];
|
||||||
let library_search_path = istr::from_estr(library_search_path);
|
|
||||||
for path: istr in fs::list_dir(library_search_path) {
|
for path: istr in fs::list_dir(library_search_path) {
|
||||||
log #fmt["searching %s", istr::to_estr(path)];
|
log #fmt["searching %s", istr::to_estr(path)];
|
||||||
let f: istr = fs::basename(path);
|
let f: istr = fs::basename(path);
|
||||||
let path = istr::to_estr(path);
|
|
||||||
if !(istr::starts_with(f, prefix) && istr::ends_with(f, suffix))
|
if !(istr::starts_with(f, prefix) && istr::ends_with(f, suffix))
|
||||||
{
|
{
|
||||||
log #fmt["skipping %s, doesn't look like %s*%s",
|
log #fmt["skipping %s, doesn't look like %s*%s",
|
||||||
path,
|
istr::to_estr(path),
|
||||||
istr::to_estr(prefix),
|
istr::to_estr(prefix),
|
||||||
istr::to_estr(suffix)];
|
istr::to_estr(suffix)];
|
||||||
cont;
|
cont;
|
||||||
@ -183,10 +183,12 @@ fn find_library_crate_aux(nn: &{prefix: str, suffix: str}, crate_name: str,
|
|||||||
alt get_metadata_section(path) {
|
alt get_metadata_section(path) {
|
||||||
option::some(cvec) {
|
option::some(cvec) {
|
||||||
if !metadata_matches(cvec, metas) {
|
if !metadata_matches(cvec, metas) {
|
||||||
log #fmt["skipping %s, metadata doesn't match", path];
|
log #fmt["skipping %s, metadata doesn't match",
|
||||||
|
istr::to_estr(path)];
|
||||||
cont;
|
cont;
|
||||||
}
|
}
|
||||||
log #fmt["found %s with matching metadata", path];
|
log #fmt["found %s with matching metadata",
|
||||||
|
istr::to_estr(path)];
|
||||||
ret some({ident: path, data: cvec});
|
ret some({ident: path, data: cvec});
|
||||||
}
|
}
|
||||||
_ { }
|
_ { }
|
||||||
@ -196,8 +198,8 @@ fn find_library_crate_aux(nn: &{prefix: str, suffix: str}, crate_name: str,
|
|||||||
ret none;
|
ret none;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_metadata_section(filename: str) -> option::t<@[u8]> {
|
fn get_metadata_section(filename: &istr) -> option::t<@[u8]> {
|
||||||
let mb = istr::as_buf(istr::from_estr(filename), { |buf|
|
let mb = istr::as_buf(filename, { |buf|
|
||||||
llvm::LLVMRustCreateMemoryBufferWithContentsOfFile(buf)
|
llvm::LLVMRustCreateMemoryBufferWithContentsOfFile(buf)
|
||||||
});
|
});
|
||||||
if mb as int == 0 { ret option::none::<@[u8]>; }
|
if mb as int == 0 { ret option::none::<@[u8]>; }
|
||||||
@ -218,8 +220,9 @@ fn get_metadata_section(filename: str) -> option::t<@[u8]> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn load_library_crate(sess: &session::session, span: span, ident: &ast::ident,
|
fn load_library_crate(sess: &session::session, span: span, ident: &ast::ident,
|
||||||
metas: &[@ast::meta_item], library_search_paths: &[str])
|
metas: &[@ast::meta_item],
|
||||||
-> {ident: str, data: @[u8]} {
|
library_search_paths: &[istr])
|
||||||
|
-> {ident: istr, data: @[u8]} {
|
||||||
|
|
||||||
|
|
||||||
alt find_library_crate(sess, ident, metas, library_search_paths) {
|
alt find_library_crate(sess, ident, metas, library_search_paths) {
|
||||||
@ -249,12 +252,13 @@ fn resolve_crate(e: env, ident: &ast::ident, metas: [@ast::meta_item],
|
|||||||
// Now resolve the crates referenced by this crate
|
// Now resolve the crates referenced by this crate
|
||||||
let cnum_map = resolve_crate_deps(e, cdata);
|
let cnum_map = resolve_crate_deps(e, cdata);
|
||||||
|
|
||||||
let cmeta = {name: istr::to_estr(ident),
|
let cmeta = {name: ident,
|
||||||
data: cdata, cnum_map: cnum_map};
|
data: cdata, cnum_map: cnum_map};
|
||||||
|
|
||||||
let cstore = e.sess.get_cstore();
|
let cstore = e.sess.get_cstore();
|
||||||
cstore::set_crate_data(cstore, cnum, cmeta);
|
cstore::set_crate_data(cstore, cnum, cmeta);
|
||||||
cstore::add_used_crate_file(cstore, cfilename);
|
cstore::add_used_crate_file(cstore,
|
||||||
|
cfilename);
|
||||||
ret cnum;
|
ret cnum;
|
||||||
} else { ret e.crate_cache.get(ident); }
|
} else { ret e.crate_cache.get(ident); }
|
||||||
}
|
}
|
||||||
@ -268,11 +272,11 @@ fn resolve_crate_deps(e: env, cdata: &@[u8]) -> cstore::cnum_map {
|
|||||||
for dep: decoder::crate_dep in decoder::get_crate_deps(cdata) {
|
for dep: decoder::crate_dep in decoder::get_crate_deps(cdata) {
|
||||||
let extrn_cnum = dep.cnum;
|
let extrn_cnum = dep.cnum;
|
||||||
let cname = dep.ident;
|
let cname = dep.ident;
|
||||||
log #fmt["resolving dep %s", cname];
|
log #fmt["resolving dep %s", istr::to_estr(cname)];
|
||||||
if e.crate_cache.contains_key(istr::from_estr(cname)) {
|
if e.crate_cache.contains_key(cname) {
|
||||||
log "already have it";
|
log "already have it";
|
||||||
// We've already seen this crate
|
// We've already seen this crate
|
||||||
let local_cnum = e.crate_cache.get(istr::from_estr(cname));
|
let local_cnum = e.crate_cache.get(cname);
|
||||||
cnum_map.insert(extrn_cnum, local_cnum);
|
cnum_map.insert(extrn_cnum, local_cnum);
|
||||||
} else {
|
} else {
|
||||||
log "need to load it";
|
log "need to load it";
|
||||||
@ -280,7 +284,7 @@ fn resolve_crate_deps(e: env, cdata: &@[u8]) -> cstore::cnum_map {
|
|||||||
// FIXME: Need better error reporting than just a bogus span
|
// FIXME: Need better error reporting than just a bogus span
|
||||||
let fake_span = ast_util::dummy_sp();
|
let fake_span = ast_util::dummy_sp();
|
||||||
let local_cnum = resolve_crate(e,
|
let local_cnum = resolve_crate(e,
|
||||||
istr::from_estr(cname),
|
cname,
|
||||||
[], fake_span);
|
[], fake_span);
|
||||||
cnum_map.insert(extrn_cnum, local_cnum);
|
cnum_map.insert(extrn_cnum, local_cnum);
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
export get_tag_variants;
|
export get_tag_variants;
|
||||||
export get_type;
|
export get_type;
|
||||||
|
|
||||||
fn get_symbol(cstore: &cstore::cstore, def: ast::def_id) -> str {
|
fn get_symbol(cstore: &cstore::cstore, def: ast::def_id) -> istr {
|
||||||
let cdata = cstore::get_crate_data(cstore, def.crate).data;
|
let cdata = cstore::get_crate_data(cstore, def.crate).data;
|
||||||
ret decoder::get_symbol(cdata, def.node);
|
ret decoder::get_symbol(cdata, def.node);
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
import std::vec;
|
import std::vec;
|
||||||
import std::map;
|
import std::map;
|
||||||
import std::str;
|
import std::str;
|
||||||
|
import std::istr;
|
||||||
import syntax::ast;
|
import syntax::ast;
|
||||||
|
|
||||||
export cstore;
|
export cstore;
|
||||||
@ -29,7 +30,7 @@
|
|||||||
// own crate numbers.
|
// own crate numbers.
|
||||||
type cnum_map = map::hashmap<ast::crate_num, ast::crate_num>;
|
type cnum_map = map::hashmap<ast::crate_num, ast::crate_num>;
|
||||||
|
|
||||||
type crate_metadata = {name: str, data: @[u8], cnum_map: cnum_map};
|
type crate_metadata = {name: istr, data: @[u8], cnum_map: cnum_map};
|
||||||
|
|
||||||
// This is a bit of an experiment at encapsulating the data in cstore. By
|
// This is a bit of an experiment at encapsulating the data in cstore. By
|
||||||
// keeping all the data in a non-exported tag variant, it's impossible for
|
// keeping all the data in a non-exported tag variant, it's impossible for
|
||||||
@ -41,9 +42,9 @@
|
|||||||
type cstore_private =
|
type cstore_private =
|
||||||
@{metas: map::hashmap<ast::crate_num, crate_metadata>,
|
@{metas: map::hashmap<ast::crate_num, crate_metadata>,
|
||||||
use_crate_map: use_crate_map,
|
use_crate_map: use_crate_map,
|
||||||
mutable used_crate_files: [str],
|
mutable used_crate_files: [istr],
|
||||||
mutable used_libraries: [str],
|
mutable used_libraries: [istr],
|
||||||
mutable used_link_args: [str]};
|
mutable used_link_args: [istr]};
|
||||||
|
|
||||||
// Map from node_id's of local use statements to crate numbers
|
// Map from node_id's of local use statements to crate numbers
|
||||||
type use_crate_map = map::hashmap<ast::node_id, ast::crate_num>;
|
type use_crate_map = map::hashmap<ast::node_id, ast::crate_num>;
|
||||||
@ -82,18 +83,18 @@ fn have_crate_data(cstore: &cstore, cnum: ast::crate_num) -> bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_used_crate_file(cstore: &cstore, lib: &str) {
|
fn add_used_crate_file(cstore: &cstore, lib: &istr) {
|
||||||
if !vec::member(lib, p(cstore).used_crate_files) {
|
if !vec::member(lib, p(cstore).used_crate_files) {
|
||||||
p(cstore).used_crate_files += [lib];
|
p(cstore).used_crate_files += [lib];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_used_crate_files(cstore: &cstore) -> [str] {
|
fn get_used_crate_files(cstore: &cstore) -> [istr] {
|
||||||
ret p(cstore).used_crate_files;
|
ret p(cstore).used_crate_files;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_used_library(cstore: &cstore, lib: &str) -> bool {
|
fn add_used_library(cstore: &cstore, lib: &istr) -> bool {
|
||||||
if lib == "" { ret false; }
|
if lib == ~"" { ret false; }
|
||||||
|
|
||||||
if vec::member(lib, p(cstore).used_libraries) { ret false; }
|
if vec::member(lib, p(cstore).used_libraries) { ret false; }
|
||||||
|
|
||||||
@ -101,15 +102,15 @@ fn add_used_library(cstore: &cstore, lib: &str) -> bool {
|
|||||||
ret true;
|
ret true;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_used_libraries(cstore: &cstore) -> [str] {
|
fn get_used_libraries(cstore: &cstore) -> [istr] {
|
||||||
ret p(cstore).used_libraries;
|
ret p(cstore).used_libraries;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_used_link_args(cstore: &cstore, args: &str) {
|
fn add_used_link_args(cstore: &cstore, args: &istr) {
|
||||||
p(cstore).used_link_args += str::split(args, ' ' as u8);
|
p(cstore).used_link_args += istr::split(args, ' ' as u8);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_used_link_args(cstore: &cstore) -> [str] {
|
fn get_used_link_args(cstore: &cstore) -> [istr] {
|
||||||
ret p(cstore).used_link_args;
|
ret p(cstore).used_link_args;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,9 +84,9 @@ fn item_family(item: &ebml::doc) -> u8 {
|
|||||||
ret ebml::doc_as_uint(fam) as u8;
|
ret ebml::doc_as_uint(fam) as u8;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn item_symbol(item: &ebml::doc) -> str {
|
fn item_symbol(item: &ebml::doc) -> istr {
|
||||||
let sym = ebml::get_doc(item, tag_items_data_item_symbol);
|
let sym = ebml::get_doc(item, tag_items_data_item_symbol);
|
||||||
ret str::unsafe_from_bytes(ebml::doc_data(sym));
|
ret istr::unsafe_from_bytes(ebml::doc_data(sym));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn variant_tag_id(d: &ebml::doc) -> ast::def_id {
|
fn variant_tag_id(d: &ebml::doc) -> ast::def_id {
|
||||||
@ -97,9 +97,9 @@ fn variant_tag_id(d: &ebml::doc) -> ast::def_id {
|
|||||||
fn item_type(item: &ebml::doc, this_cnum: ast::crate_num, tcx: ty::ctxt,
|
fn item_type(item: &ebml::doc, this_cnum: ast::crate_num, tcx: ty::ctxt,
|
||||||
extres: &external_resolver) -> ty::t {
|
extres: &external_resolver) -> ty::t {
|
||||||
fn parse_external_def_id(this_cnum: ast::crate_num,
|
fn parse_external_def_id(this_cnum: ast::crate_num,
|
||||||
extres: &external_resolver, s: str) ->
|
extres: &external_resolver, s: &istr) ->
|
||||||
ast::def_id {
|
ast::def_id {
|
||||||
let buf = str::bytes(s);
|
let buf = istr::bytes(s);
|
||||||
let external_def_id = parse_def_id(buf);
|
let external_def_id = parse_def_id(buf);
|
||||||
|
|
||||||
|
|
||||||
@ -150,16 +150,16 @@ fn tag_variant_ids(item: &ebml::doc, this_cnum: ast::crate_num) ->
|
|||||||
// Given a path and serialized crate metadata, returns the ID of the
|
// Given a path and serialized crate metadata, returns the ID of the
|
||||||
// definition the path refers to.
|
// definition the path refers to.
|
||||||
fn resolve_path(path: &[ast::ident], data: @[u8]) -> [ast::def_id] {
|
fn resolve_path(path: &[ast::ident], data: @[u8]) -> [ast::def_id] {
|
||||||
fn eq_item(data: &[u8], s: str) -> bool {
|
fn eq_item(data: &[u8], s: &istr) -> bool {
|
||||||
ret str::eq(str::unsafe_from_bytes(data), s);
|
ret istr::eq(istr::unsafe_from_bytes(data), s);
|
||||||
}
|
}
|
||||||
let s = istr::to_estr(istr::connect(path, ~"::"));
|
let s = istr::connect(path, ~"::");
|
||||||
let md = ebml::new_doc(data);
|
let md = ebml::new_doc(data);
|
||||||
let paths = ebml::get_doc(md, tag_paths);
|
let paths = ebml::get_doc(md, tag_paths);
|
||||||
let eqer = bind eq_item(_, s);
|
let eqer = bind eq_item(_, s);
|
||||||
let result: [ast::def_id] = [];
|
let result: [ast::def_id] = [];
|
||||||
for doc: ebml::doc in lookup_hash(paths, eqer,
|
for doc: ebml::doc in lookup_hash(paths, eqer,
|
||||||
hash_path(istr::from_estr(s))) {
|
hash_path(s)) {
|
||||||
let did_doc = ebml::get_doc(doc, tag_def_id);
|
let did_doc = ebml::get_doc(doc, tag_def_id);
|
||||||
result += [parse_def_id(ebml::doc_data(did_doc))];
|
result += [parse_def_id(ebml::doc_data(did_doc))];
|
||||||
}
|
}
|
||||||
@ -223,7 +223,7 @@ fn get_type_param_kinds(data: @[u8], id: ast::node_id) -> [ast::kind] {
|
|||||||
ret item_ty_param_kinds(lookup_item(id, data));
|
ret item_ty_param_kinds(lookup_item(id, data));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_symbol(data: @[u8], id: ast::node_id) -> str {
|
fn get_symbol(data: @[u8], id: ast::node_id) -> istr {
|
||||||
ret item_symbol(lookup_item(id, data));
|
ret item_symbol(lookup_item(id, data));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,31 +269,31 @@ fn family_has_type_params(fam_ch: u8) -> bool {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_path(d: &ebml::doc) -> {path: str, pos: uint} {
|
fn read_path(d: &ebml::doc) -> {path: istr, pos: uint} {
|
||||||
let desc = ebml::doc_data(d);
|
let desc = ebml::doc_data(d);
|
||||||
let pos = ebml::be_uint_from_bytes(@desc, 0u, 4u);
|
let pos = ebml::be_uint_from_bytes(@desc, 0u, 4u);
|
||||||
let pathbytes = vec::slice::<u8>(desc, 4u, vec::len::<u8>(desc));
|
let pathbytes = vec::slice::<u8>(desc, 4u, vec::len::<u8>(desc));
|
||||||
let path = str::unsafe_from_bytes(pathbytes);
|
let path = istr::unsafe_from_bytes(pathbytes);
|
||||||
ret {path: path, pos: pos};
|
ret {path: path, pos: pos};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn describe_def(items: &ebml::doc, id: ast::def_id) -> str {
|
fn describe_def(items: &ebml::doc, id: ast::def_id) -> istr {
|
||||||
if id.crate != ast::local_crate { ret "external"; }
|
if id.crate != ast::local_crate { ret ~"external"; }
|
||||||
ret item_family_to_str(item_family(find_item(id.node, items)));
|
ret item_family_to_str(item_family(find_item(id.node, items)));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn item_family_to_str(fam: u8) -> str {
|
fn item_family_to_str(fam: u8) -> istr {
|
||||||
alt fam as char {
|
alt fam as char {
|
||||||
'c' { ret "const"; }
|
'c' { ret ~"const"; }
|
||||||
'f' { ret "fn"; }
|
'f' { ret ~"fn"; }
|
||||||
'p' { ret "pure fn"; }
|
'p' { ret ~"pure fn"; }
|
||||||
'F' { ret "native fn"; }
|
'F' { ret ~"native fn"; }
|
||||||
'y' { ret "type"; }
|
'y' { ret ~"type"; }
|
||||||
'T' { ret "native type"; }
|
'T' { ret ~"native type"; }
|
||||||
't' { ret "type"; }
|
't' { ret ~"type"; }
|
||||||
'm' { ret "mod"; }
|
'm' { ret ~"mod"; }
|
||||||
'n' { ret "native mod"; }
|
'n' { ret ~"native mod"; }
|
||||||
'v' { ret "tag"; }
|
'v' { ret ~"tag"; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -368,7 +368,7 @@ fn get_crate_attributes(data: @[u8]) -> [ast::attribute] {
|
|||||||
ret get_attributes(ebml::new_doc(data));
|
ret get_attributes(ebml::new_doc(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
type crate_dep = {cnum: ast::crate_num, ident: str};
|
type crate_dep = {cnum: ast::crate_num, ident: istr};
|
||||||
|
|
||||||
fn get_crate_deps(data: @[u8]) -> [crate_dep] {
|
fn get_crate_deps(data: @[u8]) -> [crate_dep] {
|
||||||
let deps: [crate_dep] = [];
|
let deps: [crate_dep] = [];
|
||||||
@ -376,7 +376,7 @@ fn get_crate_deps(data: @[u8]) -> [crate_dep] {
|
|||||||
let depsdoc = ebml::get_doc(cratedoc, tag_crate_deps);
|
let depsdoc = ebml::get_doc(cratedoc, tag_crate_deps);
|
||||||
let crate_num = 1;
|
let crate_num = 1;
|
||||||
for each depdoc: ebml::doc in ebml::tagged_docs(depsdoc, tag_crate_dep) {
|
for each depdoc: ebml::doc in ebml::tagged_docs(depsdoc, tag_crate_dep) {
|
||||||
let depname = str::unsafe_from_bytes(ebml::doc_data(depdoc));
|
let depname = istr::unsafe_from_bytes(ebml::doc_data(depdoc));
|
||||||
deps += [{cnum: crate_num, ident: depname}];
|
deps += [{cnum: crate_num, ident: depname}];
|
||||||
crate_num += 1;
|
crate_num += 1;
|
||||||
}
|
}
|
||||||
@ -388,7 +388,8 @@ fn list_crate_deps(data: @[u8], out: io::writer) {
|
|||||||
|
|
||||||
for dep: crate_dep in get_crate_deps(data) {
|
for dep: crate_dep in get_crate_deps(data) {
|
||||||
out.write_str(
|
out.write_str(
|
||||||
istr::from_estr(#fmt["%d %s\n", dep.cnum, dep.ident]));
|
istr::from_estr(#fmt["%d %s\n", dep.cnum,
|
||||||
|
istr::to_estr(dep.ident)]));
|
||||||
}
|
}
|
||||||
|
|
||||||
out.write_str(~"\n");
|
out.write_str(~"\n");
|
||||||
@ -409,8 +410,10 @@ fn list_crate_items(bytes: &@[u8], md: &ebml::doc, out: io::writer) {
|
|||||||
let did_doc = ebml::get_doc(def, tag_def_id);
|
let did_doc = ebml::get_doc(def, tag_def_id);
|
||||||
let did = parse_def_id(ebml::doc_data(did_doc));
|
let did = parse_def_id(ebml::doc_data(did_doc));
|
||||||
out.write_str(
|
out.write_str(
|
||||||
istr::from_estr(#fmt["%s (%s)\n", data.path,
|
istr::from_estr(
|
||||||
describe_def(items, did)]));
|
#fmt["%s (%s)\n",
|
||||||
|
istr::to_estr(data.path),
|
||||||
|
istr::to_estr(describe_def(items, did))]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
out.write_str(~"\n");
|
out.write_str(~"\n");
|
||||||
|
@ -35,7 +35,7 @@ fn encode_name(ebml_w: &ebml::writer, name: &istr) {
|
|||||||
|
|
||||||
fn encode_def_id(ebml_w: &ebml::writer, id: &def_id) {
|
fn encode_def_id(ebml_w: &ebml::writer, id: &def_id) {
|
||||||
ebml::start_tag(ebml_w, tag_def_id);
|
ebml::start_tag(ebml_w, tag_def_id);
|
||||||
ebml_w.writer.write(str::bytes(def_to_str(id)));
|
ebml_w.writer.write(istr::bytes(def_to_str(id)));
|
||||||
ebml::end_tag(ebml_w);
|
ebml::end_tag(ebml_w);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,7 +177,9 @@ fn encode_inlineness(ebml_w: &ebml::writer, c: u8) {
|
|||||||
ebml::end_tag(ebml_w);
|
ebml::end_tag(ebml_w);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn def_to_str(did: &def_id) -> str { ret #fmt["%d:%d", did.crate, did.node]; }
|
fn def_to_str(did: &def_id) -> istr {
|
||||||
|
ret istr::from_estr(#fmt["%d:%d", did.crate, did.node]);
|
||||||
|
}
|
||||||
|
|
||||||
fn encode_type_param_kinds(ebml_w: &ebml::writer, tps: &[ty_param]) {
|
fn encode_type_param_kinds(ebml_w: &ebml::writer, tps: &[ty_param]) {
|
||||||
ebml::start_tag(ebml_w, tag_items_data_item_ty_param_kinds);
|
ebml::start_tag(ebml_w, tag_items_data_item_ty_param_kinds);
|
||||||
@ -196,7 +198,7 @@ fn encode_type_param_kinds(ebml_w: &ebml::writer, tps: &[ty_param]) {
|
|||||||
|
|
||||||
fn encode_variant_id(ebml_w: &ebml::writer, vid: &def_id) {
|
fn encode_variant_id(ebml_w: &ebml::writer, vid: &def_id) {
|
||||||
ebml::start_tag(ebml_w, tag_items_data_item_variant);
|
ebml::start_tag(ebml_w, tag_items_data_item_variant);
|
||||||
ebml_w.writer.write(str::bytes(def_to_str(vid)));
|
ebml_w.writer.write(istr::bytes(def_to_str(vid)));
|
||||||
ebml::end_tag(ebml_w);
|
ebml::end_tag(ebml_w);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,7 +228,7 @@ fn encode_discriminant(ecx: &@encode_ctxt, ebml_w: &ebml::writer,
|
|||||||
|
|
||||||
fn encode_tag_id(ebml_w: &ebml::writer, id: &def_id) {
|
fn encode_tag_id(ebml_w: &ebml::writer, id: &def_id) {
|
||||||
ebml::start_tag(ebml_w, tag_items_data_item_tag_id);
|
ebml::start_tag(ebml_w, tag_items_data_item_tag_id);
|
||||||
ebml_w.writer.write(str::bytes(def_to_str(id)));
|
ebml_w.writer.write(istr::bytes(def_to_str(id)));
|
||||||
ebml::end_tag(ebml_w);
|
ebml::end_tag(ebml_w);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -550,9 +552,9 @@ fn synthesize_link_attr(ecx: &@encode_ctxt, items: &[@meta_item]) ->
|
|||||||
|
|
||||||
fn encode_crate_deps(ebml_w: &ebml::writer, cstore: &cstore::cstore) {
|
fn encode_crate_deps(ebml_w: &ebml::writer, cstore: &cstore::cstore) {
|
||||||
|
|
||||||
fn get_ordered_names(cstore: &cstore::cstore) -> [str] {
|
fn get_ordered_names(cstore: &cstore::cstore) -> [istr] {
|
||||||
type hashkv = @{key: crate_num, val: cstore::crate_metadata};
|
type hashkv = @{key: crate_num, val: cstore::crate_metadata};
|
||||||
type numname = {crate: crate_num, ident: str};
|
type numname = {crate: crate_num, ident: istr};
|
||||||
|
|
||||||
// Pull the cnums and names out of cstore
|
// Pull the cnums and names out of cstore
|
||||||
let pairs: [mutable numname] = [mutable];
|
let pairs: [mutable numname] = [mutable];
|
||||||
@ -574,7 +576,7 @@ fn lteq(kv1: &numname, kv2: &numname) -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Return just the names
|
// Return just the names
|
||||||
fn name(kv: &numname) -> str { kv.ident }
|
fn name(kv: &numname) -> istr { kv.ident }
|
||||||
// mutable -> immutable hack for vec::map
|
// mutable -> immutable hack for vec::map
|
||||||
let immpairs = vec::slice(pairs, 0u, vec::len(pairs));
|
let immpairs = vec::slice(pairs, 0u, vec::len(pairs));
|
||||||
ret vec::map(name, immpairs);
|
ret vec::map(name, immpairs);
|
||||||
@ -585,15 +587,15 @@ fn name(kv: &numname) -> str { kv.ident }
|
|||||||
// FIXME: This is not nearly enough to support correct versioning
|
// FIXME: This is not nearly enough to support correct versioning
|
||||||
// but is enough to get transitive crate dependencies working.
|
// but is enough to get transitive crate dependencies working.
|
||||||
ebml::start_tag(ebml_w, tag_crate_deps);
|
ebml::start_tag(ebml_w, tag_crate_deps);
|
||||||
for cname: str in get_ordered_names(cstore) {
|
for cname: istr in get_ordered_names(cstore) {
|
||||||
ebml::start_tag(ebml_w, tag_crate_dep);
|
ebml::start_tag(ebml_w, tag_crate_dep);
|
||||||
ebml_w.writer.write(str::bytes(cname));
|
ebml_w.writer.write(istr::bytes(cname));
|
||||||
ebml::end_tag(ebml_w);
|
ebml::end_tag(ebml_w);
|
||||||
}
|
}
|
||||||
ebml::end_tag(ebml_w);
|
ebml::end_tag(ebml_w);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn encode_metadata(cx: &@crate_ctxt, crate: &@crate) -> str {
|
fn encode_metadata(cx: &@crate_ctxt, crate: &@crate) -> istr {
|
||||||
|
|
||||||
let abbrevs = map::mk_hashmap(ty::hash_ty, ty::eq_ty);
|
let abbrevs = map::mk_hashmap(ty::hash_ty, ty::eq_ty);
|
||||||
let ecx = @{ccx: cx, type_abbrevs: abbrevs};
|
let ecx = @{ccx: cx, type_abbrevs: abbrevs};
|
||||||
@ -625,7 +627,7 @@ fn encode_metadata(cx: &@crate_ctxt, crate: &@crate) -> str {
|
|||||||
// remaining % 4 bytes.
|
// remaining % 4 bytes.
|
||||||
|
|
||||||
buf_w.write([0u8, 0u8, 0u8, 0u8]);
|
buf_w.write([0u8, 0u8, 0u8, 0u8]);
|
||||||
ret istr::to_estr(string_w.get_str());
|
ret string_w.get_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the encoded string for a type
|
// Get the encoded string for a type
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
// data buffer. Whatever format you choose should not contain pipe characters.
|
// data buffer. Whatever format you choose should not contain pipe characters.
|
||||||
|
|
||||||
// Callback to translate defs to strs or back:
|
// Callback to translate defs to strs or back:
|
||||||
type str_def = fn(str) -> ast::def_id;
|
type str_def = fn(&istr) -> ast::def_id;
|
||||||
|
|
||||||
type pstate =
|
type pstate =
|
||||||
{data: @[u8], crate: int, mutable pos: uint, len: uint, tcx: ty::ctxt};
|
{data: @[u8], crate: int, mutable pos: uint, len: uint, tcx: ty::ctxt};
|
||||||
@ -344,8 +344,10 @@ fn parse_mt(st: @pstate, sd: str_def) -> ty::mt {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn parse_def(st: @pstate, sd: str_def) -> ast::def_id {
|
fn parse_def(st: @pstate, sd: str_def) -> ast::def_id {
|
||||||
let def = "";
|
let def = ~"";
|
||||||
while peek(st) as char != '|' { def += str::unsafe_from_byte(next(st)); }
|
while peek(st) as char != '|' {
|
||||||
|
def += istr::unsafe_from_byte(next(st));
|
||||||
|
}
|
||||||
st.pos = st.pos + 1u;
|
st.pos = st.pos + 1u;
|
||||||
ret sd(def);
|
ret sd(def);
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
type ctxt =
|
type ctxt =
|
||||||
// Def -> str Callback:
|
// Def -> str Callback:
|
||||||
// The type context.
|
// The type context.
|
||||||
{ds: fn(&def_id) -> str, tcx: ty::ctxt, abbrevs: abbrev_ctxt};
|
{ds: fn(&def_id) -> istr, tcx: ty::ctxt, abbrevs: abbrev_ctxt};
|
||||||
|
|
||||||
// Compact string representation for ty.t values. API ty_str & parse_from_str.
|
// Compact string representation for ty.t values. API ty_str & parse_from_str.
|
||||||
// Extra parameters are for converting to/from def_ids in the string rep.
|
// Extra parameters are for converting to/from def_ids in the string rep.
|
||||||
@ -117,7 +117,7 @@ fn enc_sty(w: &io::writer, cx: &@ctxt, st: &ty::sty) {
|
|||||||
ty::ty_istr. { w.write_char('S'); }
|
ty::ty_istr. { w.write_char('S'); }
|
||||||
ty::ty_tag(def, tys) {
|
ty::ty_tag(def, tys) {
|
||||||
w.write_str(~"t[");
|
w.write_str(~"t[");
|
||||||
w.write_str(istr::from_estr(cx.ds(def)));
|
w.write_str(cx.ds(def));
|
||||||
w.write_char('|');
|
w.write_char('|');
|
||||||
for t: ty::t in tys { enc_ty(w, cx, t); }
|
for t: ty::t in tys { enc_ty(w, cx, t); }
|
||||||
w.write_char(']');
|
w.write_char(']');
|
||||||
@ -166,7 +166,7 @@ fn enc_sty(w: &io::writer, cx: &@ctxt, st: &ty::sty) {
|
|||||||
}
|
}
|
||||||
ty::ty_res(def, ty, tps) {
|
ty::ty_res(def, ty, tps) {
|
||||||
w.write_str(~"r[");
|
w.write_str(~"r[");
|
||||||
w.write_str(istr::from_estr(cx.ds(def)));
|
w.write_str(cx.ds(def));
|
||||||
w.write_char('|');
|
w.write_char('|');
|
||||||
enc_ty(w, cx, ty);
|
enc_ty(w, cx, ty);
|
||||||
for t: ty::t in tps { enc_ty(w, cx, t); }
|
for t: ty::t in tps { enc_ty(w, cx, t); }
|
||||||
@ -178,7 +178,7 @@ fn enc_sty(w: &io::writer, cx: &@ctxt, st: &ty::sty) {
|
|||||||
}
|
}
|
||||||
ty::ty_native(def) {
|
ty::ty_native(def) {
|
||||||
w.write_char('E');
|
w.write_char('E');
|
||||||
w.write_str(istr::from_estr(cx.ds(def)));
|
w.write_str(cx.ds(def));
|
||||||
w.write_char('|');
|
w.write_char('|');
|
||||||
}
|
}
|
||||||
ty::ty_param(id, k) {
|
ty::ty_param(id, k) {
|
||||||
@ -237,7 +237,7 @@ fn enc_ty_fn(w: &io::writer, cx: &@ctxt, args: &[ty::arg], out: ty::t,
|
|||||||
fn enc_constr(w: &io::writer, cx: &@ctxt, c: &@ty::constr) {
|
fn enc_constr(w: &io::writer, cx: &@ctxt, c: &@ty::constr) {
|
||||||
w.write_str(istr::from_estr(path_to_str(c.node.path)));
|
w.write_str(istr::from_estr(path_to_str(c.node.path)));
|
||||||
w.write_char('(');
|
w.write_char('(');
|
||||||
w.write_str(istr::from_estr(cx.ds(c.node.id)));
|
w.write_str(cx.ds(c.node.id));
|
||||||
w.write_char('|');
|
w.write_char('|');
|
||||||
let semi = false;
|
let semi = false;
|
||||||
for a: @constr_arg in c.node.args {
|
for a: @constr_arg in c.node.args {
|
||||||
@ -256,7 +256,7 @@ fn enc_constr(w: &io::writer, cx: &@ctxt, c: &@ty::constr) {
|
|||||||
fn enc_ty_constr(w: &io::writer, cx: &@ctxt, c: &@ty::type_constr) {
|
fn enc_ty_constr(w: &io::writer, cx: &@ctxt, c: &@ty::type_constr) {
|
||||||
w.write_str(istr::from_estr(path_to_str(c.node.path)));
|
w.write_str(istr::from_estr(path_to_str(c.node.path)));
|
||||||
w.write_char('(');
|
w.write_char('(');
|
||||||
w.write_str(istr::from_estr(cx.ds(c.node.id)));
|
w.write_str(cx.ds(c.node.id));
|
||||||
w.write_char('|');
|
w.write_char('|');
|
||||||
let semi = false;
|
let semi = false;
|
||||||
for a: @ty::ty_constr_arg in c.node.args {
|
for a: @ty::ty_constr_arg in c.node.args {
|
||||||
|
@ -3290,7 +3290,7 @@ fn trans_external_path(cx: &@block_ctxt, did: &ast::def_id,
|
|||||||
let lcx = cx.fcx.lcx;
|
let lcx = cx.fcx.lcx;
|
||||||
let name = csearch::get_symbol(lcx.ccx.sess.get_cstore(), did);
|
let name = csearch::get_symbol(lcx.ccx.sess.get_cstore(), did);
|
||||||
ret get_extern_const(lcx.ccx.externs, lcx.ccx.llmod,
|
ret get_extern_const(lcx.ccx.externs, lcx.ccx.llmod,
|
||||||
istr::from_estr(name),
|
name,
|
||||||
type_of_ty_param_kinds_and_ty(lcx, cx.sp, tpt));
|
type_of_ty_param_kinds_and_ty(lcx, cx.sp, tpt));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3331,7 +3331,7 @@ fn lookup_discriminant(lcx: &@local_ctxt, vid: &ast::def_id) -> ValueRef {
|
|||||||
// It's an external discriminant that we haven't seen yet.
|
// It's an external discriminant that we haven't seen yet.
|
||||||
assert (vid.crate != ast::local_crate);
|
assert (vid.crate != ast::local_crate);
|
||||||
let sym = csearch::get_symbol(lcx.ccx.sess.get_cstore(), vid);
|
let sym = csearch::get_symbol(lcx.ccx.sess.get_cstore(), vid);
|
||||||
let gvar = istr::as_buf(istr::from_estr(sym), { |buf|
|
let gvar = istr::as_buf(sym, { |buf|
|
||||||
llvm::LLVMAddGlobal(lcx.ccx.llmod, T_int(), buf)
|
llvm::LLVMAddGlobal(lcx.ccx.llmod, T_int(), buf)
|
||||||
});
|
});
|
||||||
llvm::LLVMSetLinkage(gvar,
|
llvm::LLVMSetLinkage(gvar,
|
||||||
@ -6350,8 +6350,9 @@ fn create_crate_map(ccx: &@crate_ctxt) -> ValueRef {
|
|||||||
let i = 1;
|
let i = 1;
|
||||||
let cstore = ccx.sess.get_cstore();
|
let cstore = ccx.sess.get_cstore();
|
||||||
while cstore::have_crate_data(cstore, i) {
|
while cstore::have_crate_data(cstore, i) {
|
||||||
let nm = "_rust_crate_map_" + cstore::get_crate_data(cstore, i).name;
|
let nm = ~"_rust_crate_map_" +
|
||||||
let cr = istr::as_buf(istr::from_estr(nm), { |buf|
|
cstore::get_crate_data(cstore, i).name;
|
||||||
|
let cr = istr::as_buf(nm, { |buf|
|
||||||
llvm::LLVMAddGlobal(ccx.llmod, T_int(), buf)
|
llvm::LLVMAddGlobal(ccx.llmod, T_int(), buf)
|
||||||
});
|
});
|
||||||
subcrates += [p2i(cr)];
|
subcrates += [p2i(cr)];
|
||||||
@ -6379,7 +6380,7 @@ fn create_crate_map(ccx: &@crate_ctxt) -> ValueRef {
|
|||||||
fn write_metadata(cx: &@crate_ctxt, crate: &@ast::crate) {
|
fn write_metadata(cx: &@crate_ctxt, crate: &@ast::crate) {
|
||||||
if !cx.sess.get_opts().library { ret; }
|
if !cx.sess.get_opts().library { ret; }
|
||||||
let llmeta = C_postr(
|
let llmeta = C_postr(
|
||||||
istr::from_estr(metadata::encoder::encode_metadata(cx, crate)));
|
metadata::encoder::encode_metadata(cx, crate));
|
||||||
let llconst = trans_common::C_struct([llmeta]);
|
let llconst = trans_common::C_struct([llmeta]);
|
||||||
let llglobal = istr::as_buf(~"rust_metadata", { |buf|
|
let llglobal = istr::as_buf(~"rust_metadata", { |buf|
|
||||||
llvm::LLVMAddGlobal(cx.llmod, val_ty(llconst), buf)
|
llvm::LLVMAddGlobal(cx.llmod, val_ty(llconst), buf)
|
||||||
|
@ -354,9 +354,9 @@ fn get_res_dtor(ccx: &@crate_ctxt, sp: &span, did: &ast::def_id,
|
|||||||
[{mode: ty::mo_alias(false), ty: inner_t}],
|
[{mode: ty::mo_alias(false), ty: inner_t}],
|
||||||
ty::mk_nil(ccx.tcx), params);
|
ty::mk_nil(ccx.tcx), params);
|
||||||
ret trans::get_extern_const(ccx.externs, ccx.llmod,
|
ret trans::get_extern_const(ccx.externs, ccx.llmod,
|
||||||
istr::from_estr(csearch::get_symbol(
|
csearch::get_symbol(
|
||||||
ccx.sess.get_cstore(),
|
ccx.sess.get_cstore(),
|
||||||
did)),
|
did),
|
||||||
T_fn_pair(*ccx, f_t));
|
T_fn_pair(*ccx, f_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user