Convert rest of the AST to istrs. Issue #855
This commit is contained in:
parent
f603e912ee
commit
f09ef6ec66
16 changed files with 66 additions and 48 deletions
|
@ -324,12 +324,12 @@ fn build_link_meta(sess: &session::session, c: &ast::crate, output: &istr,
|
|||
for meta: @ast::meta_item in linkage_metas {
|
||||
if attr::get_meta_item_name(meta) == ~"name" {
|
||||
alt attr::get_meta_item_value_str(meta) {
|
||||
some(v) { name = some(istr::from_estr(v)); }
|
||||
some(v) { name = some(v); }
|
||||
none. { cmh_items += [meta]; }
|
||||
}
|
||||
} else if attr::get_meta_item_name(meta) == ~"vers" {
|
||||
alt attr::get_meta_item_value_str(meta) {
|
||||
some(v) { vers = some(istr::from_estr(v)); }
|
||||
some(v) { vers = some(v); }
|
||||
none. { cmh_items += [meta]; }
|
||||
}
|
||||
} else { cmh_items += [meta]; }
|
||||
|
|
|
@ -81,7 +81,7 @@ 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
|
||||
// containing a string, otherwise none
|
||||
fn get_meta_item_value_str(meta: &@ast::meta_item) -> option::t<str> {
|
||||
fn get_meta_item_value_str(meta: &@ast::meta_item) -> option::t<istr> {
|
||||
alt meta.node {
|
||||
ast::meta_name_value(_, v) {
|
||||
alt v.node {
|
||||
|
@ -196,7 +196,7 @@ fn span<@T>(item: &T) -> ast::spanned<T> {
|
|||
}
|
||||
|
||||
fn mk_name_value_item_str(name: ast::ident, value: str) -> @ast::meta_item {
|
||||
let value_lit = span(ast::lit_str(value, ast::sk_rc));
|
||||
let value_lit = span(ast::lit_str(istr::from_estr(value), ast::sk_rc));
|
||||
ret mk_name_value_item(name, value_lit);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
import std::option;
|
||||
import std::vec;
|
||||
import std::istr;
|
||||
import syntax::ast;
|
||||
import syntax::ast_util;
|
||||
import syntax::ast_util::*;
|
||||
|
@ -249,7 +250,8 @@ fn mk_test_desc_rec(cx: &test_ctxt, test: test) -> @ast::expr {
|
|||
log #fmt["encoding %s", ast_util::path_name_i(path)];
|
||||
|
||||
let name_lit: ast::lit =
|
||||
nospan(ast::lit_str(ast_util::path_name_i(path), ast::sk_rc));
|
||||
nospan(ast::lit_str(
|
||||
istr::from_estr(ast_util::path_name_i(path)), ast::sk_rc));
|
||||
let name_expr: ast::expr =
|
||||
{id: cx.next_node_id(),
|
||||
node: ast::expr_lit(@name_lit),
|
||||
|
|
|
@ -68,11 +68,14 @@ fn visit_item(e: env, i: &@ast::item) {
|
|||
ret;
|
||||
}
|
||||
let cstore = e.sess.get_cstore();
|
||||
if !cstore::add_used_library(cstore, m.native_name) { ret; }
|
||||
if !cstore::add_used_library(cstore,
|
||||
istr::to_estr(m.native_name)) { ret; }
|
||||
for a: ast::attribute in
|
||||
attr::find_attrs_by_name(i.attrs, ~"link_args") {
|
||||
alt attr::get_meta_item_value_str(attr::attr_meta(a)) {
|
||||
some(linkarg) { cstore::add_used_link_args(cstore, linkarg); }
|
||||
some(linkarg) {
|
||||
cstore::add_used_link_args(cstore, istr::to_estr(linkarg));
|
||||
}
|
||||
none. {/* fallthrough */ }
|
||||
}
|
||||
}
|
||||
|
@ -133,19 +136,21 @@ fn find_library_crate(sess: &session::session, ident: &ast::ident,
|
|||
some(i) {
|
||||
alt attr::get_meta_item_value_str(i) {
|
||||
some(n) { n }
|
||||
_ { istr::to_estr(ident) }
|
||||
_ { ident }
|
||||
}
|
||||
}
|
||||
none. { istr::to_estr(ident) }
|
||||
none. { ident }
|
||||
}
|
||||
};
|
||||
|
||||
let nn = default_native_lib_naming(sess, sess.get_opts().static);
|
||||
let x =
|
||||
find_library_crate_aux(nn, crate_name, metas, library_search_paths);
|
||||
find_library_crate_aux(nn, istr::to_estr(crate_name),
|
||||
metas, library_search_paths);
|
||||
if x != none || sess.get_opts().static { ret x; }
|
||||
let nn2 = default_native_lib_naming(sess, true);
|
||||
ret find_library_crate_aux(nn2, crate_name, metas, library_search_paths);
|
||||
ret find_library_crate_aux(nn2, istr::to_estr(crate_name),
|
||||
metas, library_search_paths);
|
||||
}
|
||||
|
||||
fn find_library_crate_aux(nn: &{prefix: str, suffix: str}, crate_name: str,
|
||||
|
|
|
@ -465,7 +465,7 @@ fn encode_meta_item(ebml_w: &ebml::writer, mi: &meta_item) {
|
|||
ebml_w.writer.write(istr::bytes(name));
|
||||
ebml::end_tag(ebml_w);
|
||||
ebml::start_tag(ebml_w, tag_meta_item_value);
|
||||
ebml_w.writer.write(str::bytes(value));
|
||||
ebml_w.writer.write(istr::bytes(value));
|
||||
ebml::end_tag(ebml_w);
|
||||
ebml::end_tag(ebml_w);
|
||||
}
|
||||
|
|
|
@ -2523,16 +2523,16 @@ fn trans_crate_lit(cx: &@crate_ctxt, lit: &ast::lit) -> ValueRef {
|
|||
}
|
||||
ret C_integral(t, i as uint, s);
|
||||
}
|
||||
ast::lit_float(fs) { ret C_float(istr::from_estr(fs)); }
|
||||
ast::lit_float(fs) { ret C_float(fs); }
|
||||
ast::lit_mach_float(tm, s) {
|
||||
let t = T_float();
|
||||
alt tm { ast::ty_f32. { t = T_f32(); } ast::ty_f64. { t = T_f64(); } }
|
||||
ret C_floating(istr::from_estr(s), t);
|
||||
ret C_floating(s, t);
|
||||
}
|
||||
ast::lit_char(c) { ret C_integral(T_char(), c as uint, False); }
|
||||
ast::lit_bool(b) { ret C_bool(b); }
|
||||
ast::lit_nil. { ret C_nil(); }
|
||||
ast::lit_str(s, ast::sk_rc.) { ret C_str(cx, istr::from_estr(s)); }
|
||||
ast::lit_str(s, ast::sk_rc.) { ret C_str(cx, s); }
|
||||
ast::lit_str(s, ast::sk_unique.) {
|
||||
cx.sess.span_unimpl(lit.span, "unique string in this context");
|
||||
}
|
||||
|
@ -2541,7 +2541,9 @@ fn trans_crate_lit(cx: &@crate_ctxt, lit: &ast::lit) -> ValueRef {
|
|||
|
||||
fn trans_lit(cx: &@block_ctxt, lit: &ast::lit) -> result {
|
||||
alt lit.node {
|
||||
ast::lit_str(s, ast::sk_unique.) { ret trans_lit_istr(cx, s); }
|
||||
ast::lit_str(s, ast::sk_unique.) {
|
||||
ret trans_lit_istr(cx, istr::to_estr(s));
|
||||
}
|
||||
_ { ret rslt(cx, trans_crate_lit(bcx_ccx(cx), lit)); }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -237,7 +237,7 @@ tag blk_sort {
|
|||
type mac = spanned<mac_>;
|
||||
|
||||
tag mac_ {
|
||||
mac_invoc(path, @expr, option::t<str>);
|
||||
mac_invoc(path, @expr, option::t<istr>);
|
||||
mac_embed_type(@ty);
|
||||
mac_embed_block(blk);
|
||||
mac_ellipsis;
|
||||
|
@ -246,13 +246,13 @@ tag mac_ {
|
|||
type lit = spanned<lit_>;
|
||||
|
||||
tag lit_ {
|
||||
lit_str(str, seq_kind);
|
||||
lit_str(istr, seq_kind);
|
||||
lit_char(char);
|
||||
lit_int(int);
|
||||
lit_uint(uint);
|
||||
lit_mach_int(ty_mach, int);
|
||||
lit_float(str);
|
||||
lit_mach_float(ty_mach, str);
|
||||
lit_float(istr);
|
||||
lit_mach_float(ty_mach, istr);
|
||||
lit_nil;
|
||||
lit_bool(bool);
|
||||
}
|
||||
|
@ -421,7 +421,7 @@ tag native_abi {
|
|||
}
|
||||
|
||||
type native_mod =
|
||||
{native_name: str,
|
||||
{native_name: istr,
|
||||
abi: native_abi,
|
||||
view_items: [@view_item],
|
||||
items: [@native_item]};
|
||||
|
@ -494,7 +494,7 @@ type native_item =
|
|||
|
||||
tag native_item_ {
|
||||
native_item_ty;
|
||||
native_item_fn(option::t<str>, fn_decl, [ty_param]);
|
||||
native_item_fn(option::t<istr>, fn_decl, [ty_param]);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -8,10 +8,10 @@ import std::map::new_str_hash;
|
|||
import codemap;
|
||||
|
||||
type syntax_expander =
|
||||
fn(&ext_ctxt, span, @ast::expr, option::t<str>) -> @ast::expr;
|
||||
fn(&ext_ctxt, span, @ast::expr, &option::t<istr>) -> @ast::expr;
|
||||
type macro_def = {ident: str, ext: syntax_extension};
|
||||
type macro_definer =
|
||||
fn(&ext_ctxt, span, @ast::expr, option::t<str>) -> macro_def;
|
||||
fn(&ext_ctxt, span, @ast::expr, &option::t<istr>) -> macro_def;
|
||||
|
||||
tag syntax_extension {
|
||||
normal(syntax_expander);
|
||||
|
@ -100,7 +100,7 @@ fn expr_to_str(cx: &ext_ctxt, expr: @ast::expr, error: str) -> str {
|
|||
alt expr.node {
|
||||
ast::expr_lit(l) {
|
||||
alt l.node {
|
||||
ast::lit_str(s, _) { ret s; }
|
||||
ast::lit_str(s, _) { ret istr::to_estr(s); }
|
||||
_ { cx.span_fatal(l.span, error); }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ import base::*;
|
|||
import syntax::ast;
|
||||
|
||||
fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @ast::expr,
|
||||
_body: option::t<str>) -> @ast::expr {
|
||||
_body: &option::t<istr>) -> @ast::expr {
|
||||
let args: [@ast::expr] =
|
||||
alt arg.node {
|
||||
ast::expr_vec(elts, _) { elts }
|
||||
|
|
|
@ -12,7 +12,7 @@ import base::*;
|
|||
export expand_syntax_ext;
|
||||
|
||||
fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @ast::expr,
|
||||
_body: option::t<str>) -> @ast::expr {
|
||||
_body: &option::t<istr>) -> @ast::expr {
|
||||
let args: [@ast::expr] =
|
||||
alt arg.node {
|
||||
ast::expr_vec(elts, _) { elts }
|
||||
|
@ -36,7 +36,7 @@ fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @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, ast::sk_rc));
|
||||
ret make_new_lit(cx, sp, ast::lit_str(istr::from_estr(s), ast::sk_rc));
|
||||
}
|
||||
//
|
||||
// Local Variables:
|
||||
|
|
|
@ -17,7 +17,7 @@ import codemap::span;
|
|||
export expand_syntax_ext;
|
||||
|
||||
fn expand_syntax_ext(cx: &ext_ctxt, sp: span, arg: @ast::expr,
|
||||
_body: option::t<str>) -> @ast::expr {
|
||||
_body: &option::t<istr>) -> @ast::expr {
|
||||
let args: [@ast::expr] =
|
||||
alt arg.node {
|
||||
ast::expr_vec(elts, _) { elts }
|
||||
|
@ -52,7 +52,7 @@ fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: &[piece],
|
|||
ret @{id: cx.next_id(), node: ast::expr_lit(sp_lit), span: sp};
|
||||
}
|
||||
fn make_new_str(cx: &ext_ctxt, sp: span, s: str) -> @ast::expr {
|
||||
let lit = ast::lit_str(s, ast::sk_rc);
|
||||
let lit = ast::lit_str(istr::from_estr(s), ast::sk_rc);
|
||||
ret make_new_lit(cx, sp, lit);
|
||||
}
|
||||
fn make_new_int(cx: &ext_ctxt, sp: span, i: int) -> @ast::expr {
|
||||
|
|
|
@ -5,7 +5,7 @@ import base::*;
|
|||
import syntax::ast;
|
||||
|
||||
fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @ast::expr,
|
||||
_body: option::t<str>) -> @ast::expr {
|
||||
_body: &option::t<istr>) -> @ast::expr {
|
||||
let args: [@ast::expr] =
|
||||
alt arg.node {
|
||||
ast::expr_vec(elts, _) { elts }
|
||||
|
@ -18,8 +18,8 @@ fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @ast::expr,
|
|||
}
|
||||
|
||||
ret make_new_lit(cx, sp,
|
||||
ast::lit_str(istr::to_estr(expr_to_ident(cx, args[0u],
|
||||
"expected an ident")),
|
||||
ast::lit_str(expr_to_ident(cx, args[0u],
|
||||
"expected an ident"),
|
||||
ast::sk_rc));
|
||||
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import syntax::ast;
|
|||
import std::istr;
|
||||
|
||||
fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @ast::expr,
|
||||
_body: option::t<str>) -> @ast::expr {
|
||||
_body: &option::t<istr>) -> @ast::expr {
|
||||
|
||||
cx.print_backtrace();
|
||||
std::io::stdout().write_line(
|
||||
|
|
|
@ -688,7 +688,7 @@ fn p_t_s_r_actual_vector(cx: &ext_ctxt, elts: [@expr], _repeat_after: bool,
|
|||
}
|
||||
|
||||
fn add_new_extension(cx: &ext_ctxt, sp: span, arg: @expr,
|
||||
_body: option::t<str>) -> base::macro_def {
|
||||
_body: &option::t<istr>) -> base::macro_def {
|
||||
let args: [@ast::expr] =
|
||||
alt arg.node {
|
||||
ast::expr_vec(elts, _) { elts }
|
||||
|
@ -768,7 +768,8 @@ fn add_new_extension(cx: &ext_ctxt, sp: span, arg: @expr,
|
|||
ext: normal(ext)};
|
||||
|
||||
fn generic_extension(cx: &ext_ctxt, sp: span, arg: @expr,
|
||||
_body: option::t<str>, clauses: [@clause]) -> @expr {
|
||||
_body: &option::t<istr>,
|
||||
clauses: [@clause]) -> @expr {
|
||||
for c: @clause in clauses {
|
||||
alt use_selectors_to_bind(c.params, arg) {
|
||||
some(bindings) { ret transcribe(cx, bindings, c.body) }
|
||||
|
|
|
@ -696,7 +696,7 @@ fn parse_lit(p: &parser) -> ast::lit {
|
|||
token::LIT_UINT(u) { p.bump(); lit = ast::lit_uint(u); }
|
||||
token::LIT_FLOAT(s) {
|
||||
p.bump();
|
||||
lit = ast::lit_float(p.get_str(s));
|
||||
lit = ast::lit_float(istr::from_estr(p.get_str(s)));
|
||||
}
|
||||
token::LIT_MACH_INT(tm, i) {
|
||||
p.bump();
|
||||
|
@ -704,12 +704,12 @@ fn parse_lit(p: &parser) -> ast::lit {
|
|||
}
|
||||
token::LIT_MACH_FLOAT(tm, s) {
|
||||
p.bump();
|
||||
lit = ast::lit_mach_float(tm, p.get_str(s));
|
||||
lit = ast::lit_mach_float(tm, istr::from_estr(p.get_str(s)));
|
||||
}
|
||||
token::LIT_CHAR(c) { p.bump(); lit = ast::lit_char(c); }
|
||||
token::LIT_STR(s) {
|
||||
p.bump();
|
||||
lit = ast::lit_str(p.get_str(s), ast::sk_rc);
|
||||
lit = ast::lit_str(istr::from_estr(p.get_str(s)), ast::sk_rc);
|
||||
}
|
||||
token::LPAREN. {
|
||||
p.bump();
|
||||
|
@ -896,7 +896,8 @@ fn parse_bottom_expr(p: &parser) -> @ast::expr {
|
|||
let sp = p.get_span();
|
||||
p.bump();
|
||||
let lit =
|
||||
@{node: ast::lit_str(p.get_str(s), ast::sk_unique),
|
||||
@{node: ast::lit_str(istr::from_estr(p.get_str(s)),
|
||||
ast::sk_unique),
|
||||
span: sp};
|
||||
ex = ast::expr_lit(lit);
|
||||
}
|
||||
|
@ -1971,7 +1972,10 @@ fn parse_item_native_fn(p: &parser, attrs: &[ast::attribute]) ->
|
|||
let t = parse_fn_header(p);
|
||||
let decl = parse_fn_decl(p, ast::impure_fn, ast::il_normal);
|
||||
let link_name = none;
|
||||
if p.peek() == token::EQ { p.bump(); link_name = some(parse_str(p)); }
|
||||
if p.peek() == token::EQ {
|
||||
p.bump();
|
||||
link_name = some(istr::from_estr(parse_str(p)));
|
||||
}
|
||||
let hi = p.get_hi_pos();
|
||||
expect(p, token::SEMI);
|
||||
ret @{ident: t.ident,
|
||||
|
@ -2006,7 +2010,7 @@ fn parse_native_mod_items(p: &parser, native_name: &str,
|
|||
initial_attrs = [];
|
||||
items += [parse_native_item(p, attrs)];
|
||||
}
|
||||
ret {native_name: native_name,
|
||||
ret {native_name: istr::from_estr(native_name),
|
||||
abi: abi,
|
||||
view_items: view_items,
|
||||
items: items};
|
||||
|
|
|
@ -371,7 +371,11 @@ fn print_native_item(s: &ps, item: &@ast::native_item) {
|
|||
decl.constraints);
|
||||
alt lname {
|
||||
none. { }
|
||||
some(ss) { space(s.s); word_space(s, "="); print_string(s, ss); }
|
||||
some(ss) {
|
||||
space(s.s);
|
||||
word_space(s, "=");
|
||||
print_string(s, istr::to_estr(ss));
|
||||
}
|
||||
}
|
||||
end(s); // end head-ibox
|
||||
word(s.s, ";");
|
||||
|
@ -426,9 +430,9 @@ fn print_item(s: &ps, item: &@ast::item) {
|
|||
}
|
||||
word_nbsp(s, "mod");
|
||||
word_nbsp(s, istr::to_estr(item.ident));
|
||||
if !str::eq(nmod.native_name, istr::to_estr(item.ident)) {
|
||||
if !istr::eq(nmod.native_name, item.ident) {
|
||||
word_space(s, "=");
|
||||
print_string(s, nmod.native_name);
|
||||
print_string(s, istr::to_estr(nmod.native_name));
|
||||
nbsp(s);
|
||||
}
|
||||
bopen(s);
|
||||
|
@ -1505,7 +1509,7 @@ fn print_literal(s: &ps, lit: &@ast::lit) {
|
|||
alt lit.node {
|
||||
ast::lit_str(st, kind) {
|
||||
if kind == ast::sk_unique { word(s.s, "~"); }
|
||||
print_string(s, st);
|
||||
print_string(s, istr::to_estr(st));
|
||||
}
|
||||
ast::lit_char(ch) {
|
||||
word(s.s,
|
||||
|
@ -1514,14 +1518,14 @@ fn print_literal(s: &ps, lit: &@ast::lit) {
|
|||
}
|
||||
ast::lit_int(val) { word(s.s, istr::to_estr(int::str(val))); }
|
||||
ast::lit_uint(val) { word(s.s, istr::to_estr(uint::str(val)) + "u"); }
|
||||
ast::lit_float(fstr) { word(s.s, fstr); }
|
||||
ast::lit_float(fstr) { word(s.s, istr::to_estr(fstr)); }
|
||||
ast::lit_mach_int(mach, val) {
|
||||
word(s.s, istr::to_estr(int::str(val as int)));
|
||||
word(s.s, ast_util::ty_mach_to_str(mach));
|
||||
}
|
||||
ast::lit_mach_float(mach, val) {
|
||||
// val is already a str
|
||||
word(s.s, val);
|
||||
word(s.s, istr::to_estr(val));
|
||||
word(s.s, ast_util::ty_mach_to_str(mach));
|
||||
}
|
||||
ast::lit_nil. { word(s.s, "()"); }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue