summary refs log tree commit diff
path: root/src/comp/syntax
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2011-08-24 21:26:19 -0700
committerBrian Anderson <banderson@mozilla.com>2011-08-27 15:54:43 -0700
commitfcc031c5b4dc8f64c497b8dd1e066068e862bd72 (patch)
treed31401261cbe92f9d5039c193dfcb66b3767e018 /src/comp/syntax
parent20178b9312675f4889bd656916a1f32cbacc94d6 (diff)
downloadrust-fcc031c5b4dc8f64c497b8dd1e066068e862bd72.tar.gz
rust-fcc031c5b4dc8f64c497b8dd1e066068e862bd72.zip
Convert std::io to istrs. Issue #855
Diffstat (limited to 'src/comp/syntax')
-rw-r--r--src/comp/syntax/codemap.rs23
-rw-r--r--src/comp/syntax/ext/log_syntax.rs4
-rw-r--r--src/comp/syntax/parse/parser.rs2
-rw-r--r--src/comp/syntax/print/pp.rs8
-rw-r--r--src/comp/syntax/print/pprust.rs6
5 files changed, 24 insertions, 19 deletions
diff --git a/src/comp/syntax/codemap.rs b/src/comp/syntax/codemap.rs
index e522becd3e0..d9aff69acfa 100644
--- a/src/comp/syntax/codemap.rs
+++ b/src/comp/syntax/codemap.rs
@@ -1,6 +1,7 @@
 import std::vec;
 import std::uint;
 import std::str;
+import std::istr;
 import std::term;
 import std::io;
 import std::option;
@@ -108,13 +109,13 @@ fn emit_diagnostic(sp: &option::t<span>, msg: &str, kind: &str, color: u8,
       }
       none. { }
     }
-    io::stdout().write_str(ss);
+    io::stdout().write_str(istr::from_estr(ss));
     if term::color_supported() {
         term::fg(io::stdout().get_buf_writer(), color);
     }
