Switch all vases of vec += elt to vec += vec. Prohibit former in rustboot. Tweak std lib vec fns in process.

This commit is contained in:
Graydon Hoare 2011-03-16 14:58:02 -07:00
parent 23eef4da22
commit 54587bdccb
29 changed files with 278 additions and 225 deletions

View file

@ -13,7 +13,6 @@ import front.parser.new_parser;
import front.parser.parse_mod_items;
import util.common;
import util.common.filename;
import util.common.append;
import util.common.span;
import util.common.new_str_hash;
@ -394,7 +393,7 @@ impure fn eval_crate_directive(parser p,
auto im = ast.item_mod(id, m0, next_id);
auto i = @spanned(cdir.span, cdir.span, im);
ast.index_item(index, i);
append[@ast.item](items, i);
_vec.push[@ast.item](items, i);
}
case (ast.cdir_dir_mod(?id, ?dir_opt, ?cdirs)) {
@ -412,11 +411,11 @@ impure fn eval_crate_directive(parser p,
auto im = ast.item_mod(id, m0, p.next_def_id());
auto i = @spanned(cdir.span, cdir.span, im);
ast.index_item(index, i);
append[@ast.item](items, i);
_vec.push[@ast.item](items, i);
}
case (ast.cdir_view_item(?vi)) {
append[@ast.view_item](view_items, vi);
_vec.push[@ast.view_item](view_items, vi);
ast.index_view_item(index, vi);
}

View file

@ -113,7 +113,7 @@ fn parse_fmt_string(str s) -> vec[piece] {
fn flush_buf(str buf, &vec[piece] pieces) -> str {
if (_str.byte_len(buf) > 0u) {
auto piece = piece_string(buf);
pieces += piece;
pieces += vec(piece);
}
ret "";
}
@ -133,7 +133,7 @@ fn parse_fmt_string(str s) -> vec[piece] {
} else {
buf = flush_buf(buf, pieces);
auto res = parse_conversion(s, i, lim);
pieces += res._0;
pieces += vec(res._0);
i = res._1;
}
} else {

View file

@ -420,7 +420,7 @@ impure fn next_token(reader rdr) -> token.token {
if (is_alpha(c) || c == '_') {
while (is_alnum(c) || c == '_') {
accum_str += (c as u8);
_str.push_byte(accum_str, (c as u8));
rdr.bump();
c = rdr.curr();
}
@ -580,23 +580,23 @@ impure fn next_token(reader rdr) -> token.token {
alt (rdr.next()) {
case ('n') {
rdr.bump();
accum_str += '\n' as u8;
_str.push_byte(accum_str, '\n' as u8);
}
case ('r') {
rdr.bump();
accum_str += '\r' as u8;
_str.push_byte(accum_str, '\r' as u8);
}
case ('t') {
rdr.bump();
accum_str += '\t' as u8;
_str.push_byte(accum_str, '\t' as u8);
}
case ('\\') {
rdr.bump();
accum_str += '\\' as u8;
_str.push_byte(accum_str, '\\' as u8);
}
case ('"') {
rdr.bump();
accum_str += '"' as u8;
_str.push_byte(accum_str, '"' as u8);
}
// FIXME: unicode numeric escapes.
case (?c2) {
@ -607,7 +607,7 @@ impure fn next_token(reader rdr) -> token.token {
}
}
case (_) {
accum_str += rdr.curr() as u8;
_str.push_byte(accum_str, rdr.curr() as u8);
}
}
rdr.bump();

View file

@ -9,7 +9,6 @@ import std.map.hashmap;
import driver.session;
import util.common;
import util.common.filename;
import util.common.append;
import util.common.span;
import util.common.new_str_hash;
@ -303,7 +302,7 @@ impure fn parse_constrs(parser p) -> common.spanned[vec[@ast.constr]] {
case (token.IDENT(_)) {
auto constr = parse_ty_constr(p);
hi = constr.span;
append[@ast.constr](constrs, constr);
_vec.push[@ast.constr](constrs, constr);
if (p.peek() == token.COMMA) {
p.bump();
more = false;
@ -573,7 +572,7 @@ impure fn parse_path(parser p, greed g) -> ast.path {
alt (p.peek()) {
case (token.IDENT(?i)) {
hi = p.get_span();
ids += i;
ids += vec(i);
p.bump();
if (p.peek() == token.DOT) {
if (g == GREEDY) {
@ -699,7 +698,7 @@ impure fn parse_bottom_expr(parser p) -> @ast.expr {
}
case (token.COMMA) {
p.bump();
fields += parse_field(p);
fields += vec(parse_field(p));
}
case (?t) {
unexpected(p, t);
@ -877,7 +876,7 @@ impure fn extend_expr_by_ident(parser p, span lo, span hi,
case (ast.expr_path(?pth, ?def, ?ann)) {
if (_vec.len[@ast.ty](pth.node.types) == 0u) {
auto idents_ = pth.node.idents;
idents_ += i;
idents_ += vec(i);
auto tys = parse_ty_args(p, hi);
auto pth_ = spanned(pth.span, tys.span,
rec(idents=idents_,
@ -1763,8 +1762,8 @@ impure fn parse_item_obj(parser p, ast.layer lyr) -> @ast.item {
dtor = some[ast.block](parse_block(p));
}
case (_) {
append[@ast.method](meths,
parse_method(p));
_vec.push[@ast.method](meths,
parse_method(p));
}
}
}
@ -2161,12 +2160,11 @@ impure fn parse_rest_import_name(parser p, ast.ident first,
-> @ast.view_item {
auto lo = p.get_span();
auto hi = lo;
let vec[ast.ident] identifiers = vec();
identifiers += first;
let vec[ast.ident] identifiers = vec(first);
while (p.peek() != token.SEMI) {
expect(p, token.DOT);
auto i = parse_ident(p);
identifiers += i;
identifiers += vec(i);
}
p.bump();
auto defined_id;
@ -2402,7 +2400,7 @@ impure fn parse_crate_directives(parser p, token.token term)
while (p.peek() != term) {
auto cdir = @parse_crate_directive(p);
append[@ast.crate_directive](cdirs, cdir);
_vec.push[@ast.crate_directive](cdirs, cdir);
}
ret cdirs;

View file

@ -3,6 +3,7 @@ import util.common.ty_mach_to_str;
import util.common.new_str_hash;
import std._int;
import std._uint;
import std._str;
tag binop {
PLUS;
@ -302,8 +303,8 @@ fn to_str(token t) -> str {
case (LIT_CHAR(?c)) {
// FIXME: escape and encode.
auto tmp = "'";
tmp += c as u8;
tmp += '\'' as u8;
_str.push_byte(tmp, c as u8);
_str.push_byte(tmp, '\'' as u8);
ret tmp;
}