diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2011-07-12 10:59:18 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2011-07-14 12:00:48 -0700 |
| commit | be489ee9e2f30d2daf1c9726536631162e21dff5 (patch) | |
| tree | 532d570a7b7971a4be83eeeb969bff9b12ecfb87 /src/comp/syntax | |
| parent | 4664b67ea2d0240cf121851d6c47e72bc26222b8 (diff) | |
| download | rust-be489ee9e2f30d2daf1c9726536631162e21dff5.tar.gz rust-be489ee9e2f30d2daf1c9726536631162e21dff5.zip | |
rustc: Move much of metadata reading over to interior vectors
Diffstat (limited to 'src/comp/syntax')
| -rw-r--r-- | src/comp/syntax/codemap.rs | 31 | ||||
| -rw-r--r-- | src/comp/syntax/parse/lexer.rs | 6 | ||||
| -rw-r--r-- | src/comp/syntax/parse/parser.rs | 6 | ||||
| -rw-r--r-- | src/comp/syntax/print/pp.rs | 6 | ||||
| -rw-r--r-- | src/comp/syntax/print/pprust.rs | 12 |
5 files changed, 31 insertions, 30 deletions
diff --git a/src/comp/syntax/codemap.rs b/src/comp/syntax/codemap.rs index 6df2f2422ad..46105f5320e 100644 --- a/src/comp/syntax/codemap.rs +++ b/src/comp/syntax/codemap.rs @@ -1,8 +1,8 @@ import std::uint; import std::str; import std::vec; -import std::term; -import std::io; +import std::termivec; +import std::ioivec; import std::option; import std::option::some; import std::option::none; @@ -70,21 +70,21 @@ fn emit_diagnostic(&option::t[span] sp, &str msg, &str kind, u8 color, } case (none) { } } - io::stdout().write_str(ss + ": "); - if (term::color_supported()) { - term::fg(io::stdout().get_buf_writer(), color); + ioivec::stdout().write_str(ss + ": "); + if (termivec::color_supported()) { + termivec::fg(ioivec::stdout().get_buf_writer(), color); } - io::stdout().write_str(#fmt("%s:", kind)); - if (term::color_supported()) { - term::reset(io::stdout().get_buf_writer()); + ioivec::stdout().write_str(#fmt("%s:", kind)); + if (termivec::color_supported()) { + termivec::reset(ioivec::stdout().get_buf_writer()); } - io::stdout().write_str(#fmt(" %s\n", msg)); + ioivec::stdout().write_str(#fmt(" %s\n", msg)); alt (maybe_lines) { case (some(?lines)) { // FIXME: reading in the entire file is the worst possible way to // get access to the necessary lines. - auto rdr = io::file_reader(lines.name); - auto file = str::unsafe_from_bytes(rdr.read_whole_stream()); + auto rdr = ioivec::file_reader(lines.name); + auto file = str::unsafe_from_bytes_ivec(rdr.read_whole_stream()); auto fm = codemap::get_filemap(cm, lines.name); // arbitrarily only print up to six lines of the error @@ -97,12 +97,13 @@ fn emit_diagnostic(&option::t[span] sp, &str msg, &str kind, u8 color, } // Print the offending lines for (uint line in display_lines) { - io::stdout().write_str(#fmt("%s:%u ", fm.name, line + 1u)); + ioivec::stdout().write_str(#fmt("%s:%u ", fm.name, + line + 1u)); auto s = codemap::get_line(fm, line as int, file); if (!str::ends_with(s, "\n")) { s += "\n"; } - io::stdout().write_str(s); + ioivec::stdout().write_str(s); } if (elided) { auto last_line = display_lines.(vec::len(display_lines) - 1u); @@ -111,7 +112,7 @@ fn emit_diagnostic(&option::t[span] sp, &str msg, &str kind, u8 color, auto out = ""; while (indent > 0u) { out += " "; indent -= 1u; } out += "...\n"; - io::stdout().write_str(out); + ioivec::stdout().write_str(out); } // If there's one line at fault we can easily point to the problem @@ -138,7 +139,7 @@ fn emit_diagnostic(&option::t[span] sp, &str msg, &str kind, u8 color, width -= 1u; } } - io::stdout().write_str(s + "\n"); + ioivec::stdout().write_str(s + "\n"); } } case (_) {} diff --git a/src/comp/syntax/parse/lexer.rs b/src/comp/syntax/parse/lexer.rs index 29670d21e86..77bde628014 100644 --- a/src/comp/syntax/parse/lexer.rs +++ b/src/comp/syntax/parse/lexer.rs @@ -1,5 +1,5 @@ -import std::io; +import std::ioivec; import std::str; import std::vec; import std::int; @@ -734,8 +734,8 @@ type lit = rec(str lit, uint pos); fn gather_comments_and_literals(&codemap::codemap cm, str path) -> rec(cmnt[] cmnts, lit[] lits) { - auto srdr = io::file_reader(path); - auto src = str::unsafe_from_bytes(srdr.read_whole_stream()); + auto srdr = ioivec::file_reader(path); + auto src = str::unsafe_from_bytes_ivec(srdr.read_whole_stream()); auto itr = @interner::mk[str](str::hash, str::eq); auto rdr = new_reader(cm, src, codemap::new_filemap(path, 0u), itr); let cmnt[] comments = ~[]; diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs index a8fd51993b1..d238e6eb2e7 100644 --- a/src/comp/syntax/parse/parser.rs +++ b/src/comp/syntax/parse/parser.rs @@ -1,5 +1,5 @@ -import std::io; +import std::ioivec; import std::ivec; import std::vec; import std::str; @@ -59,8 +59,8 @@ fn new_parser_from_file(parse_sess sess, ast::crate_cfg cfg, str path, uint pos) -> parser { auto ftype = SOURCE_FILE; if (str::ends_with(path, ".rc")) { ftype = CRATE_FILE; } - auto srdr = io::file_reader(path); - auto src = str::unsafe_from_bytes(srdr.read_whole_stream()); + auto srdr = ioivec::file_reader(path); + auto src = str::unsafe_from_bytes_ivec(srdr.read_whole_stream()); auto filemap = codemap::new_filemap(path, pos); vec::push(sess.cm.files, filemap); auto itr = @interner::mk(str::hash, str::eq); diff --git a/src/comp/syntax/print/pp.rs b/src/comp/syntax/print/pp.rs index ef3a87585c4..7ac10f6bcf0 100644 --- a/src/comp/syntax/print/pp.rs +++ b/src/comp/syntax/print/pp.rs @@ -1,5 +1,5 @@ -import std::io; +import std::ioivec; import std::vec; import std::str; @@ -98,7 +98,7 @@ type print_stack_elt = rec(int offset, print_stack_break pbreak); const int size_infinity = 0xffff; -fn mk_printer(io::writer out, uint linewidth) -> printer { +fn mk_printer(ioivec::writer out, uint linewidth) -> printer { // Yes 3, it makes the ring buffers big enough to never // fall behind. @@ -198,7 +198,7 @@ fn mk_printer(io::writer out, uint linewidth) -> printer { * the method called 'pretty_print', and the 'PRINT' process is the method * called 'print'. */ -obj printer(io::writer out, +obj printer(ioivec::writer out, uint buf_len, mutable int margin, // width of lines we're constrained to diff --git a/src/comp/syntax/print/pprust.rs b/src/comp/syntax/print/pprust.rs index 41ba5715d3b..dd3d98fb45b 100644 --- a/src/comp/syntax/print/pprust.rs +++ b/src/comp/syntax/print/pprust.rs @@ -1,7 +1,7 @@ import std::ivec; import std::int; -import std::io; +import std::ioivec; import std::str; import std::uint; import std::vec; @@ -57,7 +57,7 @@ fn ibox(&ps s, uint u) { fn end(&ps s) { ivec::pop(s.boxes); pp::end(s.s); } -fn rust_printer(io::writer writer) -> ps { +fn rust_printer(ioivec::writer writer) -> ps { let pp::breaks[] boxes = ~[]; ret @rec(s=pp::mk_printer(writer, default_columns), cm=none[codemap], @@ -74,7 +74,7 @@ const uint indent_unit = 4u; const uint default_columns = 78u; fn print_crate(&codemap cm, @ast::crate crate, str filename, - io::writer out, &pp_ann ann) { + ioivec::writer out, &pp_ann ann) { let pp::breaks[] boxes = ~[]; auto r = lexer::gather_comments_and_literals(cm, filename); auto s = @@ -104,7 +104,7 @@ fn item_to_str(&@ast::item i) -> str { be to_str(i, print_item); } fn path_to_str(&ast::path p) -> str { be to_str(p, print_path); } fn fun_to_str(&ast::_fn f, str name, &ast::ty_param[] params) -> str { - auto writer = io::string_writer(); + auto writer = ioivec::string_writer(); auto s = rust_printer(writer.get_writer()); print_fn(s, f.decl, f.proto, name, params); eof(s.s); @@ -112,7 +112,7 @@ fn fun_to_str(&ast::_fn f, str name, &ast::ty_param[] params) -> str { } fn block_to_str(&ast::block blk) -> str { - auto writer = io::string_writer(); + auto writer = ioivec::string_writer(); auto s = rust_printer(writer.get_writer()); // containing cbox, will be closed by print-block at } @@ -1505,7 +1505,7 @@ fn escape_str(str st, char to_escape) -> str { } fn to_str[T](&T t, fn(&ps, &T) f) -> str { - auto writer = io::string_writer(); + auto writer = ioivec::string_writer(); auto s = rust_printer(writer.get_writer()); f(s, t); eof(s.s); |