-    io::stdout().write_str(#fmt["%s:", kind]);
+    io::stdout().write_str(istr::from_estr(#fmt["%s:", kind]));
     if term::color_supported() { term::reset(io::stdout().get_buf_writer()); }
-    io::stdout().write_str(#fmt[" %s\n", msg]);
+    io::stdout().write_str(istr::from_estr(#fmt[" %s\n", msg]));
 
     maybe_highlight_lines(sp, cm, maybe_lines);
 }
@@ -130,7 +131,8 @@ fn maybe_highlight_lines(sp: &option::t<span>, cm: &codemap,
 
         // FIXME: reading in the entire file is the worst possible way to
         //        get access to the necessary lines.
-        let file = io::read_whole_file_str(lines.name);
+        let file = istr::to_estr(
+            io::read_whole_file_str(istr::from_estr(lines.name)));
         let fm = get_filemap(cm, lines.name);
 
         // arbitrarily only print up to six lines of the error
@@ -143,18 +145,19 @@ fn maybe_highlight_lines(sp: &option::t<span>, cm: &codemap,
         }
         // Print the offending lines
         for line: uint in display_lines {
-            io::stdout().write_str(#fmt["%s:%u ", fm.name, line + 1u]);
+            io::stdout().write_str(
+                istr::from_estr(#fmt["%s:%u ", fm.name, line + 1u]));
             let s = get_line(fm, line as int, file);
             if !str::ends_with(s, "\n") { s += "\n"; }
-            io::stdout().write_str(s);
+            io::stdout().write_str(istr::from_estr(s));
         }
         if elided {
             let last_line = display_lines[vec::len(display_lines) - 1u];
             let s = #fmt["%s:%u ", fm.name, last_line + 1u];
             let indent = str::char_len(s);
-            let out = "";
-            while indent > 0u { out += " "; indent -= 1u; }
-            out += "...\n";
+            let out = ~"";
+            while indent > 0u { out += ~" "; indent -= 1u; }
+            out += ~"...\n";
             io::stdout().write_str(out);
         }
 
@@ -180,7 +183,7 @@ fn maybe_highlight_lines(sp: &option::t<span>, cm: &codemap,
                 let width = hi.col - lo.col - 1u;
                 while width > 0u { str::push_char(s, '~'); width -= 1u; }
             }
-            io::stdout().write_str(s + "\n");
+            io::stdout().write_str(istr::from_estr(s + "\n"));
         }
       }
       _ { }
diff --git a/src/comp/syntax/ext/log_syntax.rs b/src/comp/syntax/ext/log_syntax.rs
index a03ff11a66d..3cf240097dc 100644
--- a/src/comp/syntax/ext/log_syntax.rs
+++ b/src/comp/syntax/ext/log_syntax.rs
@@ -1,12 +1,14 @@
 import std::option;
 import base::*;
 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 {
 
     cx.print_backtrace();
-    std::io::stdout().write_line(print::pprust::expr_to_str(arg));
+    std::io::stdout().write_line(
+        istr::from_estr(print::pprust::expr_to_str(arg)));
 
     //trivial expression
     ret @{id: cx.next_id(), node: ast::expr_rec([], option::none), span: sp};
diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs
index 59cea6e131d..b5d71a6ee9c 100644
--- a/src/comp/syntax/parse/parser.rs
+++ b/src/comp/syntax/parse/parser.rs
@@ -63,7 +63,7 @@ type parser =
 fn new_parser_from_file(sess: parse_sess, cfg: ast::crate_cfg, path: str,
                         chpos: uint, byte_pos: uint, ftype: file_type) ->
    parser {
-    let src = io::read_whole_file_str(path);
+    let src = istr::to_estr(io::read_whole_file_str(istr::from_estr(path)));
     let filemap = codemap::new_filemap(path, chpos, byte_pos);
     sess.cm.files += [filemap];
     let itr = @interner::mk(str::hash, str::eq);
diff --git a/src/comp/syntax/print/pp.rs b/src/comp/syntax/print/pp.rs
index adeccd4150c..3ad514fdb2e 100644
--- a/src/comp/syntax/print/pp.rs
+++ b/src/comp/syntax/print/pp.rs
@@ -2,7 +2,7 @@
 import std::io;
 import std::vec;
 import std::str;
-
+import std::istr;
 
 /*
  * This pretty-printer is a direct reimplementation of Philip Karlton's
@@ -391,7 +391,7 @@ obj printer(out: io::writer,
     }
     fn print_newline(amount: int) {
         log #fmt["NEWLINE %d", amount];
-        out.write_str("\n");
+        out.write_str(~"\n");
         pending_indentation = 0;
         self.indent(amount);
     }
@@ -407,10 +407,10 @@ obj printer(out: io::writer,
     }
     fn write_str(s: str) {
         while pending_indentation > 0 {
-            out.write_str(" ");
+            out.write_str(~" ");
             pending_indentation -= 1;
         }
-        out.write_str(s);
+        out.write_str(istr::from_estr(s));
     }
     fn print(x: token, L: int) {
         log #fmt["print %s %d (remaining line space=%d)", tok_str(x), L,
diff --git a/src/comp/syntax/print/pprust.rs b/src/comp/syntax/print/pprust.rs
index bf3942f1eab..9dcd56407f7 100644
--- a/src/comp/syntax/print/pprust.rs
+++ b/src/comp/syntax/print/pprust.rs
@@ -112,7 +112,7 @@ fn fun_to_str(f: &ast::_fn, name: str, params: &[ast::ty_param]) -> str {
     let s = rust_printer(writer.get_writer());
     print_fn(s, f.decl, f.proto, name, params, f.decl.constraints);
     eof(s.s);
-    ret writer.get_str();
+    ret istr::to_estr(writer.get_str());
 }
 
 fn block_to_str(blk: &ast::blk) -> str {
@@ -126,7 +126,7 @@ fn block_to_str(blk: &ast::blk) -> str {
     ibox(s, 0u);
     print_block(s, blk);
     eof(s.s);
-    ret writer.get_str();
+    ret istr::to_estr(writer.get_str());
 }
 
 fn meta_item_to_str(mi: &ast::meta_item) -> str {
@@ -1621,7 +1621,7 @@ fn to_str<T>(t: &T, f: fn(&ps, &T)) -> str {
     let s = rust_printer(writer.get_writer());
     f(s, t);
     eof(s.s);
-    ret writer.get_str();
+    ret istr::to_estr(writer.get_str());
 }
 
 fn next_comment(s: &ps) -> option::t<lexer::cmnt> {