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

@ -224,10 +224,10 @@ fn load_link(mis: [@ast::meta_item]) -> (option<str>,
for mis.each {|a| for mis.each {|a|
alt a.node { alt a.node {
ast::meta_name_value(v, {node: ast::lit_str(s), span: _}) { ast::meta_name_value(v, {node: ast::lit_str(s), span: _}) {
alt v { alt *v {
"name" { name = some(s); } "name" { name = some(*s); }
"vers" { vers = some(s); } "vers" { vers = some(*s); }
"uuid" { uuid = some(s); } "uuid" { uuid = some(*s); }
_ { } _ { }
} }
} }
@ -259,15 +259,15 @@ fn load_crate(filename: str) -> option<crate> {
for c.node.attrs.each {|a| for c.node.attrs.each {|a|
alt a.node.value.node { alt a.node.value.node {
ast::meta_name_value(v, {node: ast::lit_str(s), span: _}) { ast::meta_name_value(v, {node: ast::lit_str(s), span: _}) {
alt v { alt *v {
"desc" { desc = some(v); } "desc" { desc = some(*v); }
"sigs" { sigs = some(v); } "sigs" { sigs = some(*v); }
"crate_type" { crate_type = some(v); } "crate_type" { crate_type = some(*v); }
_ { } _ { }
} }
} }
ast::meta_list(v, mis) { ast::meta_list(v, mis) {
if v == "link" { if *v == "link" {
let (n, v, u) = load_link(mis); let (n, v, u) = load_link(mis);
name = n; name = n;
vers = v; vers = v;
@ -290,7 +290,7 @@ fn load_crate(filename: str) -> option<crate> {
ast::view_item_use(ident, metas, id) { ast::view_item_use(ident, metas, id) {
let name_items = attr::find_meta_items_by_name(metas, "name"); let name_items = attr::find_meta_items_by_name(metas, "name");
let m = if name_items.is_empty() { let m = if name_items.is_empty() {
metas + [attr::mk_name_value_item_str("name", ident)] metas + [attr::mk_name_value_item_str(@"name", *ident)]
} else { } else {
metas metas
}; };
@ -303,9 +303,9 @@ fn load_crate(filename: str) -> option<crate> {
some(value) { some(value) {
let name = attr::get_meta_item_name(item); let name = attr::get_meta_item_name(item);
alt name { alt *name {
"vers" { attr_vers = value; } "vers" { attr_vers = *value; }
"from" { attr_from = value; } "from" { attr_from = *value; }
_ {} _ {}
} }
} }
@ -317,11 +317,11 @@ fn load_crate(filename: str) -> option<crate> {
attr_from attr_from
} else { } else {
if !str::is_empty(attr_vers) { if !str::is_empty(attr_vers) {
attr_name + "@" + attr_vers *attr_name + "@" + attr_vers
} else { attr_name } } else { *attr_name }
}; };
alt attr_name { alt *attr_name {
"std" | "core" { } "std" | "core" { }
_ { e.deps += [query]; } _ { e.deps += [query]; }
} }

View File

@ -45,7 +45,7 @@ fn common_exprs() -> [ast::expr] {
dse(ast::expr_cont), dse(ast::expr_cont),
dse(ast::expr_fail(option::none)), dse(ast::expr_fail(option::none)),
dse(ast::expr_fail(option::some( dse(ast::expr_fail(option::some(
@dse(ast::expr_lit(@dsl(ast::lit_str("boo"))))))), @dse(ast::expr_lit(@dsl(ast::lit_str(@"boo"))))))),
dse(ast::expr_ret(option::none)), dse(ast::expr_ret(option::none)),
dse(ast::expr_lit(@dsl(ast::lit_nil))), dse(ast::expr_lit(@dsl(ast::lit_nil))),
dse(ast::expr_lit(@dsl(ast::lit_bool(false)))), dse(ast::expr_lit(@dsl(ast::lit_bool(false)))),

View File

@ -2,6 +2,7 @@
import chained::hashmap; import chained::hashmap;
export hashmap, hashfn, eqfn, set, map, chained, hashmap, str_hash; export hashmap, hashfn, eqfn, set, map, chained, hashmap, str_hash;
export box_str_hash;
export bytes_hash, int_hash, uint_hash, set_add; export bytes_hash, int_hash, uint_hash, set_add;
export hash_from_vec, hash_from_strs, hash_from_bytes; export hash_from_vec, hash_from_strs, hash_from_bytes;
export hash_from_ints, hash_from_uints; export hash_from_ints, hash_from_uints;
@ -292,6 +293,11 @@ fn str_hash<V: copy>() -> hashmap<str, V> {
ret hashmap(str::hash, str::eq); ret hashmap(str::hash, str::eq);
} }
#[doc = "Construct a hashmap for boxed string keys"]
fn box_str_hash<V: copy>() -> hashmap<@str, V> {
ret hashmap({|x: @str|str::hash(*x)}, {|x,y|str::eq(*x,*y)});
}
#[doc = "Construct a hashmap for byte string keys"] #[doc = "Construct a hashmap for byte string keys"]
fn bytes_hash<V: copy>() -> hashmap<[u8], V> { fn bytes_hash<V: copy>() -> hashmap<[u8], V> {
ret hashmap(vec::u8::hash, vec::u8::eq); ret hashmap(vec::u8::hash, vec::u8::eq);

View File

@ -30,7 +30,7 @@ fn deserialize_span<D>(_d: D) -> span {
type spanned<T> = {node: T, span: span}; type spanned<T> = {node: T, span: span};
#[auto_serialize] #[auto_serialize]
type ident = str; type ident = @str;
// Functions may or may not have names. // Functions may or may not have names.
#[auto_serialize] #[auto_serialize]
@ -399,11 +399,11 @@ type lit = spanned<lit_>;
#[auto_serialize] #[auto_serialize]
enum lit_ { enum lit_ {
lit_str(str), lit_str(@str),
lit_int(i64, int_ty), lit_int(i64, int_ty),
lit_uint(u64, uint_ty), lit_uint(u64, uint_ty),
lit_int_unsuffixed(i64, int_ty), lit_int_unsuffixed(i64, int_ty),
lit_float(str, float_ty), lit_float(@str, float_ty),
lit_nil, lit_nil,
lit_bool(bool), lit_bool(bool),
} }

View File

@ -6,14 +6,14 @@ import ast_util::path_to_ident;
import ast_util::inlined_item_methods; import ast_util::inlined_item_methods;
import diagnostic::span_handler; import diagnostic::span_handler;
enum path_elt { path_mod(str), path_name(str) } enum path_elt { path_mod(ident), path_name(ident) }
type path = [path_elt]; type path = [path_elt];
fn path_to_str_with_sep(p: path, sep: str) -> str { fn path_to_str_with_sep(p: path, sep: str) -> str {
let strs = vec::map(p) {|e| let strs = vec::map(p) {|e|
alt e { alt e {
path_mod(s) { /* FIXME: bad */ copy s } path_mod(s) { /* FIXME: bad */ copy *s }
path_name(s) { /* FIXME: bad */ copy s } path_name(s) { /* FIXME: bad */ copy *s }
} }
}; };
str::connect(strs, sep) str::connect(strs, sep)
@ -21,9 +21,9 @@ fn path_to_str_with_sep(p: path, sep: str) -> str {
fn path_ident_to_str(p: path, i: ident) -> str { fn path_ident_to_str(p: path, i: ident) -> str {
if vec::is_empty(p) { if vec::is_empty(p) {
/* FIXME: bad */ copy i /* FIXME: bad */ copy *i
} else { } else {
#fmt["%s::%s", path_to_str(p), i] #fmt["%s::%s", path_to_str(p), *i]
} }
} }
@ -59,7 +59,7 @@ type ctx = {map: map, mut path: path,
mut local_id: uint, diag: span_handler}; mut local_id: uint, diag: span_handler};
type vt = visit::vt<ctx>; type vt = visit::vt<ctx>;
fn extend(cx: ctx, +elt: str) -> @path { fn extend(cx: ctx, +elt: ident) -> @path {
@(cx.path + [path_name(elt)]) @(cx.path + [path_name(elt)])
} }
@ -192,7 +192,7 @@ fn map_item(i: @item, cx: ctx, v: vt) {
item_impl(_, _, _, _, ms) { item_impl(_, _, _, _, ms) {
let impl_did = ast_util::local_def(i.id); let impl_did = ast_util::local_def(i.id);
for ms.each {|m| for ms.each {|m|
map_method(impl_did, extend(cx, /* FIXME: bad */ copy i.ident), m, map_method(impl_did, extend(cx, i.ident), m,
cx); cx);
} }
} }
@ -208,7 +208,7 @@ fn map_item(i: @item, cx: ctx, v: vt) {
for vs.each {|v| for vs.each {|v|
cx.map.insert(v.node.id, node_variant( cx.map.insert(v.node.id, node_variant(
/* FIXME: bad */ copy v, i, /* FIXME: bad */ copy v, i,
extend(cx, /* FIXME: bad */ copy i.ident))); extend(cx, i.ident)));
} }
} }
item_native_mod(nm) { item_native_mod(nm) {
@ -229,7 +229,7 @@ fn map_item(i: @item, cx: ctx, v: vt) {
vec::iter(ifces) {|p| cx.map.insert(p.id, vec::iter(ifces) {|p| cx.map.insert(p.id,
node_item(i, item_path)); }; node_item(i, item_path)); };
let d_id = ast_util::local_def(i.id); let d_id = ast_util::local_def(i.id);
let p = extend(cx, /* FIXME: bad */ copy i.ident); let p = extend(cx, i.ident);
// only need to handle methods // only need to handle methods
vec::iter(ms) {|m| map_method(d_id, p, m, cx); } vec::iter(ms) {|m| map_method(d_id, p, m, cx); }
} }
@ -237,9 +237,9 @@ fn map_item(i: @item, cx: ctx, v: vt) {
} }
alt i.node { alt i.node {
item_mod(_) | item_native_mod(_) { item_mod(_) | item_native_mod(_) {
cx.path += [path_mod(/* FIXME: bad */ copy i.ident)]; cx.path += [path_mod(i.ident)];
} }
_ { cx.path += [path_name(/* FIXME: bad */ copy i.ident)]; } _ { cx.path += [path_name(i.ident)]; }
} }
visit::visit_item(i, cx, v); visit::visit_item(i, cx, v);
vec::pop(cx.path); vec::pop(cx.path);
@ -281,11 +281,11 @@ fn node_id_to_str(map: map, id: node_id) -> str {
} }
some(node_method(m, impl_did, path)) { some(node_method(m, impl_did, path)) {
#fmt["method %s in %s (id=%?)", #fmt["method %s in %s (id=%?)",
m.ident, path_to_str(*path), id] *m.ident, path_to_str(*path), id]
} }
some(node_variant(variant, def_id, path)) { some(node_variant(variant, def_id, path)) {
#fmt["variant %s in %s (id=%?)", #fmt["variant %s in %s (id=%?)",
variant.node.name, path_to_str(*path), id] *variant.node.name, path_to_str(*path), id]
} }
some(node_expr(expr)) { some(node_expr(expr)) {
#fmt["expr %s (id=%?)", #fmt["expr %s (id=%?)",

View File

@ -23,7 +23,10 @@ pure fn dummy_sp() -> span { ret mk_sp(0u, 0u); }
pure fn path_name(p: @path) -> str { path_name_i(p.idents) } pure fn path_name(p: @path) -> str { path_name_i(p.idents) }
pure fn path_name_i(idents: [ident]) -> str { str::connect(idents, "::") } pure fn path_name_i(idents: [ident]) -> str {
// FIXME: Bad copies
str::connect(idents.map({|i|*i}), "::")
}
pure fn path_to_ident(p: @path) -> ident { vec::last(p.idents) } pure fn path_to_ident(p: @path) -> ident { vec::last(p.idents) }
@ -380,7 +383,7 @@ fn dtor_dec() -> fn_decl {
let nil_t = @{id: 0, node: ty_nil, span: dummy_sp()}; let nil_t = @{id: 0, node: ty_nil, span: dummy_sp()};
// dtor has one argument, of type () // dtor has one argument, of type ()
{inputs: [{mode: ast::expl(ast::by_ref), {inputs: [{mode: ast::expl(ast::by_ref),
ty: nil_t, ident: "_", id: 0}], ty: nil_t, ident: @"_", id: 0}],
output: nil_t, purity: impure_fn, cf: return_val, constraints: []} output: nil_t, purity: impure_fn, cf: return_val, constraints: []}
} }

View File

@ -47,7 +47,7 @@ export require_unique_names;
/* Constructors */ /* Constructors */
fn mk_name_value_item_str(+name: ast::ident, +value: str) -> @ast::meta_item { fn mk_name_value_item_str(+name: ast::ident, +value: str) -> @ast::meta_item {
let value_lit = dummy_spanned(ast::lit_str(value)); let value_lit = dummy_spanned(ast::lit_str(@value));
ret mk_name_value_item(name, value_lit); ret mk_name_value_item(name, value_lit);
} }
@ -100,12 +100,12 @@ fn get_meta_item_name(meta: @ast::meta_item) -> ast::ident {
Gets the string value if the meta_item is a meta_name_value variant Gets the string value if the meta_item is a meta_name_value variant
containing a string, otherwise none containing a string, otherwise none
"] "]
fn get_meta_item_value_str(meta: @ast::meta_item) -> option<str> { fn get_meta_item_value_str(meta: @ast::meta_item) -> option<@str> {
alt meta.node { alt meta.node {
ast::meta_name_value(_, v) { ast::meta_name_value(_, v) {
alt v.node { alt v.node {
ast::lit_str(s) { ast::lit_str(s) {
option::some(/* FIXME bad */ copy s) option::some(s)
} }
_ { _ {
option::none option::none
@ -130,11 +130,11 @@ a tuple containing the name and string value, otherwise `none`
"] "]
fn get_name_value_str_pair( fn get_name_value_str_pair(
item: @ast::meta_item item: @ast::meta_item
) -> option<(str, str)> { ) -> option<(ast::ident, @str)> {
alt attr::get_meta_item_value_str(item) { alt attr::get_meta_item_value_str(item) {
some(value) { some(value) {
let name = attr::get_meta_item_name(item); let name = attr::get_meta_item_name(item);
some((name, /* FIXME bad */ copy value)) some((name, value))
} }
none { none } none { none }
} }
@ -146,11 +146,11 @@ fn get_name_value_str_pair(
#[doc = " #[doc = "
Search a list of attributes and return only those with a specific name Search a list of attributes and return only those with a specific name
"] "]
fn find_attrs_by_name(attrs: [ast::attribute], +name: ast::ident) -> fn find_attrs_by_name(attrs: [ast::attribute], +name: str) ->
[ast::attribute] { [ast::attribute] {
let filter = ( let filter = (
fn@(a: ast::attribute) -> option<ast::attribute> { fn@(a: ast::attribute) -> option<ast::attribute> {
if get_attr_name(a) == name { if *get_attr_name(a) == name {
option::some(a) option::some(a)
} else { option::none } } else { option::none }
} }
@ -161,10 +161,10 @@ fn find_attrs_by_name(attrs: [ast::attribute], +name: ast::ident) ->
#[doc = " #[doc = "
Searcha list of meta items and return only those with a specific name Searcha list of meta items and return only those with a specific name
"] "]
fn find_meta_items_by_name(metas: [@ast::meta_item], +name: ast::ident) -> fn find_meta_items_by_name(metas: [@ast::meta_item], +name: str) ->
[@ast::meta_item] { [@ast::meta_item] {
let filter = fn@(&&m: @ast::meta_item) -> option<@ast::meta_item> { let filter = fn@(&&m: @ast::meta_item) -> option<@ast::meta_item> {
if get_meta_item_name(m) == name { if *get_meta_item_name(m) == name {
option::some(m) option::some(m)
} else { option::none } } else { option::none }
}; };
@ -209,17 +209,17 @@ fn eq(a: @ast::meta_item, b: @ast::meta_item) -> bool {
} }
} }
fn contains_name(metas: [@ast::meta_item], +name: ast::ident) -> bool { fn contains_name(metas: [@ast::meta_item], +name: str) -> bool {
let matches = find_meta_items_by_name(metas, name); let matches = find_meta_items_by_name(metas, name);
ret vec::len(matches) > 0u; ret vec::len(matches) > 0u;
} }
fn attrs_contains_name(attrs: [ast::attribute], +name: ast::ident) -> bool { fn attrs_contains_name(attrs: [ast::attribute], +name: str) -> bool {
vec::is_not_empty(find_attrs_by_name(attrs, name)) vec::is_not_empty(find_attrs_by_name(attrs, name))
} }
fn first_attr_value_str_by_name(attrs: [ast::attribute], +name: ast::ident) fn first_attr_value_str_by_name(attrs: [ast::attribute], +name: str)
-> option<str> { -> option<@str> {
let mattrs = find_attrs_by_name(attrs, name); let mattrs = find_attrs_by_name(attrs, name);
if vec::len(mattrs) > 0u { if vec::len(mattrs) > 0u {
ret get_meta_item_value_str(attr_meta(mattrs[0])); ret get_meta_item_value_str(attr_meta(mattrs[0]));
@ -238,11 +238,11 @@ fn last_meta_item_by_name(
fn last_meta_item_value_str_by_name( fn last_meta_item_value_str_by_name(
items: [@ast::meta_item], items: [@ast::meta_item],
+name: str +name: str
) -> option<str> { ) -> option<@str> {
alt last_meta_item_by_name(items, name) { alt last_meta_item_by_name(items, name) {
some(item) { some(item) {
alt attr::get_meta_item_value_str(item) { alt attr::get_meta_item_value_str(item) {
some(value) { some(/* FIXME bad */ copy value) } some(value) { some(value) }
none { none } none { none }
} }
} }
@ -285,7 +285,7 @@ fn sort_meta_items(+items: [@ast::meta_item]) -> [@ast::meta_item] {
ret vec::from_mut(v); ret vec::from_mut(v);
} }
fn remove_meta_items_by_name(items: [@ast::meta_item], name: str) -> fn remove_meta_items_by_name(items: [@ast::meta_item], name: ast::ident) ->
[@ast::meta_item] { [@ast::meta_item] {
ret vec::filter_map(items, { ret vec::filter_map(items, {
@ -326,17 +326,17 @@ fn native_abi(attrs: [ast::attribute]) -> either<str, ast::native_abi> {
option::none { option::none {
either::right(ast::native_abi_cdecl) either::right(ast::native_abi_cdecl)
} }
option::some("rust-intrinsic") { option::some(@"rust-intrinsic") {
either::right(ast::native_abi_rust_intrinsic) either::right(ast::native_abi_rust_intrinsic)
} }
option::some("cdecl") { option::some(@"cdecl") {
either::right(ast::native_abi_cdecl) either::right(ast::native_abi_cdecl)
} }
option::some("stdcall") { option::some(@"stdcall") {
either::right(ast::native_abi_stdcall) either::right(ast::native_abi_stdcall)
} }
option::some(t) { option::some(t) {
either::left("unsupported abi: " + t) either::left("unsupported abi: " + *t)
} }
}; };
} }
@ -352,8 +352,8 @@ fn find_inline_attr(attrs: [ast::attribute]) -> inline_attr {
// TODO---validate the usage of #[inline] and #[inline(always)] // TODO---validate the usage of #[inline] and #[inline(always)]
vec::foldl(ia_none, attrs) {|ia,attr| vec::foldl(ia_none, attrs) {|ia,attr|
alt attr.node.value.node { alt attr.node.value.node {
ast::meta_word("inline") { ia_hint } ast::meta_word(@"inline") { ia_hint }
ast::meta_list("inline", items) { ast::meta_list(@"inline", items) {
if !vec::is_empty(find_meta_items_by_name(items, "always")) { if !vec::is_empty(find_meta_items_by_name(items, "always")) {
ia_always ia_always
} else { } else {
@ -373,11 +373,11 @@ fn require_unique_names(diagnostic: span_handler,
let name = get_meta_item_name(meta); let name = get_meta_item_name(meta);
// FIXME: How do I silence the warnings? --pcw // FIXME: How do I silence the warnings? --pcw
if map.contains_key(name) { if map.contains_key(*name) {
diagnostic.span_fatal(meta.span, diagnostic.span_fatal(meta.span,
#fmt["duplicate meta item `%s`", name]); #fmt["duplicate meta item `%s`", *name]);
} }
map.insert(name, ()); map.insert(*name, ());
} }
} }

View File

@ -92,7 +92,7 @@ fn expand(cx: ext_ctxt,
_mitem: ast::meta_item, _mitem: ast::meta_item,
in_items: [@ast::item]) -> [@ast::item] { in_items: [@ast::item]) -> [@ast::item] {
fn not_auto_serialize(a: ast::attribute) -> bool { fn not_auto_serialize(a: ast::attribute) -> bool {
attr::get_attr_name(a) != "auto_serialize" attr::get_attr_name(a) != @"auto_serialize"
} }
fn filter_attrs(item: @ast::item) -> @ast::item { fn filter_attrs(item: @ast::item) -> @ast::item {
@ -126,18 +126,19 @@ impl helpers for ext_ctxt {
helper_name: str) -> @ast::path { helper_name: str) -> @ast::path {
let head = vec::init(base_path.idents); let head = vec::init(base_path.idents);
let tail = vec::last(base_path.idents); let tail = vec::last(base_path.idents);
self.path(base_path.span, head + [helper_name + "_" + tail]) self.path(base_path.span, head + [@(helper_name + "_" + *tail)])
} }
fn path(span: span, strs: [str]) -> @ast::path { fn path(span: span, strs: [ast::ident]) -> @ast::path {
@{span: span, global: false, idents: strs, rp: none, types: []} @{span: span, global: false, idents: strs, rp: none, types: []}
} }
fn path_tps(span: span, strs: [str], tps: [@ast::ty]) -> @ast::path { fn path_tps(span: span, strs: [ast::ident],
tps: [@ast::ty]) -> @ast::path {
@{span: span, global: false, idents: strs, rp: none, types: tps} @{span: span, global: false, idents: strs, rp: none, types: tps}
} }
fn ty_path(span: span, strs: [str], tps: [@ast::ty]) -> @ast::ty { fn ty_path(span: span, strs: [ast::ident], tps: [@ast::ty]) -> @ast::ty {
@{id: self.next_id(), @{id: self.next_id(),
node: ast::ty_path(self.path_tps(span, strs, tps), self.next_id()), node: ast::ty_path(self.path_tps(span, strs, tps), self.next_id()),
span: span} span: span}
@ -149,7 +150,7 @@ impl helpers for ext_ctxt {
let args = vec::map(input_tys) {|ty| let args = vec::map(input_tys) {|ty|
{mode: ast::expl(ast::by_ref), {mode: ast::expl(ast::by_ref),
ty: ty, ty: ty,
ident: "", ident: @"",
id: self.next_id()} id: self.next_id()}
}; };
@ -170,7 +171,7 @@ impl helpers for ext_ctxt {
@{id: self.next_id(), node: node, span: span} @{id: self.next_id(), node: node, span: span}
} }
fn var_ref(span: span, name: str) -> @ast::expr { fn var_ref(span: span, name: ast::ident) -> @ast::expr {
self.expr(span, ast::expr_path(self.path(span, [name]))) self.expr(span, ast::expr_path(self.path(span, [name])))
} }
@ -192,7 +193,7 @@ impl helpers for ext_ctxt {
span: expr.span} span: expr.span}
} }
fn binder_pat(span: span, nm: str) -> @ast::pat { fn binder_pat(span: span, nm: ast::ident) -> @ast::pat {
let path = @{span: span, global: false, idents: [nm], let path = @{span: span, global: false, idents: [nm],
rp: none, types: []}; rp: none, types: []};
@{id: self.next_id(), @{id: self.next_id(),
@ -212,7 +213,7 @@ impl helpers for ext_ctxt {
ast::expr_alt(v, arms, ast::alt_exhaustive))) ast::expr_alt(v, arms, ast::alt_exhaustive)))
} }
fn lit_str(span: span, s: str) -> @ast::expr { fn lit_str(span: span, s: @str) -> @ast::expr {
self.expr( self.expr(
span, span,
ast::expr_lit( ast::expr_lit(
@ -310,7 +311,7 @@ fn ser_variant(cx: ext_ctxt,
bodyfn: fn(-@ast::expr, ast::blk) -> @ast::expr, bodyfn: fn(-@ast::expr, ast::blk) -> @ast::expr,
argfn: fn(-@ast::expr, uint, ast::blk) -> @ast::expr) argfn: fn(-@ast::expr, uint, ast::blk) -> @ast::expr)
-> ast::arm { -> ast::arm {
let vnames = vec::from_fn(vec::len(tys)) {|i| #fmt["__v%u", i]}; let vnames = vec::from_fn(vec::len(tys)) {|i| @#fmt["__v%u", i]};
let pats = vec::from_fn(vec::len(tys)) {|i| let pats = vec::from_fn(vec::len(tys)) {|i|
cx.binder_pat(tys[i].span, vnames[i]) cx.binder_pat(tys[i].span, vnames[i])
}; };
@ -428,7 +429,7 @@ fn ser_ty(cx: ext_ctxt, tps: ser_tps_map,
vec::is_empty(path.types) { vec::is_empty(path.types) {
let ident = path.idents[0]; let ident = path.idents[0];
alt tps.find(ident) { alt tps.find(*ident) {
some(f) { f(v) } some(f) { f(v) }
none { ser_path(cx, tps, path, s, v) } none { ser_path(cx, tps, path, s, v) }
} }
@ -474,7 +475,7 @@ fn ser_ty(cx: ext_ctxt, tps: ser_tps_map,
} }
} }
fn mk_ser_fn(cx: ext_ctxt, span: span, name: str, tps: [ast::ty_param], fn mk_ser_fn(cx: ext_ctxt, span: span, name: ast::ident, tps: [ast::ty_param],
f: fn(ext_ctxt, ser_tps_map, f: fn(ext_ctxt, ser_tps_map,
-@ast::expr, -@ast::expr) -> [@ast::stmt]) -@ast::expr, -@ast::expr) -> [@ast::stmt])
-> @ast::item { -> @ast::item {
@ -489,7 +490,7 @@ fn mk_ser_fn(cx: ext_ctxt, span: span, name: str, tps: [ast::ty_param],
ty: cx.ty_fn(span, ty: cx.ty_fn(span,
[cx.ty_path(span, [tp.ident], [])], [cx.ty_path(span, [tp.ident], [])],
cx.ty_nil(span)), cx.ty_nil(span)),
ident: "__s" + tp.ident, ident: @("__s" + *tp.ident),
id: cx.next_id()}}); id: cx.next_id()}});
#debug["tp_inputs = %?", tp_inputs]; #debug["tp_inputs = %?", tp_inputs];
@ -497,12 +498,12 @@ fn mk_ser_fn(cx: ext_ctxt, span: span, name: str, tps: [ast::ty_param],
let ser_inputs: [ast::arg] = let ser_inputs: [ast::arg] =
[{mode: ast::expl(ast::by_ref), [{mode: ast::expl(ast::by_ref),
ty: cx.ty_path(span, ["__S"], []), ty: cx.ty_path(span, [@"__S"], []),
ident: "__s", ident: @"__s",
id: cx.next_id()}, id: cx.next_id()},
{mode: ast::expl(ast::by_ref), {mode: ast::expl(ast::by_ref),
ty: v_ty, ty: v_ty,
ident: "__v", ident: @"__v",
id: cx.next_id()}] id: cx.next_id()}]
+ tp_inputs; + tp_inputs;
@ -510,21 +511,21 @@ fn mk_ser_fn(cx: ext_ctxt, span: span, name: str, tps: [ast::ty_param],
vec::iter2(tps, tp_inputs) {|tp, arg| vec::iter2(tps, tp_inputs) {|tp, arg|
let arg_ident = arg.ident; let arg_ident = arg.ident;
tps_map.insert( tps_map.insert(
tp.ident, *tp.ident,
fn@(v: @ast::expr) -> [@ast::stmt] { fn@(v: @ast::expr) -> [@ast::stmt] {
let f = cx.var_ref(span, arg_ident); let f = cx.var_ref(span, arg_ident);
#debug["serializing type arg %s", arg_ident]; #debug["serializing type arg %s", *arg_ident];
[#ast(stmt){$(f)($(v));}] [#ast(stmt){$(f)($(v));}]
}); });
} }
let ser_bnds = @[ let ser_bnds = @[
ast::bound_iface(cx.ty_path(span, ast::bound_iface(cx.ty_path(span,
["std", "serialization", "serializer"], [@"std", @"serialization", @"serializer"],
[]))]; []))];
let ser_tps: [ast::ty_param] = let ser_tps: [ast::ty_param] =
[{ident: "__S", [{ident: @"__S",
id: cx.next_id(), id: cx.next_id(),
bounds: ser_bnds}] + bounds: ser_bnds}] +
vec::map(tps) {|tp| cx.clone_ty_param(tp) }; vec::map(tps) {|tp| cx.clone_ty_param(tp) };
@ -536,7 +537,7 @@ fn mk_ser_fn(cx: ext_ctxt, span: span, name: str, tps: [ast::ty_param],
let ser_blk = cx.blk(span, let ser_blk = cx.blk(span,
f(cx, tps_map, #ast{ __s }, #ast{ __v })); f(cx, tps_map, #ast{ __s }, #ast{ __v }));
@{ident: "serialize_" + name, @{ident: @("serialize_" + *name),
attrs: [], attrs: [],
id: cx.next_id(), id: cx.next_id(),
node: ast::item_fn({inputs: ser_inputs, node: ast::item_fn({inputs: ser_inputs,
@ -651,7 +652,7 @@ fn deser_ty(cx: ext_ctxt, tps: deser_tps_map,
vec::is_empty(path.types) { vec::is_empty(path.types) {
let ident = path.idents[0]; let ident = path.idents[0];
alt tps.find(ident) { alt tps.find(*ident) {
some(f) { f() } some(f) { f() }
none { deser_path(cx, tps, path, d) } none { deser_path(cx, tps, path, d) }
} }
@ -683,7 +684,8 @@ fn deser_ty(cx: ext_ctxt, tps: deser_tps_map,
} }
} }
fn mk_deser_fn(cx: ext_ctxt, span: span, name: str, tps: [ast::ty_param], fn mk_deser_fn(cx: ext_ctxt, span: span,
name: ast::ident, tps: [ast::ty_param],
f: fn(ext_ctxt, deser_tps_map, -@ast::expr) -> @ast::expr) f: fn(ext_ctxt, deser_tps_map, -@ast::expr) -> @ast::expr)
-> @ast::item { -> @ast::item {
let ext_cx = cx; // required for #ast let ext_cx = cx; // required for #ast
@ -697,15 +699,15 @@ fn mk_deser_fn(cx: ext_ctxt, span: span, name: str, tps: [ast::ty_param],
ty: cx.ty_fn(span, ty: cx.ty_fn(span,
[], [],
cx.ty_path(span, [tp.ident], [])), cx.ty_path(span, [tp.ident], [])),
ident: "__d" + tp.ident, ident: @("__d" + *tp.ident),
id: cx.next_id()}}); id: cx.next_id()}});
#debug["tp_inputs = %?", tp_inputs]; #debug["tp_inputs = %?", tp_inputs];
let deser_inputs: [ast::arg] = let deser_inputs: [ast::arg] =
[{mode: ast::expl(ast::by_ref), [{mode: ast::expl(ast::by_ref),
ty: cx.ty_path(span, ["__D"], []), ty: cx.ty_path(span, [@"__D"], []),
ident: "__d", ident: @"__d",
id: cx.next_id()}] id: cx.next_id()}]
+ tp_inputs; + tp_inputs;
@ -713,7 +715,7 @@ fn mk_deser_fn(cx: ext_ctxt, span: span, name: str, tps: [ast::ty_param],
vec::iter2(tps, tp_inputs) {|tp, arg| vec::iter2(tps, tp_inputs) {|tp, arg|
let arg_ident = arg.ident; let arg_ident = arg.ident;
tps_map.insert( tps_map.insert(
tp.ident, *tp.ident,
fn@() -> @ast::expr { fn@() -> @ast::expr {
let f = cx.var_ref(span, arg_ident); let f = cx.var_ref(span, arg_ident);
#ast{ $(f)() } #ast{ $(f)() }
@ -721,12 +723,13 @@ fn mk_deser_fn(cx: ext_ctxt, span: span, name: str, tps: [ast::ty_param],
} }
let deser_bnds = @[ let deser_bnds = @[
ast::bound_iface(cx.ty_path(span, ast::bound_iface(cx.ty_path(
["std", "serialization", "deserializer"], span,
[]))]; [@"std", @"serialization", @"deserializer"],
[]))];
let deser_tps: [ast::ty_param] = let deser_tps: [ast::ty_param] =
[{ident: "__D", [{ident: @"__D",
id: cx.next_id(), id: cx.next_id(),
bounds: deser_bnds}] + vec::map(tps) {|tp| bounds: deser_bnds}] + vec::map(tps) {|tp|
let cloned = cx.clone_ty_param(tp); let cloned = cx.clone_ty_param(tp);
@ -735,7 +738,7 @@ fn mk_deser_fn(cx: ext_ctxt, span: span, name: str, tps: [ast::ty_param],
let deser_blk = cx.expr_blk(f(cx, tps_map, #ast(expr){__d})); let deser_blk = cx.expr_blk(f(cx, tps_map, #ast(expr){__d}));
@{ident: "deserialize_" + name, @{ident: @("deserialize_" + *name),
attrs: [], attrs: [],
id: cx.next_id(), id: cx.next_id(),
node: ast::item_fn({inputs: deser_inputs, node: ast::item_fn({inputs: deser_inputs,
@ -749,7 +752,7 @@ fn mk_deser_fn(cx: ext_ctxt, span: span, name: str, tps: [ast::ty_param],
span: span} span: span}
} }
fn ty_fns(cx: ext_ctxt, name: str, ty: @ast::ty, tps: [ast::ty_param]) fn ty_fns(cx: ext_ctxt, name: ast::ident, ty: @ast::ty, tps: [ast::ty_param])
-> [@ast::item] { -> [@ast::item] {
let span = ty.span; let span = ty.span;
@ -759,7 +762,7 @@ fn ty_fns(cx: ext_ctxt, name: str, ty: @ast::ty, tps: [ast::ty_param])
] ]
} }
fn ser_enum(cx: ext_ctxt, tps: ser_tps_map, e_name: str, fn ser_enum(cx: ext_ctxt, tps: ser_tps_map, e_name: ast::ident,
e_span: span, variants: [ast::variant], e_span: span, variants: [ast::variant],
-s: @ast::expr, -v: @ast::expr) -> [@ast::stmt] { -s: @ast::expr, -v: @ast::expr) -> [@ast::stmt] {
let ext_cx = cx; let ext_cx = cx;
@ -808,7 +811,7 @@ fn ser_enum(cx: ext_ctxt, tps: ser_tps_map, e_name: str,
[#ast(stmt){ $(s).emit_enum($(e_name), $(lam)) }] [#ast(stmt){ $(s).emit_enum($(e_name), $(lam)) }]
} }
fn deser_enum(cx: ext_ctxt, tps: deser_tps_map, e_name: str, fn deser_enum(cx: ext_ctxt, tps: deser_tps_map, e_name: ast::ident,
e_span: span, variants: [ast::variant], e_span: span, variants: [ast::variant],
-d: @ast::expr) -> @ast::expr { -d: @ast::expr) -> @ast::expr {
let ext_cx = cx; let ext_cx = cx;
@ -852,7 +855,7 @@ fn deser_enum(cx: ext_ctxt, tps: deser_tps_map, e_name: str,
#ast{ $(d).read_enum($(e_name), $(read_lambda)) } #ast{ $(d).read_enum($(e_name), $(read_lambda)) }
} }
fn enum_fns(cx: ext_ctxt, e_name: str, e_span: span, fn enum_fns(cx: ext_ctxt, e_name: ast::ident, e_span: span,
variants: [ast::variant], tps: [ast::ty_param]) variants: [ast::variant], tps: [ast::ty_param])
-> [@ast::item] { -> [@ast::item] {
[ [

View File

@ -9,7 +9,7 @@ type syntax_expander_ =
type syntax_expander = { type syntax_expander = {
expander: syntax_expander_, expander: syntax_expander_,
span: option<span>}; span: option<span>};
type macro_def = {ident: str, ext: syntax_extension}; type macro_def = {ident: ast::ident, ext: syntax_extension};
type macro_definer = type macro_definer =
fn@(ext_ctxt, span, ast::mac_arg, ast::mac_body) -> macro_def; fn@(ext_ctxt, span, ast::mac_arg, ast::mac_body) -> macro_def;
type item_decorator = type item_decorator =
@ -150,7 +150,7 @@ fn expr_to_str(cx: ext_ctxt, expr: @ast::expr, error: str) -> str {
alt expr.node { alt expr.node {
ast::expr_lit(l) { ast::expr_lit(l) {
alt l.node { alt l.node {
ast::lit_str(s) { ret s; } ast::lit_str(s) { ret *s; }
_ { cx.span_fatal(l.span, error); } _ { cx.span_fatal(l.span, error); }
} }
} }

View File

@ -6,7 +6,7 @@ fn mk_lit(cx: ext_ctxt, sp: span, lit: ast::lit_) -> @ast::expr {
ret @{id: cx.next_id(), node: ast::expr_lit(sp_lit), span: sp}; ret @{id: cx.next_id(), node: ast::expr_lit(sp_lit), span: sp};
} }
fn mk_str(cx: ext_ctxt, sp: span, s: str) -> @ast::expr { fn mk_str(cx: ext_ctxt, sp: span, s: str) -> @ast::expr {
let lit = ast::lit_str(s); let lit = ast::lit_str(@s);
ret mk_lit(cx, sp, lit); ret mk_lit(cx, sp, lit);
} }
fn mk_int(cx: ext_ctxt, sp: span, i: int) -> @ast::expr { fn mk_int(cx: ext_ctxt, sp: span, i: int) -> @ast::expr {

View File

@ -3,13 +3,13 @@ import base::*;
fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg,
_body: ast::mac_body) -> @ast::expr { _body: ast::mac_body) -> @ast::expr {
let args = get_mac_args_no_max(cx,sp,arg,1u,"concat_idents"); let args = get_mac_args_no_max(cx,sp,arg,1u,"concat_idents");
let mut res: ast::ident = ""; let mut res = "";
for args.each {|e| for args.each {|e|
res += expr_to_ident(cx, e, "expected an ident"); res += *expr_to_ident(cx, e, "expected an ident");
} }
ret @{id: cx.next_id(), ret @{id: cx.next_id(),
node: ast::expr_path(@{span: sp, global: false, idents: [res], node: ast::expr_path(@{span: sp, global: false, idents: [@res],
rp: none, types: []}), rp: none, types: []}),
span: sp}; span: sp};
} }

View File

@ -21,8 +21,8 @@ fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg,
} }
} }
fn make_new_str(cx: ext_ctxt, sp: codemap::span, s: str) -> @ast::expr { fn make_new_str(cx: ext_ctxt, sp: codemap::span, +s: str) -> @ast::expr {
ret make_new_lit(cx, sp, ast::lit_str(s)); ret make_new_lit(cx, sp, ast::lit_str(@s));
} }
// //
// Local Variables: // Local Variables:

View File

@ -21,21 +21,21 @@ fn expand_expr(exts: hashmap<str, syntax_extension>, cx: ext_ctxt,
mac_invoc(pth, args, body) { mac_invoc(pth, args, body) {
assert (vec::len(pth.idents) > 0u); assert (vec::len(pth.idents) > 0u);
let extname = pth.idents[0]; let extname = pth.idents[0];
alt exts.find(extname) { alt exts.find(*extname) {
none { none {
cx.span_fatal(pth.span, cx.span_fatal(pth.span,
#fmt["macro undefined: '%s'", extname]) #fmt["macro undefined: '%s'", *extname])
} }
some(item_decorator(_)) { some(item_decorator(_)) {
cx.span_fatal( cx.span_fatal(
pth.span, pth.span,
#fmt["%s can only be used as a decorator", extname]); #fmt["%s can only be used as a decorator", *extname]);
} }
some(normal({expander: exp, span: exp_sp})) { some(normal({expander: exp, span: exp_sp})) {
let expanded = exp(cx, pth.span, args, body); let expanded = exp(cx, pth.span, args, body);
cx.bt_push(expanded_from({call_site: s, cx.bt_push(expanded_from({call_site: s,
callie: {name: extname, span: exp_sp}})); callie: {name: *extname, span: exp_sp}}));
//keep going, outside-in //keep going, outside-in
let fully_expanded = fld.fold_expr(expanded).node; let fully_expanded = fld.fold_expr(expanded).node;
cx.bt_pop(); cx.bt_pop();
@ -44,7 +44,7 @@ fn expand_expr(exts: hashmap<str, syntax_extension>, cx: ext_ctxt,
} }
some(macro_defining(ext)) { some(macro_defining(ext)) {
let named_extension = ext(cx, pth.span, args, body); let named_extension = ext(cx, pth.span, args, body);
exts.insert(named_extension.ident, named_extension.ext); exts.insert(*named_extension.ident, named_extension.ext);
(ast::expr_rec([], none), s) (ast::expr_rec([], none), s)
} }
} }
@ -74,7 +74,7 @@ fn expand_mod_items(exts: hashmap<str, syntax_extension>, cx: ext_ctxt,
ast::meta_name_value(n, _) { n } ast::meta_name_value(n, _) { n }
ast::meta_list(n, _) { n } ast::meta_list(n, _) { n }
}; };
alt exts.find(mname) { alt exts.find(*mname) {
none | some(normal(_)) | some(macro_defining(_)) { none | some(normal(_)) | some(macro_defining(_)) {
items items
} }

View File

@ -36,9 +36,10 @@ fn expand_syntax_ext(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
fn pieces_to_expr(cx: ext_ctxt, sp: span, pieces: [piece], args: [@ast::expr]) fn pieces_to_expr(cx: ext_ctxt, sp: span, pieces: [piece], args: [@ast::expr])
-> @ast::expr { -> @ast::expr {
fn make_path_vec(_cx: ext_ctxt, ident: ast::ident) -> [ast::ident] { fn make_path_vec(_cx: ext_ctxt, ident: ast::ident) -> [ast::ident] {
ret ["extfmt", "rt", ident]; ret [@"extfmt", @"rt", ident];
} }
fn make_rt_path_expr(cx: ext_ctxt, sp: span, ident: str) -> @ast::expr { fn make_rt_path_expr(cx: ext_ctxt, sp: span,
ident: ast::ident) -> @ast::expr {
let path = make_path_vec(cx, ident); let path = make_path_vec(cx, ident);
ret mk_path(cx, sp, path); ret mk_path(cx, sp, path);
} }
@ -57,18 +58,18 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, pieces: [piece], args: [@ast::expr])
flag_sign_always { fstr = "flag_sign_always"; } flag_sign_always { fstr = "flag_sign_always"; }
flag_alternate { fstr = "flag_alternate"; } flag_alternate { fstr = "flag_alternate"; }
} }
flagexprs += [make_rt_path_expr(cx, sp, fstr)]; flagexprs += [make_rt_path_expr(cx, sp, @fstr)];
} }
ret mk_vec_e(cx, sp, flagexprs); ret mk_vec_e(cx, sp, flagexprs);
} }
fn make_count(cx: ext_ctxt, sp: span, cnt: count) -> @ast::expr { fn make_count(cx: ext_ctxt, sp: span, cnt: count) -> @ast::expr {
alt cnt { alt cnt {
count_implied { count_implied {
ret make_rt_path_expr(cx, sp, "count_implied"); ret make_rt_path_expr(cx, sp, @"count_implied");
} }
count_is(c) { count_is(c) {
let count_lit = mk_int(cx, sp, c); let count_lit = mk_int(cx, sp, c);
let count_is_path = make_path_vec(cx, "count_is"); let count_is_path = make_path_vec(cx, @"count_is");
let count_is_args = [count_lit]; let count_is_args = [count_lit];
ret mk_call(cx, sp, count_is_path, count_is_args); ret mk_call(cx, sp, count_is_path, count_is_args);
} }
@ -88,16 +89,16 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, pieces: [piece], args: [@ast::expr])
ty_octal { rt_type = "ty_octal"; } ty_octal { rt_type = "ty_octal"; }
_ { rt_type = "ty_default"; } _ { rt_type = "ty_default"; }
} }
ret make_rt_path_expr(cx, sp, rt_type); ret make_rt_path_expr(cx, sp, @rt_type);
} }
fn make_conv_rec(cx: ext_ctxt, sp: span, flags_expr: @ast::expr, fn make_conv_rec(cx: ext_ctxt, sp: span, flags_expr: @ast::expr,
width_expr: @ast::expr, precision_expr: @ast::expr, width_expr: @ast::expr, precision_expr: @ast::expr,
ty_expr: @ast::expr) -> @ast::expr { ty_expr: @ast::expr) -> @ast::expr {
ret mk_rec_e(cx, sp, ret mk_rec_e(cx, sp,
[{ident: "flags", ex: flags_expr}, [{ident: @"flags", ex: flags_expr},
{ident: "width", ex: width_expr}, {ident: @"width", ex: width_expr},
{ident: "precision", ex: precision_expr}, {ident: @"precision", ex: precision_expr},
{ident: "ty", ex: ty_expr}]); {ident: @"ty", ex: ty_expr}]);
} }
let rt_conv_flags = make_flags(cx, sp, cnv.flags); let rt_conv_flags = make_flags(cx, sp, cnv.flags);
let rt_conv_width = make_count(cx, sp, cnv.width); let rt_conv_width = make_count(cx, sp, cnv.width);
@ -109,7 +110,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, pieces: [piece], args: [@ast::expr])
fn make_conv_call(cx: ext_ctxt, sp: span, conv_type: str, cnv: conv, fn make_conv_call(cx: ext_ctxt, sp: span, conv_type: str, cnv: conv,
arg: @ast::expr) -> @ast::expr { arg: @ast::expr) -> @ast::expr {
let fname = "conv_" + conv_type; let fname = "conv_" + conv_type;
let path = make_path_vec(cx, fname); let path = make_path_vec(cx, @fname);
let cnv_expr = make_rt_conv_expr(cx, sp, cnv); let cnv_expr = make_rt_conv_expr(cx, sp, cnv);
let args = [cnv_expr, arg]; let args = [cnv_expr, arg];
ret mk_call(cx, arg.span, path, args); ret mk_call(cx, arg.span, path, args);

View File

@ -35,7 +35,7 @@ impl of qq_helper for @ast::crate {
fn visit(cx: aq_ctxt, v: vt<aq_ctxt>) {visit_crate(*self, cx, v);} fn visit(cx: aq_ctxt, v: vt<aq_ctxt>) {visit_crate(*self, cx, v);}
fn extract_mac() -> option<ast::mac_> {fail} fn extract_mac() -> option<ast::mac_> {fail}
fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr { fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr {
mk_path(cx, sp, ["syntax", "ext", "qquote", "parse_crate"]) mk_path(cx, sp, [@"syntax", @"ext", @"qquote", @"parse_crate"])
} }
fn get_fold_fn() -> str {"fold_crate"} fn get_fold_fn() -> str {"fold_crate"}
} }
@ -49,7 +49,7 @@ impl of qq_helper for @ast::expr {
} }
} }
fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr { fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr {
mk_path(cx, sp, ["syntax", "ext", "qquote", "parse_expr"]) mk_path(cx, sp, [@"syntax", @"ext", @"qquote", @"parse_expr"])
} }
fn get_fold_fn() -> str {"fold_expr"} fn get_fold_fn() -> str {"fold_expr"}
} }
@ -63,7 +63,7 @@ impl of qq_helper for @ast::ty {
} }
} }
fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr { fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr {
mk_path(cx, sp, ["syntax", "ext", "qquote", "parse_ty"]) mk_path(cx, sp, [@"syntax", @"ext", @"qquote", @"parse_ty"])
} }
fn get_fold_fn() -> str {"fold_ty"} fn get_fold_fn() -> str {"fold_ty"}
} }
@ -72,7 +72,7 @@ impl of qq_helper for @ast::item {
fn visit(cx: aq_ctxt, v: vt<aq_ctxt>) {visit_item(self, cx, v);} fn visit(cx: aq_ctxt, v: vt<aq_ctxt>) {visit_item(self, cx, v);}
fn extract_mac() -> option<ast::mac_> {fail} fn extract_mac() -> option<ast::mac_> {fail}
fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr { fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr {
mk_path(cx, sp, ["syntax", "ext", "qquote", "parse_item"]) mk_path(cx, sp, [@"syntax", @"ext", @"qquote", @"parse_item"])
} }
fn get_fold_fn() -> str {"fold_item"} fn get_fold_fn() -> str {"fold_item"}
} }
@ -81,7 +81,7 @@ impl of qq_helper for @ast::stmt {
fn visit(cx: aq_ctxt, v: vt<aq_ctxt>) {visit_stmt(self, cx, v);} fn visit(cx: aq_ctxt, v: vt<aq_ctxt>) {visit_stmt(self, cx, v);}
fn extract_mac() -> option<ast::mac_> {fail} fn extract_mac() -> option<ast::mac_> {fail}
fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr { fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr {
mk_path(cx, sp, ["syntax", "ext", "qquote", "parse_stmt"]) mk_path(cx, sp, [@"syntax", @"ext", @"qquote", @"parse_stmt"])
} }
fn get_fold_fn() -> str {"fold_stmt"} fn get_fold_fn() -> str {"fold_stmt"}
} }
@ -90,7 +90,7 @@ impl of qq_helper for @ast::pat {
fn visit(cx: aq_ctxt, v: vt<aq_ctxt>) {visit_pat(self, cx, v);} fn visit(cx: aq_ctxt, v: vt<aq_ctxt>) {visit_pat(self, cx, v);}
fn extract_mac() -> option<ast::mac_> {fail} fn extract_mac() -> option<ast::mac_> {fail}
fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr { fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr {
mk_path(cx, sp, ["syntax", "ext", "qquote", "parse_pat"]) mk_path(cx, sp, [@"syntax", @"ext", @"qquote", @"parse_pat"])
} }
fn get_fold_fn() -> str {"fold_pat"} fn get_fold_fn() -> str {"fold_pat"}
} }
@ -146,7 +146,7 @@ fn expand_ast(ecx: ext_ctxt, _sp: span,
} }
alt (args[0].node) { alt (args[0].node) {
ast::expr_path(@{idents: id, _}) if vec::len(id) == 1u ast::expr_path(@{idents: id, _}) if vec::len(id) == 1u
{what = id[0]} {what = *id[0]}
_ {ecx.span_fatal(args[0].span, "expected an identifier");} _ {ecx.span_fatal(args[0].span, "expected an identifier");}
} }
} }
@ -230,20 +230,21 @@ fn finish<T: qq_helper>
let cx = ecx; let cx = ecx;
let cfg_call = {|| let cfg_call = {||
mk_call_(cx, sp, mk_access(cx, sp, ["ext_cx"], "cfg"), []) mk_call_(cx, sp, mk_access(cx, sp, [@"ext_cx"], @"cfg"), [])
}; };
let parse_sess_call = {|| let parse_sess_call = {||
mk_call_(cx, sp, mk_access(cx, sp, ["ext_cx"], "parse_sess"), []) mk_call_(cx, sp, mk_access(cx, sp, [@"ext_cx"], @"parse_sess"), [])
}; };
let pcall = mk_call(cx,sp, let pcall = mk_call(cx,sp,
["syntax", "parse", "parser", [@"syntax", @"parse", @"parser",
"parse_from_source_str"], @"parse_from_source_str"],
[node.mk_parse_fn(cx,sp), [node.mk_parse_fn(cx,sp),
mk_str(cx,sp, fname), mk_str(cx,sp, fname),
mk_call(cx,sp, mk_call(cx,sp,
["syntax","ext","qquote", "mk_file_substr"], [@"syntax",@"ext",
@"qquote", @"mk_file_substr"],
[mk_str(cx,sp, loc.file.name), [mk_str(cx,sp, loc.file.name),
mk_uint(cx,sp, loc.line), mk_uint(cx,sp, loc.line),
mk_uint(cx,sp, loc.col)]), mk_uint(cx,sp, loc.col)]),
@ -255,15 +256,16 @@ fn finish<T: qq_helper>
let mut rcall = pcall; let mut rcall = pcall;
if (g_len > 0u) { if (g_len > 0u) {
rcall = mk_call(cx,sp, rcall = mk_call(cx,sp,
["syntax", "ext", "qquote", "replace"], [@"syntax", @"ext", @"qquote", @"replace"],
[pcall, [pcall,
mk_vec_e(cx,sp, qcx.gather.map_to_vec {|g| mk_vec_e(cx,sp, qcx.gather.map_to_vec {|g|
mk_call(cx,sp, mk_call(cx,sp,
["syntax", "ext", "qquote", g.constr], [@"syntax", @"ext",
@"qquote", @g.constr],
[g.e])}), [g.e])}),
mk_path(cx,sp, mk_path(cx,sp,
["syntax", "ext", "qquote", [@"syntax", @"ext", @"qquote",
node.get_fold_fn()])]); @node.get_fold_fn()])]);
} }
ret rcall; ret rcall;
} }

View File

@ -1,5 +1,5 @@
import codemap::span; import codemap::span;
import std::map::{hashmap, str_hash}; import std::map::{hashmap, str_hash, box_str_hash};
import dvec::{dvec, extensions}; import dvec::{dvec, extensions};
import base::*; import base::*;
@ -146,7 +146,7 @@ fn acumm_bindings(_cx: ext_ctxt, _b_dest: bindings, _b_src: bindings) { }
fn pattern_to_selectors(cx: ext_ctxt, e: @expr) -> binders { fn pattern_to_selectors(cx: ext_ctxt, e: @expr) -> binders {
let res: binders = let res: binders =
{real_binders: str_hash::<selector>(), {real_binders: box_str_hash::<selector>(),
literal_ast_matchers: dvec()}; literal_ast_matchers: dvec()};
//this oughta return binders instead, but macro args are a sequence of //this oughta return binders instead, but macro args are a sequence of
//expressions, rather than a single expression //expressions, rather than a single expression
@ -162,7 +162,7 @@ bindings. Most of the work is done in p_t_s, which generates the
selectors. */ selectors. */
fn use_selectors_to_bind(b: binders, e: @expr) -> option<bindings> { fn use_selectors_to_bind(b: binders, e: @expr) -> option<bindings> {
let res = str_hash::<arb_depth<matchable>>(); let res = box_str_hash::<arb_depth<matchable>>();
//need to do this first, to check vec lengths. //need to do this first, to check vec lengths.
for b.literal_ast_matchers.each {|sel| for b.literal_ast_matchers.each {|sel|
alt sel(match_expr(e)) { none { ret none; } _ { } } alt sel(match_expr(e)) { none { ret none; } _ { } }
@ -240,7 +240,7 @@ fn follow_for_trans(cx: ext_ctxt, mmaybe: option<arb_depth<matchable>>,
/* helper for transcribe_exprs: what vars from `b` occur in `e`? */ /* helper for transcribe_exprs: what vars from `b` occur in `e`? */
fn free_vars(b: bindings, e: @expr, it: fn(ident)) { fn free_vars(b: bindings, e: @expr, it: fn(ident)) {
let idents: hashmap<ident, ()> = str_hash::<()>(); let idents: hashmap<ident, ()> = box_str_hash::<()>();
fn mark_ident(&&i: ident, _fld: ast_fold, b: bindings, fn mark_ident(&&i: ident, _fld: ast_fold, b: bindings,
idents: hashmap<ident, ()>) -> ident { idents: hashmap<ident, ()>) -> ident {
if b.contains_key(i) { idents.insert(i, ()); } if b.contains_key(i) { idents.insert(i, ()); }
@ -282,8 +282,8 @@ fn transcribe_exprs(cx: ext_ctxt, b: bindings, idx_path: @mut [uint],
let len = vec::len(*ms); let len = vec::len(*ms);
if old_len != len { if old_len != len {
let msg = let msg =
#fmt["'%s' occurs %u times, but ", fv, len] + #fmt["'%s' occurs %u times, but ", *fv, len] +
#fmt["'%s' occurs %u times", old_name, #fmt["'%s' occurs %u times", *old_name,
old_len]; old_len];
cx.span_fatal(repeat_me.span, msg); cx.span_fatal(repeat_me.span, msg);
} }
@ -672,7 +672,7 @@ fn add_new_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
_body: ast::mac_body) -> base::macro_def { _body: ast::mac_body) -> base::macro_def {
let args = get_mac_args_no_max(cx, sp, arg, 0u, "macro"); let args = get_mac_args_no_max(cx, sp, arg, 0u, "macro");
let mut macro_name: option<str> = none; let mut macro_name: option<@str> = none;
let mut clauses: [@clause] = []; let mut clauses: [@clause] = [];
for args.each {|arg| for args.each {|arg|
alt arg.node { alt arg.node {

View File

@ -36,19 +36,20 @@ fn expand_file(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
get_mac_args(cx, sp, arg, 0u, option::some(0u), "file"); get_mac_args(cx, sp, arg, 0u, option::some(0u), "file");
let { file: @{ name: filename, _ }, _ } = let { file: @{ name: filename, _ }, _ } =
codemap::lookup_char_pos(cx.codemap(), sp.lo); codemap::lookup_char_pos(cx.codemap(), sp.lo);
ret make_new_lit(cx, sp, ast::lit_str(filename)); ret make_new_lit(cx, sp, ast::lit_str(@filename));
} }
fn expand_stringify(cx: ext_ctxt, sp: span, arg: ast::mac_arg, fn expand_stringify(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
_body: ast::mac_body) -> @ast::expr { _body: ast::mac_body) -> @ast::expr {
let args = get_mac_args(cx, sp, arg, 1u, option::some(1u), "stringify"); let args = get_mac_args(cx, sp, arg, 1u, option::some(1u), "stringify");
ret make_new_lit(cx, sp, ast::lit_str(pprust::expr_to_str(args[0]))); ret make_new_lit(cx, sp, ast::lit_str(@pprust::expr_to_str(args[0])));
} }
fn expand_mod(cx: ext_ctxt, sp: span, arg: ast::mac_arg, _body: ast::mac_body) fn expand_mod(cx: ext_ctxt, sp: span, arg: ast::mac_arg, _body: ast::mac_body)
-> @ast::expr { -> @ast::expr {
get_mac_args(cx, sp, arg, 0u, option::some(0u), "file"); get_mac_args(cx, sp, arg, 0u, option::some(0u), "file");
ret make_new_lit(cx, sp, ast::lit_str(str::connect(cx.mod_path(), "::"))); ret make_new_lit(cx, sp, ast::lit_str(
@str::connect(cx.mod_path().map({|x|*x}), "::")));
} }
fn expand_include(cx: ext_ctxt, sp: span, arg: ast::mac_arg, fn expand_include(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
@ -75,7 +76,7 @@ fn expand_include_str(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg,
} }
} }
ret make_new_lit(cx, sp, ast::lit_str(result::unwrap(res))); ret make_new_lit(cx, sp, ast::lit_str(@result::unwrap(res)));
} }
fn expand_include_bin(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, fn expand_include_bin(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg,

View File

@ -81,7 +81,7 @@ impl parser_common for parser {
fn token_is_keyword(word: str, ++tok: token::token) -> bool { fn token_is_keyword(word: str, ++tok: token::token) -> bool {
self.require_keyword(word); self.require_keyword(word);
alt tok { alt tok {
token::IDENT(sid, false) { str::eq(word, self.get_str(sid)) } token::IDENT(sid, false) { str::eq(word, *self.get_str(sid)) }
_ { false } _ { false }
} }
} }
@ -97,7 +97,7 @@ impl parser_common for parser {
// workaround LLVM bug #13042 // workaround LLVM bug #13042
alt @self.token { alt @self.token {
@token::IDENT(sid, false) { @token::IDENT(sid, false) {
if str::eq(word, self.get_str(sid)) { if str::eq(word, *self.get_str(sid)) {
self.bump(); self.bump();
ret true; ret true;
} else { ret false; } } else { ret false; }
@ -128,7 +128,7 @@ impl parser_common for parser {
} }
} }
fn check_restricted_keywords_(w: ast::ident) { fn check_restricted_keywords_(w: str) {
if self.is_restricted_keyword(w) { if self.is_restricted_keyword(w) {
self.fatal("found `" + w + "` in restricted position"); self.fatal("found `" + w + "` in restricted position");
} }

View File

@ -75,7 +75,7 @@ fn parse_companion_mod(cx: ctx, prefix: str, suffix: option<str>)
} }
} }
fn cdir_path_opt(id: str, attrs: [ast::attribute]) -> str { fn cdir_path_opt(id: ast::ident, attrs: [ast::attribute]) -> @str {
alt ::attr::first_attr_value_str_by_name(attrs, "path") { alt ::attr::first_attr_value_str_by_name(attrs, "path") {
some(d) { some(d) {
ret d; ret d;
@ -89,11 +89,11 @@ fn eval_crate_directive(cx: ctx, cdir: @ast::crate_directive, prefix: str,
&items: [@ast::item]) { &items: [@ast::item]) {
alt cdir.node { alt cdir.node {
ast::cdir_src_mod(id, attrs) { ast::cdir_src_mod(id, attrs) {
let file_path = cdir_path_opt(id + ".rs", attrs); let file_path = cdir_path_opt(@(*id + ".rs"), attrs);
let full_path = let full_path =
if path::path_is_absolute(file_path) { if path::path_is_absolute(*file_path) {
file_path *file_path
} else { prefix + path::path_sep() + file_path }; } else { prefix + path::path_sep() + *file_path };
let p0 = let p0 =
new_parser_from_file(cx.sess, cx.cfg, full_path, SOURCE_FILE); new_parser_from_file(cx.sess, cx.cfg, full_path, SOURCE_FILE);
let inner_attrs = p0.parse_inner_attrs_and_next(); let inner_attrs = p0.parse_inner_attrs_and_next();
@ -112,9 +112,9 @@ fn eval_crate_directive(cx: ctx, cdir: @ast::crate_directive, prefix: str,
ast::cdir_dir_mod(id, cdirs, attrs) { ast::cdir_dir_mod(id, cdirs, attrs) {
let path = cdir_path_opt(id, attrs); let path = cdir_path_opt(id, attrs);
let full_path = let full_path =
if path::path_is_absolute(path) { if path::path_is_absolute(*path) {
path *path
} else { prefix + path::path_sep() + path }; } else { prefix + path::path_sep() + *path };
let (m0, a0) = eval_crate_directives_to_mod( let (m0, a0) = eval_crate_directives_to_mod(
cx, cdirs, full_path, none); cx, cdirs, full_path, none);
let i = let i =

View File

@ -151,8 +151,8 @@ class parser {
fn warn(m: str) { fn warn(m: str) {
self.sess.span_diagnostic.span_warn(copy self.span, m) self.sess.span_diagnostic.span_warn(copy self.span, m)
} }
fn get_str(i: token::str_num) -> str { fn get_str(i: token::str_num) -> @str {
*interner::get(*self.reader.interner, i) interner::get(*self.reader.interner, i)
} }
fn get_id() -> node_id { next_node_id(self.sess) } fn get_id() -> node_id { next_node_id(self.sess) }
@ -178,7 +178,7 @@ class parser {
let name = self.parse_value_ident(); let name = self.parse_value_ident();
p.bump(); p.bump();
name name
} else { "" }; } else { @"" };
{mode: mode, ty: p.parse_ty(false), ident: name, {mode: mode, ty: p.parse_ty(false), ident: name,
id: p.get_id()} id: p.get_id()}
@ -229,7 +229,7 @@ class parser {
fn ident_index(args: [arg], i: ident) -> uint { fn ident_index(args: [arg], i: ident) -> uint {
let mut j = 0u; let mut j = 0u;
for args.each {|a| if a.ident == i { ret j; } j += 1u; } for args.each {|a| if a.ident == i { ret j; } j += 1u; }
self.fatal("unbound variable `" + i + "` in constraint arg"); self.fatal("unbound variable `" + *i + "` in constraint arg");
} }
fn parse_type_constr_arg() -> @ty_constr_arg { fn parse_type_constr_arg() -> @ty_constr_arg {
@ -315,7 +315,7 @@ class parser {
} }
} }
fn region_from_name(s: option<str>) -> @region { fn region_from_name(s: option<@str>) -> @region {
let r = alt s { let r = alt s {
some (string) { re_named(string) } some (string) { re_named(string) }
none { re_anon } none { re_anon }
@ -1858,13 +1858,13 @@ class parser {
fn parse_method_name() -> ident { fn parse_method_name() -> ident {
alt copy self.token { alt copy self.token {
token::BINOP(op) { self.bump(); token::binop_to_str(op) } token::BINOP(op) { self.bump(); @token::binop_to_str(op) }
token::NOT { self.bump(); "!" } token::NOT { self.bump(); @"!" }
token::LBRACKET { self.bump(); self.expect(token::RBRACKET); "[]" } token::LBRACKET { self.bump(); self.expect(token::RBRACKET); @"[]" }
_ { _ {
let id = self.parse_value_ident(); let id = self.parse_value_ident();
if id == "unary" && self.eat(token::BINOP(token::MINUS)) { if id == @"unary" && self.eat(token::BINOP(token::MINUS)) {
"unary-" @"unary-"
} }
else { id } else { id }
} }
@ -1969,7 +1969,7 @@ class parser {
// Hack. But then, this whole function is in service of a hack. // Hack. But then, this whole function is in service of a hack.
let a_r = alt rp { let a_r = alt rp {
rp_none { none } rp_none { none }
rp_self { some(self.region_from_name(some("self"))) } rp_self { some(self.region_from_name(some(@"self"))) }
}; };
@{span: s, global: false, idents: [i], @{span: s, global: false, idents: [i],
@ -2243,7 +2243,7 @@ class parser {
let mut variants: [variant] = []; let mut variants: [variant] = [];
// Newtype syntax // Newtype syntax
if self.token == token::EQ { if self.token == token::EQ {
self.check_restricted_keywords_(id); self.check_restricted_keywords_(*id);
self.bump(); self.bump();
let ty = self.parse_ty(false); let ty = self.parse_ty(false);
self.expect(token::SEMI); self.expect(token::SEMI);
@ -2381,7 +2381,7 @@ class parser {
let lo = self.span.lo; let lo = self.span.lo;
let first_ident = self.parse_ident(); let first_ident = self.parse_ident();
let mut path = [first_ident]; let mut path = [first_ident];
#debug("parsed view_path: %s", first_ident); #debug("parsed view_path: %s", *first_ident);
alt self.token { alt self.token {
token::EQ { token::EQ {
// x = foo::bar // x = foo::bar
@ -2504,7 +2504,7 @@ class parser {
config: self.cfg}); config: self.cfg});
} }
fn parse_str() -> str { fn parse_str() -> @str {
alt copy self.token { alt copy self.token {
token::LIT_STR(s) { self.bump(); self.get_str(s) } token::LIT_STR(s) { self.bump(); self.get_str(s) }
_ { _ {

View File

@ -342,7 +342,7 @@ fn print_region(s: ps, region: @ast::region) {
ast::re_anon { word_space(s, "&"); } ast::re_anon { word_space(s, "&"); }
ast::re_named(name) { ast::re_named(name) {
word(s.s, "&"); word(s.s, "&");
word_space(s, name); word_space(s, *name);
} }
} }
} }
@ -382,7 +382,7 @@ fn print_type_ex(s: ps, &&ty: @ast::ty, print_colons: bool) {
fn print_field(s: ps, f: ast::ty_field) { fn print_field(s: ps, f: ast::ty_field) {
cbox(s, indent_unit); cbox(s, indent_unit);
print_mutability(s, f.node.mt.mutbl); print_mutability(s, f.node.mt.mutbl);
word(s.s, f.node.ident); word(s.s, *f.node.ident);
word_space(s, ":"); word_space(s, ":");
print_type(s, f.node.mt.ty); print_type(s, f.node.mt.ty);
end(s); end(s);
@ -443,7 +443,7 @@ fn print_item(s: ps, &&item: @ast::item) {
alt item.node { alt item.node {
ast::item_const(ty, expr) { ast::item_const(ty, expr) {
head(s, "const"); head(s, "const");
word_space(s, item.ident + ":"); word_space(s, *item.ident + ":");
print_type(s, ty); print_type(s, ty);
space(s.s); space(s.s);
end(s); // end the head-ibox end(s); // end the head-ibox
@ -461,7 +461,7 @@ fn print_item(s: ps, &&item: @ast::item) {
} }
ast::item_mod(_mod) { ast::item_mod(_mod) {
head(s, "mod"); head(s, "mod");
word_nbsp(s, item.ident); word_nbsp(s, *item.ident);
bopen(s); bopen(s);
print_mod(s, _mod, item.attrs); print_mod(s, _mod, item.attrs);
bclose(s, item.span); bclose(s, item.span);
@ -469,7 +469,7 @@ fn print_item(s: ps, &&item: @ast::item) {
ast::item_native_mod(nmod) { ast::item_native_mod(nmod) {
head(s, "native"); head(s, "native");
word_nbsp(s, "mod"); word_nbsp(s, "mod");
word_nbsp(s, item.ident); word_nbsp(s, *item.ident);
bopen(s); bopen(s);
print_native_mod(s, nmod, item.attrs); print_native_mod(s, nmod, item.attrs);
bclose(s, item.span); bclose(s, item.span);
@ -478,7 +478,7 @@ fn print_item(s: ps, &&item: @ast::item) {
ibox(s, indent_unit); ibox(s, indent_unit);
ibox(s, 0u); ibox(s, 0u);
word_nbsp(s, "type"); word_nbsp(s, "type");
word(s.s, item.ident); word(s.s, *item.ident);
print_region_param(s, rp); print_region_param(s, rp);
print_type_params(s, params); print_type_params(s, params);
end(s); // end the inner ibox end(s); // end the inner ibox
@ -492,13 +492,13 @@ fn print_item(s: ps, &&item: @ast::item) {
ast::item_enum(variants, params, rp) { ast::item_enum(variants, params, rp) {
let newtype = let newtype =
vec::len(variants) == 1u && vec::len(variants) == 1u &&
str::eq(item.ident, variants[0].node.name) && str::eq(*item.ident, *variants[0].node.name) &&
vec::len(variants[0].node.args) == 1u; vec::len(variants[0].node.args) == 1u;
if newtype { if newtype {
ibox(s, indent_unit); ibox(s, indent_unit);
word_space(s, "enum"); word_space(s, "enum");
} else { head(s, "enum"); } } else { head(s, "enum"); }
word(s.s, item.ident); word(s.s, *item.ident);
print_region_param(s, rp); print_region_param(s, rp);
print_type_params(s, params); print_type_params(s, params);
space(s.s); space(s.s);
@ -524,7 +524,7 @@ fn print_item(s: ps, &&item: @ast::item) {
} }
ast::item_class(tps, ifaces, items, ctor, m_dtor, rp) { ast::item_class(tps, ifaces, items, ctor, m_dtor, rp) {
head(s, "class"); head(s, "class");
word_nbsp(s, item.ident); word_nbsp(s, *item.ident);
print_region_param(s, rp); print_region_param(s, rp);
print_type_params(s, tps); print_type_params(s, tps);
word_space(s, "implements"); word_space(s, "implements");
@ -570,7 +570,7 @@ fn print_item(s: ps, &&item: @ast::item) {
ast::class_mutable { word_nbsp(s, "mut"); } ast::class_mutable { word_nbsp(s, "mut"); }
_ {} _ {}
} }
word(s.s, nm); word(s.s, *nm);
word_nbsp(s, ":"); word_nbsp(s, ":");
print_type(s, t); print_type(s, t);
word(s.s, ";"); word(s.s, ";");
@ -588,7 +588,7 @@ fn print_item(s: ps, &&item: @ast::item) {
} }
ast::item_impl(tps, rp, ifce, ty, methods) { ast::item_impl(tps, rp, ifce, ty, methods) {
head(s, "impl"); head(s, "impl");
word(s.s, item.ident); word(s.s, *item.ident);
print_region_param(s, rp); print_region_param(s, rp);
print_type_params(s, tps); print_type_params(s, tps);
space(s.s); space(s.s);
@ -608,7 +608,7 @@ fn print_item(s: ps, &&item: @ast::item) {
} }
ast::item_iface(tps, rp, methods) { ast::item_iface(tps, rp, methods) {
head(s, "iface"); head(s, "iface");
word(s.s, item.ident); word(s.s, *item.ident);
print_region_param(s, rp); print_region_param(s, rp);
print_type_params(s, tps); print_type_params(s, tps);
word(s.s, " "); word(s.s, " ");
@ -627,18 +627,18 @@ fn print_item(s: ps, &&item: @ast::item) {
fn print_res(s: ps, decl: ast::fn_decl, name: ast::ident, fn print_res(s: ps, decl: ast::fn_decl, name: ast::ident,
typarams: [ast::ty_param], rp: ast::region_param) { typarams: [ast::ty_param], rp: ast::region_param) {
head(s, "resource"); head(s, "resource");
word(s.s, name); word(s.s, *name);
print_region_param(s, rp); print_region_param(s, rp);
print_type_params(s, typarams); print_type_params(s, typarams);
popen(s); popen(s);
word_space(s, decl.inputs[0].ident + ":"); word_space(s, *decl.inputs[0].ident + ":");
print_type(s, decl.inputs[0].ty); print_type(s, decl.inputs[0].ty);
pclose(s); pclose(s);
space(s.s); space(s.s);
} }
fn print_variant(s: ps, v: ast::variant) { fn print_variant(s: ps, v: ast::variant) {
word(s.s, v.node.name); word(s.s, *v.node.name);
if vec::len(v.node.args) > 0u { if vec::len(v.node.args) > 0u {
popen(s); popen(s);
fn print_variant_arg(s: ps, arg: ast::variant_arg) { fn print_variant_arg(s: ps, arg: ast::variant_arg) {
@ -892,7 +892,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) {
fn print_field(s: ps, field: ast::field) { fn print_field(s: ps, field: ast::field) {
ibox(s, indent_unit); ibox(s, indent_unit);
if field.node.mutbl == ast::m_mutbl { word_nbsp(s, "mut"); } if field.node.mutbl == ast::m_mutbl { word_nbsp(s, "mut"); }
word(s.s, field.node.ident); word(s.s, *field.node.ident);
word_space(s, ":"); word_space(s, ":");
print_expr(s, field.node.expr); print_expr(s, field.node.expr);
end(s); end(s);
@ -1089,7 +1089,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) {
print_expr_parens_if_not_bot(s, expr); print_expr_parens_if_not_bot(s, expr);
} }
word(s.s, "."); word(s.s, ".");
word(s.s, id); word(s.s, *id);
if vec::len(tys) > 0u { if vec::len(tys) > 0u {
word(s.s, "::<"); word(s.s, "::<");
commasep(s, inconsistent, tys, print_type); commasep(s, inconsistent, tys, print_type);
@ -1222,7 +1222,7 @@ fn print_decl(s: ps, decl: @ast::decl) {
} }
} }
fn print_ident(s: ps, ident: ast::ident) { word(s.s, ident); } fn print_ident(s: ps, ident: ast::ident) { word(s.s, *ident); }
fn print_for_decl(s: ps, loc: @ast::local, coll: @ast::expr) { fn print_for_decl(s: ps, loc: @ast::local, coll: @ast::expr) {
print_local_decl(s, loc); print_local_decl(s, loc);
@ -1237,7 +1237,7 @@ fn print_path(s: ps, &&path: @ast::path, colons_before_params: bool) {
let mut first = true; let mut first = true;
for path.idents.each {|id| for path.idents.each {|id|
if first { first = false; } else { word(s.s, "::"); } if first { first = false; } else { word(s.s, "::"); }
word(s.s, id); word(s.s, *id);
} }
if path.rp.is_some() || !path.types.is_empty() { if path.rp.is_some() || !path.types.is_empty() {
if colons_before_params { word(s.s, "::"); } if colons_before_params { word(s.s, "::"); }
@ -1290,7 +1290,7 @@ fn print_pat(s: ps, &&pat: @ast::pat) {
word(s.s, "{"); word(s.s, "{");
fn print_field(s: ps, f: ast::field_pat) { fn print_field(s: ps, f: ast::field_pat) {
cbox(s, indent_unit); cbox(s, indent_unit);
word(s.s, f.ident); word(s.s, *f.ident);
word_space(s, ":"); word_space(s, ":");
print_pat(s, f.pat); print_pat(s, f.pat);
end(s); end(s);
@ -1327,7 +1327,7 @@ fn print_fn(s: ps, decl: ast::fn_decl, name: ast::ident,
ast::impure_fn { head(s, "fn") } ast::impure_fn { head(s, "fn") }
_ { head(s, purity_to_str(decl.purity) + " fn") } _ { head(s, purity_to_str(decl.purity) + " fn") }
} }
word(s.s, name); word(s.s, *name);
print_type_params(s, typarams); print_type_params(s, typarams);
print_fn_args_and_ret(s, decl, []); print_fn_args_and_ret(s, decl, []);
} }
@ -1341,7 +1341,7 @@ fn print_fn_args(s: ps, decl: ast::fn_decl,
if first { first = false; } else { word_space(s, ","); } if first { first = false; } else { word_space(s, ","); }
if cap_item.is_move { word_nbsp(s, "move") } if cap_item.is_move { word_nbsp(s, "move") }
else { word_nbsp(s, "copy") } else { word_nbsp(s, "copy") }
word(s.s, cap_item.name); word(s.s, *cap_item.name);
} }
} }
} }
@ -1418,7 +1418,7 @@ fn print_type_params(s: ps, &&params: [ast::ty_param]) {
if vec::len(params) > 0u { if vec::len(params) > 0u {
word(s.s, "<"); word(s.s, "<");
fn printParam(s: ps, param: ast::ty_param) { fn printParam(s: ps, param: ast::ty_param) {
word(s.s, param.ident); word(s.s, *param.ident);
print_bounds(s, param.bounds); print_bounds(s, param.bounds);
} }
commasep(s, inconsistent, params, printParam); commasep(s, inconsistent, params, printParam);
@ -1429,14 +1429,14 @@ fn print_type_params(s: ps, &&params: [ast::ty_param]) {
fn print_meta_item(s: ps, &&item: @ast::meta_item) { fn print_meta_item(s: ps, &&item: @ast::meta_item) {
ibox(s, indent_unit); ibox(s, indent_unit);
alt item.node { alt item.node {
ast::meta_word(name) { word(s.s, name); } ast::meta_word(name) { word(s.s, *name); }
ast::meta_name_value(name, value) { ast::meta_name_value(name, value) {
word_space(s, name); word_space(s, *name);
word_space(s, "="); word_space(s, "=");
print_literal(s, @value); print_literal(s, @value);
} }
ast::meta_list(name, items) { ast::meta_list(name, items) {
word(s.s, name); word(s.s, *name);
popen(s); popen(s);
commasep(s, consistent, items, print_meta_item); commasep(s, consistent, items, print_meta_item);
pclose(s); pclose(s);
@ -1449,7 +1449,7 @@ fn print_view_path(s: ps, &&vp: @ast::view_path) {
alt vp.node { alt vp.node {
ast::view_path_simple(ident, path, _) { ast::view_path_simple(ident, path, _) {
if path.idents[vec::len(path.idents)-1u] != ident { if path.idents[vec::len(path.idents)-1u] != ident {
word_space(s, ident); word_space(s, *ident);
word_space(s, "="); word_space(s, "=");
} }
print_path(s, path, false); print_path(s, path, false);
@ -1464,7 +1464,7 @@ fn print_view_path(s: ps, &&vp: @ast::view_path) {
print_path(s, path, false); print_path(s, path, false);
word(s.s, "::{"); word(s.s, "::{");
commasep(s, inconsistent, idents) {|s, w| commasep(s, inconsistent, idents) {|s, w|
word(s.s, w.node.name) word(s.s, *w.node.name)
} }
word(s.s, "}"); word(s.s, "}");
} }
@ -1481,7 +1481,7 @@ fn print_view_item(s: ps, item: @ast::view_item) {
alt item.node { alt item.node {
ast::view_item_use(id, mta, _) { ast::view_item_use(id, mta, _) {
head(s, "use"); head(s, "use");
word(s.s, id); word(s.s, *id);
if vec::len(mta) > 0u { if vec::len(mta) > 0u {
popen(s); popen(s);
commasep(s, consistent, mta, print_meta_item); commasep(s, consistent, mta, print_meta_item);
@ -1529,11 +1529,11 @@ fn print_arg(s: ps, input: ast::arg) {
print_arg_mode(s, input.mode); print_arg_mode(s, input.mode);
alt input.ty.node { alt input.ty.node {
ast::ty_infer { ast::ty_infer {
word(s.s, input.ident); word(s.s, *input.ident);
} }
_ { _ {
if str::len(input.ident) > 0u { if str::len(*input.ident) > 0u {
word_space(s, input.ident + ":"); word_space(s, *input.ident + ":");
} }
print_type(s, input.ty); print_type(s, input.ty);
} }
@ -1546,7 +1546,7 @@ fn print_ty_fn(s: ps, opt_proto: option<ast::proto>,
tps: option<[ast::ty_param]>) { tps: option<[ast::ty_param]>) {
ibox(s, indent_unit); ibox(s, indent_unit);
word(s.s, opt_proto_to_str(opt_proto)); word(s.s, opt_proto_to_str(opt_proto));
alt id { some(id) { word(s.s, " "); word(s.s, id); } _ { } } alt id { some(id) { word(s.s, " "); word(s.s, *id); } _ { } }
alt tps { some(tps) { print_type_params(s, tps); } _ { } } alt tps { some(tps) { print_type_params(s, tps); } _ { } }
zerobreak(s.s); zerobreak(s.s);
popen(s); popen(s);
@ -1608,7 +1608,7 @@ fn print_literal(s: ps, &&lit: @ast::lit) {
_ {} _ {}
} }
alt lit.node { alt lit.node {
ast::lit_str(st) { print_string(s, st); } ast::lit_str(st) { print_string(s, *st); }
ast::lit_int(ch, ast::ty_char) { ast::lit_int(ch, ast::ty_char) {
word(s.s, "'" + char::escape_default(ch as char) + "'"); word(s.s, "'" + char::escape_default(ch as char) + "'");
} }
@ -1640,7 +1640,7 @@ fn print_literal(s: ps, &&lit: @ast::lit) {
} }
} }
ast::lit_float(f, t) { ast::lit_float(f, t) {
word(s.s, f + ast_util::float_ty_to_str(t)); word(s.s, *f + ast_util::float_ty_to_str(t));
} }
ast::lit_nil { word(s.s, "()"); } ast::lit_nil { word(s.s, "()"); }
ast::lit_bool(val) { ast::lit_bool(val) {
@ -1804,7 +1804,7 @@ fn constrs_str<T>(constrs: [T], elt: fn(T) -> str) -> str {
} }
fn fn_arg_idx_to_str(decl: ast::fn_decl, &&idx: uint) -> str { fn fn_arg_idx_to_str(decl: ast::fn_decl, &&idx: uint) -> str {
decl.inputs[idx].ident *decl.inputs[idx].ident
} }
fn opt_proto_to_str(opt_p: option<ast::proto>) -> str { fn opt_proto_to_str(opt_p: option<ast::proto>) -> str {

View File

@ -29,8 +29,8 @@ fn name_of_fn(fk: fn_kind) -> ident {
alt fk { alt fk {
fk_item_fn(name, _) | fk_method(name, _, _) | fk_res(name, _, _) fk_item_fn(name, _) | fk_method(name, _, _) | fk_res(name, _, _)
| fk_ctor(name, _, _, _) { /* FIXME: bad */ copy name } | fk_ctor(name, _, _, _) { /* FIXME: bad */ copy name }
fk_anon(*) | fk_fn_block(*) { "anon" } fk_anon(*) | fk_fn_block(*) { @"anon" }
fk_dtor(*) { "drop" } fk_dtor(*) { @"drop" }
} }
} }

View File

@ -291,24 +291,24 @@ fn build_link_meta(sess: session, c: ast::crate, output: str,
sha: sha1) -> link_meta { sha: sha1) -> link_meta {
type provided_metas = type provided_metas =
{name: option<str>, {name: option<@str>,
vers: option<str>, vers: option<@str>,
cmh_items: [@ast::meta_item]}; cmh_items: [@ast::meta_item]};
fn provided_link_metas(sess: session, c: ast::crate) -> fn provided_link_metas(sess: session, c: ast::crate) ->
provided_metas { provided_metas {
let mut name: option<str> = none; let mut name: option<@str> = none;
let mut vers: option<str> = none; let mut vers: option<@str> = none;
let mut cmh_items: [@ast::meta_item] = []; let mut cmh_items: [@ast::meta_item] = [];
let linkage_metas = attr::find_linkage_metas(c.node.attrs); let linkage_metas = attr::find_linkage_metas(c.node.attrs);
attr::require_unique_names(sess.diagnostic(), linkage_metas); attr::require_unique_names(sess.diagnostic(), linkage_metas);
for linkage_metas.each {|meta| for linkage_metas.each {|meta|
if attr::get_meta_item_name(meta) == "name" { if *attr::get_meta_item_name(meta) == "name" {
alt attr::get_meta_item_value_str(meta) { alt attr::get_meta_item_value_str(meta) {
some(v) { name = some(v); } some(v) { name = some(v); }
none { cmh_items += [meta]; } none { cmh_items += [meta]; }
} }
} else if attr::get_meta_item_name(meta) == "vers" { } else if *attr::get_meta_item_name(meta) == "vers" {
alt attr::get_meta_item_value_str(meta) { alt attr::get_meta_item_value_str(meta) {
some(v) { vers = some(v); } some(v) { vers = some(v); }
none { cmh_items += [meta]; } none { cmh_items += [meta]; }
@ -321,7 +321,7 @@ fn build_link_meta(sess: session, c: ast::crate, output: str,
// This calculates CMH as defined above // This calculates CMH as defined above
fn crate_meta_extras_hash(sha: sha1, _crate: ast::crate, fn crate_meta_extras_hash(sha: sha1, _crate: ast::crate,
metas: provided_metas, metas: provided_metas,
dep_hashes: [str]) -> str { dep_hashes: [@str]) -> str {
fn len_and_str(s: str) -> str { fn len_and_str(s: str) -> str {
ret #fmt["%u_%s", str::len(s), s]; ret #fmt["%u_%s", str::len(s), s];
} }
@ -337,10 +337,10 @@ fn build_link_meta(sess: session, c: ast::crate, output: str,
let m = m_; let m = m_;
alt m.node { alt m.node {
ast::meta_name_value(key, value) { ast::meta_name_value(key, value) {
sha.input_str(len_and_str(key)); sha.input_str(len_and_str(*key));
sha.input_str(len_and_str_lit(value)); sha.input_str(len_and_str_lit(value));
} }
ast::meta_word(name) { sha.input_str(len_and_str(name)); } ast::meta_word(name) { sha.input_str(len_and_str(*name)); }
ast::meta_list(_, _) { ast::meta_list(_, _) {
// FIXME (#607): Implement this // FIXME (#607): Implement this
fail "unimplemented meta_item variant"; fail "unimplemented meta_item variant";
@ -349,7 +349,7 @@ fn build_link_meta(sess: session, c: ast::crate, output: str,
} }
for dep_hashes.each {|dh| for dep_hashes.each {|dh|
sha.input_str(len_and_str(dh)); sha.input_str(len_and_str(*dh));
} }
ret truncated_sha1_result(sha); ret truncated_sha1_result(sha);
@ -362,7 +362,7 @@ fn build_link_meta(sess: session, c: ast::crate, output: str,
} }
fn crate_meta_name(sess: session, _crate: ast::crate, fn crate_meta_name(sess: session, _crate: ast::crate,
output: str, metas: provided_metas) -> str { output: str, metas: provided_metas) -> @str {
ret alt metas.name { ret alt metas.name {
some(v) { v } some(v) { v }
none { none {
@ -378,19 +378,19 @@ fn build_link_meta(sess: session, c: ast::crate, output: str,
str::connect(os, ".") str::connect(os, ".")
}; };
warn_missing(sess, "name", name); warn_missing(sess, "name", name);
name @name
} }
}; };
} }
fn crate_meta_vers(sess: session, _crate: ast::crate, fn crate_meta_vers(sess: session, _crate: ast::crate,
metas: provided_metas) -> str { metas: provided_metas) -> @str {
ret alt metas.vers { ret alt metas.vers {
some(v) { v } some(v) { v }
none { none {
let vers = "0.0"; let vers = "0.0";
warn_missing(sess, "vers", vers); warn_missing(sess, "vers", vers);
vers @vers
} }
}; };
} }
@ -417,7 +417,7 @@ fn symbol_hash(tcx: ty::ctxt, sha: sha1, t: ty::t,
// to be independent of one another in the crate. // to be independent of one another in the crate.
sha.reset(); sha.reset();
sha.input_str(link_meta.name); sha.input_str(*link_meta.name);
sha.input_str("-"); sha.input_str("-");
sha.input_str(link_meta.extras_hash); sha.input_str(link_meta.extras_hash);
sha.input_str("-"); sha.input_str("-");
@ -482,7 +482,7 @@ fn mangle(ss: path) -> str {
for ss.each {|s| for ss.each {|s|
alt s { path_name(s) | path_mod(s) { alt s { path_name(s) | path_mod(s) {
let sani = sanitize(s); let sani = sanitize(*s);
n += #fmt["%u%s", str::len(sani), sani]; n += #fmt["%u%s", str::len(sani), sani];
} } } }
} }
@ -490,33 +490,34 @@ fn mangle(ss: path) -> str {
n n
} }
fn exported_name(path: path, hash: str, vers: str) -> str { fn exported_name(path: path, hash: @str, vers: @str) -> str {
ret mangle(path + [path_name(hash)] + [path_name(vers)]); ret mangle(path + [path_name(hash)] + [path_name(vers)]);
} }
fn mangle_exported_name(ccx: @crate_ctxt, path: path, t: ty::t) -> str { fn mangle_exported_name(ccx: @crate_ctxt, path: path, t: ty::t) -> str {
let hash = get_symbol_hash(ccx, t); let hash = get_symbol_hash(ccx, t);
ret exported_name(path, hash, ccx.link_meta.vers); ret exported_name(path, @hash, ccx.link_meta.vers);
} }
fn mangle_internal_name_by_type_only(ccx: @crate_ctxt, t: ty::t, name: str) -> fn mangle_internal_name_by_type_only(ccx: @crate_ctxt,
t: ty::t, name: @str) ->
str { str {
let s = util::ppaux::ty_to_short_str(ccx.tcx, t); let s = @util::ppaux::ty_to_short_str(ccx.tcx, t);
let hash = get_symbol_hash(ccx, t); let hash = get_symbol_hash(ccx, t);
ret mangle([path_name(name), path_name(s), path_name(hash)]); ret mangle([path_name(name), path_name(s), path_name(@hash)]);
} }
fn mangle_internal_name_by_path_and_seq(ccx: @crate_ctxt, path: path, fn mangle_internal_name_by_path_and_seq(ccx: @crate_ctxt, path: path,
flav: str) -> str { flav: @str) -> str {
ret mangle(path + [path_name(ccx.names(flav))]); ret mangle(path + [path_name(@ccx.names(*flav))]);
} }
fn mangle_internal_name_by_path(_ccx: @crate_ctxt, path: path) -> str { fn mangle_internal_name_by_path(_ccx: @crate_ctxt, path: path) -> str {
ret mangle(path); ret mangle(path);
} }
fn mangle_internal_name_by_seq(ccx: @crate_ctxt, flav: str) -> str { fn mangle_internal_name_by_seq(ccx: @crate_ctxt, flav: @str) -> str {
ret ccx.names(flav); ret ccx.names(*flav);
} }
// If the user wants an exe generated we need to invoke // If the user wants an exe generated we need to invoke
@ -552,8 +553,8 @@ fn link_binary(sess: session,
let output = if sess.building_library { let output = if sess.building_library {
let long_libname = let long_libname =
os::dll_filename(#fmt("%s-%s-%s", os::dll_filename(#fmt("%s-%s-%s",
lm.name, lm.extras_hash, lm.vers)); *lm.name, lm.extras_hash, *lm.vers));
#debug("link_meta.name: %s", lm.name); #debug("link_meta.name: %s", *lm.name);
#debug("long_libname: %s", long_libname); #debug("long_libname: %s", long_libname);
#debug("out_filename: %s", out_filename); #debug("out_filename: %s", out_filename);
#debug("dirname(out_filename): %s", path::dirname(out_filename)); #debug("dirname(out_filename): %s", path::dirname(out_filename));

View File

@ -49,14 +49,14 @@ fn default_configuration(sess: session, argv0: str, input: input) ->
}; };
ret [ // Target bindings. ret [ // Target bindings.
attr::mk_word_item(os::family()), attr::mk_word_item(@os::family()),
mk("target_os", os::sysname()), mk(@"target_os", os::sysname()),
mk("target_family", os::family()), mk(@"target_family", os::family()),
mk("target_arch", arch), mk(@"target_arch", arch),
mk("target_libc", libc), mk(@"target_libc", libc),
// Build bindings. // Build bindings.
mk("build_compiler", argv0), mk(@"build_compiler", argv0),
mk("build_input", source_name(input))]; mk(@"build_input", source_name(input))];
} }
fn build_configuration(sess: session, argv0: str, input: input) -> fn build_configuration(sess: session, argv0: str, input: input) ->
@ -70,7 +70,7 @@ fn build_configuration(sess: session, argv0: str, input: input) ->
{ {
if sess.opts.test && !attr::contains_name(user_cfg, "test") if sess.opts.test && !attr::contains_name(user_cfg, "test")
{ {
[attr::mk_word_item("test")] [attr::mk_word_item(@"test")]
} else { [] } } else { [] }
}; };
ret user_cfg + gen_cfg + default_cfg; ret user_cfg + gen_cfg + default_cfg;
@ -82,7 +82,7 @@ fn parse_cfgspecs(cfgspecs: [str]) -> ast::crate_cfg {
// meta_item here. At the moment we just support the meta_word variant. // meta_item here. At the moment we just support the meta_word variant.
// #2399 // #2399
let mut words = []; let mut words = [];
for cfgspecs.each {|s| words += [attr::mk_word_item(s)]; } for cfgspecs.each {|s| words += [attr::mk_word_item(@s)]; }
ret words; ret words;
} }

View File

@ -199,7 +199,7 @@ fn building_library(req_crate_type: crate_type, crate: @ast::crate,
alt syntax::attr::first_attr_value_str_by_name( alt syntax::attr::first_attr_value_str_by_name(
crate.node.attrs, crate.node.attrs,
"crate_type") { "crate_type") {
option::some("lib") { true } option::some(@"lib") { true }
_ { false } _ { false }
} }
} }
@ -227,9 +227,9 @@ mod test {
style: ast::attr_outer, style: ast::attr_outer,
value: ast_util::respan(ast_util::dummy_sp(), value: ast_util::respan(ast_util::dummy_sp(),
ast::meta_name_value( ast::meta_name_value(
"crate_type", @"crate_type",
ast_util::respan(ast_util::dummy_sp(), ast_util::respan(ast_util::dummy_sp(),
ast::lit_str(t)))) ast::lit_str(@t))))
}) })
} }

View File

@ -30,11 +30,11 @@ fn inject_libcore_ref(sess: session,
let n1 = sess.next_node_id(); let n1 = sess.next_node_id();
let n2 = sess.next_node_id(); let n2 = sess.next_node_id();
let vi1 = @{node: ast::view_item_use("core", [], n1), let vi1 = @{node: ast::view_item_use(@"core", [], n1),
attrs: [], attrs: [],
vis: ast::public, vis: ast::public,
span: dummy_sp()}; span: dummy_sp()};
let vp = spanned(ast::view_path_glob(ident_to_path(dummy_sp(), "core"), let vp = spanned(ast::view_path_glob(ident_to_path(dummy_sp(), @"core"),
n2)); n2));
let vi2 = @{node: ast::view_item_import([vp]), let vi2 = @{node: ast::view_item_import([vp]),
attrs: [], attrs: [],

View File

@ -70,7 +70,7 @@ fn fold_mod(_cx: test_ctxt, m: ast::_mod, fld: fold::ast_fold) -> ast::_mod {
fn nomain(&&item: @ast::item) -> option<@ast::item> { fn nomain(&&item: @ast::item) -> option<@ast::item> {
alt item.node { alt item.node {
ast::item_fn(_, _, _) { ast::item_fn(_, _, _) {
if item.ident == "main" { if *item.ident == "main" {
option::none option::none
} else { option::some(item) } } else { option::some(item) }
} }
@ -190,9 +190,9 @@ fn mk_test_module(cx: test_ctxt) -> @ast::item {
let item_ = ast::item_mod(testmod); let item_ = ast::item_mod(testmod);
// This attribute tells resolve to let us call unexported functions // This attribute tells resolve to let us call unexported functions
let resolve_unexported_attr = let resolve_unexported_attr =
attr::mk_attr(attr::mk_word_item("!resolve_unexported")); attr::mk_attr(attr::mk_word_item(@"!resolve_unexported"));
let item: ast::item = let item: ast::item =
{ident: "__test", {ident: @"__test",
attrs: [resolve_unexported_attr], attrs: [resolve_unexported_attr],
id: cx.sess.next_node_id(), id: cx.sess.next_node_id(),
node: item_, node: item_,
@ -231,7 +231,7 @@ fn mk_tests(cx: test_ctxt) -> @ast::item {
let item_ = ast::item_fn(decl, [], body); let item_ = ast::item_fn(decl, [], body);
let item: ast::item = let item: ast::item =
{ident: "tests", {ident: @"tests",
attrs: [], attrs: [],
id: cx.sess.next_node_id(), id: cx.sess.next_node_id(),
node: item_, node: item_,
@ -246,16 +246,16 @@ fn mk_path(cx: test_ctxt, path: [ast::ident]) -> [ast::ident] {
let is_std = { let is_std = {
let items = attr::find_linkage_metas(cx.crate.node.attrs); let items = attr::find_linkage_metas(cx.crate.node.attrs);
alt attr::last_meta_item_value_str_by_name(items, "name") { alt attr::last_meta_item_value_str_by_name(items, "name") {
some("std") { true } some(@"std") { true }
_ { false } _ { false }
} }
}; };
(if is_std { [] } else { ["std"] }) + path (if is_std { [] } else { [@"std"] }) + path
} }
// The ast::ty of [std::test::test_desc] // The ast::ty of [std::test::test_desc]
fn mk_test_desc_vec_ty(cx: test_ctxt) -> @ast::ty { fn mk_test_desc_vec_ty(cx: test_ctxt) -> @ast::ty {
let test_desc_ty_path = path_node(mk_path(cx, ["test", "test_desc"])); let test_desc_ty_path = path_node(mk_path(cx, [@"test", @"test_desc"]));
let test_desc_ty: ast::ty = let test_desc_ty: ast::ty =
{id: cx.sess.next_node_id(), {id: cx.sess.next_node_id(),
@ -288,14 +288,14 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr {
#debug("encoding %s", ast_util::path_name_i(path)); #debug("encoding %s", ast_util::path_name_i(path));
let name_lit: ast::lit = let name_lit: ast::lit =
nospan(ast::lit_str(ast_util::path_name_i(path))); nospan(ast::lit_str(@ast_util::path_name_i(path)));
let name_expr: ast::expr = let name_expr: ast::expr =
{id: cx.sess.next_node_id(), {id: cx.sess.next_node_id(),
node: ast::expr_lit(@name_lit), node: ast::expr_lit(@name_lit),
span: span}; span: span};
let name_field: ast::field = let name_field: ast::field =
nospan({mutbl: ast::m_imm, ident: "name", expr: @name_expr}); nospan({mutbl: ast::m_imm, ident: @"name", expr: @name_expr});
let fn_path = path_node(path); let fn_path = path_node(path);
@ -307,7 +307,7 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr {
let fn_wrapper_expr = mk_test_wrapper(cx, fn_expr, span); let fn_wrapper_expr = mk_test_wrapper(cx, fn_expr, span);
let fn_field: ast::field = let fn_field: ast::field =
nospan({mutbl: ast::m_imm, ident: "fn", expr: fn_wrapper_expr}); nospan({mutbl: ast::m_imm, ident: @"fn", expr: fn_wrapper_expr});
let ignore_lit: ast::lit = nospan(ast::lit_bool(test.ignore)); let ignore_lit: ast::lit = nospan(ast::lit_bool(test.ignore));
@ -317,7 +317,7 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr {
span: span}; span: span};
let ignore_field: ast::field = let ignore_field: ast::field =
nospan({mutbl: ast::m_imm, ident: "ignore", expr: @ignore_expr}); nospan({mutbl: ast::m_imm, ident: @"ignore", expr: @ignore_expr});
let fail_lit: ast::lit = nospan(ast::lit_bool(test.should_fail)); let fail_lit: ast::lit = nospan(ast::lit_bool(test.should_fail));
@ -327,7 +327,7 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr {
span: span}; span: span};
let fail_field: ast::field = let fail_field: ast::field =
nospan({mutbl: ast::m_imm, ident: "should_fail", expr: @fail_expr}); nospan({mutbl: ast::m_imm, ident: @"should_fail", expr: @fail_expr});
let desc_rec_: ast::expr_ = let desc_rec_: ast::expr_ =
ast::expr_rec([name_field, fn_field, ignore_field, fail_field], ast::expr_rec([name_field, fn_field, ignore_field, fail_field],
@ -379,7 +379,7 @@ fn mk_test_wrapper(cx: test_ctxt,
} }
fn mk_main(cx: test_ctxt) -> @ast::item { fn mk_main(cx: test_ctxt) -> @ast::item {
let str_pt = path_node(["str"]); let str_pt = path_node([@"str"]);
let str_ty = @{id: cx.sess.next_node_id(), let str_ty = @{id: cx.sess.next_node_id(),
node: ast::ty_path(str_pt, cx.sess.next_node_id()), node: ast::ty_path(str_pt, cx.sess.next_node_id()),
span: dummy_sp()}; span: dummy_sp()};
@ -391,7 +391,7 @@ fn mk_main(cx: test_ctxt) -> @ast::item {
let args_arg: ast::arg = let args_arg: ast::arg =
{mode: ast::expl(ast::by_val), {mode: ast::expl(ast::by_val),
ty: @args_ty, ty: @args_ty,
ident: "args", ident: @"args",
id: cx.sess.next_node_id()}; id: cx.sess.next_node_id()};
let ret_ty = {id: cx.sess.next_node_id(), let ret_ty = {id: cx.sess.next_node_id(),
@ -414,7 +414,7 @@ fn mk_main(cx: test_ctxt) -> @ast::item {
let item_ = ast::item_fn(decl, [], body); let item_ = ast::item_fn(decl, [], body);
let item: ast::item = let item: ast::item =
{ident: "main", {ident: @"main",
attrs: [], attrs: [],
id: cx.sess.next_node_id(), id: cx.sess.next_node_id(),
node: item_, node: item_,
@ -426,7 +426,7 @@ fn mk_main(cx: test_ctxt) -> @ast::item {
fn mk_test_main_call(cx: test_ctxt) -> @ast::expr { fn mk_test_main_call(cx: test_ctxt) -> @ast::expr {
// Get the args passed to main so we can pass the to test_main // Get the args passed to main so we can pass the to test_main
let args_path = path_node(["args"]); let args_path = path_node([@"args"]);
let args_path_expr_: ast::expr_ = ast::expr_path(args_path); let args_path_expr_: ast::expr_ = ast::expr_path(args_path);
@ -434,7 +434,7 @@ fn mk_test_main_call(cx: test_ctxt) -> @ast::expr {
{id: cx.sess.next_node_id(), node: args_path_expr_, span: dummy_sp()}; {id: cx.sess.next_node_id(), node: args_path_expr_, span: dummy_sp()};
// Call __test::test to generate the vector of test_descs // Call __test::test to generate the vector of test_descs
let test_path = path_node(["tests"]); let test_path = path_node([@"tests"]);
let test_path_expr_: ast::expr_ = ast::expr_path(test_path); let test_path_expr_: ast::expr_ = ast::expr_path(test_path);
@ -447,7 +447,7 @@ fn mk_test_main_call(cx: test_ctxt) -> @ast::expr {
{id: cx.sess.next_node_id(), node: test_call_expr_, span: dummy_sp()}; {id: cx.sess.next_node_id(), node: test_call_expr_, span: dummy_sp()};
// Call std::test::test_main // Call std::test::test_main
let test_main_path = path_node(mk_path(cx, ["test", "test_main"])); let test_main_path = path_node(mk_path(cx, [@"test", @"test_main"]));
let test_main_path_expr_: ast::expr_ = ast::expr_path(test_main_path); let test_main_path_expr_: ast::expr_ = ast::expr_path(test_main_path);

View File

@ -132,5 +132,5 @@ fn hash_path(&&s: str) -> uint {
ret h; 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 = { type cache_entry = {
cnum: int, cnum: int,
span: span, span: span,
hash: str, hash: @str,
metas: @[@ast::meta_item] metas: @[@ast::meta_item]
}; };
@ -53,7 +53,7 @@ fn dump_crates(crate_cache: dvec<cache_entry>) {
#debug("span: %?", entry.span); #debug("span: %?", entry.span);
#debug("hash: %?", entry.hash); #debug("hash: %?", entry.hash);
let attrs = [ 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| for attr::find_linkage_attrs(attrs).each {|attr|
#debug("meta: %s", pprust::attr_to_str(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 { if matches.len() != 1u {
diag.handler().warn( diag.handler().warn(
#fmt("using multiple versions of crate `%s`", name)); #fmt("using multiple versions of crate `%s`", *name));
for matches.each {|match| for matches.each {|match|
diag.span_note(match.span, "used here"); diag.span_note(match.span, "used here");
let attrs = [ 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); loader::note_linkage_attrs(diag, attrs);
} }
@ -129,7 +129,7 @@ fn visit_item(e: env, i: @ast::item) {
let native_name = let native_name =
alt attr::first_attr_value_str_by_name(i.attrs, "link_name") { alt attr::first_attr_value_str_by_name(i.attrs, "link_name") {
some(nn) { some(nn) {
if nn == "" { if *nn == "" {
e.diag.span_fatal( e.diag.span_fatal(
i.span, i.span,
"empty #[link_name] not allowed; use #[nolink]."); "empty #[link_name] not allowed; use #[nolink].");
@ -140,17 +140,17 @@ fn visit_item(e: env, i: @ast::item) {
}; };
let mut already_added = false; let mut already_added = false;
if vec::len(attr::find_attrs_by_name(i.attrs, "nolink")) == 0u { 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"); let link_args = attr::find_attrs_by_name(i.attrs, "link_args");
if vec::len(link_args) > 0u && already_added { 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."); "' already added: can't specify link_args.");
} }
for link_args.each {|a| for link_args.each {|a|
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, linkarg); cstore::add_used_link_args(cstore, *linkarg);
} }
none {/* fallthrough */ } 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] { 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() { if name_items.is_empty() {
metas + [attr::mk_name_value_item_str(key, ident)] metas + [attr::mk_name_value_item_str(key, *ident)]
} else { } else {
metas metas
} }
@ -172,7 +172,7 @@ fn metas_with(ident: ast::ident, key: str,
fn metas_with_ident(ident: ast::ident, fn metas_with_ident(ident: ast::ident,
metas: [@ast::meta_item]) -> [@ast::meta_item] { 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) -> 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| for e.crate_cache.each {|c|
if loader::metadata_matches(*c.metas, metas) if loader::metadata_matches(*c.metas, metas)
&& (hash.is_empty() || c.hash == hash) { && (hash.is_empty() || *c.hash == hash) {
ret some(c.cnum); 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::some(v) { v }
option::none { ident } option::none { ident }
}; };
let cmeta = @{name: cname, data: cdata, let cmeta = @{name: *cname, data: cdata,
cnum_map: cnum_map, cnum: cnum}; cnum_map: cnum_map, cnum: cnum};
let cstore = e.cstore; 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| for decoder::get_crate_deps(cdata).each {|dep|
let extrn_cnum = dep.cnum; let extrn_cnum = dep.cnum;
let cname = dep.name; 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", #debug("resolving dep crate %s ver: %s hash: %s",
dep.name, dep.vers, dep.hash); *dep.name, *dep.vers, *dep.hash);
alt existing_match(e, metas_with_ident(cname, cmetas), dep.hash) { alt existing_match(e, metas_with_ident(cname, cmetas), *dep.hash) {
some(local_cnum) { some(local_cnum) {
#debug("already have it"); #debug("already have it");
// We've already seen this crate // We've already seen this crate
@ -265,7 +265,7 @@ fn resolve_crate_deps(e: env, cdata: @[u8]) -> cstore::cnum_map {
// #2404 // #2404
let fake_span = ast_util::dummy_sp(); let fake_span = ast_util::dummy_sp();
let local_cnum = 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); 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)] { [(ast::crate_num, @[u8], ast::def_id)] {
let cm = cstore::get_crate_data(cstore, cnum); let cm = cstore::get_crate_data(cstore, cnum);
#debug("resolve_path %s in crates[%d]:%s", #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 = []; let mut result = [];
for decoder::resolve_path(path, cm.data).each {|def| for decoder::resolve_path(path, cm.data).each {|def|
if def.crate == ast::local_crate { 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 // FIXME #1920: This path is not always correct if the crate is not linked
// into the root namespace. // into the root namespace.
[ast_map::path_mod(cdata.name)] + path [ast_map::path_mod(@cdata.name)] + path
} }
enum found_ast { 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) 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 { -> ast::def_id {
let cdata = cstore::get_crate_data(cstore, def.crate); let cdata = cstore::get_crate_data(cstore, def.crate);
decoder::get_impl_method(cdata, def.node, mname) 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 for their methods (so that get_iface_methods can be reused to get
class methods), classes require a slightly different version of class methods), classes require a slightly different version of
get_impl_method. Sigh. */ 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 { -> ast::def_id {
let cdata = cstore::get_crate_data(cstore, def.crate); let cdata = cstore::get_crate_data(cstore, def.crate);
decoder::get_class_method(cdata, def.node, mname) 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 // 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 // renamed imports or reexports. This map keeps the "real" module path
// and def_id. // 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, type crate_metadata = @{name: str,
data: @[u8], data: @[u8],
@ -83,12 +83,12 @@ fn get_crate_data(cstore: cstore, cnum: ast::crate_num) -> crate_metadata {
ret p(cstore).metas.get(cnum); 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); let cdata = get_crate_data(cstore, cnum);
ret decoder::get_crate_hash(cdata.data); 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); let cdata = get_crate_data(cstore, cnum);
ret decoder::get_crate_vers(cdata.data); 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| vec::iter(decoder::get_crate_module_paths(data.data)) {|dp|
let (did, path) = dp; let (did, path) = dp;
let d = {crate: cnum, node: did.node}; 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 // returns hashes of crates directly used by this crate. Hashes are
// sorted by crate name. // sorted by crate name.
fn get_dep_hashes(cstore: cstore) -> [str] { fn get_dep_hashes(cstore: cstore) -> [@str] {
type crate_hash = {name: str, hash: str}; type crate_hash = {name: @str, hash: @str};
let mut result = []; let mut result = [];
for p(cstore).use_crate_map.each_value {|cnum| for p(cstore).use_crate_map.each_value {|cnum|
let cdata = cstore::get_crate_data(cstore, cnum); let cdata = cstore::get_crate_data(cstore, cnum);
let hash = decoder::get_crate_hash(cdata.data); let hash = decoder::get_crate_hash(cdata.data);
#debug("Add hash[%s]: %s", cdata.name, hash); #debug("Add hash[%s]: %s", cdata.name, *hash);
result += [{name: cdata.name, hash: hash}]; result += [{name: @cdata.name, hash: hash}];
}; };
fn lteq(a: crate_hash, b: crate_hash) -> bool { 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); let sorted = std::sort::merge_sort(lteq, result);
#debug("sorted:"); #debug("sorted:");
for sorted.each {|x| 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); 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(_, "::"); // let f = bind str::split_str(_, "::");
option::map_default(p(cstore).mod_path_map.find(d), [], 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: // Local Variables:
// mode: rust // 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 { fn eq_item(data: [u8], s: str) -> bool {
ret str::eq(str::from_bytes(data), s); 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 md = ebml::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);
@ -235,10 +235,10 @@ fn item_path(item_doc: ebml::doc) -> ast_map::path {
ebml::docs(path_doc) {|tag, elt_doc| ebml::docs(path_doc) {|tag, elt_doc|
if tag == tag_path_elt_mod { if tag == tag_path_elt_mod {
let str = ebml::doc_as_str(elt_doc); 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 { } else if tag == tag_path_elt_name {
let str = ebml::doc_as_str(elt_doc); let str = ebml::doc_as_str(elt_doc);
result += [ast_map::path_name(str)]; result += [ast_map::path_name(@str)];
} else { } else {
// ignore tag_path_len element // 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 { fn item_name(item: ebml::doc) -> ast::ident {
let name = ebml::get_doc(item, tag_paths_data_name); 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 { 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) 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 items = ebml::get_doc(ebml::doc(cdata.data), tag_items);
let mut found = none; let mut found = none;
ebml::tagged_docs(find_item(id, items), tag_item_impl_method) {|mid| 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) 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 items = ebml::get_doc(ebml::doc(cdata.data), tag_items);
let mut found = none; let mut found = none;
let cls_items = alt maybe_find_item(id, items) { let cls_items = alt maybe_find_item(id, items) {
some(it) { it } some(it) { it }
none { fail (#fmt("get_class_method: class id not found \ 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| ebml::tagged_docs(cls_items, tag_item_iface_method) {|mid|
let m_did = class_member_id(mid, cdata); let m_did = class_member_id(mid, cdata);
if item_name(mid) == name { 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 { alt found {
some(found) { 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| ebml::tagged_docs(md, tag_meta_item_word) {|meta_item_doc|
let nd = ebml::get_doc(meta_item_doc, tag_meta_item_name); let nd = ebml::get_doc(meta_item_doc, tag_meta_item_name);
let n = str::from_bytes(ebml::doc_data(nd)); 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| ebml::tagged_docs(md, tag_meta_item_name_value) {|meta_item_doc|
let nd = ebml::get_doc(meta_item_doc, tag_meta_item_name); 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)); let v = str::from_bytes(ebml::doc_data(vd));
// FIXME (#623): Should be able to decode meta_name_value variants, // FIXME (#623): Should be able to decode meta_name_value variants,
// but currently the encoder just drops them // 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| ebml::tagged_docs(md, tag_meta_item_list) {|meta_item_doc|
let nd = ebml::get_doc(meta_item_doc, tag_meta_item_name); let nd = ebml::get_doc(meta_item_doc, tag_meta_item_name);
let n = str::from_bytes(ebml::doc_data(nd)); let n = str::from_bytes(ebml::doc_data(nd));
let subitems = get_meta_items(meta_item_doc); let subitems = get_meta_items(meta_item_doc);
items += [attr::mk_list_item(n, subitems)]; items += [attr::mk_list_item(@n, subitems)];
}; };
ret items; 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) { fn list_crate_attributes(md: ebml::doc, hash: @str, out: io::writer) {
out.write_str(#fmt("=Crate Attributes (%s)=\n", hash)); out.write_str(#fmt("=Crate Attributes (%s)=\n", *hash));
for get_attributes(md).each {|attr| for get_attributes(md).each {|attr|
out.write_str(#fmt["%s\n", pprust::attribute_to_str(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, 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] { fn get_crate_deps(data: @[u8]) -> [crate_dep] {
let mut deps: [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| ebml::tagged_docs(depsdoc, tag_crate_dep) {|depdoc|
deps += [{cnum: crate_num, deps += [{cnum: crate_num,
name: docstr(depdoc, tag_crate_dep_name), name: @docstr(depdoc, tag_crate_dep_name),
vers: docstr(depdoc, tag_crate_dep_vers), vers: @docstr(depdoc, tag_crate_dep_vers),
hash: docstr(depdoc, tag_crate_dep_hash)}]; hash: @docstr(depdoc, tag_crate_dep_hash)}];
crate_num += 1; crate_num += 1;
}; };
ret deps; ret deps;
@ -660,24 +662,24 @@ fn list_crate_deps(data: @[u8], out: io::writer) {
for get_crate_deps(data).each {|dep| for get_crate_deps(data).each {|dep|
out.write_str(#fmt["%d %s-%s-%s\n", 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"); out.write_str("\n");
} }
fn get_crate_hash(data: @[u8]) -> str { fn get_crate_hash(data: @[u8]) -> @str {
let cratedoc = ebml::doc(data); let cratedoc = ebml::doc(data);
let hashdoc = ebml::get_doc(cratedoc, tag_crate_hash); 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); let attrs = decoder::get_crate_attributes(data);
ret alt attr::last_meta_item_value_str_by_name( ret alt attr::last_meta_item_value_str_by_name(
attr::find_linkage_metas(attrs), "vers") { attr::find_linkage_metas(attrs), "vers") {
some(ver) { ver } 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 // Path table encoding
fn encode_name(ebml_w: ebml::writer, name: str) { fn encode_name(ebml_w: ebml::writer, name: ident) {
ebml_w.wr_tagged_str(tag_paths_data_name, name); ebml_w.wr_tagged_str(tag_paths_data_name, *name);
} }
fn encode_def_id(ebml_w: ebml::writer, id: def_id) { 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) {|| ebml_w.wr_tag(tag_paths_data_item) {||
encode_name(ebml_w, name); encode_name(ebml_w, name);
encode_def_id(ebml_w, id); 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}; type entry<T> = {val: T, pos: uint};
fn encode_enum_variant_paths(ebml_w: ebml::writer, variants: [variant], 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| for variants.each {|variant|
add_to_index(ebml_w, path, index, variant.node.name); add_to_index(ebml_w, path, index, variant.node.name);
ebml_w.wr_tag(tag_paths_data_item) {|| 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>], fn add_to_index(ebml_w: ebml::writer, path: [ident], &index: [entry<str>],
name: str) { name: ident) {
let full_path = path + [name]; let full_path = path + [name];
index += 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, 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| for nmod.items.each {|nitem|
add_to_index(ebml_w, path, index, nitem.ident); add_to_index(ebml_w, path, index, nitem.ident);
encode_named_def_id(ebml_w, nitem.ident, local_def(nitem.id)); 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, 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| for items.each {|it|
alt ast_util::class_member_visibility(it) { alt ast_util::class_member_visibility(it) {
private { cont; } 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, 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| for module.items.each {|it|
if !reachable(ecx, it.id) || if !reachable(ecx, it.id) ||
!ast_util::is_exported(it.ident, module) { cont; } !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) fn encode_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt, crate: @crate)
-> [entry<str>] { -> [entry<str>] {
let mut index: [entry<str>] = []; let mut index: [entry<str>] = [];
let mut path: [str] = []; let mut path: [ident] = [];
ebml_w.start_tag(tag_paths); ebml_w.start_tag(tag_paths);
encode_module_item_paths(ebml_w, ecx, crate.node.module, path, index); encode_module_item_paths(ebml_w, ecx, crate.node.module, path, index);
encode_reexport_paths(ebml_w, ecx, 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; let (path, def_id) = reexport;
index += [{val: path, pos: ebml_w.writer.tell()}]; index += [{val: path, pos: ebml_w.writer.tell()}];
ebml_w.start_tag(tag_paths_data_item); 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); encode_def_id(ebml_w, def_id);
ebml_w.end_tag(); 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) } 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) {|| 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) { instance_var(nm, _, mt, id, vis) {
*index += [{val: id, pos: ebml_w.writer.tell()}]; *index += [{val: id, pos: ebml_w.writer.tell()}];
ebml_w.start_tag(tag_items_data_item); 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_visibility(ebml_w, vis);
encode_name(ebml_w, nm); encode_name(ebml_w, nm);
encode_path(ebml_w, path, ast_map::path_name(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 */ but it works for now -- tjc */
*global_index += [{val: m.id, pos: ebml_w.writer.tell()}]; *global_index += [{val: m.id, pos: ebml_w.writer.tell()}];
let impl_path = path + [ast_map::path_name(m.ident)]; 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, encode_info_for_method(ecx, ebml_w, impl_path,
should_inline(m.attrs), id, m, should_inline(m.attrs), id, m,
class_tps + m.tps); 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_family(ebml_w, purity_fn_family(decl.purity));
encode_type_param_bounds(ebml_w, ecx, tps); encode_type_param_bounds(ebml_w, ecx, tps);
let its_ty = node_id_to_type(ecx.tcx, id); 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); util::ppaux::ty_to_str(ecx.tcx, its_ty), id);
encode_type(ecx, ebml_w, its_ty); encode_type(ecx, ebml_w, its_ty);
encode_path(ebml_w, path, ast_map::path_name(ident)); 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, impl_path: ast_map::path, should_inline: bool,
parent_id: node_id, parent_id: node_id,
m: @method, all_tps: [ty_param]) { 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); ebml_w.start_tag(tag_items_data_item);
encode_def_id(ebml_w, local_def(m.id)); encode_def_id(ebml_w, local_def(m.id));
encode_family(ebml_w, purity_fn_family(m.decl.purity)); 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 */ /* Encode the dtor */
option::iter(m_dtor) {|dtor| option::iter(m_dtor) {|dtor|
*index += [{val: dtor.node.id, pos: ebml_w.writer.tell()}]; *index += [{val: dtor.node.id, pos: ebml_w.writer.tell()}];
encode_info_for_fn(ecx, ebml_w, dtor.node.id, item.ident encode_info_for_fn(ecx, ebml_w, dtor.node.id, @(*item.ident
+ "_dtor", path, if tps.len() > 0u { + "_dtor"), path, if tps.len() > 0u {
some(ii_dtor(dtor, item.ident, tps, some(ii_dtor(dtor, item.ident, tps,
local_def(item.id))) } local_def(item.id))) }
else { none }, tps, ast_util::dtor_dec()); 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); ebml_w.start_tag(tag_items_data);
*index += [{val: crate_node_id, pos: ebml_w.writer.tell()}]; *index += [{val: crate_node_id, pos: ebml_w.writer.tell()}];
encode_info_for_mod(ecx, ebml_w, crate.node.module, encode_info_for_mod(ecx, ebml_w, crate.node.module,
crate_node_id, [], ""); crate_node_id, [], @"");
visit::visit_crate(*crate, (), visit::mk_vt(@{ visit::visit_crate(*crate, (), visit::mk_vt(@{
visit_expr: {|_e, _cx, _v|}, visit_expr: {|_e, _cx, _v|},
visit_item: {|i, cx, v, copy ebml_w| 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 */ /* encode ctor, then encode items */
alt i.node { alt i.node {
item_class(tps, _, _, ctor, m_dtor, _) { 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); ctor.node.id);
*index += [{val: ctor.node.id, pos: ebml_w.writer.tell()}]; *index += [{val: ctor.node.id, pos: ebml_w.writer.tell()}];
encode_info_for_fn(ecx, ebml_w, ctor.node.id, i.ident, 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) { meta_word(name) {
ebml_w.start_tag(tag_meta_item_word); ebml_w.start_tag(tag_meta_item_word);
ebml_w.start_tag(tag_meta_item_name); 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();
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) { lit_str(value) {
ebml_w.start_tag(tag_meta_item_name_value); ebml_w.start_tag(tag_meta_item_name_value);
ebml_w.start_tag(tag_meta_item_name); 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();
ebml_w.start_tag(tag_meta_item_value); 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();
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) { meta_list(name, items) {
ebml_w.start_tag(tag_meta_item_list); ebml_w.start_tag(tag_meta_item_list);
ebml_w.start_tag(tag_meta_item_name); 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();
for items.each {|inner_item| for items.each {|inner_item|
encode_meta_item(ebml_w, *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]) -> fn synthesize_link_attr(ecx: @encode_ctxt, items: [@meta_item]) ->
attribute { attribute {
assert (ecx.link_meta.name != ""); assert (*ecx.link_meta.name != "");
assert (ecx.link_meta.vers != ""); assert (*ecx.link_meta.vers != "");
let name_item = 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 = 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 other_items =
{ {
let tmp = attr::remove_meta_items_by_name(items, "name"); let tmp = attr::remove_meta_items_by_name(items, @"name");
attr::remove_meta_items_by_name(tmp, "vers") attr::remove_meta_items_by_name(tmp, @"vers")
}; };
let meta_items = [name_item, vers_item] + other_items; 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); 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; let mut found_link_attr = false;
for crate.node.attrs.each {|attr| for crate.node.attrs.each {|attr|
attrs += attrs +=
if attr::get_attr_name(attr) != "link" { if *attr::get_attr_name(attr) != "link" {
[attr] [attr]
} else { } else {
alt attr.node.value.node { 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 // Pull the cnums and name,vers,hash out of cstore
let mut deps: [mut numdep] = [mut]; let mut deps: [mut numdep] = [mut];
cstore::iter_crate_data(cstore) {|key, val| 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), vers: decoder::get_crate_vers(val.data),
hash: decoder::get_crate_hash(val.data)}; hash: decoder::get_crate_hash(val.data)};
deps += [mut dep]; 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) { 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);
ebml_w.start_tag(tag_crate_dep_name); 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.end_tag();
ebml_w.start_tag(tag_crate_dep_vers); 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.end_tag();
ebml_w.start_tag(tag_crate_dep_hash); 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();
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; } some(t) { ret t; }
none { none {
cx.diag.span_fatal( 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) -> filesearch: filesearch::filesearch) ->
option<{ident: str, data: @[u8]}> { option<{ident: str, data: @[u8]}> {
let crate_name = crate_name_from_metas(cx.metas); 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 suffix: str = nn.suffix;
let mut matches = []; let mut matches = [];
@ -107,7 +107,7 @@ fn find_library_crate_aux(cx: ctxt,
some(matches[0]) some(matches[0])
} else { } else {
cx.diag.span_err( 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:"); cx.diag.handler().note("candidates:");
for matches.each {|match| for matches.each {|match|
cx.diag.handler().note(#fmt("path: %s", match.ident)); 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"); let name_items = attr::find_meta_items_by_name(metas, "name");
alt vec::last_opt(name_items) { alt vec::last_opt(name_items) {
some(i) { 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); let linkage_metas = attr::find_linkage_metas(attrs);
if hash.is_not_empty() { if hash.is_not_empty() {
let chash = decoder::get_crate_hash(crate_data); let chash = decoder::get_crate_hash(crate_data);
if chash != hash { ret false; } if *chash != hash { ret false; }
} }
metadata_matches(linkage_metas, metas) 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)) { while !is_last(peek(st)) {
rslt += str::from_byte(next_byte(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) { alt check next(st) {
's' { ty::br_self } 's' { ty::br_self }
'a' { ty::br_anon } '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) == '['); assert (next(st) == '[');
let mut fields: [ty::field] = []; let mut fields: [ty::field] = [];
while peek(st) != ']' { while peek(st) != ']' {
let name = parse_str(st, '='); let name = @parse_str(st, '=');
fields += [{ident: name, mt: parse_mt(st, conv)}]; fields += [{ident: name, mt: parse_mt(st, conv)}];
} }
st.pos = st.pos + 1u; 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_anon { w.write_char('a') }
ty::br_named(s) { ty::br_named(s) {
w.write_char('['); w.write_char('[');
w.write_str(s); w.write_str(*s);
w.write_char(']') w.write_char(']')
} }
} }
@ -256,7 +256,7 @@ fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) {
ty::ty_rec(fields) { ty::ty_rec(fields) {
w.write_str("R["/&); w.write_str("R["/&);
for fields.each {|field| for fields.each {|field|
w.write_str(field.ident); w.write_str(*field.ident);
w.write_char('='); w.write_char('=');
enc_mt(w, cx, field.mt); enc_mt(w, cx, field.mt);
} }

View File

@ -83,7 +83,7 @@ fn encode_inlined_item(ecx: @e::encode_ctxt,
ii: ast::inlined_item, ii: ast::inlined_item,
maps: maps) { maps: maps) {
#debug["> Encoding inlined item: %s::%s (%u)", #debug["> Encoding inlined item: %s::%s (%u)",
ast_map::path_to_str(path), ii.ident(), ast_map::path_to_str(path), *ii.ident(),
ebml_w.writer.tell()]; ebml_w.writer.tell()];
let id_range = compute_id_range(ii); let id_range = compute_id_range(ii);
@ -94,7 +94,7 @@ fn encode_inlined_item(ecx: @e::encode_ctxt,
} }
#debug["< Encoded inlined fn: %s::%s (%u)", #debug["< Encoded inlined fn: %s::%s (%u)",
ast_map::path_to_str(path), ii.ident(), ast_map::path_to_str(path), *ii.ident(),
ebml_w.writer.tell()]; ebml_w.writer.tell()];
} }
@ -117,10 +117,10 @@ fn decode_inlined_item(cdata: cstore::crate_metadata,
let ii = renumber_ast(xcx, raw_ii); let ii = renumber_ast(xcx, raw_ii);
ast_map::map_decoded_item(tcx.sess.diagnostic(), ast_map::map_decoded_item(tcx.sess.diagnostic(),
dcx.tcx.items, path, ii); dcx.tcx.items, path, ii);
#debug["Fn named: %s", ii.ident()]; #debug["Fn named: %s", *ii.ident()];
decode_side_tables(xcx, ast_doc); decode_side_tables(xcx, ast_doc);
#debug["< Decoded inlined fn: %s::%s", #debug["< Decoded inlined fn: %s::%s",
ast_map::path_to_str(path), ii.ident()]; ast_map::path_to_str(path), *ii.ident()];
alt ii { alt ii {
ast::ii_item(i) { ast::ii_item(i) {
#debug(">>> DECODED ITEM >>>\n%s\n<<< DECODED ITEM <<<", #debug(">>> DECODED ITEM >>>\n%s\n<<< DECODED ITEM <<<",

View File

@ -241,7 +241,7 @@ enum comp_kind {
comp_tuple, // elt in a tuple comp_tuple, // elt in a tuple
comp_res, // data for a resource comp_res, // data for a resource
comp_variant(ast::def_id), // internals to a variant of given enum comp_variant(ast::def_id), // internals to a variant of given enum
comp_field(str, // name of field comp_field(ast::ident, // name of field
ast::mutability), // declared mutability of field ast::mutability), // declared mutability of field
comp_index(ty::t, // type of vec/str/etc being deref'd comp_index(ty::t, // type of vec/str/etc being deref'd
ast::mutability) // mutability of vec content ast::mutability) // mutability of vec content
@ -409,7 +409,7 @@ impl to_str_methods for borrowck_ctxt {
fn comp_to_repr(comp: comp_kind) -> str { fn comp_to_repr(comp: comp_kind) -> str {
alt comp { alt comp {
comp_field(fld, _) { fld } comp_field(fld, _) { *fld }
comp_index(*) { "[]" } comp_index(*) { "[]" }
comp_tuple { "()" } comp_tuple { "()" }
comp_res { "<res>" } comp_res { "<res>" }

View File

@ -295,14 +295,15 @@ impl public_methods for borrowck_ctxt {
ret @{cat:cat_discr(cmt, alt_id) with *cmt}; ret @{cat:cat_discr(cmt, alt_id) with *cmt};
} }
fn cat_field<N:ast_node>(node: N, base_cmt: cmt, f_name: str) -> cmt { fn cat_field<N:ast_node>(node: N, base_cmt: cmt,
f_name: ast::ident) -> cmt {
let f_mutbl = alt field_mutbl(self.tcx, base_cmt.ty, f_name) { let f_mutbl = alt field_mutbl(self.tcx, base_cmt.ty, f_name) {
some(f_mutbl) { f_mutbl } some(f_mutbl) { f_mutbl }
none { none {
self.tcx.sess.span_bug( self.tcx.sess.span_bug(
node.span(), node.span(),
#fmt["Cannot find field `%s` in type `%s`", #fmt["Cannot find field `%s` in type `%s`",
f_name, ty_to_str(self.tcx, base_cmt.ty)]); *f_name, ty_to_str(self.tcx, base_cmt.ty)]);
} }
}; };
let m = alt f_mutbl { let m = alt f_mutbl {
@ -427,7 +428,7 @@ impl private_methods for borrowck_ctxt {
fn field_mutbl(tcx: ty::ctxt, fn field_mutbl(tcx: ty::ctxt,
base_ty: ty::t, base_ty: ty::t,
f_name: str) -> option<ast::mutability> { f_name: ast::ident) -> option<ast::mutability> {
// Need to refactor so that records/class fields can be treated uniformly. // Need to refactor so that records/class fields can be treated uniformly.
alt ty::get(base_ty).struct { alt ty::get(base_ty).struct {
ty::ty_rec(fields) { ty::ty_rec(fields) {

View File

@ -44,7 +44,7 @@ fn check_capture_clause(tcx: ty::ctxt,
tcx.sess.span_warn( tcx.sess.span_warn(
cap_item.span, cap_item.span,
#fmt("captured variable '%s' not used in closure", #fmt("captured variable '%s' not used in closure",
cap_item.name)); *cap_item.name));
} }
let cap_def_id = ast_util::def_id_of_def(cap_def).node; let cap_def_id = ast_util::def_id_of_def(cap_def).node;
@ -52,7 +52,7 @@ fn check_capture_clause(tcx: ty::ctxt,
tcx.sess.span_err( tcx.sess.span_err(
cap_item.span, cap_item.span,
#fmt("variable '%s' captured more than once", #fmt("variable '%s' captured more than once",
cap_item.name)); *cap_item.name));
} }
} }
} }
@ -68,7 +68,7 @@ fn compute_capture_vars(tcx: ty::ctxt,
for (*cap_clause).each { |cap_item| for (*cap_clause).each { |cap_item|
#debug("Doing capture var: %s (%?)", #debug("Doing capture var: %s (%?)",
cap_item.name, cap_item.id); *cap_item.name, cap_item.id);
let cap_def = tcx.def_map.get(cap_item.id); let cap_def = tcx.def_map.get(cap_item.id);
let cap_def_id = ast_util::def_id_of_def(cap_def).node; let cap_def_id = ast_util::def_id_of_def(cap_def).node;

View File

@ -67,8 +67,8 @@ fn check_exhaustive(tcx: ty::ctxt, sp: span, pats: [@pat]) {
alt ty::get(ty).struct { alt ty::get(ty).struct {
ty::ty_bool { ty::ty_bool {
alt check ctor { alt check ctor {
val(const_int(1i64)) { some("true") } val(const_int(1i64)) { some(@"true") }
val(const_int(0i64)) { some("false") } val(const_int(0i64)) { some(@"false") }
} }
} }
ty::ty_enum(id, _) { ty::ty_enum(id, _) {
@ -83,7 +83,7 @@ fn check_exhaustive(tcx: ty::ctxt, sp: span, pats: [@pat]) {
} }
}; };
let msg = "non-exhaustive patterns" + alt ext { let msg = "non-exhaustive patterns" + alt ext {
some(s) { ": " + s + " not covered" } some(s) { ": " + *s + " not covered" }
none { "" } none { "" }
}; };
tcx.sess.span_err(sp, msg); tcx.sess.span_err(sp, msg);

View File

@ -108,11 +108,11 @@ fn eval_const_expr(tcx: middle::ty::ctxt, e: @expr) -> const_val {
fn lit_to_const(lit: @lit) -> const_val { fn lit_to_const(lit: @lit) -> const_val {
alt lit.node { alt lit.node {
lit_str(s) { const_str(s) } lit_str(s) { const_str(*s) }
lit_int(n, _) { const_int(n) } lit_int(n, _) { const_int(n) }
lit_uint(n, _) { const_uint(n) } lit_uint(n, _) { const_uint(n) }
lit_int_unsuffixed(n, _) { const_int(n) } lit_int_unsuffixed(n, _) { const_int(n) }
lit_float(n, _) { const_float(option::get(float::from_str(n)) as f64) } lit_float(n, _) { const_float(option::get(float::from_str(*n)) as f64) }
lit_nil { const_int(0i64) } lit_nil { const_int(0i64) }
lit_bool(b) { const_int(b as i64) } lit_bool(b) { const_int(b as i64) }
} }

View File

@ -210,7 +210,7 @@ impl methods for ctxt {
for metas.each {|meta| for metas.each {|meta|
alt meta.node { alt meta.node {
ast::meta_word(lintname) { ast::meta_word(lintname) {
alt lookup_lint(self.dict, lintname) { alt lookup_lint(self.dict, *lintname) {
(name, none) { (name, none) {
self.span_lint( self.span_lint(
self.get_level(unrecognized_warning), self.get_level(unrecognized_warning),
@ -444,7 +444,7 @@ fn check_item_old_vecs(cx: ty::ctxt, it: @ast::item) {
ast::ty_path(@{span: _, global: _, idents: ids, ast::ty_path(@{span: _, global: _, idents: ids,
rp: none, types: _}, _) rp: none, types: _}, _)
if ids == ["str"] && (! uses_vstore.contains_key(t.id)) { if ids == [@"str"] && (! uses_vstore.contains_key(t.id)) {
cx.sess.span_lint( cx.sess.span_lint(
old_vecs, it.id, t.id, old_vecs, it.id, t.id,
t.span, "deprecated str type"); t.span, "deprecated str type");

View File

@ -45,7 +45,7 @@ of `f`.
*/ */
import dvec::{dvec, extensions}; import dvec::{dvec, extensions};
import std::map::{hashmap, int_hash, str_hash}; import std::map::{hashmap, int_hash, str_hash, box_str_hash};
import syntax::{visit, ast_util}; import syntax::{visit, ast_util};
import syntax::print::pprust::{expr_to_str}; import syntax::print::pprust::{expr_to_str};
import visit::vt; import visit::vt;
@ -134,9 +134,9 @@ enum relevant_def { rdef_var(node_id), rdef_self }
type capture_info = {ln: live_node, is_move: bool, rv: relevant_def}; type capture_info = {ln: live_node, is_move: bool, rv: relevant_def};
enum var_kind { enum var_kind {
vk_arg(node_id, str, rmode), vk_arg(node_id, ident, rmode),
vk_local(node_id, str), vk_local(node_id, ident),
vk_field(str), vk_field(ident),
vk_self, vk_self,
vk_implicit_ret vk_implicit_ret
} }
@ -158,7 +158,7 @@ class ir_maps {
let mut num_vars: uint; let mut num_vars: uint;
let live_node_map: hashmap<node_id, live_node>; let live_node_map: hashmap<node_id, live_node>;
let variable_map: hashmap<node_id, variable>; let variable_map: hashmap<node_id, variable>;
let field_map: hashmap<str, variable>; let field_map: hashmap<ident, variable>;
let capture_map: hashmap<node_id, @[capture_info]>; let capture_map: hashmap<node_id, @[capture_info]>;
let mut var_kinds: [var_kind]; let mut var_kinds: [var_kind];
let mut lnks: [live_node_kind]; let mut lnks: [live_node_kind];
@ -174,7 +174,7 @@ class ir_maps {
self.live_node_map = int_hash(); self.live_node_map = int_hash();
self.variable_map = int_hash(); self.variable_map = int_hash();
self.capture_map = int_hash(); self.capture_map = int_hash();
self.field_map = str_hash(); self.field_map = box_str_hash();
self.var_kinds = []; self.var_kinds = [];
self.lnks = []; self.lnks = [];
} }
@ -227,12 +227,12 @@ class ir_maps {
} }
} }
fn variable_name(var: variable) -> str { fn variable_name(var: variable) -> ident {
alt self.var_kinds[*var] { alt self.var_kinds[*var] {
vk_local(_, name) | vk_arg(_, name, _) {name} vk_local(_, name) | vk_arg(_, name, _) {name}
vk_field(name) {"self." + name} vk_field(name) {@("self." + *name)}
vk_self {"self"} vk_self {@"self"}
vk_implicit_ret {"<implicit-ret>"} vk_implicit_ret {@"<implicit-ret>"}
} }
} }
@ -1208,7 +1208,8 @@ class liveness {
} }
} }
fn as_self_field(expr: @expr, fld: str) -> option<(live_node,variable)> { fn as_self_field(expr: @expr,
fld: ident) -> option<(live_node,variable)> {
// If we checking a constructor, then we treat self.f as a // If we checking a constructor, then we treat self.f as a
// variable. we use the live_node id that will be assigned to // variable. we use the live_node id that will be assigned to
// the reference to self but the variable id for `f`. // the reference to self but the variable id for `f`.
@ -1429,7 +1430,7 @@ impl check_methods for @liveness {
none { /* ok */ } none { /* ok */ }
some(lnk_exit) { some(lnk_exit) {
self.tcx.sess.span_err( self.tcx.sess.span_err(
sp, #fmt["field `self.%s` is never initialized", nm]); sp, #fmt["field `self.%s` is never initialized", *nm]);
} }
some(lnk) { some(lnk) {
self.report_illegal_read( self.report_illegal_read(
@ -1605,13 +1606,13 @@ impl check_methods for @liveness {
self.tcx.sess.span_err( self.tcx.sess.span_err(
move_span, move_span,
#fmt["illegal move from argument `%s`, which is not \ #fmt["illegal move from argument `%s`, which is not \
copy or move mode", name]); copy or move mode", *name]);
ret; ret;
} }
vk_field(name) { vk_field(name) {
self.tcx.sess.span_err( self.tcx.sess.span_err(
move_span, move_span,
#fmt["illegal move from field `%s`", name]); #fmt["illegal move from field `%s`", *name]);
ret; ret;
} }
vk_local(*) | vk_self | vk_implicit_ret { vk_local(*) | vk_self | vk_implicit_ret {
@ -1643,12 +1644,12 @@ impl check_methods for @liveness {
lnk_freevar(span) { lnk_freevar(span) {
self.tcx.sess.span_err( self.tcx.sess.span_err(
span, span,
#fmt["capture of %s: `%s`", msg, name]); #fmt["capture of %s: `%s`", msg, *name]);
} }
lnk_expr(span) { lnk_expr(span) {
self.tcx.sess.span_err( self.tcx.sess.span_err(
span, span,
#fmt["use of %s: `%s`", msg, name]); #fmt["use of %s: `%s`", msg, *name]);
} }
lnk_exit | lnk_exit |
lnk_vdef(_) { lnk_vdef(_) {
@ -1659,9 +1660,9 @@ impl check_methods for @liveness {
} }
} }
fn should_warn(var: variable) -> option<str> { fn should_warn(var: variable) -> option<ident> {
let name = (*self.ir).variable_name(var); let name = (*self.ir).variable_name(var);
if name[0] == ('_' as u8) {none} else {some(name)} if (*name)[0] == ('_' as u8) {none} else {some(name)}
} }
fn warn_about_unused_args(sp: span, decl: fn_decl, entry_ln: live_node) { fn warn_about_unused_args(sp: span, decl: fn_decl, entry_ln: live_node) {
@ -1712,10 +1713,10 @@ impl check_methods for @liveness {
if is_assigned { if is_assigned {
self.tcx.sess.span_warn( self.tcx.sess.span_warn(
sp, #fmt["variable `%s` is assigned to, \ sp, #fmt["variable `%s` is assigned to, \
but never used", name]); but never used", *name]);
} else { } else {
self.tcx.sess.span_warn( self.tcx.sess.span_warn(
sp, #fmt["unused variable: `%s`", name]); sp, #fmt["unused variable: `%s`", *name]);
} }
} }
ret true; ret true;
@ -1728,7 +1729,7 @@ impl check_methods for @liveness {
for self.should_warn(var).each { |name| for self.should_warn(var).each { |name|
self.tcx.sess.span_warn( self.tcx.sess.span_warn(
sp, sp,
#fmt["value assigned to `%s` is never read", name]); #fmt["value assigned to `%s` is never read", *name]);
} }
} }
} }

View File

@ -9,12 +9,12 @@ import std::map::hashmap;
export pat_binding_ids, pat_bindings, pat_id_map; export pat_binding_ids, pat_bindings, pat_id_map;
export pat_is_variant; export pat_is_variant;
type pat_id_map = std::map::hashmap<str, node_id>; type pat_id_map = std::map::hashmap<ident, node_id>;
// This is used because same-named variables in alternative patterns need to // This is used because same-named variables in alternative patterns need to
// use the node_id of their namesake in the first pattern. // use the node_id of their namesake in the first pattern.
fn pat_id_map(dm: resolve::def_map, pat: @pat) -> pat_id_map { fn pat_id_map(dm: resolve::def_map, pat: @pat) -> pat_id_map {
let map = std::map::str_hash(); let map = std::map::box_str_hash();
pat_bindings(dm, pat) {|p_id, _s, n| pat_bindings(dm, pat) {|p_id, _s, n|
map.insert(path_to_ident(n), p_id); map.insert(path_to_ident(n), p_id);
}; };

View File

@ -9,7 +9,7 @@ import syntax::attr;
import metadata::{csearch, cstore}; import metadata::{csearch, cstore};
import driver::session::session; import driver::session::session;
import util::common::is_main_name; import util::common::is_main_name;
import std::map::{int_hash, str_hash, hashmap}; import std::map::{int_hash, str_hash, box_str_hash, hashmap};
import vec::each; import vec::each;
import syntax::codemap::span; import syntax::codemap::span;
import syntax::visit; import syntax::visit;
@ -68,16 +68,16 @@ enum glob_import_state {
option<def>), /* module */ option<def>), /* module */
} }
type ext_hash = hashmap<{did: def_id, ident: str, ns: namespace}, def>; type ext_hash = hashmap<{did: def_id, ident: ast::ident, ns: namespace}, def>;
fn new_ext_hash() -> ext_hash { fn new_ext_hash() -> ext_hash {
type key = {did: def_id, ident: str, ns: namespace}; type key = {did: def_id, ident: ast::ident, ns: namespace};
fn hash(v: key) -> uint { fn hash(v: key) -> uint {
str::hash(v.ident) + ast_util::hash_def(v.did) + v.ns as uint str::hash(*v.ident) + ast_util::hash_def(v.did) + v.ns as uint
} }
fn eq(v1: key, v2: key) -> bool { fn eq(v1: key, v2: key) -> bool {
ret ast_util::def_eq(v1.did, v2.did) && ret ast_util::def_eq(v1.did, v2.did) &&
str::eq(v1.ident, v2.ident) && v1.ns == v2.ns; str::eq(*v1.ident, *v2.ident) && v1.ns == v2.ns;
} }
std::map::hashmap(hash, {|a, b| a == b}) std::map::hashmap(hash, {|a, b| a == b})
} }
@ -102,7 +102,7 @@ type indexed_mod = {
index: mod_index, index: mod_index,
glob_imports: dvec<glob_imp_def>, glob_imports: dvec<glob_imp_def>,
mut globbed_exports: [ident], mut globbed_exports: [ident],
glob_imported_names: hashmap<str, glob_import_state>, glob_imported_names: hashmap<ident, glob_import_state>,
path: str path: str
}; };
@ -132,7 +132,7 @@ type env =
ext_cache: ext_hash, ext_cache: ext_hash,
used_imports: {mut track: bool, used_imports: {mut track: bool,
mut data: [node_id]}, mut data: [node_id]},
reported: dvec<{ident: str, sc: scope}>, reported: dvec<{ident: ast::ident, sc: scope}>,
mut ignored_imports: [node_id], mut ignored_imports: [node_id],
mut current_tp: option<uint>, mut current_tp: option<uint>,
mut resolve_unexported: bool, mut resolve_unexported: bool,
@ -256,7 +256,7 @@ fn map_crate(e: @env, c: @ast::crate) {
let mut path = n + "::"; let mut path = n + "::";
list::iter(sc) {|s| list::iter(sc) {|s|
alt s { alt s {
scope_item(i) { path = i.ident + "::" + path; } scope_item(i) { path = *i.ident + "::" + path; }
_ {} _ {}
} }
} }
@ -272,8 +272,8 @@ fn map_crate(e: @env, c: @ast::crate) {
index: index_mod(md), index: index_mod(md),
glob_imports: dvec(), glob_imports: dvec(),
mut globbed_exports: [], mut globbed_exports: [],
glob_imported_names: str_hash(), glob_imported_names: box_str_hash(),
path: path_from_scope(sc, i.ident)}); path: path_from_scope(sc, *i.ident)});
} }
ast::item_native_mod(nmd) { ast::item_native_mod(nmd) {
e.mod_map.insert(i.id, e.mod_map.insert(i.id,
@ -281,8 +281,8 @@ fn map_crate(e: @env, c: @ast::crate) {
index: index_nmod(nmd), index: index_nmod(nmd),
glob_imports: dvec(), glob_imports: dvec(),
mut globbed_exports: [], mut globbed_exports: [],
glob_imported_names: str_hash(), glob_imported_names: box_str_hash(),
path: path_from_scope(sc, i.ident)}); path: path_from_scope(sc, *i.ident)});
} }
_ { } _ { }
} }
@ -340,7 +340,7 @@ fn map_crate(e: @env, c: @ast::crate) {
index: index_mod(c.node.module), index: index_mod(c.node.module),
glob_imports: dvec(), glob_imports: dvec(),
mut globbed_exports: [], mut globbed_exports: [],
glob_imported_names: str_hash(), glob_imported_names: box_str_hash(),
path: ""}); path: ""});
// Next, assemble the links for globbed imports and exports. // Next, assemble the links for globbed imports and exports.
@ -377,10 +377,10 @@ fn check_unused_imports(e: @env, level: lint::level) {
if !vec::contains(e.used_imports.data, k) { if !vec::contains(e.used_imports.data, k) {
alt level { alt level {
lint::warn { lint::warn {
e.sess.span_warn(sp, "unused import " + name); e.sess.span_warn(sp, "unused import " + *name);
} }
lint::error { lint::error {
e.sess.span_err(sp, "unused import " + name); e.sess.span_err(sp, "unused import " + *name);
} }
lint::ignore { lint::ignore {
} }
@ -518,7 +518,7 @@ fn resolve_names(e: @env, c: @ast::crate) {
} }
some(fnd@ast::def_const(_)) { some(fnd@ast::def_const(_)) {
e.sess.span_err(p.span, "pattern variable conflicts \ e.sess.span_err(p.span, "pattern variable conflicts \
with constant '" + path_to_ident(p) + "'"); with constant '" + *path_to_ident(p) + "'");
} }
// Binds a var -- nothing needs to be done // Binds a var -- nothing needs to be done
_ {} _ {}
@ -701,7 +701,7 @@ fn visit_local_with_scope(e: @env, loc: @local, &&sc: scopes, v:vt<scopes>) {
e.sess.span_err(loc.span, e.sess.span_err(loc.span,
#fmt("declaration of `%s` shadows an \ #fmt("declaration of `%s` shadows an \
enum that's in scope", enum that's in scope",
path_to_ident(path))); *path_to_ident(path)));
} }
_ {} _ {}
} }
@ -734,7 +734,7 @@ fn follow_import(e: env, &&sc: scopes, path: [ident], sp: span) ->
alt dcur { alt dcur {
some(ast::def_mod(_)) | some(ast::def_native_mod(_)) { ret dcur; } some(ast::def_mod(_)) | some(ast::def_native_mod(_)) { ret dcur; }
_ { _ {
e.sess.span_err(sp, str::connect(path, "::") + e.sess.span_err(sp, str::connect(path.map({|x|*x}), "::") +
" does not name a module."); " does not name a module.");
ret none; ret none;
} }
@ -860,7 +860,7 @@ fn resolve_import(e: env, n_id: node_id, name: ast::ident,
// import // import
alt e.imports.find(n_id) { alt e.imports.find(n_id) {
some(resolving(sp)) { some(resolving(sp)) {
e.imports.insert(n_id, resolved(none, none, none, @[], "", sp)); e.imports.insert(n_id, resolved(none, none, none, @[], @"", sp));
} }
_ { } _ { }
} }
@ -897,7 +897,7 @@ fn unresolved_err(e: env, cx: ctxt, sp: span, name: ident, kind: str) {
alt find_fn_or_mod_scope(sc) { alt find_fn_or_mod_scope(sc) {
some(err_scope) { some(err_scope) {
for e.reported.each {|rs| for e.reported.each {|rs|
if str::eq(rs.ident, name) && err_scope == rs.sc { ret; } if str::eq(*rs.ident, *name) && err_scope == rs.sc { ret; }
} }
e.reported.push({ident: name, sc: err_scope}); e.reported.push({ident: name, sc: err_scope});
} }
@ -907,10 +907,10 @@ fn unresolved_err(e: env, cx: ctxt, sp: span, name: ident, kind: str) {
in_mod(def) { in_mod(def) {
let did = def_id_of_def(def); let did = def_id_of_def(def);
if did.crate == ast::local_crate { if did.crate == ast::local_crate {
path = e.mod_map.get(did.node).path + path; path = @(e.mod_map.get(did.node).path + *path);
} else if did.node != ast::crate_node_id { } else if did.node != ast::crate_node_id {
let paths = e.ext_map.get(did); let paths = e.ext_map.get(did);
path = str::connect(paths + [path], "::"); path = @str::connect((paths + [path]).map({|x|*x}), "::");
} }
} }
} }
@ -922,7 +922,7 @@ fn unresolved_fatal(e: env, sp: span, id: ident, kind: str) -> ! {
} }
fn mk_unresolved_msg(id: ident, kind: str) -> str { fn mk_unresolved_msg(id: ident, kind: str) -> str {
ret #fmt["unresolved %s: %s", kind, id]; ret #fmt["unresolved %s: %s", kind, *id];
} }
// Lookup helpers // Lookup helpers
@ -1010,7 +1010,7 @@ fn lookup_in_scope(e: env, &&sc: scopes, sp: span, name: ident, ns: namespace,
alt s { alt s {
scope_toplevel { scope_toplevel {
if ns == ns_type { if ns == ns_type {
ret some(ast::def_prim_ty(alt name { ret some(ast::def_prim_ty(alt *name {
"bool" { ast::ty_bool } "bool" { ast::ty_bool }
"int" { ast::ty_int(ast::ty_i) } "int" { ast::ty_int(ast::ty_i) }
"uint" { ast::ty_uint(ast::ty_u) } "uint" { ast::ty_uint(ast::ty_u) }
@ -1045,7 +1045,7 @@ fn lookup_in_scope(e: env, &&sc: scopes, sp: span, name: ident, ns: namespace,
} }
ast::item_iface(tps, _, _) { ast::item_iface(tps, _, _) {
if ns == ns_type { if ns == ns_type {
if name == "self" { if *name == "self" {
ret some(def_self(it.id)); ret some(def_self(it.id));
} }
ret lookup_in_ty_params(e, name, tps); ret lookup_in_ty_params(e, name, tps);
@ -1070,7 +1070,7 @@ fn lookup_in_scope(e: env, &&sc: scopes, sp: span, name: ident, ns: namespace,
} }
} }
scope_method(id, tps) { scope_method(id, tps) {
if (name == "self" && ns == ns_val) { if (*name == "self" && ns == ns_val) {
ret some(ast::def_self(id)); ret some(ast::def_self(id));
} else if ns == ns_type { } else if ns == ns_type {
ret lookup_in_ty_params(e, name, tps); ret lookup_in_ty_params(e, name, tps);
@ -1135,7 +1135,7 @@ fn lookup_in_scope(e: env, &&sc: scopes, sp: span, name: ident, ns: namespace,
let mut i = vec::len(closing); let mut i = vec::len(closing);
while i > 0u { while i > 0u {
i -= 1u; i -= 1u;
#debug["name=%s df=%?", name, df]; #debug["name=%s df=%?", *name, df];
assert def_is_local(df) || def_is_self(df); assert def_is_local(df) || def_is_self(df);
let df_id = def_id_of_def(df).node; let df_id = def_id_of_def(df).node;
df = ast::def_upvar(df_id, @df, closing[i]); df = ast::def_upvar(df_id, @df, closing[i]);
@ -1164,7 +1164,7 @@ fn lookup_in_ty_params(e: env, name: ident, ty_params: [ast::ty_param])
-> option<def> { -> option<def> {
let mut n = 0u; let mut n = 0u;
for ty_params.each {|tp| for ty_params.each {|tp|
if str::eq(tp.ident, name) && alt e.current_tp { if str::eq(*tp.ident, *name) && alt e.current_tp {
some(cur) { n < cur } none { true } some(cur) { n < cur } none { true }
} { ret some(ast::def_ty_param(local_def(tp.id), n)); } } { ret some(ast::def_ty_param(local_def(tp.id), n)); }
n += 1u; n += 1u;
@ -1176,7 +1176,7 @@ fn lookup_in_pat(e: env, name: ident, pat: @ast::pat) -> option<node_id> {
let mut found = none; let mut found = none;
pat_util::pat_bindings(e.def_map, pat) {|p_id, _sp, n| pat_util::pat_bindings(e.def_map, pat) {|p_id, _sp, n|
if str::eq(path_to_ident(n), name) if str::eq(*path_to_ident(n), *name)
{ found = some(p_id); } { found = some(p_id); }
}; };
ret found; ret found;
@ -1188,7 +1188,7 @@ fn lookup_in_fn(e: env, name: ident, decl: ast::fn_decl,
alt ns { alt ns {
ns_val { ns_val {
for decl.inputs.each {|a| for decl.inputs.each {|a|
if str::eq(a.ident, name) { if str::eq(*a.ident, *name) {
ret some(ast::def_arg(a.id, a.mode)); ret some(ast::def_arg(a.id, a.mode));
} }
} }
@ -1231,14 +1231,14 @@ fn lookup_in_block(e: env, name: ident, sp: span, b: ast::blk_, pos: uint,
alt it.node { alt it.node {
ast::item_enum(variants, _, _) { ast::item_enum(variants, _, _) {
if ns == ns_type { if ns == ns_type {
if str::eq(it.ident, name) { if str::eq(*it.ident, *name) {
ret some(ast::def_ty(local_def(it.id))); ret some(ast::def_ty(local_def(it.id)));
} }
} else { } else {
alt ns { alt ns {
ns_val { ns_val {
for variants.each {|v| for variants.each {|v|
if str::eq(v.node.name, name) { if str::eq(*v.node.name, *name) {
let i = v.node.id; let i = v.node.id;
ret some(ast::def_variant ret some(ast::def_variant
(local_def(it.id), local_def(i))); (local_def(it.id), local_def(i)));
@ -1250,7 +1250,7 @@ fn lookup_in_block(e: env, name: ident, sp: span, b: ast::blk_, pos: uint,
} }
} }
_ { _ {
if str::eq(it.ident, name) { if str::eq(*it.ident, *name) {
let found = found_def_item(it, ns); let found = found_def_item(it, ns);
if !is_none(found) { if !is_none(found) {
ret found; ret found;
@ -1521,9 +1521,9 @@ fn lookup_in_globs(e: env, globs: [glob_imp_def], sp: span, id: ident,
} else { } else {
for matches.each {|match| for matches.each {|match|
let sp = match.path.span; let sp = match.path.span;
e.sess.span_note(sp, #fmt["'%s' is imported here", id]); e.sess.span_note(sp, #fmt["'%s' is imported here", *id]);
} }
e.sess.span_fatal(sp, "'" + id + "' is glob-imported from" + e.sess.span_fatal(sp, "'" + *id + "' is glob-imported from" +
" multiple different modules."); " multiple different modules.");
} }
} }
@ -1627,7 +1627,7 @@ fn index_view_items(view_items: [@ast::view_item],
} }
fn index_mod(md: ast::_mod) -> mod_index { fn index_mod(md: ast::_mod) -> mod_index {
let index = str_hash::<@list<mod_index_entry>>(); let index = box_str_hash::<@list<mod_index_entry>>();
index_view_items(md.view_items, index); index_view_items(md.view_items, index);
@ -1667,7 +1667,7 @@ fn index_mod(md: ast::_mod) -> mod_index {
fn index_nmod(md: ast::native_mod) -> mod_index { fn index_nmod(md: ast::native_mod) -> mod_index {
let index = str_hash::<@list<mod_index_entry>>(); let index = box_str_hash::<@list<mod_index_entry>>();
index_view_items(md.view_items, index); index_view_items(md.view_items, index);
@ -1727,7 +1727,7 @@ fn check_mod_name(e: env, name: ident, entries: @list<mod_index_entry>) {
let mut saw_value = false; let mut saw_value = false;
let mut entries = entries; let mut entries = entries;
fn dup(e: env, sp: span, word: str, name: ident) { fn dup(e: env, sp: span, word: str, name: ident) {
e.sess.span_fatal(sp, "duplicate definition of " + word + name); e.sess.span_fatal(sp, "duplicate definition of " + word + *name);
} }
loop { loop {
alt *entries { alt *entries {
@ -1817,11 +1817,11 @@ fn check_arm(e: @env, a: ast::arm, &&x: (), v: vt<()>) {
"inconsistent number of bindings"); "inconsistent number of bindings");
} else { } else {
for ch.seen.each {|name| for ch.seen.each {|name|
if is_none(vec::find(seen0, bind str::eq(name, _))) { if is_none(vec::find(seen0, {|x|str::eq(*name, *x)})) {
// Fight the alias checker // Fight the alias checker
let name_ = name; let name_ = name;
e.sess.span_err(a.pats[i].span, e.sess.span_err(a.pats[i].span,
"binding " + name_ + "binding " + *name_ +
" does not occur in first pattern"); " does not occur in first pattern");
} }
} }
@ -1915,8 +1915,9 @@ fn checker(e: env, kind: str) -> checker {
fn check_name(ch: checker, sp: span, name: ident) { fn check_name(ch: checker, sp: span, name: ident) {
for ch.seen.each {|s| for ch.seen.each {|s|
if str::eq(s, name) { if str::eq(*s, *name) {
ch.sess.span_fatal(sp, "duplicate " + ch.kind + " name: " + name); ch.sess.span_fatal(
sp, "duplicate " + ch.kind + " name: " + *name);
} }
} }
} }
@ -2000,7 +2001,7 @@ fn check_exports(e: @env) {
e.exp_map.insert(export_id, found + [{reexp: reexp, id: target_id}]); e.exp_map.insert(export_id, found + [{reexp: reexp, id: target_id}]);
} }
fn check_export(e: @env, ident: str, _mod: @indexed_mod, fn check_export(e: @env, ident: ident, _mod: @indexed_mod,
export_id: node_id, vi: @view_item) { export_id: node_id, vi: @view_item) {
let mut found_something = false; let mut found_something = false;
if _mod.index.contains_key(ident) { if _mod.index.contains_key(ident) {
@ -2036,7 +2037,7 @@ fn check_exports(e: @env) {
lookup_glob_any(e, _mod, vi.span, ident, export_id); lookup_glob_any(e, _mod, vi.span, ident, export_id);
if !found_something { if !found_something {
e.sess.span_warn(vi.span, e.sess.span_warn(vi.span,
#fmt("exported item %s is not defined", ident)); #fmt("exported item %s is not defined", *ident));
} }
} }
@ -2044,7 +2045,7 @@ fn check_exports(e: @env) {
-> node_id { -> node_id {
alt _mod.index.find(id) { alt _mod.index.find(id) {
none { none {
e.sess.span_fatal(sp, #fmt("undefined id %s in an export", id)); e.sess.span_fatal(sp, #fmt("undefined id %s in an export", *id));
} }
some(ms) { some(ms) {
let maybe_id = list_search(ms) {|m| let maybe_id = list_search(ms) {|m|
@ -2056,7 +2057,7 @@ fn check_exports(e: @env) {
alt maybe_id { alt maybe_id {
some(an_id) { an_id } some(an_id) { an_id }
_ { e.sess.span_fatal(sp, #fmt("%s does not refer \ _ { e.sess.span_fatal(sp, #fmt("%s does not refer \
to an enumeration", id)); } to an enumeration", *id)); }
} }
} }
} }
@ -2079,7 +2080,7 @@ fn check_exports(e: @env) {
e.sess.span_err( e.sess.span_err(
span, #fmt("variant %s doesn't belong to \ span, #fmt("variant %s doesn't belong to \
enum %s", enum %s",
variant_id.node.name, id)); *variant_id.node.name, *id));
} }
} }
_ {} _ {}
@ -2090,7 +2091,7 @@ fn check_exports(e: @env) {
} }
if !found { if !found {
e.sess.span_err(span, #fmt("%s is not a variant", e.sess.span_err(span, #fmt("%s is not a variant",
variant_id.node.name)); *variant_id.node.name));
} }
} }
} }

View File

@ -78,9 +78,9 @@ fn variant_opt(tcx: ty::ctxt, pat_id: ast::node_id) -> opt {
} }
type bind_map = [{ident: ast::ident, val: ValueRef}]; type bind_map = [{ident: ast::ident, val: ValueRef}];
fn assoc(key: str, list: bind_map) -> option<ValueRef> { fn assoc(key: ast::ident, list: bind_map) -> option<ValueRef> {
for vec::each(list) {|elt| for vec::each(list) {|elt|
if str::eq(elt.ident, key) { ret some(elt.val); } if str::eq(*elt.ident, *key) { ret some(elt.val); }
} }
ret none; ret none;
} }
@ -194,7 +194,7 @@ fn enter_rec(dm: def_map, m: match, col: uint, fields: [ast::ident],
for vec::each(fields) {|fname| for vec::each(fields) {|fname|
let mut pat = dummy; let mut pat = dummy;
for vec::each(fpats) {|fpat| for vec::each(fpats) {|fpat|
if str::eq(fpat.ident, fname) { pat = fpat.pat; break; } if str::eq(*fpat.ident, *fname) { pat = fpat.pat; break; }
} }
pats += [pat]; pats += [pat];
} }
@ -287,12 +287,12 @@ fn extract_variant_args(bcx: block, pat_id: ast::node_id,
} }
fn collect_record_fields(m: match, col: uint) -> [ast::ident] { fn collect_record_fields(m: match, col: uint) -> [ast::ident] {
let mut fields = []; let mut fields: [ast::ident] = [];
for vec::each(m) {|br| for vec::each(m) {|br|
alt br.pats[col].node { alt br.pats[col].node {
ast::pat_rec(fs, _) { ast::pat_rec(fs, _) {
for vec::each(fs) {|f| for vec::each(fs) {|f|
if !vec::any(fields, bind str::eq(f.ident, _)) { if !vec::any(fields, {|x| str::eq(*f.ident, *x)}) {
fields += [f.ident]; fields += [f.ident];
} }
} }

View File

@ -513,8 +513,8 @@ fn declare_tydesc(ccx: @crate_ctxt, t: ty::t) -> @tydesc_info {
let mut name; let mut name;
//XXX this triggers duplicate LLVM symbols //XXX this triggers duplicate LLVM symbols
if false /*ccx.sess.opts.debuginfo*/ { if false /*ccx.sess.opts.debuginfo*/ {
name = mangle_internal_name_by_type_only(ccx, t, "tydesc"); name = mangle_internal_name_by_type_only(ccx, t, @"tydesc");
} else { name = mangle_internal_name_by_seq(ccx, "tydesc"); } } else { name = mangle_internal_name_by_seq(ccx, @"tydesc"); }
note_unique_llvm_symbol(ccx, name); note_unique_llvm_symbol(ccx, name);
let gvar = str::as_c_str(name, {|buf| let gvar = str::as_c_str(name, {|buf|
llvm::LLVMAddGlobal(ccx.llmod, ccx.tydesc_type, buf) llvm::LLVMAddGlobal(ccx.llmod, ccx.tydesc_type, buf)
@ -541,9 +541,9 @@ fn declare_generic_glue(ccx: @crate_ctxt, t: ty::t, llfnty: TypeRef,
let mut fn_nm; let mut fn_nm;
//XXX this triggers duplicate LLVM symbols //XXX this triggers duplicate LLVM symbols
if false /*ccx.sess.opts.debuginfo*/ { if false /*ccx.sess.opts.debuginfo*/ {
fn_nm = mangle_internal_name_by_type_only(ccx, t, "glue_" + name); fn_nm = mangle_internal_name_by_type_only(ccx, t, @("glue_" + name));
} else { } else {
fn_nm = mangle_internal_name_by_seq(ccx, "glue_" + name); fn_nm = mangle_internal_name_by_seq(ccx, @("glue_" + name));
} }
note_unique_llvm_symbol(ccx, fn_nm); note_unique_llvm_symbol(ccx, fn_nm);
let llfn = decl_cdecl_fn(ccx.llmod, fn_nm, llfnty); let llfn = decl_cdecl_fn(ccx.llmod, fn_nm, llfnty);
@ -697,8 +697,8 @@ fn incr_refcnt_of_boxed(cx: block, box_ptr: ValueRef) {
fn make_visit_glue(bcx: block, v: ValueRef, t: ty::t) { fn make_visit_glue(bcx: block, v: ValueRef, t: ty::t) {
let _icx = bcx.insn_ctxt("make_visit_glue"); let _icx = bcx.insn_ctxt("make_visit_glue");
let mut bcx = bcx; let mut bcx = bcx;
assert bcx.ccx().tcx.intrinsic_ifaces.contains_key("ty_visitor"); assert bcx.ccx().tcx.intrinsic_ifaces.contains_key(@"ty_visitor");
let (iid, ty) = bcx.ccx().tcx.intrinsic_ifaces.get("ty_visitor"); let (iid, ty) = bcx.ccx().tcx.intrinsic_ifaces.get(@"ty_visitor");
let v = PointerCast(bcx, v, T_ptr(type_of::type_of(bcx.ccx(), ty))); let v = PointerCast(bcx, v, T_ptr(type_of::type_of(bcx.ccx(), ty)));
bcx = reflect::emit_calls_to_iface_visit_ty(bcx, t, v, iid); bcx = reflect::emit_calls_to_iface_visit_ty(bcx, t, v, iid);
build_return(bcx); build_return(bcx);
@ -1495,7 +1495,7 @@ fn trans_crate_lit(cx: @crate_ctxt, lit: ast::lit) -> ValueRef {
// to actually generate from this? // to actually generate from this?
C_integral(T_int_ty(cx, t), i as u64, True) C_integral(T_int_ty(cx, t), i as u64, True)
} }
ast::lit_float(fs, t) { C_floating(fs, T_float_ty(cx, t)) } ast::lit_float(fs, t) { C_floating(*fs, T_float_ty(cx, t)) }
ast::lit_bool(b) { C_bool(b) } ast::lit_bool(b) { C_bool(b) }
ast::lit_nil { C_nil() } ast::lit_nil { C_nil() }
ast::lit_str(s) { ast::lit_str(s) {
@ -2158,7 +2158,7 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, real_substs: [ty::t],
ast_map::node_ctor(nm, _, ct, pt) { (pt, nm, alt ct { ast_map::node_ctor(nm, _, ct, pt) { (pt, nm, alt ct {
ast_map::res_ctor(_, _, sp) { sp } ast_map::res_ctor(_, _, sp) { sp }
ast_map::class_ctor(ct_, _) { ct_.span }}) } ast_map::class_ctor(ct_, _) { ct_.span }}) }
ast_map::node_dtor(_, dtor, _, pt) {(pt, "drop", dtor.span)} ast_map::node_dtor(_, dtor, _, pt) {(pt, @"drop", dtor.span)}
ast_map::node_expr(*) { ccx.tcx.sess.bug("Can't monomorphize an expr") } ast_map::node_expr(*) { ccx.tcx.sess.bug("Can't monomorphize an expr") }
ast_map::node_export(*) { ast_map::node_export(*) {
ccx.tcx.sess.bug("Can't monomorphize an export") ccx.tcx.sess.bug("Can't monomorphize an export")
@ -2184,7 +2184,7 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, real_substs: [ty::t],
} }
ccx.monomorphizing.insert(fn_id, depth + 1u); ccx.monomorphizing.insert(fn_id, depth + 1u);
let pt = *pt + [path_name(ccx.names(name))]; let pt = *pt + [path_name(@ccx.names(*name))];
let s = mangle_exported_name(ccx, pt, mono_ty); let s = mangle_exported_name(ccx, pt, mono_ty);
let mk_lldecl = {|| let mk_lldecl = {||
@ -3382,7 +3382,7 @@ fn trans_rec(bcx: block, fields: [ast::field],
let mut temp_cleanups = []; let mut temp_cleanups = [];
for fields.each {|fld| for fields.each {|fld|
let ix = option::get(vec::position(ty_fields, {|ft| let ix = option::get(vec::position(ty_fields, {|ft|
str::eq(fld.node.ident, ft.ident) str::eq(*fld.node.ident, *ft.ident)
})); }));
let dst = GEPi(bcx, addr, [0u, ix]); let dst = GEPi(bcx, addr, [0u, ix]);
bcx = trans_expr_save_in(bcx, fld.node.expr, dst); bcx = trans_expr_save_in(bcx, fld.node.expr, dst);
@ -3395,7 +3395,7 @@ fn trans_rec(bcx: block, fields: [ast::field],
bcx = cx; bcx = cx;
// Copy over inherited fields // Copy over inherited fields
for ty_fields.eachi {|i, tf| for ty_fields.eachi {|i, tf|
if !vec::any(fields, {|f| str::eq(f.node.ident, tf.ident)}) { if !vec::any(fields, {|f| str::eq(*f.node.ident, *tf.ident)}) {
let dst = GEPi(bcx, addr, [0u, i]); let dst = GEPi(bcx, addr, [0u, i]);
let base = GEPi(bcx, base_val, [0u, i]); let base = GEPi(bcx, base_val, [0u, i]);
let val = load_if_immediate(bcx, base, tf.mt.ty); let val = load_if_immediate(bcx, base, tf.mt.ty);
@ -3841,7 +3841,7 @@ fn trans_log(log_ex: @ast::expr, lvl: @ast::expr,
ccx.module_data.get(modname) ccx.module_data.get(modname)
} else { } else {
let s = link::mangle_internal_name_by_path_and_seq( let s = link::mangle_internal_name_by_path_and_seq(
ccx, modpath, "loglevel"); ccx, modpath, @"loglevel");
let global = str::as_c_str(s, {|buf| let global = str::as_c_str(s, {|buf|
llvm::LLVMAddGlobal(ccx.llmod, T_i32(), buf) llvm::LLVMAddGlobal(ccx.llmod, T_i32(), buf)
}); });
@ -4320,7 +4320,7 @@ fn alloc_local(cx: block, local: @ast::local) -> block {
let val = alloc_ty(cx, t); let val = alloc_ty(cx, t);
if cx.sess().opts.debuginfo { if cx.sess().opts.debuginfo {
option::iter(simple_name) {|name| option::iter(simple_name) {|name|
str::as_c_str(name, {|buf| str::as_c_str(*name, {|buf|
llvm::LLVMSetValueName(val, buf) llvm::LLVMSetValueName(val, buf)
}); });
} }
@ -4604,7 +4604,7 @@ fn trans_enum_variant(ccx: @crate_ctxt, enum_id: ast::node_id,
let fn_args = vec::map(variant.node.args, {|varg| let fn_args = vec::map(variant.node.args, {|varg|
{mode: ast::expl(ast::by_copy), {mode: ast::expl(ast::by_copy),
ty: varg.ty, ty: varg.ty,
ident: "arg", ident: @"arg",
id: varg.id} id: varg.id}
}); });
let fcx = new_fn_ctxt_w_id(ccx, [], llfndecl, variant.node.id, let fcx = new_fn_ctxt_w_id(ccx, [], llfndecl, variant.node.id,
@ -5122,7 +5122,7 @@ fn get_dtor_symbol(ccx: @crate_ctxt, path: path, id: ast::node_id) -> str {
some(s) { s } some(s) { s }
none { none {
let s = mangle_exported_name(ccx, path + let s = mangle_exported_name(ccx, path +
[path_name(ccx.names("dtor"))], ty::node_id_to_type(ccx.tcx, id)); [path_name(@ccx.names("dtor"))], ty::node_id_to_type(ccx.tcx, id));
ccx.item_symbols.insert(id, s); ccx.item_symbols.insert(id, s);
s s
} }
@ -5164,7 +5164,7 @@ fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef {
// def_ids otherwise -- one to identify the type, and one to // def_ids otherwise -- one to identify the type, and one to
// find the dtor symbol. // find the dtor symbol.
let t = ty::node_id_to_type(ccx.tcx, dtor_id); let t = ty::node_id_to_type(ccx.tcx, dtor_id);
register_fn_full(ccx, i.span, my_path + [path_name("dtor")], register_fn_full(ccx, i.span, my_path + [path_name(@"dtor")],
i.id, t) i.id, t)
} }
} }
@ -5172,7 +5172,7 @@ fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef {
ast_map::node_method(m, impl_id, pth) { ast_map::node_method(m, impl_id, pth) {
exprt = true; exprt = true;
let mty = ty::node_id_to_type(ccx.tcx, id); let mty = ty::node_id_to_type(ccx.tcx, id);
let pth = *pth + [path_name(ccx.names("meth")), let pth = *pth + [path_name(@ccx.names("meth")),
path_name(m.ident)]; path_name(m.ident)];
let llfn = register_fn_full(ccx, m.span, pth, id, mty); let llfn = register_fn_full(ccx, m.span, pth, id, mty);
set_inline_hint_if_appr(m.attrs, llfn); set_inline_hint_if_appr(m.attrs, llfn);
@ -5248,7 +5248,7 @@ fn trans_constant(ccx: @crate_ctxt, it: @ast::item) {
let path = item_path(ccx, it); let path = item_path(ccx, it);
for vec::each(variants) {|variant| for vec::each(variants) {|variant|
let p = path + [path_name(variant.node.name), let p = path + [path_name(variant.node.name),
path_name("discrim")]; path_name(@"discrim")];
let s = mangle_exported_name(ccx, p, ty::mk_int(ccx.tcx)); let s = mangle_exported_name(ccx, p, ty::mk_int(ccx.tcx));
let disr_val = vi[i].disr_val; let disr_val = vi[i].disr_val;
note_unique_llvm_symbol(ccx, s); note_unique_llvm_symbol(ccx, s);
@ -5376,7 +5376,7 @@ fn decl_crate_map(sess: session::session, mapmeta: link_meta,
let cstore = sess.cstore; let cstore = sess.cstore;
while cstore::have_crate_data(cstore, n_subcrates) { n_subcrates += 1; } while cstore::have_crate_data(cstore, n_subcrates) { n_subcrates += 1; }
let mapname = if sess.building_library { let mapname = if sess.building_library {
mapmeta.name + "_" + mapmeta.vers + "_" + mapmeta.extras_hash *mapmeta.name + "_" + *mapmeta.vers + "_" + mapmeta.extras_hash
} else { "toplevel" }; } else { "toplevel" };
let sym_name = "_rust_crate_map_" + mapname; let sym_name = "_rust_crate_map_" + mapname;
let arrtype = T_array(int_type, n_subcrates as uint); let arrtype = T_array(int_type, n_subcrates as uint);
@ -5395,8 +5395,8 @@ fn fill_crate_map(ccx: @crate_ctxt, map: ValueRef) {
while cstore::have_crate_data(cstore, i) { while cstore::have_crate_data(cstore, i) {
let cdata = cstore::get_crate_data(cstore, i); let cdata = cstore::get_crate_data(cstore, i);
let nm = "_rust_crate_map_" + cdata.name + let nm = "_rust_crate_map_" + cdata.name +
"_" + cstore::get_crate_vers(cstore, i) + "_" + *cstore::get_crate_vers(cstore, i) +
"_" + cstore::get_crate_hash(cstore, i); "_" + *cstore::get_crate_hash(cstore, i);
let cr = str::as_c_str(nm, {|buf| let cr = str::as_c_str(nm, {|buf|
llvm::LLVMAddGlobal(ccx.llmod, ccx.int_type, buf) llvm::LLVMAddGlobal(ccx.llmod, ccx.int_type, buf)
}); });
@ -5506,7 +5506,7 @@ fn trans_crate(sess: session::session, crate: @ast::crate, tcx: ty::ctxt,
// crashes if the module identifer is same as other symbols // crashes if the module identifer is same as other symbols
// such as a function name in the module. // such as a function name in the module.
// 1. http://llvm.org/bugs/show_bug.cgi?id=11479 // 1. http://llvm.org/bugs/show_bug.cgi?id=11479
let llmod_id = link_meta.name + ".rc"; let llmod_id = *link_meta.name + ".rc";
let llmod = str::as_c_str(llmod_id, {|buf| let llmod = str::as_c_str(llmod_id, {|buf|
llvm::LLVMModuleCreateWithNameInContext llvm::LLVMModuleCreateWithNameInContext

View File

@ -390,7 +390,7 @@ fn trans_expr_fn(bcx: block,
let ccx = bcx.ccx(), bcx = bcx; let ccx = bcx.ccx(), bcx = bcx;
let fty = node_id_type(bcx, id); let fty = node_id_type(bcx, id);
let llfnty = type_of_fn_from_ty(ccx, fty); let llfnty = type_of_fn_from_ty(ccx, fty);
let sub_path = bcx.fcx.path + [path_name("anon")]; let sub_path = bcx.fcx.path + [path_name(@"anon")];
let s = mangle_internal_name_by_path(ccx, sub_path); let s = mangle_internal_name_by_path(ccx, sub_path);
let llfn = decl_internal_cdecl_fn(ccx.llmod, s, llfnty); let llfn = decl_internal_cdecl_fn(ccx.llmod, s, llfnty);
@ -676,7 +676,7 @@ fn trans_bind_thunk(ccx: @crate_ctxt,
// construct and return that thunk. // construct and return that thunk.
// Give the thunk a name, type, and value. // Give the thunk a name, type, and value.
let s = mangle_internal_name_by_path_and_seq(ccx, path, "thunk"); let s = mangle_internal_name_by_path_and_seq(ccx, path, @"thunk");
let llthunk_ty = get_pair_fn_ty(type_of(ccx, incoming_fty)); let llthunk_ty = get_pair_fn_ty(type_of(ccx, incoming_fty));
let llthunk = decl_internal_cdecl_fn(ccx.llmod, s, llthunk_ty); let llthunk = decl_internal_cdecl_fn(ccx.llmod, s, llthunk_ty);

View File

@ -933,7 +933,7 @@ fn path_str(p: path) -> str {
alt e { ast_map::path_name(s) | ast_map::path_mod(s) { alt e { ast_map::path_name(s) | ast_map::path_mod(s) {
if first { first = false; } if first { first = false; }
else { r += "::"; } else { r += "::"; }
r += s; r += *s;
} } } }
} }
r r
@ -966,7 +966,7 @@ fn field_idx_strict(cx: ty::ctxt, sp: span, ident: ast::ident,
-> uint { -> uint {
alt ty::field_idx(ident, fields) { alt ty::field_idx(ident, fields) {
none { cx.sess.span_bug(sp, #fmt("base expr doesn't appear to \ none { cx.sess.span_bug(sp, #fmt("base expr doesn't appear to \
have a field named %s", ident)); } have a field named %s", *ident)); }
some(i) { i } some(i) { i }
} }
} }

View File

@ -421,7 +421,7 @@ fn create_record(cx: @crate_ctxt, t: ty::t, fields: [ast::ty_field],
let field_t = ty::get_field(t, field.node.ident).mt.ty; let field_t = ty::get_field(t, field.node.ident).mt.ty;
let ty_md = create_ty(cx, field_t, field.node.mt.ty); let ty_md = create_ty(cx, field_t, field.node.mt.ty);
let (size, align) = size_and_align_of(cx, field_t); let (size, align) = size_and_align_of(cx, field_t);
add_member(scx, field.node.ident, add_member(scx, *field.node.ident,
line_from_span(cx.sess.codemap, field.span) as int, line_from_span(cx.sess.codemap, field.span) as int,
size as int, align as int, ty_md.node); size as int, align as int, ty_md.node);
} }
@ -661,7 +661,7 @@ fn create_local_var(bcx: block, local: @ast::local)
none { create_function(bcx.fcx).node } none { create_function(bcx.fcx).node }
some(_) { create_block(bcx).node } some(_) { create_block(bcx).node }
}; };
let mdnode = create_var(tg, context, name, filemd.node, let mdnode = create_var(tg, context, *name, filemd.node,
loc.line as int, tymd.node); loc.line as int, tymd.node);
let mdval = @{node: mdnode, data: {id: local.node.id}}; let mdval = @{node: mdnode, data: {id: local.node.id}};
update_cache(cache, AutoVariableTag, local_var_metadata(mdval)); update_cache(cache, AutoVariableTag, local_var_metadata(mdval));
@ -703,7 +703,7 @@ fn create_arg(bcx: block, arg: ast::arg, sp: span)
let tymd = create_ty(cx, ty, arg.ty); let tymd = create_ty(cx, ty, arg.ty);
let filemd = create_file(cx, loc.file.name); let filemd = create_file(cx, loc.file.name);
let context = create_function(bcx.fcx); let context = create_function(bcx.fcx);
let mdnode = create_var(tg, context.node, arg.ident, filemd.node, let mdnode = create_var(tg, context.node, *arg.ident, filemd.node,
loc.line as int, tymd.node); loc.line as int, tymd.node);
let mdval = @{node: mdnode, data: {id: arg.id}}; let mdval = @{node: mdnode, data: {id: arg.id}};
update_cache(cache, tg, argument_metadata(mdval)); update_cache(cache, tg, argument_metadata(mdval));
@ -769,10 +769,10 @@ fn create_function(fcx: fn_ctxt) -> @metadata<subprogram_md> {
ast_map::node_expr(expr) { ast_map::node_expr(expr) {
alt expr.node { alt expr.node {
ast::expr_fn(_, decl, _, _) { ast::expr_fn(_, decl, _, _) {
(dbg_cx.names("fn"), decl.output, expr.id) (@dbg_cx.names("fn"), decl.output, expr.id)
} }
ast::expr_fn_block(decl, _, _) { ast::expr_fn_block(decl, _, _) {
(dbg_cx.names("fn"), decl.output, expr.id) (@dbg_cx.names("fn"), decl.output, expr.id)
} }
_ { fcx.ccx.sess.span_bug(expr.span, "create_function: \ _ { fcx.ccx.sess.span_bug(expr.span, "create_function: \
expected an expr_fn or fn_block here"); } expected an expr_fn or fn_block here"); }
@ -810,8 +810,8 @@ fn create_function(fcx: fn_ctxt) -> @metadata<subprogram_md> {
let fn_metadata = [lltag(SubprogramTag), let fn_metadata = [lltag(SubprogramTag),
llunused(), llunused(),
file_node, file_node,
llstr(ident), llstr(*ident),
llstr(ident), //XXX fully-qualified C++ name llstr(*ident), //XXX fully-qualified C++ name
llstr(""), //XXX MIPS name????? llstr(""), //XXX MIPS name?????
file_node, file_node,
lli32(loc.line as int), lli32(loc.line as int),

View File

@ -421,8 +421,8 @@ fn decl_x86_64_fn(tys: x86_64_tys,
fn link_name(i: @ast::native_item) -> str { fn link_name(i: @ast::native_item) -> str {
alt attr::first_attr_value_str_by_name(i.attrs, "link_name") { alt attr::first_attr_value_str_by_name(i.attrs, "link_name") {
none { ret i.ident; } none { ret *i.ident; }
option::some(ln) { ret ln; } option::some(ln) { ret *ln; }
} }
} }
@ -805,7 +805,7 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::native_item,
let fcx = new_fn_ctxt_w_id(ccx, path, decl, item.id, let fcx = new_fn_ctxt_w_id(ccx, path, decl, item.id,
some(substs), some(item.span)); some(substs), some(item.span));
let mut bcx = top_scope_block(fcx, none), lltop = bcx.llbb; let mut bcx = top_scope_block(fcx, none), lltop = bcx.llbb;
alt check item.ident { alt check *item.ident {
"size_of" { "size_of" {
let tp_ty = substs.tys[0]; let tp_ty = substs.tys[0];
let lltp_ty = type_of::type_of(ccx, tp_ty); let lltp_ty = type_of::type_of(ccx, tp_ty);
@ -913,7 +913,7 @@ fn trans_crust_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl,
let _icx = ccx.insn_ctxt("native::crust::build_rust_fn"); let _icx = ccx.insn_ctxt("native::crust::build_rust_fn");
let t = ty::node_id_to_type(ccx.tcx, id); let t = ty::node_id_to_type(ccx.tcx, id);
let ps = link::mangle_internal_name_by_path( let ps = link::mangle_internal_name_by_path(
ccx, path + [ast_map::path_name("__rust_abi")]); ccx, path + [ast_map::path_name(@"__rust_abi")]);
let llty = type_of_fn_from_ty(ccx, t); let llty = type_of_fn_from_ty(ccx, t);
let llfndecl = decl_internal_cdecl_fn(ccx.llmod, ps, llty); let llfndecl = decl_internal_cdecl_fn(ccx.llmod, ps, llty);
trans_fn(ccx, path, decl, body, llfndecl, no_self, none, id); trans_fn(ccx, path, decl, body, llfndecl, no_self, none, id);
@ -950,7 +950,7 @@ fn trans_crust_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl,
} }
let shim_name = link::mangle_internal_name_by_path( let shim_name = link::mangle_internal_name_by_path(
ccx, path + [ast_map::path_name("__rust_stack_shim")]); ccx, path + [ast_map::path_name(@"__rust_stack_shim")]);
ret build_shim_fn_(ccx, shim_name, llrustfn, tys, ret build_shim_fn_(ccx, shim_name, llrustfn, tys,
lib::llvm::CCallConv, lib::llvm::CCallConv,
build_args, build_ret); build_args, build_ret);

View File

@ -41,7 +41,7 @@ impl methods for reflector {
fn visit(ty_name: str, args: [ValueRef]) { fn visit(ty_name: str, args: [ValueRef]) {
let tcx = self.bcx.tcx(); let tcx = self.bcx.tcx();
let mth_idx = option::get(ty::method_idx("visit_" + ty_name, let mth_idx = option::get(ty::method_idx(@("visit_" + ty_name),
*self.visitor_methods)); *self.visitor_methods));
let mth_ty = ty::mk_fn(tcx, self.visitor_methods[mth_idx].fty); let mth_ty = ty::mk_fn(tcx, self.visitor_methods[mth_idx].fty);
let v = self.visitor_val; let v = self.visitor_val;
@ -142,7 +142,7 @@ impl methods for reflector {
for fields.eachi {|i, field| for fields.eachi {|i, field|
self.bracketed_mt("rec_field", field.mt, self.bracketed_mt("rec_field", field.mt,
[self.c_uint(i), [self.c_uint(i),
self.c_slice(field.ident)]); self.c_slice(*field.ident)]);
} }
self.visit("leave_rec", [self.c_uint(vec::len(fields))]); self.visit("leave_rec", [self.c_uint(vec::len(fields))]);
} }
@ -209,7 +209,7 @@ impl methods for reflector {
for fields.eachi {|i, field| for fields.eachi {|i, field|
self.bracketed_mt("class_field", field.mt, self.bracketed_mt("class_field", field.mt,
[self.c_uint(i), [self.c_uint(i),
self.c_slice(field.ident)]); self.c_slice(*field.ident)]);
} }
self.visit("leave_class", [self.c_uint(vec::len(fields))]); self.visit("leave_class", [self.c_uint(vec::len(fields))]);
} }
@ -228,7 +228,7 @@ impl methods for reflector {
let extra = [self.c_uint(i), let extra = [self.c_uint(i),
self.c_int(v.disr_val), self.c_int(v.disr_val),
self.c_uint(vec::len(v.args)), self.c_uint(vec::len(v.args)),
self.c_slice(v.name)]; self.c_slice(*v.name)];
self.visit("enter_enum_variant", extra); self.visit("enter_enum_variant", extra);
for v.args.eachi {|j, a| for v.args.eachi {|j, a|
self.bracketed_t("enum_variant_field", a, self.bracketed_t("enum_variant_field", a,

View File

@ -421,7 +421,7 @@ fn gen_enum_shapes(ccx: @crate_ctxt) -> ValueRef {
let variant_shape = shape_of_variant(ccx, v); let variant_shape = shape_of_variant(ccx, v);
add_substr(data, variant_shape); add_substr(data, variant_shape);
let zname = str::bytes(v.name) + [0u8]; let zname = str::bytes(*v.name) + [0u8];
add_substr(data, zname); add_substr(data, zname);
} }
enum_variants += [variants]; enum_variants += [variants];

View File

@ -233,7 +233,7 @@ fn get_base_and_len(cx: block, v: ValueRef, e_ty: ty::t)
} }
} }
fn trans_estr(bcx: block, s: str, vstore: ast::vstore, fn trans_estr(bcx: block, s: @str, vstore: ast::vstore,
dest: dest) -> block { dest: dest) -> block {
let _icx = bcx.insn_ctxt("tvec::trans_estr"); let _icx = bcx.insn_ctxt("tvec::trans_estr");
let ccx = bcx.ccx(); let ccx = bcx.ccx();
@ -242,27 +242,27 @@ fn trans_estr(bcx: block, s: str, vstore: ast::vstore,
ast::vstore_fixed(_) ast::vstore_fixed(_)
{ {
// "hello"/_ => "hello"/5 => [i8 x 6] in llvm // "hello"/_ => "hello"/5 => [i8 x 6] in llvm
#debug("trans_estr: fixed: %s", s); #debug("trans_estr: fixed: %s", *s);
C_postr(s) C_postr(*s)
} }
ast::vstore_slice(_) { ast::vstore_slice(_) {
// "hello" => (*i8, 6u) in llvm // "hello" => (*i8, 6u) in llvm
#debug("trans_estr: slice '%s'", s); #debug("trans_estr: slice '%s'", *s);
C_estr_slice(ccx, s) C_estr_slice(ccx, *s)
} }
ast::vstore_uniq { ast::vstore_uniq {
let cs = PointerCast(bcx, C_cstr(ccx, s), T_ptr(T_i8())); let cs = PointerCast(bcx, C_cstr(ccx, *s), T_ptr(T_i8()));
let len = C_uint(ccx, str::len(s)); let len = C_uint(ccx, str::len(*s));
let c = Call(bcx, ccx.upcalls.str_new_uniq, [cs, len]); let c = Call(bcx, ccx.upcalls.str_new_uniq, [cs, len]);
PointerCast(bcx, c, PointerCast(bcx, c,
T_unique_ptr(T_unique(ccx, T_vec(ccx, T_i8())))) T_unique_ptr(T_unique(ccx, T_vec(ccx, T_i8()))))
} }
ast::vstore_box { ast::vstore_box {
let cs = PointerCast(bcx, C_cstr(ccx, s), T_ptr(T_i8())); let cs = PointerCast(bcx, C_cstr(ccx, *s), T_ptr(T_i8()));
let len = C_uint(ccx, str::len(s)); let len = C_uint(ccx, str::len(*s));
Call(bcx, ccx.upcalls.str_new_shared, [cs, len]) Call(bcx, ccx.upcalls.str_new_shared, [cs, len])
} }
}; };

View File

@ -76,7 +76,7 @@ fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint)
} }
ast_map::node_native_item(i@@{node: native_item_fn(_, _), _}, abi, _) { ast_map::node_native_item(i@@{node: native_item_fn(_, _), _}, abi, _) {
if abi == native_abi_rust_intrinsic { if abi == native_abi_rust_intrinsic {
let flags = alt check i.ident { let flags = alt check *i.ident {
"visit_ty" { 3u } "visit_ty" { 3u }
"size_of" | "pref_align_of" | "min_align_of" | "size_of" | "pref_align_of" | "min_align_of" |
"init" | "reinterpret_cast" { use_repr } "init" | "reinterpret_cast" { use_repr }

View File

@ -41,7 +41,7 @@ fn comma_str(args: [@constr_arg_use]) -> str {
if comma { rslt += ", "; } else { comma = true; } if comma { rslt += ", "; } else { comma = true; }
alt a.node { alt a.node {
carg_base { rslt += "*"; } carg_base { rslt += "*"; }
carg_ident(i) { rslt += i.ident; } carg_ident(i) { rslt += *i.ident; }
carg_lit(l) { rslt += lit_to_str(l); } carg_lit(l) { rslt += lit_to_str(l); }
} }
} }
@ -143,11 +143,11 @@ fn log_states_err(pp: pre_and_post_state) {
log_cond_err(p2); log_cond_err(p2);
} }
fn print_ident(i: ident) { log(debug, " " + i + " "); } fn print_ident(i: ident) { log(debug, " " + *i + " "); }
fn print_idents(&idents: [ident]) { fn print_idents(&idents: [ident]) {
if vec::len::<ident>(idents) == 0u { ret; } if vec::len::<ident>(idents) == 0u { ret; }
log(debug, "an ident: " + vec::pop::<ident>(idents)); log(debug, "an ident: " + *vec::pop::<ident>(idents));
print_idents(idents); print_idents(idents);
} }
@ -500,7 +500,7 @@ fn constraints(fcx: fn_ctxt) -> [norm_constraint] {
fn match_args(fcx: fn_ctxt, occs: @dvec<pred_args>, fn match_args(fcx: fn_ctxt, occs: @dvec<pred_args>,
occ: [@constr_arg_use]) -> uint { occ: [@constr_arg_use]) -> uint {
#debug("match_args: looking at %s", #debug("match_args: looking at %s",
constr_args_to_str(fn@(i: inst) -> str { ret i.ident; }, occ)); constr_args_to_str(fn@(i: inst) -> str { ret *i.ident; }, occ));
for (*occs).each {|pd| for (*occs).each {|pd|
log(debug, log(debug,
"match_args: candidate " + pred_args_to_str(pd)); "match_args: candidate " + pred_args_to_str(pd));
@ -581,7 +581,7 @@ fn expr_to_constr(tcx: ty::ctxt, e: @expr) -> sp_constr {
fn pred_args_to_str(p: pred_args) -> str { fn pred_args_to_str(p: pred_args) -> str {
"<" + uint::str(p.node.bit_num) + ", " + "<" + uint::str(p.node.bit_num) + ", " +
constr_args_to_str(fn@(i: inst) -> str { ret i.ident; }, p.node.args) constr_args_to_str(fn@(i: inst) -> str { ret *i.ident; }, p.node.args)
+ ">" + ">"
} }
@ -695,7 +695,7 @@ fn insts_to_str(stuff: [constr_arg_general_<inst>]) -> str {
rslt += rslt +=
" " + " " +
alt i { alt i {
carg_ident(p) { p.ident } carg_ident(p) { *p.ident }
carg_base { "*" } carg_base { "*" }
carg_lit(_) { "[lit]" } carg_lit(_) { "[lit]" }
} + " "; } + " ";

View File

@ -138,7 +138,7 @@ fn mk_fn_info(ccx: crate_ctxt,
used_vars: v, used_vars: v,
ignore: ignore}; ignore: ignore};
ccx.fm.insert(id, rslt); ccx.fm.insert(id, rslt);
#debug("%s has %u constraints", name, num_constraints(rslt)); #debug("%s has %u constraints", *name, num_constraints(rslt));
} }

View File

@ -516,7 +516,7 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
fn find_pre_post_state_stmt(fcx: fn_ctxt, pres: prestate, s: @stmt) -> bool { fn find_pre_post_state_stmt(fcx: fn_ctxt, pres: prestate, s: @stmt) -> bool {
let stmt_ann = stmt_to_ann(fcx.ccx, *s); let stmt_ann = stmt_to_ann(fcx.ccx, *s);
#debug["[ %s ]", fcx.name]; #debug["[ %s ]", *fcx.name];
#debug["*At beginning: stmt = %s", stmt_to_str(*s)]; #debug["*At beginning: stmt = %s", stmt_to_str(*s)];
#debug["*prestate = %s", tritv::to_str(stmt_ann.states.prestate)]; #debug["*prestate = %s", tritv::to_str(stmt_ann.states.prestate)];
#debug["*poststate = %s", tritv::to_str(stmt_ann.states.prestate)]; #debug["*poststate = %s", tritv::to_str(stmt_ann.states.prestate)];

View File

@ -237,7 +237,7 @@ type ctxt =
node_type_substs: hashmap<node_id, [t]>, node_type_substs: hashmap<node_id, [t]>,
items: ast_map::map, items: ast_map::map,
intrinsic_ifaces: hashmap<str, (ast::def_id, t)>, intrinsic_ifaces: hashmap<ast::ident, (ast::def_id, t)>,
freevars: freevars::freevar_map, freevars: freevars::freevar_map,
tcache: type_cache, tcache: type_cache,
rcache: creader_cache, rcache: creader_cache,
@ -322,7 +322,7 @@ enum region {
enum bound_region { enum bound_region {
br_self, // The self region for classes, impls br_self, // The self region for classes, impls
br_anon, // The anonymous region parameter for a given function. br_anon, // The anonymous region parameter for a given function.
br_named(str) // A named region parameter. br_named(ast::ident) // A named region parameter.
} }
type opt_region = option<region>; type opt_region = option<region>;
@ -414,7 +414,7 @@ enum type_err {
terr_constr_mismatch(@type_constr, @type_constr), terr_constr_mismatch(@type_constr, @type_constr),
terr_regions_differ(region, region), terr_regions_differ(region, region),
terr_vstores_differ(terr_vstore_kind, vstore, vstore), terr_vstores_differ(terr_vstore_kind, vstore, vstore),
terr_in_field(@type_err, str), terr_in_field(@type_err, ast::ident),
terr_sorts(t, t), terr_sorts(t, t),
terr_self_substs terr_self_substs
} }
@ -516,7 +516,7 @@ fn mk_ctxt(s: session::session, dm: resolve::def_map, amap: ast_map::map,
node_types: @smallintmap::mk(), node_types: @smallintmap::mk(),
node_type_substs: map::int_hash(), node_type_substs: map::int_hash(),
items: amap, items: amap,
intrinsic_ifaces: map::str_hash(), intrinsic_ifaces: map::box_str_hash(),
freevars: freevars, freevars: freevars,
tcache: ast_util::new_def_hash(), tcache: ast_util::new_def_hash(),
rcache: mk_rcache(), rcache: mk_rcache(),
@ -1992,7 +1992,7 @@ fn hash_bound_region(br: bound_region) -> uint {
alt br { // no idea if this is any good alt br { // no idea if this is any good
ty::br_self { 0u } ty::br_self { 0u }
ty::br_anon { 1u } ty::br_anon { 1u }
ty::br_named(str) { str::hash(str) } ty::br_named(str) { str::hash(*str) }
} }
} }
@ -2298,7 +2298,7 @@ fn field_idx(id: ast::ident, fields: [field]) -> option<uint> {
} }
fn get_field(rec_ty: t, id: ast::ident) -> field { fn get_field(rec_ty: t, id: ast::ident) -> field {
alt check vec::find(get_fields(rec_ty), {|f| str::eq(f.ident, id) }) { alt check vec::find(get_fields(rec_ty), {|f| str::eq(*f.ident, *id) }) {
some(f) { f } some(f) { f }
} }
} }
@ -2490,8 +2490,8 @@ fn type_err_to_str(cx: ctxt, err: type_err) -> str {
} }
terr_record_mutability { ret "record elements differ in mutability"; } terr_record_mutability { ret "record elements differ in mutability"; }
terr_record_fields(e_fld, a_fld) { terr_record_fields(e_fld, a_fld) {
ret "expected a record with field `" + e_fld + ret "expected a record with field `" + *e_fld +
"` but found one with field `" + a_fld + "`"; "` but found one with field `" + *a_fld + "`";
} }
terr_arg_count { ret "incorrect number of function parameters"; } terr_arg_count { ret "incorrect number of function parameters"; }
terr_mode_mismatch(e_mode, a_mode) { terr_mode_mismatch(e_mode, a_mode) {
@ -2521,7 +2521,7 @@ fn type_err_to_str(cx: ctxt, err: type_err) -> str {
vstore_to_str(cx, a_vs)); vstore_to_str(cx, a_vs));
} }
terr_in_field(err, fname) { terr_in_field(err, fname) {
ret #fmt("in field `%s`, %s", fname, type_err_to_str(cx, *err)); ret #fmt("in field `%s`, %s", *fname, type_err_to_str(cx, *err));
} }
terr_sorts(exp, act) { terr_sorts(exp, act) {
ret #fmt("%s vs %s", ty_sort_str(cx, exp), ty_sort_str(cx, act)); ret #fmt("%s vs %s", ty_sort_str(cx, exp), ty_sort_str(cx, act));
@ -2592,7 +2592,7 @@ fn ty_to_def_id(ty: t) -> option<ast::def_id> {
} }
// Enum information // Enum information
type variant_info = @{args: [t], ctor_ty: t, name: str, type variant_info = @{args: [t], ctor_ty: t, name: ast::ident,
id: ast::def_id, disr_val: int}; id: ast::def_id, disr_val: int};
fn substd_enum_variants(cx: ctxt, fn substd_enum_variants(cx: ctxt,
@ -2667,7 +2667,7 @@ fn item_path(cx: ctxt, id: ast::def_id) -> ast_map::path {
*path + [ast_map::path_name(nm)] *path + [ast_map::path_name(nm)]
} }
ast_map::node_dtor(_, _, _, path) { ast_map::node_dtor(_, _, _, path) {
*path + [ast_map::path_name("dtor")] *path + [ast_map::path_name(@"dtor")]
} }
@ -2861,7 +2861,7 @@ fn lookup_class_method_by_name(cx:ctxt, did: ast::def_id, name: ident,
} }
} }
cx.sess.span_fatal(sp, #fmt("Class doesn't have a method \ cx.sess.span_fatal(sp, #fmt("Class doesn't have a method \
named %s", name)); named %s", *name));
} }
else { else {
csearch::get_class_method(cx.sess.cstore, did, name) csearch::get_class_method(cx.sess.cstore, did, name)

View File

@ -260,7 +260,7 @@ fn check_fn(ccx: @crate_ctxt,
vec::iter2(arg_tys, decl.inputs) {|arg_ty, input| vec::iter2(arg_tys, decl.inputs) {|arg_ty, input|
assign(input.id, some(arg_ty)); assign(input.id, some(arg_ty));
#debug["Argument %s is assigned to %s", #debug["Argument %s is assigned to %s",
input.ident, fcx.locals.get(input.id).to_str()]; *input.ident, fcx.locals.get(input.id).to_str()];
} }
// Add explicitly-declared locals. // Add explicitly-declared locals.
@ -284,7 +284,7 @@ fn check_fn(ccx: @crate_ctxt,
if !pat_util::pat_is_variant(fcx.ccx.tcx.def_map, p) { if !pat_util::pat_is_variant(fcx.ccx.tcx.def_map, p) {
assign(p.id, none); assign(p.id, none);
#debug["Pattern binding %s is assigned to %s", #debug["Pattern binding %s is assigned to %s",
path.idents[0], *path.idents[0],
fcx.locals.get(p.id).to_str()]; fcx.locals.get(p.id).to_str()];
} }
_ {} _ {}
@ -443,13 +443,13 @@ impl of region_scope for @fn_ctxt {
fn anon_region() -> result<ty::region, str> { fn anon_region() -> result<ty::region, str> {
result::ok(self.infcx.next_region_var()) result::ok(self.infcx.next_region_var())
} }
fn named_region(id: str) -> result<ty::region, str> { fn named_region(id: ast::ident) -> result<ty::region, str> {
empty_rscope.named_region(id).chain_err { |_e| empty_rscope.named_region(id).chain_err { |_e|
alt self.in_scope_regions.find(ty::br_named(id)) { alt self.in_scope_regions.find(ty::br_named(id)) {
some(r) { result::ok(r) } some(r) { result::ok(r) }
none if id == "blk" { self.block_region() } none if *id == "blk" { self.block_region() }
none { none {
result::err(#fmt["named region `%s` not in scope here", id]) result::err(#fmt["named region `%s` not in scope here", *id])
} }
} }
} }
@ -937,7 +937,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
self_expr: self_ex, self_expr: self_ex,
borrow_scope: op_ex.id, borrow_scope: op_ex.id,
node_id: callee_id, node_id: callee_id,
m_name: opname, m_name: @opname,
self_ty: self_t, self_ty: self_t,
supplied_tps: [], supplied_tps: [],
include_private: false}); include_private: false});
@ -1113,7 +1113,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
ast::expr_vstore(ev, vst) { ast::expr_vstore(ev, vst) {
let typ = alt ev.node { let typ = alt ev.node {
ast::expr_lit(@{node: ast::lit_str(s), span:_}) { ast::expr_lit(@{node: ast::lit_str(s), span:_}) {
let tt = ast_expr_vstore_to_vstore(fcx, ev, str::len(s), vst); let tt = ast_expr_vstore_to_vstore(fcx, ev, str::len(*s), vst);
ty::mk_estr(tcx, tt) ty::mk_estr(tcx, tt)
} }
ast::expr_vec(args, mutbl) { ast::expr_vec(args, mutbl) {
@ -1553,7 +1553,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
for fields_t.each {|f| for fields_t.each {|f|
let mut found = false; let mut found = false;
for base_fields.each {|bf| for base_fields.each {|bf|
if str::eq(f.node.ident, bf.ident) { if str::eq(*f.node.ident, *bf.ident) {
demand::suptype(fcx, f.span, bf.mt.ty, f.node.mt.ty); demand::suptype(fcx, f.span, bf.mt.ty, f.node.mt.ty);
found = true; found = true;
} }
@ -1561,7 +1561,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
if !found { if !found {
tcx.sess.span_fatal(f.span, tcx.sess.span_fatal(f.span,
"unknown field in record update: " + "unknown field in record update: " +
f.node.ident); *f.node.ident);
} }
} }
} }
@ -1645,7 +1645,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
let t_err = fcx.infcx.resolve_type_vars_if_possible(expr_t); let t_err = fcx.infcx.resolve_type_vars_if_possible(expr_t);
let msg = #fmt["attempted access of field %s on type %s, but \ let msg = #fmt["attempted access of field %s on type %s, but \
no public field or method with that name was found", no public field or method with that name was found",
field, ty_to_str(tcx, t_err)]; *field, ty_to_str(tcx, t_err)];
tcx.sess.span_err(expr.span, msg); tcx.sess.span_err(expr.span, msg);
// NB: Adding a bogus type to allow typechecking to continue // NB: Adding a bogus type to allow typechecking to continue
fcx.write_ty(id, fcx.infcx.next_ty_var()); fcx.write_ty(id, fcx.infcx.next_ty_var());
@ -1690,7 +1690,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
self_expr: p, self_expr: p,
borrow_scope: expr.id, borrow_scope: expr.id,
node_id: alloc_id, node_id: alloc_id,
m_name: "alloc", m_name: @"alloc",
self_ty: p_ty, self_ty: p_ty,
supplied_tps: [], supplied_tps: [],
include_private: false}); include_private: false});
@ -2310,7 +2310,7 @@ fn check_bounds_are_used(ccx: @crate_ctxt,
for tps_used.eachi { |i, b| for tps_used.eachi { |i, b|
if !b { if !b {
ccx.tcx.sess.span_err( ccx.tcx.sess.span_err(
span, #fmt["Type parameter %s is unused.", tps[i].ident]); span, #fmt["Type parameter %s is unused.", *tps[i].ident]);
} }
} }
} }
@ -2323,7 +2323,7 @@ fn check_intrinsic_type(ccx: @crate_ctxt, it: @ast::native_item) {
{mode: ast::expl(m), ty: ty} {mode: ast::expl(m), ty: ty}
} }
let tcx = ccx.tcx; let tcx = ccx.tcx;
let (n_tps, inputs, output) = alt it.ident { let (n_tps, inputs, output) = alt *it.ident {
"size_of" | "size_of" |
"pref_align_of" | "min_align_of" { (1u, [], ty::mk_uint(ccx.tcx)) } "pref_align_of" | "min_align_of" { (1u, [], ty::mk_uint(ccx.tcx)) }
"get_tydesc" { (1u, [], ty::mk_nil_ptr(tcx)) } "get_tydesc" { (1u, [], ty::mk_nil_ptr(tcx)) }
@ -2337,8 +2337,8 @@ fn check_intrinsic_type(ccx: @crate_ctxt, it: @ast::native_item) {
"needs_drop" { (1u, [], ty::mk_bool(tcx)) } "needs_drop" { (1u, [], ty::mk_bool(tcx)) }
"visit_ty" { "visit_ty" {
assert ccx.tcx.intrinsic_ifaces.contains_key("ty_visitor"); assert ccx.tcx.intrinsic_ifaces.contains_key(@"ty_visitor");
let (_, visitor_iface) = ccx.tcx.intrinsic_ifaces.get("ty_visitor"); let (_, visitor_iface) = ccx.tcx.intrinsic_ifaces.get(@"ty_visitor");
(1u, [arg(ast::by_ref, visitor_iface)], ty::mk_nil(tcx)) (1u, [arg(ast::by_ref, visitor_iface)], ty::mk_nil(tcx))
} }
"frame_address" { "frame_address" {

View File

@ -191,8 +191,8 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) {
fields", fields",
ex_f_count, f_count]); ex_f_count, f_count]);
} }
fn matches(name: str, f: ty::field) -> bool { fn matches(name: ast::ident, f: ty::field) -> bool {
ret str::eq(name, f.ident); ret str::eq(*name, *f.ident);
} }
for fields.each {|f| for fields.each {|f|
alt vec::find(ex_fields, bind matches(f.ident, _)) { alt vec::find(ex_fields, bind matches(f.ident, _)) {
@ -203,7 +203,7 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) {
tcx.sess.span_fatal(pat.span, tcx.sess.span_fatal(pat.span,
#fmt["mismatched types: did not \ #fmt["mismatched types: did not \
expect a record with a field `%s`", expect a record with a field `%s`",
f.ident]); *f.ident]);
} }
} }
} }

View File

@ -19,7 +19,7 @@ impl methods for lookup {
// Entrypoint: // Entrypoint:
fn method() -> option<method_origin> { fn method() -> option<method_origin> {
#debug["method lookup(m_name=%s, self_ty=%s)", #debug["method lookup(m_name=%s, self_ty=%s)",
self.m_name, self.fcx.infcx.ty_to_str(self.self_ty)]; *self.m_name, self.fcx.infcx.ty_to_str(self.self_ty)];
// First, see whether this is an interface-bounded parameter // First, see whether this is an interface-bounded parameter
let pass1 = alt ty::get(self.self_ty).struct { let pass1 = alt ty::get(self.self_ty).struct {

View File

@ -65,7 +65,7 @@ fn visit_pat(p: @ast::pat, &&rcx: rcx, v: rvt) {
alt p.node { alt p.node {
ast::pat_ident(path, _) ast::pat_ident(path, _)
if !pat_util::pat_is_variant(fcx.ccx.tcx.def_map, p) { if !pat_util::pat_is_variant(fcx.ccx.tcx.def_map, p) {
#debug["visit_pat binding=%s", path.idents[0]]; #debug["visit_pat binding=%s", *path.idents[0]];
visit_node(p.id, p.span, rcx); visit_node(p.id, p.span, rcx);
} }
_ {} _ {}

View File

@ -29,7 +29,7 @@ fn collect_item_types(ccx: @crate_ctxt, crate: @ast::crate) {
// there ought to be a better approach. Attributes? // there ought to be a better approach. Attributes?
for crate.node.module.items.each {|crate_item| for crate.node.module.items.each {|crate_item|
if crate_item.ident == "intrinsic" { if *crate_item.ident == "intrinsic" {
alt crate_item.node { alt crate_item.node {
ast::item_mod(m) { ast::item_mod(m) {
for m.items.each {|intrinsic_item| for m.items.each {|intrinsic_item|
@ -170,7 +170,7 @@ fn compare_impl_method(tcx: ty::ctxt, sp: span,
self_ty: ty::t) { self_ty: ty::t) {
if impl_m.tps != if_m.tps { if impl_m.tps != if_m.tps {
tcx.sess.span_err(sp, "method `" + if_m.ident + tcx.sess.span_err(sp, "method `" + *if_m.ident +
"` has an incompatible set of type parameters"); "` has an incompatible set of type parameters");
ret; ret;
} }
@ -178,7 +178,7 @@ fn compare_impl_method(tcx: ty::ctxt, sp: span,
if vec::len(impl_m.fty.inputs) != vec::len(if_m.fty.inputs) { if vec::len(impl_m.fty.inputs) != vec::len(if_m.fty.inputs) {
tcx.sess.span_err(sp,#fmt["method `%s` has %u parameters \ tcx.sess.span_err(sp,#fmt["method `%s` has %u parameters \
but the iface has %u", but the iface has %u",
if_m.ident, *if_m.ident,
vec::len(impl_m.fty.inputs), vec::len(impl_m.fty.inputs),
vec::len(if_m.fty.inputs)]); vec::len(if_m.fty.inputs)]);
ret; ret;
@ -211,7 +211,7 @@ fn compare_impl_method(tcx: ty::ctxt, sp: span,
}; };
require_same_types( require_same_types(
tcx, sp, impl_fty, if_fty, tcx, sp, impl_fty, if_fty,
{|| "method `" + if_m.ident + "` has an incompatible type"}); {|| "method `" + *if_m.ident + "` has an incompatible type"});
ret; ret;
// Replaces bound references to the self region with `with_r`. // Replaces bound references to the self region with `with_r`.
@ -242,7 +242,7 @@ fn check_methods_against_iface(ccx: @crate_ctxt,
ccx.tcx.sess.span_err( ccx.tcx.sess.span_err(
span, #fmt["method `%s`'s purity \ span, #fmt["method `%s`'s purity \
not match the iface method's \ not match the iface method's \
purity", m.ident]); purity", *m.ident]);
} }
compare_impl_method( compare_impl_method(
ccx.tcx, span, m, vec::len(tps), ccx.tcx, span, m, vec::len(tps),
@ -251,7 +251,7 @@ fn check_methods_against_iface(ccx: @crate_ctxt,
none { none {
tcx.sess.span_err( tcx.sess.span_err(
a_ifacety.path.span, a_ifacety.path.span,
#fmt["missing method `%s`", if_m.ident]); #fmt["missing method `%s`", *if_m.ident]);
} }
} // alt } // alt
} // |if_m| } // |if_m|
@ -511,7 +511,7 @@ fn ty_of_item(ccx: @crate_ctxt, it: @ast::item)
rp: ast::rp_none, // functions do not have a self rp: ast::rp_none, // functions do not have a self
ty: ty::mk_fn(ccx.tcx, tofd)}; ty: ty::mk_fn(ccx.tcx, tofd)};
#debug["type of %s (id %d) is %s", #debug["type of %s (id %d) is %s",
it.ident, it.id, ty_to_str(tcx, tpt.ty)]; *it.ident, it.id, ty_to_str(tcx, tpt.ty)];
ccx.tcx.tcache.insert(local_def(it.id), tpt); ccx.tcx.tcache.insert(local_def(it.id), tpt);
ret tpt; ret tpt;
} }

View File

@ -2,7 +2,7 @@ import result::result;
iface region_scope { iface region_scope {
fn anon_region() -> result<ty::region, str>; fn anon_region() -> result<ty::region, str>;
fn named_region(id: str) -> result<ty::region, str>; fn named_region(id: ast::ident) -> result<ty::region, str>;
} }
enum empty_rscope { empty_rscope } enum empty_rscope { empty_rscope }
@ -10,8 +10,8 @@ impl of region_scope for empty_rscope {
fn anon_region() -> result<ty::region, str> { fn anon_region() -> result<ty::region, str> {
result::err("region types are not allowed here") result::err("region types are not allowed here")
} }
fn named_region(id: str) -> result<ty::region, str> { fn named_region(id: ast::ident) -> result<ty::region, str> {
if id == "static" { result::ok(ty::re_static) } if *id == "static" { result::ok(ty::re_static) }
else { result::err("only the static region is allowed here") } else { result::err("only the static region is allowed here") }
} }
} }
@ -27,9 +27,9 @@ impl of region_scope for type_rscope {
} }
} }
} }
fn named_region(id: str) -> result<ty::region, str> { fn named_region(id: ast::ident) -> result<ty::region, str> {
empty_rscope.named_region(id).chain_err { |_e| empty_rscope.named_region(id).chain_err { |_e|
if id == "self" { self.anon_region() } if *id == "self" { self.anon_region() }
else { else {
result::err("named regions other than `self` are not \ result::err("named regions other than `self` are not \
allowed as part of a type declaration") allowed as part of a type declaration")
@ -47,7 +47,7 @@ impl of region_scope for @anon_rscope {
fn anon_region() -> result<ty::region, str> { fn anon_region() -> result<ty::region, str> {
result::ok(self.anon) result::ok(self.anon)
} }
fn named_region(id: str) -> result<ty::region, str> { fn named_region(id: ast::ident) -> result<ty::region, str> {
self.base.named_region(id) self.base.named_region(id)
} }
} }
@ -61,7 +61,7 @@ impl of region_scope for @binding_rscope {
fn anon_region() -> result<ty::region, str> { fn anon_region() -> result<ty::region, str> {
result::ok(ty::re_bound(ty::br_anon)) result::ok(ty::re_bound(ty::br_anon))
} }
fn named_region(id: str) -> result<ty::region, str> { fn named_region(id: ast::ident) -> result<ty::region, str> {
self.base.named_region(id).chain_err {|_e| self.base.named_region(id).chain_err {|_e|
result::ok(ty::re_bound(ty::br_named(id))) result::ok(ty::re_bound(ty::br_named(id)))
} }

View File

@ -72,7 +72,7 @@ fn local_rhs_span(l: @ast::local, def: span) -> span {
fn is_main_name(path: syntax::ast_map::path) -> bool { fn is_main_name(path: syntax::ast_map::path) -> bool {
// FIXME: path should be a constrained type, so we know // FIXME: path should be a constrained type, so we know
// the call to last doesn't fail // the call to last doesn't fail
vec::last(path) == syntax::ast_map::path_name("main") vec::last(path) == syntax::ast_map::path_name(@"main")
} }
// //

View File

@ -21,7 +21,7 @@ import driver::session::session;
fn bound_region_to_str(cx: ctxt, br: bound_region) -> str { fn bound_region_to_str(cx: ctxt, br: bound_region) -> str {
alt br { alt br {
br_anon { "&" } br_anon { "&" }
br_named(str) { #fmt["&%s", str] } br_named(str) { #fmt["&%s", *str] }
br_self if cx.sess.ppregions() { "&<self>" } br_self if cx.sess.ppregions() { "&<self>" }
br_self { "&self" } br_self { "&self" }
} }
@ -130,7 +130,7 @@ fn ty_to_str(cx: ctxt, typ: t) -> str {
_ {purity_to_str(purity) + " "} _ {purity_to_str(purity) + " "}
}; };
s += proto_to_str(proto); s += proto_to_str(proto);
alt ident { some(i) { s += " "; s += i; } _ { } } alt ident { some(i) { s += " "; s += *i; } _ { } }
s += "("; s += "(";
let mut strs = []; let mut strs = [];
for inputs.each {|a| strs += [fn_input_to_str(cx, a)]; } for inputs.each {|a| strs += [fn_input_to_str(cx, a)]; }
@ -152,7 +152,7 @@ fn ty_to_str(cx: ctxt, typ: t) -> str {
m.fty.output, m.fty.ret_style, m.fty.constraints) + ";"; m.fty.output, m.fty.ret_style, m.fty.constraints) + ";";
} }
fn field_to_str(cx: ctxt, f: field) -> str { fn field_to_str(cx: ctxt, f: field) -> str {
ret f.ident + ": " + mt_to_str(cx, f.mt); ret *f.ident + ": " + mt_to_str(cx, f.mt);
} }
// if there is an id, print that instead of the structural type: // if there is an id, print that instead of the structural type:

View File

@ -67,7 +67,8 @@ fn parse_crate(attrs: [ast::attribute]) -> crate_attrs {
let link_metas = attr::find_linkage_metas(attrs); let link_metas = attr::find_linkage_metas(attrs);
{ {
name: attr::last_meta_item_value_str_by_name(link_metas, "name") name: attr::last_meta_item_value_str_by_name(
link_metas, "name").map({|x|*x})
} }
} }
@ -98,7 +99,7 @@ fn should_not_extract_crate_name_if_no_name_value_in_link_attribute() {
fn parse_desc(attrs: [ast::attribute]) -> option<str> { fn parse_desc(attrs: [ast::attribute]) -> option<str> {
alt doc_meta(attrs) { alt doc_meta(attrs) {
some(meta) { some(meta) {
attr::get_meta_item_value_str(meta) attr::get_meta_item_value_str(meta).map({|x|*x})
} }
none { none } none { none }
} }

View File

@ -151,7 +151,7 @@ fn fold_enum(
}, _) { }, _) {
let ast_variant = option::get( let ast_variant = option::get(
vec::find(ast_variants) {|v| vec::find(ast_variants) {|v|
v.node.name == variant.name *v.node.name == variant.name
}); });
attr_parser::parse_desc(ast_variant.node.attrs) attr_parser::parse_desc(ast_variant.node.attrs)
@ -207,14 +207,14 @@ fn merge_method_attrs(
node: ast::item_iface(_, _, methods), _ node: ast::item_iface(_, _, methods), _
}, _) { }, _) {
par::seqmap(methods) {|method| par::seqmap(methods) {|method|
(method.ident, attr_parser::parse_desc(method.attrs)) (*method.ident, attr_parser::parse_desc(method.attrs))
} }
} }
ast_map::node_item(@{ ast_map::node_item(@{
node: ast::item_impl(_, _, _, _, methods), _ node: ast::item_impl(_, _, _, _, methods), _
}, _) { }, _) {
par::seqmap(methods) {|method| par::seqmap(methods) {|method|
(method.ident, attr_parser::parse_desc(method.attrs)) (*method.ident, attr_parser::parse_desc(method.attrs))
} }
} }
_ { fail "unexpected item" } _ { fail "unexpected item" }

View File

@ -33,14 +33,14 @@ fn top_moddoc_from_crate(
crate: @ast::crate, crate: @ast::crate,
default_name: str default_name: str
) -> doc::moddoc { ) -> doc::moddoc {
moddoc_from_mod(mk_itemdoc(ast::crate_node_id, default_name), moddoc_from_mod(mk_itemdoc(ast::crate_node_id, @default_name),
crate.node.module) crate.node.module)
} }
fn mk_itemdoc(id: ast::node_id, name: ast::ident) -> doc::itemdoc { fn mk_itemdoc(id: ast::node_id, name: ast::ident) -> doc::itemdoc {
{ {
id: id, id: id,
name: name, name: *name,
path: [], path: [],
brief: none, brief: none,
desc: none, desc: none,
@ -169,7 +169,7 @@ fn variantdocs_from_variants(
fn variantdoc_from_variant(variant: ast::variant) -> doc::variantdoc { fn variantdoc_from_variant(variant: ast::variant) -> doc::variantdoc {
{ {
name: variant.node.name, name: *variant.node.name,
desc: none, desc: none,
sig: none sig: none
} }
@ -210,7 +210,7 @@ fn ifacedoc_from_iface(
item: itemdoc, item: itemdoc,
methods: par::seqmap(methods) {|method| methods: par::seqmap(methods) {|method|
{ {
name: method.ident, name: *method.ident,
brief: none, brief: none,
desc: none, desc: none,
sections: [], sections: [],
@ -242,7 +242,7 @@ fn impldoc_from_impl(
self_ty: none, self_ty: none,
methods: par::seqmap(methods) {|method| methods: par::seqmap(methods) {|method|
{ {
name: method.ident, name: *method.ident,
brief: none, brief: none,
desc: none, desc: none,
sections: [], sections: [],

View File

@ -114,7 +114,7 @@ fn is_exported_from_mod(
ast_map::node_item(item, _) { ast_map::node_item(item, _) {
alt item.node { alt item.node {
ast::item_mod(m) { ast::item_mod(m) {
ast_util::is_exported(item_name, m) ast_util::is_exported(@item_name, m)
} }
_ { _ {
fail "is_exported_from_mod: not a mod"; fail "is_exported_from_mod: not a mod";
@ -131,7 +131,7 @@ fn is_exported_from_crate(
item_name: str item_name: str
) -> bool { ) -> bool {
astsrv::exec(srv) {|ctxt| astsrv::exec(srv) {|ctxt|
ast_util::is_exported(item_name, ctxt.ast.node.module) ast_util::is_exported(@item_name, ctxt.ast.node.module)
} }
} }

View File

@ -187,7 +187,7 @@ fn build_reexport_path_map(srv: astsrv::srv, -def_map: def_map) -> path_map {
if !def.reexp { cont; } if !def.reexp { cont; }
alt def_map.find(def.id) { alt def_map.find(def.id) {
some(itemtag) { some(itemtag) {
reexportdocs += [(name, itemtag)]; reexportdocs += [(*name, itemtag)];
} }
_ {} _ {}
} }
@ -231,9 +231,9 @@ fn find_reexport_impl_docs(
some(ast_map::node_item(item, path)) { some(ast_map::node_item(item, path)) {
let path = ast_map::path_to_str(*path); let path = ast_map::path_to_str(*path);
if str::is_empty(path) { if str::is_empty(path) {
item.ident *item.ident
} else { } else {
path + "::" + item.ident path + "::" + *item.ident
} }
} }
_ { _ {
@ -241,7 +241,7 @@ fn find_reexport_impl_docs(
"" ""
} }
}; };
let ident = i.ident; let ident = *i.ident;
let doc = alt check def_map.find(i.did) { let doc = alt check def_map.find(i.did) {
some(doc) { doc } some(doc) { doc }
}; };

View File

@ -116,7 +116,7 @@ fn fold_enum(
}, _) { }, _) {
let ast_variant = option::get( let ast_variant = option::get(
vec::find(ast_variants) {|v| vec::find(ast_variants) {|v|
v.node.name == variant.name *v.node.name == variant.name
}); });
pprust::variant_to_str(ast_variant) pprust::variant_to_str(ast_variant)
@ -151,7 +151,7 @@ fn fold_res(
ast_map::node_item(@{ ast_map::node_item(@{
node: ast::item_res(decl, tys, _, _, _, rp), _ node: ast::item_res(decl, tys, _, _, _, rp), _
}, _) { }, _) {
pprust::res_to_str(decl, doc.name(), tys, rp) pprust::res_to_str(decl, @doc.name(), tys, rp)
} }
} }
}) })
@ -200,7 +200,7 @@ fn get_method_sig(
node: ast::item_iface(_, _, methods), _ node: ast::item_iface(_, _, methods), _
}, _) { }, _) {
alt check vec::find(methods) {|method| alt check vec::find(methods) {|method|
method.ident == method_name *method.ident == method_name
} { } {
some(method) { some(method) {
some(pprust::fun_to_str( some(pprust::fun_to_str(
@ -215,7 +215,7 @@ fn get_method_sig(
node: ast::item_impl(_, _, _, _, methods), _ node: ast::item_impl(_, _, _, _, methods), _
}, _) { }, _) {
alt check vec::find(methods) {|method| alt check vec::find(methods) {|method|
method.ident == method_name *method.ident == method_name
} { } {
some(method) { some(method) {
some(pprust::fun_to_str( some(pprust::fun_to_str(
@ -307,7 +307,7 @@ fn fold_type(
}, _) { }, _) {
some(#fmt( some(#fmt(
"type %s%s = %s", "type %s%s = %s",
ident, *ident,
pprust::typarams_to_str(params), pprust::typarams_to_str(params),
pprust::ty_to_str(ty) pprust::ty_to_str(ty)
)) ))