Skip to content

Commit f09ef6e

Browse files
committed
Convert rest of the AST to istrs. Issue #855
1 parent f603e91 commit f09ef6e

File tree

16 files changed

+66
-48
lines changed

16 files changed

+66
-48
lines changed

src/comp/back/link.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,12 +324,12 @@ fn build_link_meta(sess: &session::session, c: &ast::crate, output: &istr,
324324
for meta: @ast::meta_item in linkage_metas {
325325
if attr::get_meta_item_name(meta) == ~"name" {
326326
alt attr::get_meta_item_value_str(meta) {
327-
some(v) { name = some(istr::from_estr(v)); }
327+
some(v) { name = some(v); }
328328
none. { cmh_items += [meta]; }
329329
}
330330
} else if attr::get_meta_item_name(meta) == ~"vers" {
331331
alt attr::get_meta_item_value_str(meta) {
332-
some(v) { vers = some(istr::from_estr(v)); }
332+
some(v) { vers = some(v); }
333333
none. { cmh_items += [meta]; }
334334
}
335335
} else { cmh_items += [meta]; }

src/comp/front/attr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ fn get_meta_item_name(meta: &@ast::meta_item) -> ast::ident {
8181

8282
// Gets the string value if the meta_item is a meta_name_value variant
8383
// containing a string, otherwise none
84-
fn get_meta_item_value_str(meta: &@ast::meta_item) -> option::t<str> {
84+
fn get_meta_item_value_str(meta: &@ast::meta_item) -> option::t<istr> {
8585
alt meta.node {
8686
ast::meta_name_value(_, v) {
8787
alt v.node {
@@ -196,7 +196,7 @@ fn span<@T>(item: &T) -> ast::spanned<T> {
196196
}
197197

198198
fn mk_name_value_item_str(name: ast::ident, value: str) -> @ast::meta_item {
199-
let value_lit = span(ast::lit_str(value, ast::sk_rc));
199+
let value_lit = span(ast::lit_str(istr::from_estr(value), ast::sk_rc));
200200
ret mk_name_value_item(name, value_lit);
201201
}
202202

src/comp/front/test.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import std::option;
44
import std::vec;
5+
import std::istr;
56
import syntax::ast;
67
import syntax::ast_util;
78
import syntax::ast_util::*;
@@ -249,7 +250,8 @@ fn mk_test_desc_rec(cx: &test_ctxt, test: test) -> @ast::expr {
249250
log #fmt["encoding %s", ast_util::path_name_i(path)];
250251

251252
let name_lit: ast::lit =
252-
nospan(ast::lit_str(ast_util::path_name_i(path), ast::sk_rc));
253+
nospan(ast::lit_str(
254+
istr::from_estr(ast_util::path_name_i(path)), ast::sk_rc));
253255
let name_expr: ast::expr =
254256
{id: cx.next_node_id(),
255257
node: ast::expr_lit(@name_lit),

src/comp/metadata/creader.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,14 @@ fn visit_item(e: env, i: &@ast::item) {
6868
ret;
6969
}
7070
let cstore = e.sess.get_cstore();
71-
if !cstore::add_used_library(cstore, m.native_name) { ret; }
71+
if !cstore::add_used_library(cstore,
72+
istr::to_estr(m.native_name)) { ret; }
7273
for a: ast::attribute in
7374
attr::find_attrs_by_name(i.attrs, ~"link_args") {
7475
alt attr::get_meta_item_value_str(attr::attr_meta(a)) {
75-
some(linkarg) { cstore::add_used_link_args(cstore, linkarg); }
76+
some(linkarg) {
77+
cstore::add_used_link_args(cstore, istr::to_estr(linkarg));
78+
}
7679
none. {/* fallthrough */ }
7780
}
7881
}
@@ -133,19 +136,21 @@ fn find_library_crate(sess: &session::session, ident: &ast::ident,
133136
some(i) {
134137
alt attr::get_meta_item_value_str(i) {
135138
some(n) { n }
136-
_ { istr::to_estr(ident) }
139+
_ { ident }
137140
}
138141
}
139-
none. { istr::to_estr(ident) }
142+
none. { ident }
140143
}
141144
};
142145

143146
let nn = default_native_lib_naming(sess, sess.get_opts().static);
144147
let x =
145-
find_library_crate_aux(nn, crate_name, metas, library_search_paths);
148+
find_library_crate_aux(nn, istr::to_estr(crate_name),
149+
metas, library_search_paths);
146150
if x != none || sess.get_opts().static { ret x; }
147151
let nn2 = default_native_lib_naming(sess, true);
148-
ret find_library_crate_aux(nn2, crate_name, metas, library_search_paths);
152+
ret find_library_crate_aux(nn2, istr::to_estr(crate_name),
153+
metas, library_search_paths);
149154
}
150155

151156
fn find_library_crate_aux(nn: &{prefix: str, suffix: str}, crate_name: str,

src/comp/metadata/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ fn encode_meta_item(ebml_w: &ebml::writer, mi: &meta_item) {
465465
ebml_w.writer.write(istr::bytes(name));
466466
ebml::end_tag(ebml_w);
467467
ebml::start_tag(ebml_w, tag_meta_item_value);
468-
ebml_w.writer.write(str::bytes(value));
468+
ebml_w.writer.write(istr::bytes(value));
469469
ebml::end_tag(ebml_w);
470470
ebml::end_tag(ebml_w);
471471
}

src/comp/middle/trans.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2523,16 +2523,16 @@ fn trans_crate_lit(cx: &@crate_ctxt, lit: &ast::lit) -> ValueRef {
25232523
}
25242524
ret C_integral(t, i as uint, s);
25252525
}
2526-
ast::lit_float(fs) { ret C_float(istr::from_estr(fs)); }
2526+
ast::lit_float(fs) { ret C_float(fs); }
25272527
ast::lit_mach_float(tm, s) {
25282528
let t = T_float();
25292529
alt tm { ast::ty_f32. { t = T_f32(); } ast::ty_f64. { t = T_f64(); } }
2530-
ret C_floating(istr::from_estr(s), t);
2530+
ret C_floating(s, t);
25312531
}
25322532
ast::lit_char(c) { ret C_integral(T_char(), c as uint, False); }
25332533
ast::lit_bool(b) { ret C_bool(b); }
25342534
ast::lit_nil. { ret C_nil(); }
2535-
ast::lit_str(s, ast::sk_rc.) { ret C_str(cx, istr::from_estr(s)); }
2535+
ast::lit_str(s, ast::sk_rc.) { ret C_str(cx, s); }
25362536
ast::lit_str(s, ast::sk_unique.) {
25372537
cx.sess.span_unimpl(lit.span, "unique string in this context");
25382538
}
@@ -2541,7 +2541,9 @@ fn trans_crate_lit(cx: &@crate_ctxt, lit: &ast::lit) -> ValueRef {
25412541

25422542
fn trans_lit(cx: &@block_ctxt, lit: &ast::lit) -> result {
25432543
alt lit.node {
2544-
ast::lit_str(s, ast::sk_unique.) { ret trans_lit_istr(cx, s); }
2544+
ast::lit_str(s, ast::sk_unique.) {
2545+
ret trans_lit_istr(cx, istr::to_estr(s));
2546+
}
25452547
_ { ret rslt(cx, trans_crate_lit(bcx_ccx(cx), lit)); }
25462548
}
25472549
}

src/comp/syntax/ast.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ tag blk_sort {
237237
type mac = spanned<mac_>;
238238

239239
tag mac_ {
240-
mac_invoc(path, @expr, option::t<str>);
240+
mac_invoc(path, @expr, option::t<istr>);
241241
mac_embed_type(@ty);
242242
mac_embed_block(blk);
243243
mac_ellipsis;
@@ -246,13 +246,13 @@ tag mac_ {
246246
type lit = spanned<lit_>;
247247

248248
tag lit_ {
249-
lit_str(str, seq_kind);
249+
lit_str(istr, seq_kind);
250250
lit_char(char);
251251
lit_int(int);
252252
lit_uint(uint);
253253
lit_mach_int(ty_mach, int);
254-
lit_float(str);
255-
lit_mach_float(ty_mach, str);
254+
lit_float(istr);
255+
lit_mach_float(ty_mach, istr);
256256
lit_nil;
257257
lit_bool(bool);
258258
}
@@ -421,7 +421,7 @@ tag native_abi {
421421
}
422422

423423
type native_mod =
424-
{native_name: str,
424+
{native_name: istr,
425425
abi: native_abi,
426426
view_items: [@view_item],
427427
items: [@native_item]};
@@ -494,7 +494,7 @@ type native_item =
494494

495495
tag native_item_ {
496496
native_item_ty;
497-
native_item_fn(option::t<str>, fn_decl, [ty_param]);
497+
native_item_fn(option::t<istr>, fn_decl, [ty_param]);
498498
}
499499

500500
//

src/comp/syntax/ext/base.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import std::map::new_str_hash;
88
import codemap;
99

1010
type syntax_expander =
11-
fn(&ext_ctxt, span, @ast::expr, option::t<str>) -> @ast::expr;
11+
fn(&ext_ctxt, span, @ast::expr, &option::t<istr>) -> @ast::expr;
1212
type macro_def = {ident: str, ext: syntax_extension};
1313
type macro_definer =
14-
fn(&ext_ctxt, span, @ast::expr, option::t<str>) -> macro_def;
14+
fn(&ext_ctxt, span, @ast::expr, &option::t<istr>) -> macro_def;
1515

1616
tag syntax_extension {
1717
normal(syntax_expander);
@@ -100,7 +100,7 @@ fn expr_to_str(cx: &ext_ctxt, expr: @ast::expr, error: str) -> str {
100100
alt expr.node {
101101
ast::expr_lit(l) {
102102
alt l.node {
103-
ast::lit_str(s, _) { ret s; }
103+
ast::lit_str(s, _) { ret istr::to_estr(s); }
104104
_ { cx.span_fatal(l.span, error); }
105105
}
106106
}

src/comp/syntax/ext/concat_idents.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import base::*;
33
import syntax::ast;
44

55
fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @ast::expr,
6-
_body: option::t<str>) -> @ast::expr {
6+
_body: &option::t<istr>) -> @ast::expr {
77
let args: [@ast::expr] =
88
alt arg.node {
99
ast::expr_vec(elts, _) { elts }

src/comp/syntax/ext/env.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import base::*;
1212
export expand_syntax_ext;
1313

1414
fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @ast::expr,
15-
_body: option::t<str>) -> @ast::expr {
15+
_body: &option::t<istr>) -> @ast::expr {
1616
let args: [@ast::expr] =
1717
alt arg.node {
1818
ast::expr_vec(elts, _) { elts }
@@ -36,7 +36,7 @@ fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @ast::expr,
3636
}
3737

3838
fn make_new_str(cx: &ext_ctxt, sp: codemap::span, s: str) -> @ast::expr {
39-
ret make_new_lit(cx, sp, ast::lit_str(s, ast::sk_rc));
39+
ret make_new_lit(cx, sp, ast::lit_str(istr::from_estr(s), ast::sk_rc));
4040
}
4141
//
4242
// Local Variables:

src/comp/syntax/ext/fmt.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import codemap::span;
1717
export expand_syntax_ext;
1818

1919
fn expand_syntax_ext(cx: &ext_ctxt, sp: span, arg: @ast::expr,
20-
_body: option::t<str>) -> @ast::expr {
20+
_body: &option::t<istr>) -> @ast::expr {
2121
let args: [@ast::expr] =
2222
alt arg.node {
2323
ast::expr_vec(elts, _) { elts }
@@ -52,7 +52,7 @@ fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: &[piece],
5252
ret @{id: cx.next_id(), node: ast::expr_lit(sp_lit), span: sp};
5353
}
5454
fn make_new_str(cx: &ext_ctxt, sp: span, s: str) -> @ast::expr {
55-
let lit = ast::lit_str(s, ast::sk_rc);
55+
let lit = ast::lit_str(istr::from_estr(s), ast::sk_rc);
5656
ret make_new_lit(cx, sp, lit);
5757
}
5858
fn make_new_int(cx: &ext_ctxt, sp: span, i: int) -> @ast::expr {

src/comp/syntax/ext/ident_to_str.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import base::*;
55
import syntax::ast;
66

77
fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @ast::expr,
8-
_body: option::t<str>) -> @ast::expr {
8+
_body: &option::t<istr>) -> @ast::expr {
99
let args: [@ast::expr] =
1010
alt arg.node {
1111
ast::expr_vec(elts, _) { elts }
@@ -18,8 +18,8 @@ fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @ast::expr,
1818
}
1919

2020
ret make_new_lit(cx, sp,
21-
ast::lit_str(istr::to_estr(expr_to_ident(cx, args[0u],
22-
"expected an ident")),
21+
ast::lit_str(expr_to_ident(cx, args[0u],
22+
"expected an ident"),
2323
ast::sk_rc));
2424

2525
}

src/comp/syntax/ext/log_syntax.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import syntax::ast;
44
import std::istr;
55

66
fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @ast::expr,
7-
_body: option::t<str>) -> @ast::expr {
7+
_body: &option::t<istr>) -> @ast::expr {
88

99
cx.print_backtrace();
1010
std::io::stdout().write_line(

src/comp/syntax/ext/simplext.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ fn p_t_s_r_actual_vector(cx: &ext_ctxt, elts: [@expr], _repeat_after: bool,
688688
}
689689

690690
fn add_new_extension(cx: &ext_ctxt, sp: span, arg: @expr,
691-
_body: option::t<str>) -> base::macro_def {
691+
_body: &option::t<istr>) -> base::macro_def {
692692
let args: [@ast::expr] =
693693
alt arg.node {
694694
ast::expr_vec(elts, _) { elts }
@@ -768,7 +768,8 @@ fn add_new_extension(cx: &ext_ctxt, sp: span, arg: @expr,
768768
ext: normal(ext)};
769769

770770
fn generic_extension(cx: &ext_ctxt, sp: span, arg: @expr,
771-
_body: option::t<str>, clauses: [@clause]) -> @expr {
771+
_body: &option::t<istr>,
772+
clauses: [@clause]) -> @expr {
772773
for c: @clause in clauses {
773774
alt use_selectors_to_bind(c.params, arg) {
774775
some(bindings) { ret transcribe(cx, bindings, c.body) }

src/comp/syntax/parse/parser.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -696,20 +696,20 @@ fn parse_lit(p: &parser) -> ast::lit {
696696
token::LIT_UINT(u) { p.bump(); lit = ast::lit_uint(u); }
697697
token::LIT_FLOAT(s) {
698698
p.bump();
699-
lit = ast::lit_float(p.get_str(s));
699+
lit = ast::lit_float(istr::from_estr(p.get_str(s)));
700700
}
701701
token::LIT_MACH_INT(tm, i) {
702702
p.bump();
703703
lit = ast::lit_mach_int(tm, i);
704704
}
705705
token::LIT_MACH_FLOAT(tm, s) {
706706
p.bump();
707-
lit = ast::lit_mach_float(tm, p.get_str(s));
707+
lit = ast::lit_mach_float(tm, istr::from_estr(p.get_str(s)));
708708
}
709709
token::LIT_CHAR(c) { p.bump(); lit = ast::lit_char(c); }
710710
token::LIT_STR(s) {
711711
p.bump();
712-
lit = ast::lit_str(p.get_str(s), ast::sk_rc);
712+
lit = ast::lit_str(istr::from_estr(p.get_str(s)), ast::sk_rc);
713713
}
714714
token::LPAREN. {
715715
p.bump();
@@ -896,7 +896,8 @@ fn parse_bottom_expr(p: &parser) -> @ast::expr {
896896
let sp = p.get_span();
897897
p.bump();
898898
let lit =
899-
@{node: ast::lit_str(p.get_str(s), ast::sk_unique),
899+
@{node: ast::lit_str(istr::from_estr(p.get_str(s)),
900+
ast::sk_unique),
900901
span: sp};
901902
ex = ast::expr_lit(lit);
902903
}
@@ -1971,7 +1972,10 @@ fn parse_item_native_fn(p: &parser, attrs: &[ast::attribute]) ->
19711972
let t = parse_fn_header(p);
19721973
let decl = parse_fn_decl(p, ast::impure_fn, ast::il_normal);
19731974
let link_name = none;
1974-
if p.peek() == token::EQ { p.bump(); link_name = some(parse_str(p)); }
1975+
if p.peek() == token::EQ {
1976+
p.bump();
1977+
link_name = some(istr::from_estr(parse_str(p)));
1978+
}
19751979
let hi = p.get_hi_pos();
19761980
expect(p, token::SEMI);
19771981
ret @{ident: t.ident,
@@ -2006,7 +2010,7 @@ fn parse_native_mod_items(p: &parser, native_name: &str,
20062010
initial_attrs = [];
20072011
items += [parse_native_item(p, attrs)];
20082012
}
2009-
ret {native_name: native_name,
2013+
ret {native_name: istr::from_estr(native_name),
20102014
abi: abi,
20112015
view_items: view_items,
20122016
items: items};

src/comp/syntax/print/pprust.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,11 @@ fn print_native_item(s: &ps, item: &@ast::native_item) {
371371
decl.constraints);
372372
alt lname {
373373
none. { }
374-
some(ss) { space(s.s); word_space(s, "="); print_string(s, ss); }
374+
some(ss) {
375+
space(s.s);
376+
word_space(s, "=");
377+
print_string(s, istr::to_estr(ss));
378+
}
375379
}
376380
end(s); // end head-ibox
377381
word(s.s, ";");
@@ -426,9 +430,9 @@ fn print_item(s: &ps, item: &@ast::item) {
426430
}
427431
word_nbsp(s, "mod");
428432
word_nbsp(s, istr::to_estr(item.ident));
429-
if !str::eq(nmod.native_name, istr::to_estr(item.ident)) {
433+
if !istr::eq(nmod.native_name, item.ident) {
430434
word_space(s, "=");
431-
print_string(s, nmod.native_name);
435+
print_string(s, istr::to_estr(nmod.native_name));
432436
nbsp(s);
433437
}
434438
bopen(s);
@@ -1505,7 +1509,7 @@ fn print_literal(s: &ps, lit: &@ast::lit) {
15051509
alt lit.node {
15061510
ast::lit_str(st, kind) {
15071511
if kind == ast::sk_unique { word(s.s, "~"); }
1508-
print_string(s, st);
1512+
print_string(s, istr::to_estr(st));
15091513
}
15101514
ast::lit_char(ch) {
15111515
word(s.s,
@@ -1514,14 +1518,14 @@ fn print_literal(s: &ps, lit: &@ast::lit) {
15141518
}
15151519
ast::lit_int(val) { word(s.s, istr::to_estr(int::str(val))); }
15161520
ast::lit_uint(val) { word(s.s, istr::to_estr(uint::str(val)) + "u"); }
1517-
ast::lit_float(fstr) { word(s.s, fstr); }
1521+
ast::lit_float(fstr) { word(s.s, istr::to_estr(fstr)); }
15181522
ast::lit_mach_int(mach, val) {
15191523
word(s.s, istr::to_estr(int::str(val as int)));
15201524
word(s.s, ast_util::ty_mach_to_str(mach));
15211525
}
15221526
ast::lit_mach_float(mach, val) {
15231527
// val is already a str
1524-
word(s.s, val);
1528+
word(s.s, istr::to_estr(val));
15251529
word(s.s, ast_util::ty_mach_to_str(mach));
15261530
}
15271531
ast::lit_nil. { word(s.s, "()"); }

0 commit comments

Comments
 (0)