diff options
| author | Brian Anderson <banderson@mozilla.com> | 2011-08-27 18:01:52 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2011-08-27 18:05:59 -0700 |
| commit | 5f57a508af9c43adc03a4edd575ceae41cc8cd3a (patch) | |
| tree | 4f5675666fd7cd9b99cb8ddae0db687858dcd1e6 /src/comp/syntax | |
| parent | cffd9b8044cd4792d281c9129c5a6edc16edd0d5 (diff) | |
| download | rust-5f57a508af9c43adc03a4edd575ceae41cc8cd3a.tar.gz rust-5f57a508af9c43adc03a4edd575ceae41cc8cd3a.zip | |
Convert misc compiler bits to istrs. Issue #855
Diffstat (limited to 'src/comp/syntax')
| -rw-r--r-- | src/comp/syntax/ext/env.rs | 8 | ||||
| -rw-r--r-- | src/comp/syntax/ext/fmt.rs | 61 | ||||
| -rw-r--r-- | src/comp/syntax/ext/simplext.rs | 25 |
3 files changed, 47 insertions, 47 deletions
diff --git a/src/comp/syntax/ext/env.rs b/src/comp/syntax/ext/env.rs index a183e8f3455..23feb43d817 100644 --- a/src/comp/syntax/ext/env.rs +++ b/src/comp/syntax/ext/env.rs @@ -28,15 +28,15 @@ fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @ast::expr, let var = expr_to_str(cx, args[0], ~"#env requires a string"); alt generic_os::getenv(var) { - option::none. { ret make_new_str(cx, sp, ""); } + option::none. { ret make_new_str(cx, sp, ~""); } option::some(s) { - ret make_new_str(cx, sp, istr::to_estr(s)); + ret make_new_str(cx, sp, s); } } } -fn make_new_str(cx: &ext_ctxt, sp: codemap::span, s: str) -> @ast::expr { - ret make_new_lit(cx, sp, ast::lit_str(istr::from_estr(s), ast::sk_rc)); +fn make_new_str(cx: &ext_ctxt, sp: codemap::span, s: &istr) -> @ast::expr { + ret make_new_lit(cx, sp, ast::lit_str(s, ast::sk_rc)); } // // Local Variables: diff --git a/src/comp/syntax/ext/fmt.rs b/src/comp/syntax/ext/fmt.rs index 1bdd819d708..121300f6490 100644 --- a/src/comp/syntax/ext/fmt.rs +++ b/src/comp/syntax/ext/fmt.rs @@ -52,8 +52,8 @@ fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: &[piece], let sp_lit = @{node: lit, span: sp}; 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(istr::from_estr(s), ast::sk_rc); + fn make_new_str(cx: &ext_ctxt, sp: span, s: &istr) -> @ast::expr { + let lit = ast::lit_str(s, ast::sk_rc); ret make_new_lit(cx, sp, lit); } fn make_new_int(cx: &ext_ctxt, sp: span, i: int) -> @ast::expr { @@ -109,8 +109,9 @@ fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: &[piece], ret [~"extfmt", ~"rt", ident]; } else { ret [~"std", ~"extfmt", ~"rt", ident]; } } - fn make_rt_path_expr(cx: &ext_ctxt, sp: span, ident: str) -> @ast::expr { - let path = make_path_vec(cx, istr::from_estr(ident)); + fn make_rt_path_expr(cx: &ext_ctxt, sp: span, + ident: &istr) -> @ast::expr { + let path = make_path_vec(cx, ident); ret make_path_expr(cx, sp, path); } // Produces an AST expression that represents a RT::conv record, @@ -122,11 +123,11 @@ fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: &[piece], for f: flag in flags { let fstr; alt f { - flag_left_justify. { fstr = "flag_left_justify"; } - flag_left_zero_pad. { fstr = "flag_left_zero_pad"; } - flag_space_for_sign. { fstr = "flag_space_for_sign"; } - flag_sign_always. { fstr = "flag_sign_always"; } - flag_alternate. { fstr = "flag_alternate"; } + flag_left_justify. { fstr = ~"flag_left_justify"; } + flag_left_zero_pad. { fstr = ~"flag_left_zero_pad"; } + flag_space_for_sign. { fstr = ~"flag_space_for_sign"; } + flag_sign_always. { fstr = ~"flag_sign_always"; } + flag_alternate. { fstr = ~"flag_alternate"; } } flagexprs += [make_rt_path_expr(cx, sp, fstr)]; } @@ -135,14 +136,14 @@ fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: &[piece], // this is a hack placeholder flag if vec::len::<@ast::expr>(flagexprs) == 0u { - flagexprs += [make_rt_path_expr(cx, sp, "flag_none")]; + flagexprs += [make_rt_path_expr(cx, sp, ~"flag_none")]; } ret make_vec_expr(cx, sp, flagexprs); } fn make_count(cx: &ext_ctxt, sp: span, cnt: &count) -> @ast::expr { alt cnt { count_implied. { - ret make_rt_path_expr(cx, sp, "count_implied"); + ret make_rt_path_expr(cx, sp, ~"count_implied"); } count_is(c) { let count_lit = make_new_int(cx, sp, c); @@ -158,13 +159,13 @@ fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: &[piece], alt t { ty_hex(c) { alt c { - case_upper. { rt_type = "ty_hex_upper"; } - case_lower. { rt_type = "ty_hex_lower"; } + case_upper. { rt_type = ~"ty_hex_upper"; } + case_lower. { rt_type = ~"ty_hex_lower"; } } } - ty_bits. { rt_type = "ty_bits"; } - ty_octal. { rt_type = "ty_octal"; } - _ { rt_type = "ty_default"; } + ty_bits. { rt_type = ~"ty_bits"; } + ty_octal. { rt_type = ~"ty_octal"; } + _ { rt_type = ~"ty_default"; } } ret make_rt_path_expr(cx, sp, rt_type); } @@ -184,9 +185,9 @@ fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: &[piece], ret make_conv_rec(cx, sp, rt_conv_flags, rt_conv_width, rt_conv_precision, rt_conv_ty); } - fn make_conv_call(cx: &ext_ctxt, sp: span, conv_type: str, cnv: &conv, - arg: @ast::expr) -> @ast::expr { - let fname = ~"conv_" + istr::from_estr(conv_type); + fn make_conv_call(cx: &ext_ctxt, sp: span, conv_type: &istr, + cnv: &conv, arg: @ast::expr) -> @ast::expr { + let fname = ~"conv_" + conv_type; let path = make_path_vec(cx, fname); let cnv_expr = make_rt_conv_expr(cx, sp, cnv); let args = [cnv_expr, arg]; @@ -241,21 +242,21 @@ fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: &[piece], _ { cx.span_unimpl(sp, unsupported); } } alt cnv.ty { - ty_str. { ret make_conv_call(cx, arg.span, "str", cnv, arg); } - ty_istr. { ret make_conv_call(cx, arg.span, "istr", cnv, arg); } + ty_str. { ret make_conv_call(cx, arg.span, ~"str", cnv, arg); } + ty_istr. { ret make_conv_call(cx, arg.span, ~"istr", cnv, arg); } ty_int(sign) { alt sign { - signed. { ret make_conv_call(cx, arg.span, "int", cnv, arg); } + signed. { ret make_conv_call(cx, arg.span, ~"int", cnv, arg); } unsigned. { - ret make_conv_call(cx, arg.span, "uint", cnv, arg); + ret make_conv_call(cx, arg.span, ~"uint", cnv, arg); } } } - ty_bool. { ret make_conv_call(cx, arg.span, "bool", cnv, arg); } - ty_char. { ret make_conv_call(cx, arg.span, "char", cnv, arg); } - ty_hex(_) { ret make_conv_call(cx, arg.span, "uint", cnv, arg); } - ty_bits. { ret make_conv_call(cx, arg.span, "uint", cnv, arg); } - ty_octal. { ret make_conv_call(cx, arg.span, "uint", cnv, arg); } + ty_bool. { ret make_conv_call(cx, arg.span, ~"bool", cnv, arg); } + ty_char. { ret make_conv_call(cx, arg.span, ~"char", cnv, arg); } + ty_hex(_) { ret make_conv_call(cx, arg.span, ~"uint", cnv, arg); } + ty_bits. { ret make_conv_call(cx, arg.span, ~"uint", cnv, arg); } + ty_octal. { ret make_conv_call(cx, arg.span, ~"uint", cnv, arg); } _ { cx.span_unimpl(sp, unsupported); } } } @@ -319,12 +320,12 @@ fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: &[piece], } let fmt_sp = args[0].span; let n = 0u; - let tmp_expr = make_new_str(cx, sp, ""); + let tmp_expr = make_new_str(cx, sp, ~""); let nargs = vec::len::<@ast::expr>(args); for pc: piece in pieces { alt pc { piece_string(s) { - let s_expr = make_new_str(cx, fmt_sp, s); + let s_expr = make_new_str(cx, fmt_sp, istr::from_estr(s)); tmp_expr = make_add_expr(cx, fmt_sp, tmp_expr, s_expr); } piece_conv(conv) { diff --git a/src/comp/syntax/ext/simplext.rs b/src/comp/syntax/ext/simplext.rs index 247b5aee150..ccd792d78f5 100644 --- a/src/comp/syntax/ext/simplext.rs +++ b/src/comp/syntax/ext/simplext.rs @@ -57,8 +57,7 @@ tag matchable { } /* for when given an incompatible bit of AST */ -fn match_error(cx: &ext_ctxt, m: &matchable, expected: &str) -> ! { - let expected = istr::from_estr(expected); +fn match_error(cx: &ext_ctxt, m: &matchable, expected: &istr) -> ! { alt m { match_expr(x) { cx.span_fatal(x.span, @@ -355,7 +354,7 @@ fn transcribe_ident(cx: &ext_ctxt, b: &bindings, idx_path: @mutable [uint], i: &ident, _fld: ast_fold) -> ident { ret alt follow_for_trans(cx, b.find(i), idx_path) { some(match_ident(a_id)) { a_id.node } - some(m) { match_error(cx, m, "an identifier") } + some(m) { match_error(cx, m, ~"an identifier") } none. { i } } } @@ -370,7 +369,7 @@ fn transcribe_path(cx: &ext_ctxt, b: &bindings, idx_path: @mutable [uint], {global: false, idents: [id.node], types: []} } some(match_path(a_pth)) { a_pth.node } - some(m) { match_error(cx, m, "a path") } + some(m) { match_error(cx, m, ~"a path") } none. { p } } } @@ -395,7 +394,7 @@ fn transcribe_expr(cx: &ext_ctxt, b: &bindings, idx_path: @mutable [uint], } some(match_path(a_pth)) { expr_path(a_pth) } some(match_expr(a_exp)) { a_exp.node } - some(m) { match_error(cx, m, "an expression") } + some(m) { match_error(cx, m, ~"an expression") } none. { orig(e, fld) } } } @@ -412,7 +411,7 @@ fn transcribe_type(cx: &ext_ctxt, b: &bindings, idx_path: @mutable [uint], some(id) { alt follow_for_trans(cx, b.find(id), idx_path) { some(match_ty(ty)) { ty.node } - some(m) { match_error(cx, m, "a type") } + some(m) { match_error(cx, m, ~"a type") } none. { orig(t, fld) } } } @@ -439,7 +438,7 @@ fn transcribe_block(cx: &ext_ctxt, b: &bindings, idx_path: @mutable [uint], // possibly allow promotion of ident/path/expr to blocks? some(m) { - match_error(cx, m, "a block") + match_error(cx, m, ~"a block") } none. { orig(blk, fld) } } @@ -564,13 +563,13 @@ fn p_t_s_r_mac(cx: &ext_ctxt, mac: &ast::mac, s: &selector, b: &binders) { _ { cx.bug(~"broken traversal in p_t_s_r") } } } - fn no_des(cx: &ext_ctxt, sp: &span, syn: &str) -> ! { + fn no_des(cx: &ext_ctxt, sp: &span, syn: &istr) -> ! { cx.span_fatal(sp, ~"destructuring " - + istr::from_estr(syn) + ~" is not yet supported"); + + syn + ~" is not yet supported"); } alt mac.node { ast::mac_ellipsis. { cx.span_fatal(mac.span, ~"misused `...`"); } - ast::mac_invoc(_, _, _) { no_des(cx, mac.span, "macro calls"); } + ast::mac_invoc(_, _, _) { no_des(cx, mac.span, ~"macro calls"); } ast::mac_embed_type(ty) { alt ty.node { ast::ty_path(pth, _) { @@ -587,10 +586,10 @@ fn p_t_s_r_mac(cx: &ext_ctxt, mac: &ast::mac, s: &selector, b: &binders) { b.real_binders.insert( id, compose_sels(s, final_step)); } - none. { no_des(cx, pth.span, "under `#<>`"); } + none. { no_des(cx, pth.span, ~"under `#<>`"); } } } - _ { no_des(cx, ty.span, "under `#<>`"); } + _ { no_des(cx, ty.span, ~"under `#<>`"); } } } ast::mac_embed_block(blk) { @@ -608,7 +607,7 @@ fn p_t_s_r_mac(cx: &ext_ctxt, mac: &ast::mac, s: &selector, b: &binders) { b.real_binders.insert(id, compose_sels(s, final_step)); } - none. { no_des(cx, blk.span, "under `#{}`"); } + none. { no_des(cx, blk.span, ~"under `#{}`"); } } } } |
