diff options
| author | Brian Anderson <banderson@mozilla.com> | 2011-08-27 14:42:29 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2011-08-27 15:54:46 -0700 |
| commit | 9fb085560d969eb654c0fe0f0e1501dfb3665280 (patch) | |
| tree | e7d56aad494df8354c57461d9e7d5a33851867d1 /src/comp/syntax | |
| parent | cbad23a747c282d190e3c264f515765a938b0c98 (diff) | |
| download | rust-9fb085560d969eb654c0fe0f0e1501dfb3665280.tar.gz rust-9fb085560d969eb654c0fe0f0e1501dfb3665280.zip | |
Convert rustc::syntax::ast_util to istrs. Issue #855
Diffstat (limited to 'src/comp/syntax')
| -rw-r--r-- | src/comp/syntax/ast_util.rs | 78 | ||||
| -rw-r--r-- | src/comp/syntax/parse/token.rs | 4 | ||||
| -rw-r--r-- | src/comp/syntax/print/pprust.rs | 12 |
3 files changed, 47 insertions, 47 deletions
diff --git a/src/comp/syntax/ast_util.rs b/src/comp/syntax/ast_util.rs index 72a633da928..1aaa4c7a8f3 100644 --- a/src/comp/syntax/ast_util.rs +++ b/src/comp/syntax/ast_util.rs @@ -14,10 +14,10 @@ fn mk_sp(lo: uint, hi: uint) -> span { // make this a const, once the compiler supports it fn dummy_sp() -> span { ret mk_sp(0u, 0u); } -fn path_name(p: &path) -> str { path_name_i(p.node.idents) } +fn path_name(p: &path) -> istr { path_name_i(p.node.idents) } -fn path_name_i(idents: &[ident]) -> str { - istr::to_estr(istr::connect(idents, ~"::")) +fn path_name_i(idents: &[ident]) -> istr { + istr::connect(idents, ~"::") } fn local_def(id: node_id) -> def_id { ret {crate: local_crate, node: id}; } @@ -83,27 +83,27 @@ fn pat_binding_ids(pat: &@pat) -> [node_id] { ret found; } -fn binop_to_str(op: binop) -> str { +fn binop_to_str(op: binop) -> istr { alt op { - add. { ret "+"; } - sub. { ret "-"; } - mul. { ret "*"; } - div. { ret "/"; } - rem. { ret "%"; } - and. { ret "&&"; } - or. { ret "||"; } - bitxor. { ret "^"; } - bitand. { ret "&"; } - bitor. { ret "|"; } - lsl. { ret "<<"; } - lsr. { ret ">>"; } - asr. { ret ">>>"; } - eq. { ret "=="; } - lt. { ret "<"; } - le. { ret "<="; } - ne. { ret "!="; } - ge. { ret ">="; } - gt. { ret ">"; } + add. { ret ~"+"; } + sub. { ret ~"-"; } + mul. { ret ~"*"; } + div. { ret ~"/"; } + rem. { ret ~"%"; } + and. { ret ~"&&"; } + or. { ret ~"||"; } + bitxor. { ret ~"^"; } + bitand. { ret ~"&"; } + bitor. { ret ~"|"; } + lsl. { ret ~"<<"; } + lsr. { ret ~">>"; } + asr. { ret ~">>>"; } + eq. { ret ~"=="; } + lt. { ret ~"<"; } + le. { ret ~"<="; } + ne. { ret ~"!="; } + ge. { ret ~">="; } + gt. { ret ~">"; } } } @@ -111,12 +111,12 @@ pure fn lazy_binop(b: binop) -> bool { alt b { and. { true } or. { true } _ { false } } } -fn unop_to_str(op: unop) -> str { +fn unop_to_str(op: unop) -> istr { alt op { - box(mt) { if mt == mut { ret "@mutable "; } ret "@"; } - deref. { ret "*"; } - not. { ret "!"; } - neg. { ret "-"; } + box(mt) { if mt == mut { ret ~"@mutable "; } ret ~"@"; } + deref. { ret ~"*"; } + not. { ret ~"!"; } + neg. { ret ~"-"; } } } @@ -124,18 +124,18 @@ fn is_path(e: &@expr) -> bool { ret alt e.node { expr_path(_) { true } _ { false } }; } -fn ty_mach_to_str(tm: ty_mach) -> str { +fn ty_mach_to_str(tm: ty_mach) -> istr { alt tm { - ty_u8. { ret "u8"; } - ty_u16. { ret "u16"; } - ty_u32. { ret "u32"; } - ty_u64. { ret "u64"; } - ty_i8. { ret "i8"; } - ty_i16. { ret "i16"; } - ty_i32. { ret "i32"; } - ty_i64. { ret "i64"; } - ty_f32. { ret "f32"; } - ty_f64. { ret "f64"; } + ty_u8. { ret ~"u8"; } + ty_u16. { ret ~"u16"; } + ty_u32. { ret ~"u32"; } + ty_u64. { ret ~"u64"; } + ty_i8. { ret ~"i8"; } + ty_i16. { ret ~"i16"; } + ty_i32. { ret ~"i32"; } + ty_i64. { ret ~"i64"; } + ty_f32. { ret ~"f32"; } + ty_f64. { ret ~"f64"; } } } diff --git a/src/comp/syntax/parse/token.rs b/src/comp/syntax/parse/token.rs index bb678d26c7e..b83a2f27e31 100644 --- a/src/comp/syntax/parse/token.rs +++ b/src/comp/syntax/parse/token.rs @@ -149,12 +149,12 @@ fn to_str(r: lexer::reader, t: token) -> istr { } LIT_UINT(u) { ret uint::to_str(u, 10u); } LIT_MACH_INT(tm, i) { - ret int::to_str(i, 10u) + ~"_" + istr::from_estr(ty_mach_to_str(tm)); + ret int::to_str(i, 10u) + ~"_" + ty_mach_to_str(tm); } LIT_MACH_FLOAT(tm, s) { ret interner::get::<istr>( *r.get_interner(), s) + ~"_" + - istr::from_estr(ty_mach_to_str(tm)); + ty_mach_to_str(tm); } LIT_FLOAT(s) { ret interner::get::<istr>(*r.get_interner(), s); diff --git a/src/comp/syntax/print/pprust.rs b/src/comp/syntax/print/pprust.rs index d98f1476b6b..c01ede9d391 100644 --- a/src/comp/syntax/print/pprust.rs +++ b/src/comp/syntax/print/pprust.rs @@ -276,7 +276,7 @@ fn print_type(s: &ps, ty: &@ast::ty) { ast::ty_uint. { word(s.s, ~"uint"); } ast::ty_float. { word(s.s, ~"float"); } ast::ty_machine(tm) { - word(s.s, istr::from_estr(ast_util::ty_mach_to_str(tm))); + word(s.s, ast_util::ty_mach_to_str(tm)); } ast::ty_char. { word(s.s, ~"char"); } ast::ty_str. { word(s.s, ~"str"); } @@ -846,11 +846,11 @@ fn print_expr(s: &ps, expr: &@ast::expr) { let prec = operator_prec(op); print_maybe_parens(s, lhs, prec); space(s.s); - word_space(s, istr::from_estr(ast_util::binop_to_str(op))); + word_space(s, ast_util::binop_to_str(op)); print_maybe_parens(s, rhs, prec + 1); } ast::expr_unary(op, expr) { - word(s.s, istr::from_estr(ast_util::unop_to_str(op))); + word(s.s, ast_util::unop_to_str(op)); print_maybe_parens(s, expr, parse::parser::unop_prec); } ast::expr_lit(lit) { print_literal(s, lit); } @@ -982,7 +982,7 @@ fn print_expr(s: &ps, expr: &@ast::expr) { ast::expr_assign_op(op, lhs, rhs) { print_expr(s, lhs); space(s.s); - word(s.s, istr::from_estr(ast_util::binop_to_str(op))); + word(s.s, ast_util::binop_to_str(op)); word_space(s, ~"="); print_expr(s, rhs); } @@ -1526,12 +1526,12 @@ fn print_literal(s: &ps, lit: &@ast::lit) { ast::lit_float(fstr) { word(s.s, fstr); } ast::lit_mach_int(mach, val) { word(s.s, int::str(val as int)); - word(s.s, istr::from_estr(ast_util::ty_mach_to_str(mach))); + 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::from_estr(ast_util::ty_mach_to_str(mach))); + word(s.s, ast_util::ty_mach_to_str(mach)); } ast::lit_nil. { word(s.s, ~"()"); } ast::lit_bool(val) { |
