Rename std::istr to std::str. Issue #855

This commit is contained in:
Brian Anderson 2011-09-01 17:27:58 -07:00
parent 913667ba25
commit ab6bb035e5
112 changed files with 741 additions and 741 deletions

View file

@ -1,4 +1,4 @@
import std::istr;
import std::str;
import std::option;
import codemap::span;
import ast::*;
@ -16,7 +16,7 @@ fn dummy_sp() -> span { ret mk_sp(0u, 0u); }
fn path_name(p: &path) -> istr { path_name_i(p.node.idents) }
fn path_name_i(idents: &[ident]) -> istr {
istr::connect(idents, ~"::")
str::connect(idents, ~"::")
}
fn local_def(id: node_id) -> def_id { ret {crate: local_crate, node: id}; }
@ -157,7 +157,7 @@ fn is_exported(i: ident, m: _mod) -> bool {
for vi: @view_item in m.view_items {
alt vi.node {
view_item_export(ids, _) {
for id in ids { if istr::eq(i, id) { ret true; } }
for id in ids { if str::eq(i, id) { ret true; } }
count += 1u;
}
_ {/* fall through */ }

View file

@ -1,6 +1,6 @@
import std::vec;
import std::uint;
import std::istr;
import std::str;
import std::term;
import std::io;
import std::option;
@ -148,13 +148,13 @@ fn maybe_highlight_lines(sp: &option::t<span>, cm: &codemap,
io::stdout().write_str(
#ifmt[~"%s:%u ", fm.name, line + 1u]);
let s = get_line(fm, line as int, file);
if !istr::ends_with(s, ~"\n") { s += ~"\n"; }
if !str::ends_with(s, ~"\n") { s += ~"\n"; }
io::stdout().write_str(s);
}
if elided {
let last_line = display_lines[vec::len(display_lines) - 1u];
let s = #ifmt[~"%s:%u ", fm.name, last_line + 1u];
let indent = istr::char_len(s);
let indent = str::char_len(s);
let out = ~"";
while indent > 0u { out += ~" "; indent -= 1u; }
out += ~"...\n";
@ -172,16 +172,16 @@ fn maybe_highlight_lines(sp: &option::t<span>, cm: &codemap,
while num > 0u { num /= 10u; digits += 1u; }
// indent past |name:## | and the 0-offset column location
let left = istr::char_len(fm.name) + digits + lo.col + 3u;
let left = str::char_len(fm.name) + digits + lo.col + 3u;
let s = ~"";
while left > 0u { istr::push_char(s, ' '); left -= 1u; }
while left > 0u { str::push_char(s, ' '); left -= 1u; }
s += ~"^";
let hi = lookup_char_pos(cm, option::get(sp).hi);
if hi.col != lo.col {
// the ^ already takes up one space
let width = hi.col - lo.col - 1u;
while width > 0u { istr::push_char(s, '~'); width -= 1u; }
while width > 0u { str::push_char(s, '~'); width -= 1u; }
}
io::stdout().write_str(s + ~"\n");
}
@ -221,12 +221,12 @@ fn get_line(fm: filemap, line: int, file: &istr) -> istr {
// If we're not done parsing the file, we're at the limit of what's
// parsed. If we just slice the rest of the string, we'll print out
// the remainder of the file, which is undesirable.
end = istr::byte_len(file);
let rest = istr::slice(file, begin, end);
let newline = istr::index(rest, '\n' as u8);
end = str::byte_len(file);
let rest = str::slice(file, begin, end);
let newline = str::index(rest, '\n' as u8);
if newline != -1 { end = begin + (newline as uint); }
}
ret istr::slice(file, begin, end);
ret str::slice(file, begin, end);
}
fn get_filemap(cm: codemap, filename: istr) -> filemap {

View file

@ -1,4 +1,4 @@
import std::istr;
import std::str;
import std::vec;
import std::option;
import std::map::hashmap;

View file

@ -5,7 +5,7 @@
* interface.
*/
import std::vec;
import std::istr;
import std::str;
import std::option;
import std::generic_os;
import base::*;

View file

@ -5,7 +5,7 @@ import std::option::some;
import std::map::hashmap;
import std::vec;
import std::istr;
import std::str;
import syntax::ast::crate;
import syntax::ast::expr_;

View file

@ -1,5 +1,5 @@
import std::vec;
import std::istr;
import std::str;
import std::option;
import base::*;
import syntax::ast;

View file

@ -6,7 +6,7 @@
* compiler syntax extension plugin interface.
*/
import std::vec;
import std::istr;
import std::str;
import std::option;
import std::option::none;
import std::option::some;
@ -103,7 +103,7 @@ fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: &[piece],
}
fn make_path_vec(cx: &ext_ctxt, ident: &ast::ident) -> [ast::ident] {
fn compiling_std(cx: &ext_ctxt) -> bool {
ret istr::find(cx.crate_file_name(), ~"std.rc") >= 0;
ret str::find(cx.crate_file_name(), ~"std.rc") >= 0;
}
if compiling_std(cx) {
ret [~"extifmt", ~"rt", ident];

View file

@ -1,7 +1,7 @@
import std::option;
import base::*;
import syntax::ast;
import std::istr;
import std::str;
fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @ast::expr,
_body: &option::t<istr>) -> @ast::expr {

View file

@ -2,7 +2,7 @@ use std;
import codemap::span;
import std::vec;
import std::istr;
import std::str;
import std::option;
import std::map::hashmap;
import std::map::new_str_hash;

View file

@ -1,5 +1,5 @@
import std::istr;
import std::str;
import std::option;
import std::option::some;
import std::option::none;

View file

@ -2,7 +2,7 @@
import std::io;
import std::int;
import std::vec;
import std::istr;
import std::str;
import std::map;
import std::map::hashmap;
import std::option;
@ -44,19 +44,19 @@ fn new_reader(cm: &codemap::codemap, src: &istr, filemap: codemap::filemap,
fn get_str_from(start: uint) -> istr {
// I'm pretty skeptical about this subtraction. What if there's a
// multi-byte character before the mark?
ret istr::slice(src, start - 1u, pos - 1u);
ret str::slice(src, start - 1u, pos - 1u);
}
fn get_chpos() -> uint { ret chpos; }
fn get_byte_pos() -> uint { ret pos; }
fn curr() -> char { ret ch; }
fn next() -> char {
if pos < len {
ret istr::char_at(src, pos);
ret str::char_at(src, pos);
} else { ret -1 as char; }
}
fn init() {
if pos < len {
let next = istr::char_range_at(src, pos);
let next = str::char_range_at(src, pos);
pos = next.next;
ch = next.ch;
}
@ -69,7 +69,7 @@ fn new_reader(cm: &codemap::codemap, src: &istr, filemap: codemap::filemap,
codemap::next_line(fm, chpos, pos + fm.start_pos.byte);
col = 0u;
}
let next = istr::char_range_at(src, pos);
let next = str::char_range_at(src, pos);
pos = next.next;
ch = next.ch;
} else { ch = -1 as char; }
@ -85,7 +85,7 @@ fn new_reader(cm: &codemap::codemap, src: &istr, filemap: codemap::filemap,
}
let strs: [istr] = [];
let rd =
reader(cm, src, istr::byte_len(src), 0u, 0u, -1 as char,
reader(cm, src, str::byte_len(src), 0u, 0u, -1 as char,
filemap.start_pos.ch, strs, filemap, itr);
rd.init();
ret rd;
@ -178,15 +178,15 @@ fn scan_exponent(rdr: &reader) -> option::t<istr> {
let c = rdr.curr();
let rslt = ~"";
if c == 'e' || c == 'E' {
rslt += istr::unsafe_from_bytes([c as u8]);
rslt += str::unsafe_from_bytes([c as u8]);
rdr.bump();
c = rdr.curr();
if c == '-' || c == '+' {
rslt += istr::unsafe_from_bytes([c as u8]);
rslt += str::unsafe_from_bytes([c as u8]);
rdr.bump();
}
let exponent = scan_dec_digits(rdr);
if istr::byte_len(exponent) > 0u {
if str::byte_len(exponent) > 0u {
ret some(rslt + exponent);
} else { rdr.err(~"scan_exponent: bad fp literal"); fail; }
} else { ret none::<istr>; }
@ -196,7 +196,7 @@ fn scan_dec_digits(rdr: &reader) -> istr {
let c = rdr.curr();
let rslt: istr = ~"";
while is_dec_digit(c) || c == '_' {
if c != '_' { rslt += istr::unsafe_from_bytes([c as u8]); }
if c != '_' { rslt += str::unsafe_from_bytes([c as u8]); }
rdr.bump();
c = rdr.curr();
}
@ -348,11 +348,11 @@ fn next_token_inner(rdr: &reader) -> token::token {
let c = rdr.curr();
if is_alpha(c) || c == '_' {
while is_alnum(c) || c == '_' {
istr::push_char(accum_str, c);
str::push_char(accum_str, c);
rdr.bump();
c = rdr.curr();
}
if istr::eq(accum_str, ~"_") { ret token::UNDERSCORE; }
if str::eq(accum_str, ~"_") { ret token::UNDERSCORE; }
let is_mod_name = c == ':' && rdr.next() == ':';
ret token::IDENT(interner::intern::<istr>(
*rdr.get_interner(),
@ -493,20 +493,20 @@ fn next_token_inner(rdr: &reader) -> token::token {
let escaped = rdr.curr();
rdr.bump();
alt escaped {
'n' { istr::push_byte(accum_str, '\n' as u8); }
'r' { istr::push_byte(accum_str, '\r' as u8); }
't' { istr::push_byte(accum_str, '\t' as u8); }
'\\' { istr::push_byte(accum_str, '\\' as u8); }
'"' { istr::push_byte(accum_str, '"' as u8); }
'n' { str::push_byte(accum_str, '\n' as u8); }
'r' { str::push_byte(accum_str, '\r' as u8); }
't' { str::push_byte(accum_str, '\t' as u8); }
'\\' { str::push_byte(accum_str, '\\' as u8); }
'"' { str::push_byte(accum_str, '"' as u8); }
'\n' { consume_whitespace(rdr); }
'x' {
istr::push_char(accum_str, scan_numeric_escape(rdr, 2u));
str::push_char(accum_str, scan_numeric_escape(rdr, 2u));
}
'u' {
istr::push_char(accum_str, scan_numeric_escape(rdr, 4u));
str::push_char(accum_str, scan_numeric_escape(rdr, 4u));
}
'U' {
istr::push_char(accum_str, scan_numeric_escape(rdr, 8u));
str::push_char(accum_str, scan_numeric_escape(rdr, 8u));
}
c2 {
rdr.err(
@ -516,7 +516,7 @@ fn next_token_inner(rdr: &reader) -> token::token {
}
}
}
_ { istr::push_char(accum_str, ch); }
_ { str::push_char(accum_str, ch); }
}
}
rdr.bump();
@ -569,7 +569,7 @@ type cmnt = {style: cmnt_style, lines: [istr], pos: uint};
fn read_to_eol(rdr: &reader) -> istr {
let val = ~"";
while rdr.curr() != '\n' && !rdr.is_eof() {
istr::push_char(val, rdr.curr());
str::push_char(val, rdr.curr());
rdr.bump();
}
if rdr.curr() == '\n' { rdr.bump(); }
@ -634,8 +634,8 @@ fn trim_whitespace_prefix_and_push_line(lines: &mutable [istr], s: &istr,
col: uint) {
let s1;
if all_whitespace(s, 0u, col) {
if col < istr::byte_len(s) {
s1 = istr::slice(s, col, istr::byte_len(s));
if col < str::byte_len(s) {
s1 = str::slice(s, col, str::byte_len(s));
} else { s1 = ~""; }
} else { s1 = s; }
log ~"pushing line: " + s1;
@ -659,7 +659,7 @@ fn read_block_comment(rdr: &reader, code_to_the_left: bool) -> cmnt {
curr_line = ~"";
rdr.bump();
} else {
istr::push_char(curr_line, rdr.curr());
str::push_char(curr_line, rdr.curr());
if rdr.curr() == '/' && rdr.next() == '*' {
rdr.bump();
rdr.bump();
@ -675,7 +675,7 @@ fn read_block_comment(rdr: &reader, code_to_the_left: bool) -> cmnt {
}
}
}
if istr::byte_len(curr_line) != 0u {
if str::byte_len(curr_line) != 0u {
trim_whitespace_prefix_and_push_line(lines, curr_line, col);
}
let style = if code_to_the_left { trailing } else { isolated };
@ -722,8 +722,8 @@ type lit = {lit: istr, pos: uint};
fn gather_comments_and_literals(cm: &codemap::codemap, path: &istr,
srdr: io::reader) ->
{cmnts: [cmnt], lits: [lit]} {
let src = istr::unsafe_from_bytes(srdr.read_whole_stream());
let itr = @interner::mk::<istr>(istr::hash, istr::eq);
let src = str::unsafe_from_bytes(srdr.read_whole_stream());
let itr = @interner::mk::<istr>(str::hash, str::eq);
let rdr = new_reader(cm, src,
codemap::new_filemap(
path, 0u, 0u), itr);

View file

@ -1,7 +1,7 @@
import std::io;
import std::vec;
import std::istr;
import std::str;
import std::option;
import std::option::some;
import std::option::none;
@ -66,7 +66,7 @@ fn new_parser_from_file(sess: parse_sess, cfg: &ast::crate_cfg, path: &istr,
let filemap = codemap::new_filemap(
path, chpos, byte_pos);
sess.cm.files += [filemap];
let itr = @interner::mk(istr::hash, istr::eq);
let itr = @interner::mk(str::hash, str::eq);
let rdr = lexer::new_reader(sess.cm, src, filemap, itr);
ret new_parser(sess, cfg, rdr, ftype);
}
@ -247,7 +247,7 @@ fn eat(p: &parser, tok: &token::token) -> bool {
fn is_word(p: &parser, word: &istr) -> bool {
ret alt p.peek() {
token::IDENT(sid, false) { istr::eq(word, p.get_str(sid)) }
token::IDENT(sid, false) { str::eq(word, p.get_str(sid)) }
_ { false }
};
}
@ -255,7 +255,7 @@ fn is_word(p: &parser, word: &istr) -> bool {
fn eat_word(p: &parser, word: &istr) -> bool {
alt p.peek() {
token::IDENT(sid, false) {
if istr::eq(word, p.get_str(sid)) {
if str::eq(word, p.get_str(sid)) {
p.bump();
ret true;
} else { ret false; }
@ -2036,14 +2036,14 @@ fn parse_item_native_mod(p: &parser, attrs: &[ast::attribute]) -> @ast::item {
let abi = ast::native_abi_cdecl;
if !is_word(p, ~"mod") {
let t = parse_str(p);
if istr::eq(t, ~"cdecl") {
} else if istr::eq(t, ~"rust") {
if str::eq(t, ~"cdecl") {
} else if str::eq(t, ~"rust") {
abi = ast::native_abi_rust;
} else if istr::eq(t, ~"llvm") {
} else if str::eq(t, ~"llvm") {
abi = ast::native_abi_llvm;
} else if istr::eq(t, ~"rust-intrinsic") {
} else if str::eq(t, ~"rust-intrinsic") {
abi = ast::native_abi_rust_intrinsic;
} else if istr::eq(t, ~"x86stdcall") {
} else if str::eq(t, ~"x86stdcall") {
abi = ast::native_abi_x86stdcall;
} else { p.fatal(~"unsupported abi: " + t); }
}
@ -2419,8 +2419,8 @@ fn is_view_item(p: &parser) -> bool {
alt p.peek() {
token::IDENT(sid, false) {
let st = p.get_str(sid);
ret istr::eq(st, ~"use") || istr::eq(st, ~"import") ||
istr::eq(st, ~"export");
ret str::eq(st, ~"use") || str::eq(st, ~"import") ||
str::eq(st, ~"export");
}
_ { ret false; }
}
@ -2450,7 +2450,7 @@ fn parse_crate_from_source_str(name: &istr, source: &istr,
let ftype = SOURCE_FILE;
let filemap = codemap::new_filemap(name, 0u, 0u);
sess.cm.files += [filemap];
let itr = @interner::mk(istr::hash, istr::eq);
let itr = @interner::mk(str::hash, str::eq);
let rdr = lexer::new_reader(sess.cm, source,
filemap, itr);
let p = new_parser(sess, cfg, rdr, ftype);
@ -2588,9 +2588,9 @@ fn parse_crate_from_crate_file(input: &istr, cfg: &ast::crate_cfg,
fn parse_crate_from_file(input: &istr, cfg: &ast::crate_cfg,
sess: &parse_sess) -> @ast::crate {
if istr::ends_with(input, ~".rc") {
if str::ends_with(input, ~".rc") {
parse_crate_from_crate_file(input, cfg, sess)
} else if istr::ends_with(input, ~".rs") {
} else if str::ends_with(input, ~".rs") {
parse_crate_from_source_file(input, cfg, sess)
} else {
codemap::emit_error(none, ~"unknown input file type: "

View file

@ -5,7 +5,7 @@ import std::map::new_str_hash;
import util::interner;
import std::int;
import std::uint;
import std::istr;
import std::str;
type str_num = uint;
@ -166,8 +166,8 @@ fn to_str(r: lexer::reader, t: token) -> istr {
LIT_CHAR(c) {
// FIXME: escape.
let tmp = ~"'";
istr::push_char(tmp, c);
istr::push_byte(tmp, '\'' as u8);
str::push_char(tmp, c);
str::push_byte(tmp, '\'' as u8);
ret tmp;
}
LIT_BOOL(b) { if b { ret ~"true"; } else { ret ~"false"; } }

View file

@ -1,7 +1,7 @@
import std::io;
import std::vec;
import std::istr;
import std::str;
/*
* This pretty-printer is a direct reimplementation of Philip Karlton's
@ -496,7 +496,7 @@ fn end(p: printer) { p.pretty_print(END); }
fn eof(p: printer) { p.pretty_print(EOF); }
fn word(p: printer, wrd: &istr) {
p.pretty_print(STRING(wrd, istr::char_len(wrd) as int));
p.pretty_print(STRING(wrd, str::char_len(wrd) as int));
}
fn huge_word(p: printer, wrd: &istr) {

View file

@ -2,7 +2,7 @@
import std::vec;
import std::int;
import std::io;
import std::istr;
import std::str;
import std::uint;
import std::option;
import parse::lexer;
@ -156,7 +156,7 @@ fn head(s: &ps, w: &istr) {
// outer-box is consistent
cbox(s, indent_unit);
// head-box is inconsistent
ibox(s, istr::char_len(w) + 1u);
ibox(s, str::char_len(w) + 1u);
// keyword that starts the head
word_nbsp(s, w);
}
@ -432,7 +432,7 @@ fn print_item(s: &ps, item: &@ast::item) {
}
word_nbsp(s, ~"mod");
word_nbsp(s, item.ident);
if !istr::eq(nmod.native_name, item.ident) {
if !str::eq(nmod.native_name, item.ident) {
word_space(s, ~"=");
print_string(s, nmod.native_name);
nbsp(s);
@ -458,7 +458,7 @@ fn print_item(s: &ps, item: &@ast::item) {
ast::item_tag(variants, params) {
let newtype =
vec::len(variants) == 1u &&
istr::eq(item.ident, variants[0].node.name) &&
str::eq(item.ident, variants[0].node.name) &&
vec::len(variants[0].node.args) == 1u;
if newtype {
ibox(s, indent_unit);
@ -1318,7 +1318,7 @@ fn print_view_item(s: &ps, item: &@ast::view_item) {
}
ast::view_item_import(id, ids, _) {
head(s, ~"import");
if !istr::eq(id, ids[vec::len(ids) - 1u]) {
if !str::eq(id, ids[vec::len(ids) - 1u]) {
word_space(s, id);
word_space(s, ~"=");
}
@ -1510,7 +1510,7 @@ fn print_literal(s: &ps, lit: &@ast::lit) {
}
ast::lit_char(ch) {
word(s.s,
~"'" + escape_str(istr::unsafe_from_bytes([ch as u8]), '\'') +
~"'" + escape_str(str::unsafe_from_bytes([ch as u8]), '\'') +
~"'");
}
ast::lit_int(val) { word(s.s, int::str(val)); }
@ -1572,7 +1572,7 @@ fn print_comment(s: &ps, cmnt: lexer::cmnt) {
for line: istr in cmnt.lines {
// Don't print empty lines because they will end up as trailing
// whitespace
if istr::is_not_empty(line) {
if str::is_not_empty(line) {
word(s.s, line);
}
hardbreak(s.s);
@ -1586,7 +1586,7 @@ fn print_comment(s: &ps, cmnt: lexer::cmnt) {
} else {
ibox(s, 0u);
for line: istr in cmnt.lines {
if istr::is_not_empty(line) {
if str::is_not_empty(line) {
word(s.s, line);
}
hardbreak(s.s);
@ -1615,7 +1615,7 @@ fn print_string(s: &ps, st: &istr) {
fn escape_str(st: &istr, to_escape: char) -> istr {
let out: istr = ~"";
let len = istr::byte_len(st);
let len = str::byte_len(st);
let i = 0u;
while i < len {
alt st[i] as char {
@ -1627,7 +1627,7 @@ fn escape_str(st: &istr, to_escape: char) -> istr {
if cur == to_escape { out += ~"\\"; }
// FIXME some (or all?) non-ascii things should be escaped
istr::push_char(out, cur);
str::push_char(out, cur);
}
}
i += 1u;