Box AST idents

This commit is contained in:
Brian Anderson 2012-06-10 00:49:59 -07:00
parent bdd2000066
commit ce750a7dbc
74 changed files with 629 additions and 603 deletions

View file

@ -132,5 +132,5 @@ fn hash_path(&&s: str) -> uint {
ret h;
}
type link_meta = {name: str, vers: str, extras_hash: str};
type link_meta = {name: @str, vers: @str, extras_hash: str};

View file

@ -42,7 +42,7 @@ fn read_crates(diag: span_handler, crate: ast::crate,
type cache_entry = {
cnum: int,
span: span,
hash: str,
hash: @str,
metas: @[@ast::meta_item]
};
@ -53,7 +53,7 @@ fn dump_crates(crate_cache: dvec<cache_entry>) {
#debug("span: %?", entry.span);
#debug("hash: %?", entry.hash);
let attrs = [
attr::mk_attr(attr::mk_list_item("link", *entry.metas))
attr::mk_attr(attr::mk_list_item(@"link", *entry.metas))
];
for attr::find_linkage_attrs(attrs).each {|attr|
#debug("meta: %s", pprust::attr_to_str(attr));
@ -81,11 +81,11 @@ fn warn_if_multiple_versions(diag: span_handler,
if matches.len() != 1u {
diag.handler().warn(
#fmt("using multiple versions of crate `%s`", name));
#fmt("using multiple versions of crate `%s`", *name));
for matches.each {|match|
diag.span_note(match.span, "used here");
let attrs = [
attr::mk_attr(attr::mk_list_item("link", *match.metas))
attr::mk_attr(attr::mk_list_item(@"link", *match.metas))
];
loader::note_linkage_attrs(diag, attrs);
}
@ -129,7 +129,7 @@ fn visit_item(e: env, i: @ast::item) {
let native_name =
alt attr::first_attr_value_str_by_name(i.attrs, "link_name") {
some(nn) {
if nn == "" {
if *nn == "" {
e.diag.span_fatal(
i.span,
"empty #[link_name] not allowed; use #[nolink].");
@ -140,17 +140,17 @@ fn visit_item(e: env, i: @ast::item) {
};
let mut already_added = false;
if vec::len(attr::find_attrs_by_name(i.attrs, "nolink")) == 0u {
already_added = !cstore::add_used_library(cstore, native_name);
already_added = !cstore::add_used_library(cstore, *native_name);
}
let link_args = attr::find_attrs_by_name(i.attrs, "link_args");
if vec::len(link_args) > 0u && already_added {
e.diag.span_fatal(i.span, "library '" + native_name +
e.diag.span_fatal(i.span, "library '" + *native_name +
"' already added: can't specify link_args.");
}
for link_args.each {|a|
alt attr::get_meta_item_value_str(attr::attr_meta(a)) {
some(linkarg) {
cstore::add_used_link_args(cstore, linkarg);
cstore::add_used_link_args(cstore, *linkarg);
}
none {/* fallthrough */ }
}
@ -160,11 +160,11 @@ fn visit_item(e: env, i: @ast::item) {
}
}
fn metas_with(ident: ast::ident, key: str,
fn metas_with(ident: ast::ident, key: ast::ident,
metas: [@ast::meta_item]) -> [@ast::meta_item] {
let name_items = attr::find_meta_items_by_name(metas, key);
let name_items = attr::find_meta_items_by_name(metas, *key);
if name_items.is_empty() {
metas + [attr::mk_name_value_item_str(key, ident)]
metas + [attr::mk_name_value_item_str(key, *ident)]
} else {
metas
}
@ -172,7 +172,7 @@ fn metas_with(ident: ast::ident, key: str,
fn metas_with_ident(ident: ast::ident,
metas: [@ast::meta_item]) -> [@ast::meta_item] {
metas_with(ident, "name", metas)
metas_with(ident, @"name", metas)
}
fn existing_match(e: env, metas: [@ast::meta_item], hash: str) ->
@ -180,7 +180,7 @@ fn existing_match(e: env, metas: [@ast::meta_item], hash: str) ->
for e.crate_cache.each {|c|
if loader::metadata_matches(*c.metas, metas)
&& (hash.is_empty() || c.hash == hash) {
&& (hash.is_empty() || *c.hash == hash) {
ret some(c.cnum);
}
}
@ -226,7 +226,7 @@ fn resolve_crate(e: env, ident: ast::ident, metas: [@ast::meta_item],
option::some(v) { v }
option::none { ident }
};
let cmeta = @{name: cname, data: cdata,
let cmeta = @{name: *cname, data: cdata,
cnum_map: cnum_map, cnum: cnum};
let cstore = e.cstore;
@ -249,10 +249,10 @@ fn resolve_crate_deps(e: env, cdata: @[u8]) -> cstore::cnum_map {
for decoder::get_crate_deps(cdata).each {|dep|
let extrn_cnum = dep.cnum;
let cname = dep.name;
let cmetas = metas_with(dep.vers, "vers", []);
let cmetas = metas_with(dep.vers, @"vers", []);
#debug("resolving dep crate %s ver: %s hash: %s",
dep.name, dep.vers, dep.hash);
alt existing_match(e, metas_with_ident(cname, cmetas), dep.hash) {
*dep.name, *dep.vers, *dep.hash);
alt existing_match(e, metas_with_ident(cname, cmetas), *dep.hash) {
some(local_cnum) {
#debug("already have it");
// We've already seen this crate
@ -265,7 +265,7 @@ fn resolve_crate_deps(e: env, cdata: @[u8]) -> cstore::cnum_map {
// #2404
let fake_span = ast_util::dummy_sp();
let local_cnum =
resolve_crate(e, cname, cmetas, dep.hash, fake_span);
resolve_crate(e, cname, cmetas, *dep.hash, fake_span);
cnum_map.insert(extrn_cnum, local_cnum);
}
}

View file

@ -64,7 +64,7 @@ fn resolve_path(cstore: cstore::cstore, cnum: ast::crate_num,
[(ast::crate_num, @[u8], ast::def_id)] {
let cm = cstore::get_crate_data(cstore, cnum);
#debug("resolve_path %s in crates[%d]:%s",
str::connect(path, "::"), cnum, cm.name);
ast_util::path_name_i(path), cnum, cm.name);
let mut result = [];
for decoder::resolve_path(path, cm.data).each {|def|
if def.crate == ast::local_crate {
@ -88,7 +88,7 @@ fn get_item_path(tcx: ty::ctxt, def: ast::def_id) -> ast_map::path {
// FIXME #1920: This path is not always correct if the crate is not linked
// into the root namespace.
[ast_map::path_mod(cdata.name)] + path
[ast_map::path_mod(@cdata.name)] + path
}
enum found_ast {
@ -170,7 +170,8 @@ fn get_impl_iface(tcx: ty::ctxt, def: ast::def_id) -> option<ty::t> {
decoder::get_impl_iface(cdata, def.node, tcx)
}
fn get_impl_method(cstore: cstore::cstore, def: ast::def_id, mname: str)
fn get_impl_method(cstore: cstore::cstore,
def: ast::def_id, mname: ast::ident)
-> ast::def_id {
let cdata = cstore::get_crate_data(cstore, def.crate);
decoder::get_impl_method(cdata, def.node, mname)
@ -180,7 +181,8 @@ fn get_impl_method(cstore: cstore::cstore, def: ast::def_id, mname: str)
for their methods (so that get_iface_methods can be reused to get
class methods), classes require a slightly different version of
get_impl_method. Sigh. */
fn get_class_method(cstore: cstore::cstore, def: ast::def_id, mname: str)
fn get_class_method(cstore: cstore::cstore,
def: ast::def_id, mname: ast::ident)
-> ast::def_id {
let cdata = cstore::get_crate_data(cstore, def.crate);
decoder::get_class_method(cdata, def.node, mname)

View file

@ -37,7 +37,7 @@ type cnum_map = map::hashmap<ast::crate_num, ast::crate_num>;
// Multiple items may have the same def_id in crate metadata. They may be
// renamed imports or reexports. This map keeps the "real" module path
// and def_id.
type mod_path_map = map::hashmap<ast::def_id, str>;
type mod_path_map = map::hashmap<ast::def_id, @str>;
type crate_metadata = @{name: str,
data: @[u8],
@ -83,12 +83,12 @@ fn get_crate_data(cstore: cstore, cnum: ast::crate_num) -> crate_metadata {
ret p(cstore).metas.get(cnum);
}
fn get_crate_hash(cstore: cstore, cnum: ast::crate_num) -> str {
fn get_crate_hash(cstore: cstore, cnum: ast::crate_num) -> @str {
let cdata = get_crate_data(cstore, cnum);
ret decoder::get_crate_hash(cdata.data);
}
fn get_crate_vers(cstore: cstore, cnum: ast::crate_num) -> str {
fn get_crate_vers(cstore: cstore, cnum: ast::crate_num) -> @str {
let cdata = get_crate_data(cstore, cnum);
ret decoder::get_crate_vers(cdata.data);
}
@ -99,7 +99,7 @@ fn set_crate_data(cstore: cstore, cnum: ast::crate_num,
vec::iter(decoder::get_crate_module_paths(data.data)) {|dp|
let (did, path) = dp;
let d = {crate: cnum, node: did.node};
p(cstore).mod_path_map.insert(d, path);
p(cstore).mod_path_map.insert(d, @path);
}
}
@ -153,32 +153,32 @@ fn find_use_stmt_cnum(cstore: cstore,
// returns hashes of crates directly used by this crate. Hashes are
// sorted by crate name.
fn get_dep_hashes(cstore: cstore) -> [str] {
type crate_hash = {name: str, hash: str};
fn get_dep_hashes(cstore: cstore) -> [@str] {
type crate_hash = {name: @str, hash: @str};
let mut result = [];
for p(cstore).use_crate_map.each_value {|cnum|
let cdata = cstore::get_crate_data(cstore, cnum);
let hash = decoder::get_crate_hash(cdata.data);
#debug("Add hash[%s]: %s", cdata.name, hash);
result += [{name: cdata.name, hash: hash}];
#debug("Add hash[%s]: %s", cdata.name, *hash);
result += [{name: @cdata.name, hash: hash}];
};
fn lteq(a: crate_hash, b: crate_hash) -> bool {
ret a.name <= b.name;
ret *a.name <= *b.name;
}
let sorted = std::sort::merge_sort(lteq, result);
#debug("sorted:");
for sorted.each {|x|
#debug(" hash[%s]: %s", x.name, x.hash);
#debug(" hash[%s]: %s", *x.name, *x.hash);
}
fn mapper(ch: crate_hash) -> str { ret ch.hash; }
fn mapper(ch: crate_hash) -> @str { ret ch.hash; }
ret vec::map(sorted, mapper);
}
fn get_path(cstore: cstore, d: ast::def_id) -> [str] {
fn get_path(cstore: cstore, d: ast::def_id) -> [ast::ident] {
// let f = bind str::split_str(_, "::");
option::map_default(p(cstore).mod_path_map.find(d), [],
{|ds| str::split_str(ds, "::")})
{|ds| str::split_str(*ds, "::").map({|x|@x})})
}
// Local Variables:
// mode: rust

View file

@ -210,7 +210,7 @@ fn resolve_path(path: [ast::ident], data: @[u8]) -> [ast::def_id] {
fn eq_item(data: [u8], s: str) -> bool {
ret str::eq(str::from_bytes(data), s);
}
let s = str::connect(path, "::");
let s = ast_util::path_name_i(path);
let md = ebml::doc(data);
let paths = ebml::get_doc(md, tag_paths);
let eqer = bind eq_item(_, s);
@ -235,10 +235,10 @@ fn item_path(item_doc: ebml::doc) -> ast_map::path {
ebml::docs(path_doc) {|tag, elt_doc|
if tag == tag_path_elt_mod {
let str = ebml::doc_as_str(elt_doc);
result += [ast_map::path_mod(str)];
result += [ast_map::path_mod(@str)];
} else if tag == tag_path_elt_name {
let str = ebml::doc_as_str(elt_doc);
result += [ast_map::path_name(str)];
result += [ast_map::path_name(@str)];
} else {
// ignore tag_path_len element
}
@ -249,7 +249,7 @@ fn item_path(item_doc: ebml::doc) -> ast_map::path {
fn item_name(item: ebml::doc) -> ast::ident {
let name = ebml::get_doc(item, tag_paths_data_name);
str::from_bytes(ebml::doc_data(name))
@str::from_bytes(ebml::doc_data(name))
}
fn lookup_item_name(data: @[u8], id: ast::node_id) -> ast::ident {
@ -302,7 +302,8 @@ fn get_impl_iface(cdata: cmd, id: ast::node_id, tcx: ty::ctxt)
item_impl_iface(lookup_item(id, cdata.data), tcx, cdata)
}
fn get_impl_method(cdata: cmd, id: ast::node_id, name: str) -> ast::def_id {
fn get_impl_method(cdata: cmd, id: ast::node_id,
name: ast::ident) -> ast::def_id {
let items = ebml::get_doc(ebml::doc(cdata.data), tag_items);
let mut found = none;
ebml::tagged_docs(find_item(id, items), tag_item_impl_method) {|mid|
@ -314,13 +315,14 @@ fn get_impl_method(cdata: cmd, id: ast::node_id, name: str) -> ast::def_id {
option::get(found)
}
fn get_class_method(cdata: cmd, id: ast::node_id, name: str) -> ast::def_id {
fn get_class_method(cdata: cmd, id: ast::node_id,
name: ast::ident) -> ast::def_id {
let items = ebml::get_doc(ebml::doc(cdata.data), tag_items);
let mut found = none;
let cls_items = alt maybe_find_item(id, items) {
some(it) { it }
none { fail (#fmt("get_class_method: class id not found \
when looking up method %s", name)) }};
when looking up method %s", *name)) }};
ebml::tagged_docs(cls_items, tag_item_iface_method) {|mid|
let m_did = class_member_id(mid, cdata);
if item_name(mid) == name {
@ -329,7 +331,7 @@ fn get_class_method(cdata: cmd, id: ast::node_id, name: str) -> ast::def_id {
}
alt found {
some(found) { found }
none { fail (#fmt("get_class_method: no method named %s", name)) }
none { fail (#fmt("get_class_method: no method named %s", *name)) }
}
}
@ -574,7 +576,7 @@ fn get_meta_items(md: ebml::doc) -> [@ast::meta_item] {
ebml::tagged_docs(md, tag_meta_item_word) {|meta_item_doc|
let nd = ebml::get_doc(meta_item_doc, tag_meta_item_name);
let n = str::from_bytes(ebml::doc_data(nd));
items += [attr::mk_word_item(n)];
items += [attr::mk_word_item(@n)];
};
ebml::tagged_docs(md, tag_meta_item_name_value) {|meta_item_doc|
let nd = ebml::get_doc(meta_item_doc, tag_meta_item_name);
@ -583,13 +585,13 @@ fn get_meta_items(md: ebml::doc) -> [@ast::meta_item] {
let v = str::from_bytes(ebml::doc_data(vd));
// FIXME (#623): Should be able to decode meta_name_value variants,
// but currently the encoder just drops them
items += [attr::mk_name_value_item_str(n, v)];
items += [attr::mk_name_value_item_str(@n, v)];
};
ebml::tagged_docs(md, tag_meta_item_list) {|meta_item_doc|
let nd = ebml::get_doc(meta_item_doc, tag_meta_item_name);
let n = str::from_bytes(ebml::doc_data(nd));
let subitems = get_meta_items(meta_item_doc);
items += [attr::mk_list_item(n, subitems)];
items += [attr::mk_list_item(@n, subitems)];
};
ret items;
}
@ -620,8 +622,8 @@ fn list_meta_items(meta_items: ebml::doc, out: io::writer) {
}
}
fn list_crate_attributes(md: ebml::doc, hash: str, out: io::writer) {
out.write_str(#fmt("=Crate Attributes (%s)=\n", hash));
fn list_crate_attributes(md: ebml::doc, hash: @str, out: io::writer) {
out.write_str(#fmt("=Crate Attributes (%s)=\n", *hash));
for get_attributes(md).each {|attr|
out.write_str(#fmt["%s\n", pprust::attribute_to_str(attr)]);
@ -635,7 +637,7 @@ fn get_crate_attributes(data: @[u8]) -> [ast::attribute] {
}
type crate_dep = {cnum: ast::crate_num, name: ast::ident,
vers: str, hash: str};
vers: @str, hash: @str};
fn get_crate_deps(data: @[u8]) -> [crate_dep] {
let mut deps: [crate_dep] = [];
@ -647,9 +649,9 @@ fn get_crate_deps(data: @[u8]) -> [crate_dep] {
}
ebml::tagged_docs(depsdoc, tag_crate_dep) {|depdoc|
deps += [{cnum: crate_num,
name: docstr(depdoc, tag_crate_dep_name),
vers: docstr(depdoc, tag_crate_dep_vers),
hash: docstr(depdoc, tag_crate_dep_hash)}];
name: @docstr(depdoc, tag_crate_dep_name),
vers: @docstr(depdoc, tag_crate_dep_vers),
hash: @docstr(depdoc, tag_crate_dep_hash)}];
crate_num += 1;
};
ret deps;
@ -660,24 +662,24 @@ fn list_crate_deps(data: @[u8], out: io::writer) {
for get_crate_deps(data).each {|dep|
out.write_str(#fmt["%d %s-%s-%s\n",
dep.cnum, dep.name, dep.hash, dep.vers]);
dep.cnum, *dep.name, *dep.hash, *dep.vers]);
}
out.write_str("\n");
}
fn get_crate_hash(data: @[u8]) -> str {
fn get_crate_hash(data: @[u8]) -> @str {
let cratedoc = ebml::doc(data);
let hashdoc = ebml::get_doc(cratedoc, tag_crate_hash);
ret str::from_bytes(ebml::doc_data(hashdoc));
ret @str::from_bytes(ebml::doc_data(hashdoc));
}
fn get_crate_vers(data: @[u8]) -> str {
fn get_crate_vers(data: @[u8]) -> @str {
let attrs = decoder::get_crate_attributes(data);
ret alt attr::last_meta_item_value_str_by_name(
attr::find_linkage_metas(attrs), "vers") {
some(ver) { ver }
none { "0.0" }
none { @"0.0" }
};
}

View file

@ -71,8 +71,8 @@ fn reachable(ecx: @encode_ctxt, id: node_id) -> bool {
}
// Path table encoding
fn encode_name(ebml_w: ebml::writer, name: str) {
ebml_w.wr_tagged_str(tag_paths_data_name, name);
fn encode_name(ebml_w: ebml::writer, name: ident) {
ebml_w.wr_tagged_str(tag_paths_data_name, *name);
}
fn encode_def_id(ebml_w: ebml::writer, id: def_id) {
@ -92,7 +92,7 @@ fn encode_region_param(ebml_w: ebml::writer, rp: region_param) {
}
}
fn encode_named_def_id(ebml_w: ebml::writer, name: str, id: def_id) {
fn encode_named_def_id(ebml_w: ebml::writer, name: ident, id: def_id) {
ebml_w.wr_tag(tag_paths_data_item) {||
encode_name(ebml_w, name);
encode_def_id(ebml_w, id);
@ -109,7 +109,7 @@ fn encode_mutability(ebml_w: ebml::writer, mt: class_mutability) {
type entry<T> = {val: T, pos: uint};
fn encode_enum_variant_paths(ebml_w: ebml::writer, variants: [variant],
path: [str], &index: [entry<str>]) {
path: [ident], &index: [entry<str>]) {
for variants.each {|variant|
add_to_index(ebml_w, path, index, variant.node.name);
ebml_w.wr_tag(tag_paths_data_item) {||
@ -119,15 +119,15 @@ fn encode_enum_variant_paths(ebml_w: ebml::writer, variants: [variant],
}
}
fn add_to_index(ebml_w: ebml::writer, path: [str], &index: [entry<str>],
name: str) {
fn add_to_index(ebml_w: ebml::writer, path: [ident], &index: [entry<str>],
name: ident) {
let full_path = path + [name];
index +=
[{val: str::connect(full_path, "::"), pos: ebml_w.writer.tell()}];
[{val: ast_util::path_name_i(full_path), pos: ebml_w.writer.tell()}];
}
fn encode_native_module_item_paths(ebml_w: ebml::writer, nmod: native_mod,
path: [str], &index: [entry<str>]) {
path: [ident], &index: [entry<str>]) {
for nmod.items.each {|nitem|
add_to_index(ebml_w, path, index, nitem.ident);
encode_named_def_id(ebml_w, nitem.ident, local_def(nitem.id));
@ -135,7 +135,7 @@ fn encode_native_module_item_paths(ebml_w: ebml::writer, nmod: native_mod,
}
fn encode_class_item_paths(ebml_w: ebml::writer,
items: [@class_member], path: [str], &index: [entry<str>]) {
items: [@class_member], path: [ident], &index: [entry<str>]) {
for items.each {|it|
alt ast_util::class_member_visibility(it) {
private { cont; }
@ -152,7 +152,8 @@ fn encode_class_item_paths(ebml_w: ebml::writer,
}
fn encode_module_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt,
module: _mod, path: [str], &index: [entry<str>]) {
module: _mod, path: [ident],
&index: [entry<str>]) {
for module.items.each {|it|
if !reachable(ecx, it.id) ||
!ast_util::is_exported(it.ident, module) { cont; }
@ -235,7 +236,7 @@ fn encode_iface_ref(ebml_w: ebml::writer, ecx: @encode_ctxt, t: @iface_ref) {
fn encode_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt, crate: @crate)
-> [entry<str>] {
let mut index: [entry<str>] = [];
let mut path: [str] = [];
let mut path: [ident] = [];
ebml_w.start_tag(tag_paths);
encode_module_item_paths(ebml_w, ecx, crate.node.module, path, index);
encode_reexport_paths(ebml_w, ecx, index);
@ -249,7 +250,7 @@ fn encode_reexport_paths(ebml_w: ebml::writer,
let (path, def_id) = reexport;
index += [{val: path, pos: ebml_w.writer.tell()}];
ebml_w.start_tag(tag_paths_data_item);
encode_name(ebml_w, path);
encode_name(ebml_w, @path);
encode_def_id(ebml_w, def_id);
ebml_w.end_tag();
}
@ -374,7 +375,7 @@ fn encode_path(ebml_w: ebml::writer,
ast_map::path_name(name) { (tag_path_elt_name, name) }
};
ebml_w.wr_tagged_str(tag, name);
ebml_w.wr_tagged_str(tag, *name);
}
ebml_w.wr_tag(tag_path) {||
@ -439,7 +440,7 @@ fn encode_info_for_class(ecx: @encode_ctxt, ebml_w: ebml::writer,
instance_var(nm, _, mt, id, vis) {
*index += [{val: id, pos: ebml_w.writer.tell()}];
ebml_w.start_tag(tag_items_data_item);
#debug("encode_info_for_class: doing %s %d", nm, id);
#debug("encode_info_for_class: doing %s %d", *nm, id);
encode_visibility(ebml_w, vis);
encode_name(ebml_w, nm);
encode_path(ebml_w, path, ast_map::path_name(nm));
@ -456,7 +457,7 @@ fn encode_info_for_class(ecx: @encode_ctxt, ebml_w: ebml::writer,
but it works for now -- tjc */
*global_index += [{val: m.id, pos: ebml_w.writer.tell()}];
let impl_path = path + [ast_map::path_name(m.ident)];
#debug("encode_info_for_class: doing %s %d", m.ident, m.id);
#debug("encode_info_for_class: doing %s %d", *m.ident, m.id);
encode_info_for_method(ecx, ebml_w, impl_path,
should_inline(m.attrs), id, m,
class_tps + m.tps);
@ -479,7 +480,7 @@ fn encode_info_for_fn(ecx: @encode_ctxt, ebml_w: ebml::writer,
encode_family(ebml_w, purity_fn_family(decl.purity));
encode_type_param_bounds(ebml_w, ecx, tps);
let its_ty = node_id_to_type(ecx.tcx, id);
#debug("fn name = %s ty = %s its node id = %d", ident,
#debug("fn name = %s ty = %s its node id = %d", *ident,
util::ppaux::ty_to_str(ecx.tcx, its_ty), id);
encode_type(ecx, ebml_w, its_ty);
encode_path(ebml_w, path, ast_map::path_name(ident));
@ -498,7 +499,7 @@ fn encode_info_for_method(ecx: @encode_ctxt, ebml_w: ebml::writer,
impl_path: ast_map::path, should_inline: bool,
parent_id: node_id,
m: @method, all_tps: [ty_param]) {
#debug("encode_info_for_method: %d %s %u", m.id, m.ident, all_tps.len());
#debug("encode_info_for_method: %d %s %u", m.id, *m.ident, all_tps.len());
ebml_w.start_tag(tag_items_data_item);
encode_def_id(ebml_w, local_def(m.id));
encode_family(ebml_w, purity_fn_family(m.decl.purity));
@ -627,8 +628,8 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
/* Encode the dtor */
option::iter(m_dtor) {|dtor|
*index += [{val: dtor.node.id, pos: ebml_w.writer.tell()}];
encode_info_for_fn(ecx, ebml_w, dtor.node.id, item.ident
+ "_dtor", path, if tps.len() > 0u {
encode_info_for_fn(ecx, ebml_w, dtor.node.id, @(*item.ident
+ "_dtor"), path, if tps.len() > 0u {
some(ii_dtor(dtor, item.ident, tps,
local_def(item.id))) }
else { none }, tps, ast_util::dtor_dec());
@ -805,7 +806,7 @@ fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: ebml::writer,
ebml_w.start_tag(tag_items_data);
*index += [{val: crate_node_id, pos: ebml_w.writer.tell()}];
encode_info_for_mod(ecx, ebml_w, crate.node.module,
crate_node_id, [], "");
crate_node_id, [], @"");
visit::visit_crate(*crate, (), visit::mk_vt(@{
visit_expr: {|_e, _cx, _v|},
visit_item: {|i, cx, v, copy ebml_w|
@ -816,7 +817,7 @@ fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: ebml::writer,
/* encode ctor, then encode items */
alt i.node {
item_class(tps, _, _, ctor, m_dtor, _) {
#debug("encoding info for ctor %s %d", i.ident,
#debug("encoding info for ctor %s %d", *i.ident,
ctor.node.id);
*index += [{val: ctor.node.id, pos: ebml_w.writer.tell()}];
encode_info_for_fn(ecx, ebml_w, ctor.node.id, i.ident,
@ -898,7 +899,7 @@ fn encode_meta_item(ebml_w: ebml::writer, mi: meta_item) {
meta_word(name) {
ebml_w.start_tag(tag_meta_item_word);
ebml_w.start_tag(tag_meta_item_name);
ebml_w.writer.write(str::bytes(name));
ebml_w.writer.write(str::bytes(*name));
ebml_w.end_tag();
ebml_w.end_tag();
}
@ -907,10 +908,10 @@ fn encode_meta_item(ebml_w: ebml::writer, mi: meta_item) {
lit_str(value) {
ebml_w.start_tag(tag_meta_item_name_value);
ebml_w.start_tag(tag_meta_item_name);
ebml_w.writer.write(str::bytes(name));
ebml_w.writer.write(str::bytes(*name));
ebml_w.end_tag();
ebml_w.start_tag(tag_meta_item_value);
ebml_w.writer.write(str::bytes(value));
ebml_w.writer.write(str::bytes(*value));
ebml_w.end_tag();
ebml_w.end_tag();
}
@ -920,7 +921,7 @@ fn encode_meta_item(ebml_w: ebml::writer, mi: meta_item) {
meta_list(name, items) {
ebml_w.start_tag(tag_meta_item_list);
ebml_w.start_tag(tag_meta_item_name);
ebml_w.writer.write(str::bytes(name));
ebml_w.writer.write(str::bytes(*name));
ebml_w.end_tag();
for items.each {|inner_item|
encode_meta_item(ebml_w, *inner_item);
@ -949,22 +950,22 @@ fn synthesize_crate_attrs(ecx: @encode_ctxt, crate: @crate) -> [attribute] {
fn synthesize_link_attr(ecx: @encode_ctxt, items: [@meta_item]) ->
attribute {
assert (ecx.link_meta.name != "");
assert (ecx.link_meta.vers != "");
assert (*ecx.link_meta.name != "");
assert (*ecx.link_meta.vers != "");
let name_item =
attr::mk_name_value_item_str("name", ecx.link_meta.name);
attr::mk_name_value_item_str(@"name", *ecx.link_meta.name);
let vers_item =
attr::mk_name_value_item_str("vers", ecx.link_meta.vers);
attr::mk_name_value_item_str(@"vers", *ecx.link_meta.vers);
let other_items =
{
let tmp = attr::remove_meta_items_by_name(items, "name");
attr::remove_meta_items_by_name(tmp, "vers")
let tmp = attr::remove_meta_items_by_name(items, @"name");
attr::remove_meta_items_by_name(tmp, @"vers")
};
let meta_items = [name_item, vers_item] + other_items;
let link_item = attr::mk_list_item("link", meta_items);
let link_item = attr::mk_list_item(@"link", meta_items);
ret attr::mk_attr(link_item);
}
@ -973,7 +974,7 @@ fn synthesize_crate_attrs(ecx: @encode_ctxt, crate: @crate) -> [attribute] {
let mut found_link_attr = false;
for crate.node.attrs.each {|attr|
attrs +=
if attr::get_attr_name(attr) != "link" {
if *attr::get_attr_name(attr) != "link" {
[attr]
} else {
alt attr.node.value.node {
@ -1000,9 +1001,9 @@ fn encode_crate_deps(ebml_w: ebml::writer, cstore: cstore::cstore) {
// Pull the cnums and name,vers,hash out of cstore
let mut deps: [mut numdep] = [mut];
cstore::iter_crate_data(cstore) {|key, val|
let dep = {cnum: key, name: val.name,
let dep = {cnum: key, name: @val.name,
vers: decoder::get_crate_vers(val.data),
hash: decoder::get_crate_hash(val.data)};
hash: decoder::get_crate_hash(val.data)};
deps += [mut dep];
};
@ -1036,13 +1037,13 @@ fn encode_crate_deps(ebml_w: ebml::writer, cstore: cstore::cstore) {
fn encode_crate_dep(ebml_w: ebml::writer, dep: decoder::crate_dep) {
ebml_w.start_tag(tag_crate_dep);
ebml_w.start_tag(tag_crate_dep_name);
ebml_w.writer.write(str::bytes(dep.name));
ebml_w.writer.write(str::bytes(*dep.name));
ebml_w.end_tag();
ebml_w.start_tag(tag_crate_dep_vers);
ebml_w.writer.write(str::bytes(dep.vers));
ebml_w.writer.write(str::bytes(*dep.vers));
ebml_w.end_tag();
ebml_w.start_tag(tag_crate_dep_hash);
ebml_w.writer.write(str::bytes(dep.hash));
ebml_w.writer.write(str::bytes(*dep.hash));
ebml_w.end_tag();
ebml_w.end_tag();
}

View file

@ -44,7 +44,7 @@ fn load_library_crate(cx: ctxt) -> {ident: str, data: @[u8]} {
some(t) { ret t; }
none {
cx.diag.span_fatal(
cx.span, #fmt["can't find crate for '%s'", cx.ident]);
cx.span, #fmt["can't find crate for '%s'", *cx.ident]);
}
}
}
@ -69,7 +69,7 @@ fn find_library_crate_aux(cx: ctxt,
filesearch: filesearch::filesearch) ->
option<{ident: str, data: @[u8]}> {
let crate_name = crate_name_from_metas(cx.metas);
let prefix: str = nn.prefix + crate_name + "-";
let prefix: str = nn.prefix + *crate_name + "-";
let suffix: str = nn.suffix;
let mut matches = [];
@ -107,7 +107,7 @@ fn find_library_crate_aux(cx: ctxt,
some(matches[0])
} else {
cx.diag.span_err(
cx.span, #fmt("multiple matching crates for `%s`", crate_name));
cx.span, #fmt("multiple matching crates for `%s`", *crate_name));
cx.diag.handler().note("candidates:");
for matches.each {|match|
cx.diag.handler().note(#fmt("path: %s", match.ident));
@ -119,7 +119,7 @@ fn find_library_crate_aux(cx: ctxt,
}
}
fn crate_name_from_metas(metas: [@ast::meta_item]) -> str {
fn crate_name_from_metas(metas: [@ast::meta_item]) -> @str {
let name_items = attr::find_meta_items_by_name(metas, "name");
alt vec::last_opt(name_items) {
some(i) {
@ -146,7 +146,7 @@ fn crate_matches(crate_data: @[u8], metas: [@ast::meta_item], hash: str) ->
let linkage_metas = attr::find_linkage_metas(attrs);
if hash.is_not_empty() {
let chash = decoder::get_crate_hash(crate_data);
if chash != hash { ret false; }
if *chash != hash { ret false; }
}
metadata_matches(linkage_metas, metas)
}

View file

@ -46,7 +46,7 @@ fn parse_ident_(st: @pstate, is_last: fn@(char) -> bool) ->
while !is_last(peek(st)) {
rslt += str::from_byte(next_byte(st));
}
ret rslt;
ret @rslt;
}
@ -210,7 +210,7 @@ fn parse_bound_region(st: @pstate) -> ty::bound_region {
alt check next(st) {
's' { ty::br_self }
'a' { ty::br_anon }
'[' { ty::br_named(parse_str(st, ']')) }
'[' { ty::br_named(@parse_str(st, ']')) }
}
}
@ -322,7 +322,7 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t {
assert (next(st) == '[');
let mut fields: [ty::field] = [];
while peek(st) != ']' {
let name = parse_str(st, '=');
let name = @parse_str(st, '=');
fields += [{ident: name, mt: parse_mt(st, conv)}];
}
st.pos = st.pos + 1u;

View file

@ -157,7 +157,7 @@ fn enc_bound_region(w: io::writer, br: ty::bound_region) {
ty::br_anon { w.write_char('a') }
ty::br_named(s) {
w.write_char('[');
w.write_str(s);
w.write_str(*s);
w.write_char(']')
}
}
@ -256,7 +256,7 @@ fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) {
ty::ty_rec(fields) {
w.write_str("R["/&);
for fields.each {|field|
w.write_str(field.ident);
w.write_str(*field.ident);
w.write_char('=');
enc_mt(w, cx, field.mt);
}