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:
parent
23eef4da22
commit
54587bdccb
29 changed files with 278 additions and 225 deletions
|
|
@ -469,7 +469,6 @@ TEST_XFAILS_RUSTC := $(addprefix test/run-pass/, \
|
|||
acyclic-unwind.rs \
|
||||
alt-pattern-drop.rs \
|
||||
alt-type-simple.rs \
|
||||
append-units.rs \
|
||||
basic-1.rs \
|
||||
basic-2.rs \
|
||||
basic.rs \
|
||||
|
|
|
|||
|
|
@ -993,8 +993,7 @@ let check_block (cx:Semant.ctxt) : (fn_ctx -> Ast.block -> unit) =
|
|||
let src_ty = check_atom ~deref:true src in
|
||||
let dst_ty = check_lval dst in
|
||||
match fundamental_ty dst_ty, fundamental_ty src_ty with
|
||||
Ast.TY_vec elt1, Ast.TY_vec elt2
|
||||
| Ast.TY_vec elt1, elt2 ->
|
||||
Ast.TY_vec elt1, Ast.TY_vec elt2 ->
|
||||
if elt1 = elt2
|
||||
then ()
|
||||
else
|
||||
|
|
@ -1002,7 +1001,6 @@ let check_block (cx:Semant.ctxt) : (fn_ctx -> Ast.block -> unit) =
|
|||
"mismatched types in vec-append: %s += %s"
|
||||
(pretty_ty_str dst_ty)
|
||||
(pretty_ty_str src_ty)
|
||||
| Ast.TY_str, (Ast.TY_mach Common.TY_u8)
|
||||
| Ast.TY_str, Ast.TY_str -> ()
|
||||
| _ ->
|
||||
infer_lval src_ty dst;
|
||||
|
|
|
|||
|
|
@ -203,8 +203,8 @@ impure fn main(vec[str] args) {
|
|||
alt (output_file) {
|
||||
case (none[str]) {
|
||||
let vec[str] parts = _str.split(ifile, '.' as u8);
|
||||
parts = _vec.pop[str](parts);
|
||||
parts += ".bc";
|
||||
_vec.pop[str](parts);
|
||||
parts += vec(".bc");
|
||||
auto ofile = _str.concat(parts);
|
||||
compile_input(sess, env, ifile, ofile, shared,
|
||||
library_search_paths);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import util.common.new_str_hash;
|
|||
import util.common.spanned;
|
||||
import util.common.span;
|
||||
import util.common.ty_mach;
|
||||
import util.common.append;
|
||||
|
||||
import front.ast;
|
||||
import front.ast.fn_decl;
|
||||
|
|
@ -318,7 +317,7 @@ type ast_fold[ENV] =
|
|||
fn fold_path[ENV](&ENV env, ast_fold[ENV] fld, &path p) -> path {
|
||||
let vec[@ast.ty] tys_ = vec();
|
||||
for (@ast.ty t in p.node.types) {
|
||||
append[@ast.ty](tys_, fold_ty(env, fld, t));
|
||||
_vec.push[@ast.ty](tys_, fold_ty(env, fld, t));
|
||||
}
|
||||
let ast.path_ p_ = rec(idents=p.node.idents, types=tys_);
|
||||
ret fld.fold_path(env, p.span, p_);
|
||||
|
|
@ -357,7 +356,7 @@ fn fold_ty[ENV](&ENV env, ast_fold[ENV] fld, @ty t) -> @ty {
|
|||
case (ast.ty_tup(?elts)) {
|
||||
let vec[@ty] elts_ = vec();
|
||||
for (@ty elt in elts) {
|
||||
append[@ty](elts_,fold_ty(env, fld, elt));
|
||||
_vec.push[@ty](elts_,fold_ty(env, fld, elt));
|
||||
}
|
||||
ret fld.fold_ty_tup(env_, t.span, elts_);
|
||||
}
|
||||
|
|
@ -365,7 +364,7 @@ fn fold_ty[ENV](&ENV env, ast_fold[ENV] fld, @ty t) -> @ty {
|
|||
case (ast.ty_rec(?flds)) {
|
||||
let vec[ast.ty_field] flds_ = vec();
|
||||
for (ast.ty_field f in flds) {
|
||||
append[ast.ty_field]
|
||||
_vec.push[ast.ty_field]
|
||||
(flds_, rec(ty=fold_ty(env, fld, f.ty) with f));
|
||||
}
|
||||
ret fld.fold_ty_rec(env_, t.span, flds_);
|
||||
|
|
@ -378,7 +377,7 @@ fn fold_ty[ENV](&ENV env, ast_fold[ENV] fld, @ty t) -> @ty {
|
|||
m.inputs, m.output);
|
||||
alt (tfn.node) {
|
||||
case (ast.ty_fn(?p, ?ins, ?out)) {
|
||||
append[ast.ty_method]
|
||||
_vec.push[ast.ty_method]
|
||||
(meths_, rec(proto=p, inputs=ins, output=out
|
||||
with m));
|
||||
}
|
||||
|
|
@ -494,7 +493,7 @@ fn fold_pat[ENV](&ENV env, ast_fold[ENV] fld, @ast.pat p) -> @ast.pat {
|
|||
fn fold_exprs[ENV](&ENV env, ast_fold[ENV] fld, vec[@expr] es) -> vec[@expr] {
|
||||
let vec[@expr] exprs = vec();
|
||||
for (@expr e in es) {
|
||||
append[@expr](exprs, fold_expr(env, fld, e));
|
||||
_vec.push[@expr](exprs, fold_expr(env, fld, e));
|
||||
}
|
||||
ret exprs;
|
||||
}
|
||||
|
|
@ -525,7 +524,7 @@ fn fold_expr[ENV](&ENV env, ast_fold[ENV] fld, &@expr e) -> @expr {
|
|||
case (ast.expr_tup(?es, ?t)) {
|
||||
let vec[ast.elt] elts = vec();
|
||||
for (ast.elt e in es) {
|
||||
elts += fold_tup_elt[ENV](env, fld, e);
|
||||
elts += vec(fold_tup_elt[ENV](env, fld, e));
|
||||
}
|
||||
ret fld.fold_expr_tup(env_, e.span, elts, t);
|
||||
}
|
||||
|
|
@ -534,7 +533,7 @@ fn fold_expr[ENV](&ENV env, ast_fold[ENV] fld, &@expr e) -> @expr {
|
|||
let vec[ast.field] fields = vec();
|
||||
let option.t[@expr] b = none[@expr];
|
||||
for (ast.field f in fs) {
|
||||
fields += fold_rec_field(env, fld, f);
|
||||
fields += vec(fold_rec_field(env, fld, f));
|
||||
}
|
||||
alt (base) {
|
||||
case (none[@ast.expr]) { }
|
||||
|
|
@ -557,7 +556,7 @@ fn fold_expr[ENV](&ENV env, ast_fold[ENV] fld, &@expr e) -> @expr {
|
|||
for (option.t[@ast.expr] t_opt in args_opt) {
|
||||
alt (t_opt) {
|
||||
case (none[@ast.expr]) {
|
||||
aargs_opt += none[@ast.expr];
|
||||
aargs_opt += vec(none[@ast.expr]);
|
||||
}
|
||||
case (some[@ast.expr](?e)) {
|
||||
aargs_opt += vec(some(fold_expr(env_, fld, e)));
|
||||
|
|
@ -779,7 +778,7 @@ fn fold_block[ENV](&ENV env, ast_fold[ENV] fld, &block blk) -> block {
|
|||
let vec[@ast.stmt] stmts = vec();
|
||||
for (@ast.stmt s in blk.node.stmts) {
|
||||
auto new_stmt = fold_stmt[ENV](env_, fld, s);
|
||||
append[@ast.stmt](stmts, new_stmt);
|
||||
_vec.push[@ast.stmt](stmts, new_stmt);
|
||||
ast.index_stmt(index, new_stmt);
|
||||
}
|
||||
|
||||
|
|
@ -812,7 +811,7 @@ fn fold_fn_decl[ENV](&ENV env, ast_fold[ENV] fld,
|
|||
&ast.fn_decl decl) -> ast.fn_decl {
|
||||
let vec[ast.arg] inputs = vec();
|
||||
for (ast.arg a in decl.inputs) {
|
||||
inputs += fold_arg(env, fld, a);
|
||||
inputs += vec(fold_arg(env, fld, a));
|
||||
}
|
||||
auto output = fold_ty[ENV](env, fld, decl.output);
|
||||
ret fld.fold_fn_decl(env, decl.effect, inputs, output);
|
||||
|
|
@ -846,7 +845,7 @@ fn fold_obj[ENV](&ENV env, ast_fold[ENV] fld, &ast._obj ob) -> ast._obj {
|
|||
let vec[ast.obj_field] fields = vec();
|
||||
let vec[@ast.method] meths = vec();
|
||||
for (ast.obj_field f in ob.fields) {
|
||||
fields += fold_obj_field(env, fld, f);
|
||||
fields += vec(fold_obj_field(env, fld, f));
|
||||
}
|
||||
let option.t[block] dtor = none[block];
|
||||
alt (ob.dtor) {
|
||||
|
|
@ -867,7 +866,7 @@ fn fold_obj[ENV](&ENV env, ast_fold[ENV] fld, &ast._obj ob) -> ast._obj {
|
|||
m.node.ann),
|
||||
span=m.span);
|
||||
let ENV _env = fld.update_env_for_item(env, i);
|
||||
append[@ast.method](meths, fold_method(_env, fld, m));
|
||||
_vec.push[@ast.method](meths, fold_method(_env, fld, m));
|
||||
}
|
||||
ret fld.fold_obj(env, fields, meths, dtor);
|
||||
}
|
||||
|
|
@ -944,8 +943,8 @@ fn fold_item[ENV](&ENV env, ast_fold[ENV] fld, @item i) -> @item {
|
|||
auto new_ty = fold_ty[ENV](env_, fld, va.ty);
|
||||
new_args += vec(rec(ty=new_ty, id=va.id));
|
||||
}
|
||||
new_variants += rec(name=v.name, args=new_args, id=v.id,
|
||||
ann=v.ann);
|
||||
new_variants += vec(rec(name=v.name, args=new_args, id=v.id,
|
||||
ann=v.ann));
|
||||
}
|
||||
ret fld.fold_item_tag(env_, i.span, ident, new_variants,
|
||||
ty_params, id);
|
||||
|
|
@ -969,13 +968,13 @@ fn fold_mod[ENV](&ENV e, ast_fold[ENV] fld, &ast._mod m) -> ast._mod {
|
|||
|
||||
for (@view_item vi in m.view_items) {
|
||||
auto new_vi = fold_view_item[ENV](e, fld, vi);
|
||||
append[@view_item](view_items, new_vi);
|
||||
_vec.push[@view_item](view_items, new_vi);
|
||||
ast.index_view_item(index, new_vi);
|
||||
}
|
||||
|
||||
for (@item i in m.items) {
|
||||
auto new_item = fold_item[ENV](e, fld, i);
|
||||
append[@item](items, new_item);
|
||||
_vec.push[@item](items, new_item);
|
||||
ast.index_item(index, new_item);
|
||||
}
|
||||
|
||||
|
|
@ -1009,12 +1008,12 @@ fn fold_native_mod[ENV](&ENV e, ast_fold[ENV] fld,
|
|||
|
||||
for (@view_item vi in m.view_items) {
|
||||
auto new_vi = fold_view_item[ENV](e, fld, vi);
|
||||
append[@view_item](view_items, new_vi);
|
||||
_vec.push[@view_item](view_items, new_vi);
|
||||
}
|
||||
|
||||
for (@native_item i in m.items) {
|
||||
auto new_item = fold_native_item[ENV](e, fld, i);
|
||||
append[@native_item](items, new_item);
|
||||
_vec.push[@native_item](items, new_item);
|
||||
ast.index_native_item(index, new_item);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ import middle.ty.pat_ty;
|
|||
import middle.ty.plain_ty;
|
||||
|
||||
import util.common;
|
||||
import util.common.append;
|
||||
import util.common.istr;
|
||||
import util.common.new_def_hash;
|
||||
import util.common.new_str_hash;
|
||||
|
|
@ -476,7 +475,7 @@ fn type_of_explicit_args(@crate_ctxt cx,
|
|||
for (ty.arg arg in inputs) {
|
||||
if (ty.type_has_dynamic_size(arg.ty)) {
|
||||
check (arg.mode == ast.alias);
|
||||
atys += T_typaram_ptr(cx.tn);
|
||||
atys += vec(T_typaram_ptr(cx.tn));
|
||||
} else {
|
||||
let TypeRef t;
|
||||
alt (arg.mode) {
|
||||
|
|
@ -487,7 +486,7 @@ fn type_of_explicit_args(@crate_ctxt cx,
|
|||
t = type_of_inner(cx, arg.ty, false);
|
||||
}
|
||||
}
|
||||
atys += t;
|
||||
atys += vec(t);
|
||||
}
|
||||
}
|
||||
ret atys;
|
||||
|
|
@ -510,22 +509,22 @@ fn type_of_fn_full(@crate_ctxt cx,
|
|||
|
||||
// Arg 0: Output pointer.
|
||||
if (ty.type_has_dynamic_size(output)) {
|
||||
atys += T_typaram_ptr(cx.tn);
|
||||
atys += vec(T_typaram_ptr(cx.tn));
|
||||
} else {
|
||||
atys += T_ptr(type_of_inner(cx, output, false));
|
||||
atys += vec(T_ptr(type_of_inner(cx, output, false)));
|
||||
}
|
||||
|
||||
// Arg 1: Task pointer.
|
||||
atys += T_taskptr(cx.tn);
|
||||
atys += vec(T_taskptr(cx.tn));
|
||||
|
||||
// Arg 2: Env (closure-bindings / self-obj)
|
||||
alt (obj_self) {
|
||||
case (some[TypeRef](?t)) {
|
||||
check (t as int != 0);
|
||||
atys += t;
|
||||
atys += vec(t);
|
||||
}
|
||||
case (_) {
|
||||
atys += T_opaque_closure_ptr(cx.tn);
|
||||
atys += vec(T_opaque_closure_ptr(cx.tn));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -533,7 +532,7 @@ fn type_of_fn_full(@crate_ctxt cx,
|
|||
if (obj_self == none[TypeRef]) {
|
||||
auto i = 0u;
|
||||
while (i < ty_param_count) {
|
||||
atys += T_ptr(T_tydesc(cx.tn));
|
||||
atys += vec(T_ptr(T_tydesc(cx.tn)));
|
||||
i += 1u;
|
||||
}
|
||||
}
|
||||
|
|
@ -542,10 +541,11 @@ fn type_of_fn_full(@crate_ctxt cx,
|
|||
// If it's an iter, the 'output' type of the iter is actually the
|
||||
// *input* type of the function we're given as our iter-block
|
||||
// argument.
|
||||
atys += T_fn_pair(cx.tn,
|
||||
atys +=
|
||||
vec(T_fn_pair(cx.tn,
|
||||
type_of_fn_full(cx, ast.proto_fn, none[TypeRef],
|
||||
vec(rec(mode=ast.val, ty=output)),
|
||||
plain_ty(ty.ty_nil), 0u));
|
||||
plain_ty(ty.ty_nil), 0u)));
|
||||
}
|
||||
|
||||
// ... then explicit args.
|
||||
|
|
@ -568,12 +568,12 @@ fn type_of_native_fn(@crate_ctxt cx, ast.native_abi abi,
|
|||
@ty.t output) -> TypeRef {
|
||||
let vec[TypeRef] atys = vec();
|
||||
if (abi == ast.native_abi_rust) {
|
||||
atys += T_taskptr(cx.tn);
|
||||
atys += vec(T_taskptr(cx.tn));
|
||||
auto t = ty.ty_native_fn(abi, inputs, output);
|
||||
auto ty_param_count = ty.count_ty_params(plain_ty(t));
|
||||
auto i = 0u;
|
||||
while (i < ty_param_count) {
|
||||
atys += T_ptr(T_tydesc(cx.tn));
|
||||
atys += vec(T_ptr(T_tydesc(cx.tn)));
|
||||
i += 1u;
|
||||
}
|
||||
}
|
||||
|
|
@ -623,14 +623,14 @@ fn type_of_inner(@crate_ctxt cx, @ty.t t, bool boxed) -> TypeRef {
|
|||
case (ty.ty_tup(?elts)) {
|
||||
let vec[TypeRef] tys = vec();
|
||||
for (@ty.t elt in elts) {
|
||||
tys += type_of_inner(cx, elt, boxed);
|
||||
tys += vec(type_of_inner(cx, elt, boxed));
|
||||
}
|
||||
llty = T_struct(tys);
|
||||
}
|
||||
case (ty.ty_rec(?fields)) {
|
||||
let vec[TypeRef] tys = vec();
|
||||
for (ty.field f in fields) {
|
||||
tys += type_of_inner(cx, f.ty, boxed);
|
||||
tys += vec(type_of_inner(cx, f.ty, boxed));
|
||||
}
|
||||
llty = T_struct(tys);
|
||||
}
|
||||
|
|
@ -650,7 +650,7 @@ fn type_of_inner(@crate_ctxt cx, @ty.t t, bool boxed) -> TypeRef {
|
|||
type_of_fn_full(cx, m.proto,
|
||||
some[TypeRef](self_ty),
|
||||
m.inputs, m.output, 0u);
|
||||
mtys += T_ptr(mty);
|
||||
mtys += vec(T_ptr(mty));
|
||||
}
|
||||
let TypeRef vtbl = T_struct(mtys);
|
||||
let TypeRef pair = T_struct(vec(T_ptr(vtbl),
|
||||
|
|
@ -870,10 +870,10 @@ fn trans_upcall2(builder b, @glue_fns glues, ValueRef lltaskptr,
|
|||
|
||||
let ValueRef llglue = glues.upcall_glues.(n);
|
||||
let vec[ValueRef] call_args = vec(llupcall);
|
||||
call_args += b.PtrToInt(lltaskptr, T_int());
|
||||
call_args += vec( b.PtrToInt(lltaskptr, T_int()));
|
||||
|
||||
for (ValueRef a in args) {
|
||||
call_args += b.ZExtOrBitCast(a, T_int());
|
||||
call_args += vec(b.ZExtOrBitCast(a, T_int()));
|
||||
}
|
||||
|
||||
ret b.FastCall(llglue, call_args);
|
||||
|
|
@ -1112,7 +1112,7 @@ fn GEP_tup_like(@block_ctxt cx, @ty.t t,
|
|||
if (! ty.type_has_dynamic_size(t)) {
|
||||
let vec[ValueRef] v = vec();
|
||||
for (int i in ixs) {
|
||||
v += C_int(i);
|
||||
v += vec(C_int(i));
|
||||
}
|
||||
ret res(cx, cx.build.GEP(base, v));
|
||||
}
|
||||
|
|
@ -1159,8 +1159,8 @@ fn GEP_tup_like(@block_ctxt cx, @ty.t t,
|
|||
let vec[@ty.t] prefix = vec();
|
||||
let int i = 0;
|
||||
while (i < ix) {
|
||||
append[@ty.t](prefix, ty.get_element_type(t, i as uint));
|
||||
i +=1 ;
|
||||
_vec.push[@ty.t](prefix, ty.get_element_type(t, i as uint));
|
||||
i += 1 ;
|
||||
}
|
||||
|
||||
auto selected = ty.get_element_type(t, i as uint);
|
||||
|
|
@ -1310,8 +1310,8 @@ fn linearize_ty_params(@block_ctxt cx, @ty.t t)
|
|||
}
|
||||
}
|
||||
if (!seen) {
|
||||
r.vals += r.cx.fcx.lltydescs.get(pid);
|
||||
r.defs += pid;
|
||||
r.vals += vec(r.cx.fcx.lltydescs.get(pid));
|
||||
r.defs += vec(pid);
|
||||
}
|
||||
}
|
||||
case (_) { }
|
||||
|
|
@ -2365,7 +2365,7 @@ fn trans_unary(@block_ctxt cx, ast.unop op,
|
|||
auto box_ty = node_ann_type(sub.bcx.fcx.ccx, a);
|
||||
sub = trans_malloc_boxed(sub.bcx, e_ty);
|
||||
find_scope_cx(cx).cleanups +=
|
||||
clean(bind drop_ty(_, sub.val, box_ty));
|
||||
vec(clean(bind drop_ty(_, sub.val, box_ty)));
|
||||
|
||||
auto box = sub.val;
|
||||
auto rc = sub.bcx.build.GEP(box,
|
||||
|
|
@ -2646,7 +2646,8 @@ fn trans_vec_add(@block_ctxt cx, @ty.t t,
|
|||
r = copy_ty(r.bcx, INIT, tmp, lhs, t);
|
||||
auto bcx = trans_vec_append(r.bcx, t, tmp, rhs).bcx;
|
||||
tmp = load_scalar_or_boxed(bcx, tmp, t);
|
||||
find_scope_cx(cx).cleanups += clean(bind drop_ty(_, tmp, t));
|
||||
find_scope_cx(cx).cleanups +=
|
||||
vec(clean(bind drop_ty(_, tmp, t)));
|
||||
ret res(bcx, tmp);
|
||||
}
|
||||
|
||||
|
|
@ -2800,9 +2801,9 @@ fn join_results(@block_ctxt parent_cx,
|
|||
|
||||
for (result r in ins) {
|
||||
if (! is_terminated(r.bcx)) {
|
||||
live += r;
|
||||
vals += r.val;
|
||||
bbs += r.bcx.llbb;
|
||||
live += vec(r);
|
||||
vals += vec(r.val);
|
||||
bbs += vec(r.bcx.llbb);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2875,7 +2876,8 @@ fn trans_for(@block_ctxt cx,
|
|||
cx.build.Br(scope_cx.llbb);
|
||||
auto local_res = alloc_local(scope_cx, local);
|
||||
auto bcx = copy_ty(local_res.bcx, INIT, local_res.val, curr, t).bcx;
|
||||
scope_cx.cleanups += clean(bind drop_slot(_, local_res.val, t));
|
||||
scope_cx.cleanups +=
|
||||
vec(clean(bind drop_slot(_, local_res.val, t)));
|
||||
bcx = trans_block(bcx, body).bcx;
|
||||
bcx.build.Br(next_cx.llbb);
|
||||
ret res(next_cx, C_nil());
|
||||
|
|
@ -3245,7 +3247,8 @@ fn trans_pat_binding(@block_ctxt cx, @ast.pat pat, ValueRef llval)
|
|||
|
||||
llvm.LLVMSetValueName(dst, _str.buf(id));
|
||||
bcx.fcx.lllocals.insert(def_id, dst);
|
||||
bcx.cleanups += clean(bind drop_slot(_, dst, ty));
|
||||
bcx.cleanups +=
|
||||
vec(clean(bind drop_slot(_, dst, ty)));
|
||||
|
||||
ret copy_ty(bcx, INIT, dst, llval, ty);
|
||||
}
|
||||
|
|
@ -3368,7 +3371,7 @@ fn lval_generic_fn(@block_ctxt cx,
|
|||
for (@ty.t t in tys) {
|
||||
auto td = get_tydesc(bcx, t);
|
||||
bcx = td.bcx;
|
||||
append[ValueRef](tydescs, td.val);
|
||||
_vec.push[ValueRef](tydescs, td.val);
|
||||
}
|
||||
auto gen = rec( item_type = tpt._1,
|
||||
tydescs = tydescs );
|
||||
|
|
@ -3692,7 +3695,7 @@ fn trans_bind_thunk(@crate_ctxt cx,
|
|||
val = bcx.build.PointerCast(val, llout_arg_ty);
|
||||
}
|
||||
|
||||
llargs += val;
|
||||
llargs += vec(val);
|
||||
b += 1;
|
||||
}
|
||||
|
||||
|
|
@ -3706,7 +3709,7 @@ fn trans_bind_thunk(@crate_ctxt cx,
|
|||
llout_arg_ty);
|
||||
}
|
||||
|
||||
llargs += passed_arg;
|
||||
llargs += vec(passed_arg);
|
||||
a += 1u;
|
||||
}
|
||||
}
|
||||
|
|
@ -3750,7 +3753,7 @@ fn trans_bind(@block_ctxt cx, @ast.expr f,
|
|||
case (none[@ast.expr]) {
|
||||
}
|
||||
case (some[@ast.expr](?e)) {
|
||||
append[@ast.expr](bound, e);
|
||||
_vec.push[@ast.expr](bound, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3786,8 +3789,8 @@ fn trans_bind(@block_ctxt cx, @ast.expr f,
|
|||
auto arg = trans_expr(bcx, e);
|
||||
bcx = arg.bcx;
|
||||
|
||||
append[ValueRef](bound_vals, arg.val);
|
||||
append[@ty.t](bound_tys, ty.expr_ty(e));
|
||||
_vec.push[ValueRef](bound_vals, arg.val);
|
||||
_vec.push[@ty.t](bound_tys, ty.expr_ty(e));
|
||||
|
||||
i += 1u;
|
||||
}
|
||||
|
|
@ -3914,7 +3917,7 @@ fn trans_bind(@block_ctxt cx, @ast.expr f,
|
|||
pair_box);
|
||||
|
||||
find_scope_cx(cx).cleanups +=
|
||||
clean(bind drop_slot(_, pair_v, pair_ty));
|
||||
vec(clean(bind drop_slot(_, pair_v, pair_ty)));
|
||||
|
||||
ret res(bcx, pair_v);
|
||||
}
|
||||
|
|
@ -3959,23 +3962,24 @@ fn trans_args(@block_ctxt cx,
|
|||
}
|
||||
}
|
||||
if (ty.type_has_dynamic_size(retty)) {
|
||||
llargs += bcx.build.PointerCast(llretslot,
|
||||
T_typaram_ptr(cx.fcx.ccx.tn));
|
||||
llargs += vec(bcx.build.PointerCast(llretslot,
|
||||
T_typaram_ptr(cx.fcx.ccx.tn)));
|
||||
} else if (ty.count_ty_params(retty) != 0u) {
|
||||
// It's possible that the callee has some generic-ness somewhere in
|
||||
// its return value -- say a method signature within an obj or a fn
|
||||
// type deep in a structure -- which the caller has a concrete view
|
||||
// of. If so, cast the caller's view of the restlot to the callee's
|
||||
// view, for the sake of making a type-compatible call.
|
||||
llargs += cx.build.PointerCast(llretslot,
|
||||
T_ptr(type_of(bcx.fcx.ccx, retty)));
|
||||
llargs +=
|
||||
vec(cx.build.PointerCast(llretslot,
|
||||
T_ptr(type_of(bcx.fcx.ccx, retty))));
|
||||
} else {
|
||||
llargs += llretslot;
|
||||
llargs += vec(llretslot);
|
||||
}
|
||||
|
||||
|
||||
// Arg 1: Task pointer.
|
||||
llargs += bcx.fcx.lltaskptr;
|
||||
llargs += vec(bcx.fcx.lltaskptr);
|
||||
|
||||
// Arg 2: Env (closure-bindings / self-obj)
|
||||
alt (llobj) {
|
||||
|
|
@ -3983,10 +3987,10 @@ fn trans_args(@block_ctxt cx,
|
|||
// Every object is always found in memory,
|
||||
// and not-yet-loaded (as part of an lval x.y
|
||||
// doted method-call).
|
||||
llargs += bcx.build.Load(ob);
|
||||
llargs += vec(bcx.build.Load(ob));
|
||||
}
|
||||
case (_) {
|
||||
llargs += llenv;
|
||||
llargs += vec(llenv);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3997,7 +4001,7 @@ fn trans_args(@block_ctxt cx,
|
|||
alt (lliterbody) {
|
||||
case (none[ValueRef]) {}
|
||||
case (some[ValueRef](?lli)) {
|
||||
llargs += lli;
|
||||
llargs += vec(lli);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -4054,7 +4058,7 @@ fn trans_args(@block_ctxt cx,
|
|||
val = bcx.build.PointerCast(val, lldestty);
|
||||
}
|
||||
|
||||
llargs += val;
|
||||
llargs += vec(val);
|
||||
i += 1u;
|
||||
}
|
||||
|
||||
|
|
@ -4116,7 +4120,8 @@ fn trans_call(@block_ctxt cx, @ast.expr f,
|
|||
// Retval doesn't correspond to anything really tangible in the frame,
|
||||
// but it's a ref all the same, so we put a note here to drop it when
|
||||
// we're done in this scope.
|
||||
find_scope_cx(cx).cleanups += clean(bind drop_ty(_, retval, ret_ty));
|
||||
find_scope_cx(cx).cleanups +=
|
||||
vec(clean(bind drop_ty(_, retval, ret_ty)));
|
||||
}
|
||||
|
||||
ret res(bcx, retval);
|
||||
|
|
@ -4130,7 +4135,8 @@ fn trans_tup(@block_ctxt cx, vec[ast.elt] elts,
|
|||
auto tup_val = tup_res.val;
|
||||
bcx = tup_res.bcx;
|
||||
|
||||
find_scope_cx(cx).cleanups += clean(bind drop_ty(_, tup_val, t));
|
||||
find_scope_cx(cx).cleanups +=
|
||||
vec(clean(bind drop_ty(_, tup_val, t)));
|
||||
let int i = 0;
|
||||
|
||||
for (ast.elt e in elts) {
|
||||
|
|
@ -4171,7 +4177,8 @@ fn trans_vec(@block_ctxt cx, vec[@ast.expr] args,
|
|||
|
||||
auto llty = type_of(bcx.fcx.ccx, t);
|
||||
auto vec_val = vi2p(bcx, sub.val, llty);
|
||||
find_scope_cx(bcx).cleanups += clean(bind drop_ty(_, vec_val, t));
|
||||
find_scope_cx(bcx).cleanups +=
|
||||
vec(clean(bind drop_ty(_, vec_val, t)));
|
||||
|
||||
auto body = bcx.build.GEP(vec_val, vec(C_int(0),
|
||||
C_int(abi.vec_elt_data)));
|
||||
|
|
@ -4226,7 +4233,8 @@ fn trans_rec(@block_ctxt cx, vec[ast.field] fields,
|
|||
auto rec_val = rec_res.val;
|
||||
bcx = rec_res.bcx;
|
||||
|
||||
find_scope_cx(cx).cleanups += clean(bind drop_ty(_, rec_val, t));
|
||||
find_scope_cx(cx).cleanups +=
|
||||
vec(clean(bind drop_ty(_, rec_val, t)));
|
||||
let int i = 0;
|
||||
|
||||
auto base_val = C_nil();
|
||||
|
|
@ -4499,7 +4507,7 @@ fn trans_put(@block_ctxt cx, &option.t[@ast.expr] e) -> result {
|
|||
llarg = bcx.build.Load(llarg);
|
||||
}
|
||||
|
||||
llargs += llarg;
|
||||
llargs += vec(llarg);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -4557,7 +4565,7 @@ fn init_local(@block_ctxt cx, @ast.local local) -> result {
|
|||
auto bcx = cx;
|
||||
|
||||
find_scope_cx(cx).cleanups +=
|
||||
clean(bind drop_slot(_, llptr, ty));
|
||||
vec(clean(bind drop_slot(_, llptr, ty)));
|
||||
|
||||
alt (local.init) {
|
||||
case (some[@ast.expr](?e)) {
|
||||
|
|
@ -5026,7 +5034,7 @@ fn trans_vtbl(@crate_ctxt cx, TypeRef self_ty,
|
|||
|
||||
trans_fn(mcx, m.node.meth, m.node.id, some[TypeRef](self_ty),
|
||||
ty_params, m.node.ann);
|
||||
methods += llfn;
|
||||
methods += vec(llfn);
|
||||
}
|
||||
auto vtbl = C_struct(methods);
|
||||
auto gvar = llvm.LLVMAddGlobal(cx.llmod,
|
||||
|
|
@ -5085,14 +5093,14 @@ fn trans_obj(@crate_ctxt cx, &ast._obj ob, ast.def_id oid,
|
|||
// Malloc a box for the body and copy args in.
|
||||
let vec[@ty.t] obj_fields = vec();
|
||||
for (ty.arg a in arg_tys) {
|
||||
append[@ty.t](obj_fields, a.ty);
|
||||
_vec.push[@ty.t](obj_fields, a.ty);
|
||||
}
|
||||
|
||||
// Synthesize an obj body type.
|
||||
auto tydesc_ty = plain_ty(ty.ty_type);
|
||||
let vec[@ty.t] tps = vec();
|
||||
for (ast.ty_param tp in ty_params) {
|
||||
append[@ty.t](tps, tydesc_ty);
|
||||
_vec.push[@ty.t](tps, tydesc_ty);
|
||||
}
|
||||
|
||||
let @ty.t typarams_ty = plain_ty(ty.ty_tup(tps));
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import driver.session;
|
|||
import front.ast;
|
||||
import front.ast.mutability;
|
||||
import util.common;
|
||||
import util.common.append;
|
||||
import util.common.new_def_hash;
|
||||
import util.common.span;
|
||||
|
||||
|
|
@ -756,7 +755,7 @@ fn field_num(session.session sess, &span sp, &ast.ident id) -> uint {
|
|||
accum += (c as uint) - ('0' as uint);
|
||||
} else {
|
||||
auto s = "";
|
||||
s += c;
|
||||
s += _str.unsafe_from_byte(c);
|
||||
sess.span_err(sp,
|
||||
"bad numeric field on tuple: "
|
||||
+ " non-digit character: "
|
||||
|
|
@ -1104,7 +1103,7 @@ fn unify(@ty.t expected, @ty.t actual, &unify_handler handler)
|
|||
|
||||
alt (result) {
|
||||
case (ures_ok(?rty)) {
|
||||
append[@ty.t](result_tps, rty);
|
||||
_vec.push[@ty.t](result_tps, rty);
|
||||
}
|
||||
case (_) {
|
||||
ret result;
|
||||
|
|
@ -1244,7 +1243,7 @@ fn unify(@ty.t expected, @ty.t actual, &unify_handler handler)
|
|||
handler);
|
||||
alt (result) {
|
||||
case (ures_ok(?rty)) {
|
||||
append[@ty.t](result_elems,rty);
|
||||
_vec.push[@ty.t](result_elems,rty);
|
||||
}
|
||||
case (_) {
|
||||
ret result;
|
||||
|
|
@ -1301,7 +1300,7 @@ fn unify(@ty.t expected, @ty.t actual, &unify_handler handler)
|
|||
handler);
|
||||
alt (result) {
|
||||
case (ures_ok(?rty)) {
|
||||
append[field]
|
||||
_vec.push[field]
|
||||
(result_fields,
|
||||
rec(ty=rty with expected_field));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import front.ast.mutability;
|
|||
import middle.fold;
|
||||
import driver.session;
|
||||
import util.common;
|
||||
import util.common.append;
|
||||
import util.common.span;
|
||||
|
||||
import middle.ty;
|
||||
|
|
@ -320,14 +319,14 @@ fn ast_ty_to_ty(ty_getter getter, &@ast.ty ast_ty) -> @ty.t {
|
|||
case (ast.ty_tup(?fields)) {
|
||||
let vec[@ty.t] flds = vec();
|
||||
for (@ast.ty field in fields) {
|
||||
append[@ty.t](flds, ast_ty_to_ty(getter, field));
|
||||
_vec.push[@ty.t](flds, ast_ty_to_ty(getter, field));
|
||||
}
|
||||
sty = ty.ty_tup(flds);
|
||||
}
|
||||
case (ast.ty_rec(?fields)) {
|
||||
let vec[field] flds = vec();
|
||||
for (ast.ty_field f in fields) {
|
||||
append[field](flds, rec(ident=f.ident,
|
||||
_vec.push[field](flds, rec(ident=f.ident,
|
||||
ty=ast_ty_to_ty(getter, f.ty)));
|
||||
}
|
||||
sty = ty.ty_rec(flds);
|
||||
|
|
@ -371,7 +370,7 @@ fn ast_ty_to_ty(ty_getter getter, &@ast.ty ast_ty) -> @ty.t {
|
|||
for (ast.ty_method m in meths) {
|
||||
auto ins = _vec.map[ast.ty_arg, arg](f, m.inputs);
|
||||
auto out = ast_ty_to_ty(getter, m.output);
|
||||
append[ty.method](tmeths,
|
||||
_vec.push[ty.method](tmeths,
|
||||
rec(proto=m.proto,
|
||||
ident=m.ident,
|
||||
inputs=ins,
|
||||
|
|
@ -565,7 +564,7 @@ fn collect_item_types(session.session sess, @ast.crate crate)
|
|||
for (ast.obj_field f in obj_info.fields) {
|
||||
auto g = bind getter(id_to_ty_item, item_to_ty, _);
|
||||
auto t_field = ast_ty_to_ty(g, f.ty);
|
||||
append[arg](t_inputs, rec(mode=ast.alias, ty=t_field));
|
||||
_vec.push[arg](t_inputs, rec(mode=ast.alias, ty=t_field));
|
||||
}
|
||||
auto t_fn = plain_ty(ty.ty_fn(ast.proto_fn, t_inputs, t_obj));
|
||||
ret t_fn;
|
||||
|
|
@ -870,7 +869,7 @@ fn collect_item_types(session.session sess, @ast.crate crate)
|
|||
with meth.node
|
||||
);
|
||||
m = @rec(node=m_ with *meth);
|
||||
append[@ast.method](methods, m);
|
||||
_vec.push[@ast.method](methods, m);
|
||||
}
|
||||
auto g = bind getter(e.id_to_ty_item, e.item_to_ty, _);
|
||||
for (ast.obj_field fld in ob.fields) {
|
||||
|
|
@ -879,7 +878,7 @@ fn collect_item_types(session.session sess, @ast.crate crate)
|
|||
ann=ast.ann_type(fty, none[vec[@ty.t]])
|
||||
with fld
|
||||
);
|
||||
append[ast.obj_field](fields, f);
|
||||
_vec.push[ast.obj_field](fields, f);
|
||||
}
|
||||
|
||||
auto ob_ = rec(methods = methods,
|
||||
|
|
@ -1572,14 +1571,14 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
|
|||
|
||||
// FIXME: this breaks aliases. We need a ty_fn_arg.
|
||||
auto arg_ty = rec(mode=ast.val, ty=expr_ty(a_0));
|
||||
append[arg](arg_tys_0, arg_ty);
|
||||
_vec.push[arg](arg_tys_0, arg_ty);
|
||||
}
|
||||
case (none[@ast.expr]) {
|
||||
args_0 += vec(none[@ast.expr]);
|
||||
|
||||
// FIXME: breaks aliases too?
|
||||
auto typ = next_ty_var(fcx.ccx);
|
||||
append[arg](arg_tys_0, rec(mode=ast.val, ty=typ));
|
||||
_vec.push[arg](arg_tys_0, rec(mode=ast.val, ty=typ));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1623,10 +1622,11 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
|
|||
case (some[@ast.expr](?e_0)) {
|
||||
auto arg_ty_1 = arg_tys_1.(i);
|
||||
auto e_1 = demand_expr(fcx, arg_ty_1.ty, e_0);
|
||||
append[option.t[@ast.expr]](args_1, some[@ast.expr](e_1));
|
||||
_vec.push[option.t[@ast.expr]](args_1,
|
||||
some[@ast.expr](e_1));
|
||||
}
|
||||
case (none[@ast.expr]) {
|
||||
append[option.t[@ast.expr]](args_1, none[@ast.expr]);
|
||||
_vec.push[option.t[@ast.expr]](args_1, none[@ast.expr]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2114,7 +2114,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
|
|||
auto expr_1 = check_expr(fcx, e);
|
||||
auto expr_t = expr_ty(expr_1);
|
||||
demand(fcx, expr.span, t, expr_t);
|
||||
append[@ast.expr](args_1,expr_1);
|
||||
_vec.push[@ast.expr](args_1,expr_1);
|
||||
}
|
||||
auto ann = ast.ann_type(plain_ty(ty.ty_vec(t)), none[vec[@ty.t]]);
|
||||
ret @fold.respan[ast.expr_](expr.span,
|
||||
|
|
@ -2131,8 +2131,8 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
|
|||
if (e.mut == ast.mut) {
|
||||
expr_t = @rec(mut=ast.mut with *expr_t);
|
||||
}
|
||||
append[ast.elt](elts_1, rec(expr=expr_1 with e));
|
||||
append[@ty.t](elts_t, expr_t);
|
||||
_vec.push[ast.elt](elts_1, rec(expr=expr_1 with e));
|
||||
_vec.push[@ty.t](elts_t, expr_t);
|
||||
}
|
||||
|
||||
auto ann = ast.ann_type(plain_ty(ty.ty_tup(elts_t)),
|
||||
|
|
@ -2160,8 +2160,8 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
|
|||
if (f.mut == ast.mut) {
|
||||
expr_t = @rec(mut=ast.mut with *expr_t);
|
||||
}
|
||||
append[ast.field](fields_1, rec(expr=expr_1 with f));
|
||||
append[field](fields_t, rec(ident=f.ident, ty=expr_t));
|
||||
_vec.push[ast.field](fields_1, rec(expr=expr_1 with f));
|
||||
_vec.push[field](fields_t, rec(ident=f.ident, ty=expr_t));
|
||||
}
|
||||
|
||||
auto ann = ast.ann_none;
|
||||
|
|
@ -2418,7 +2418,7 @@ fn check_stmt(&@fn_ctxt fcx, &@ast.stmt stmt) -> @ast.stmt {
|
|||
fn check_block(&@fn_ctxt fcx, &ast.block block) -> ast.block {
|
||||
let vec[@ast.stmt] stmts = vec();
|
||||
for (@ast.stmt s in block.node.stmts) {
|
||||
append[@ast.stmt](stmts, check_stmt(fcx, s));
|
||||
_vec.push[@ast.stmt](stmts, check_stmt(fcx, s));
|
||||
}
|
||||
|
||||
auto expr = none[@ast.expr];
|
||||
|
|
|
|||
|
|
@ -39,12 +39,12 @@ fn mkstate(io.writer out, uint width) -> ps {
|
|||
|
||||
impure fn push_context(ps p, contexttype tp, uint indent) {
|
||||
before_print(p, false);
|
||||
p.context = _vec.push[context](p.context, rec(tp=tp, indent=base_indent(p)
|
||||
+ indent));
|
||||
_vec.push[context](p.context, rec(tp=tp, indent=base_indent(p)
|
||||
+ indent));
|
||||
}
|
||||
|
||||
impure fn pop_context(ps p) {
|
||||
p.context = _vec.pop[context](p.context);
|
||||
fn pop_context(ps p) {
|
||||
_vec.pop[context](p.context);
|
||||
}
|
||||
|
||||
impure fn add_token(ps p, token tok) {
|
||||
|
|
@ -110,7 +110,8 @@ impure fn finish_block_scan(ps p, contexttype tp) {
|
|||
}
|
||||
p.scandepth = 0u;
|
||||
push_context(p, tp, indent);
|
||||
for (token t in _vec.shift[token](p.buffered)) {add_token(p, t);}
|
||||
_vec.shift[token](p.buffered);
|
||||
for (token t in p.buffered) { add_token(p, t); }
|
||||
}
|
||||
|
||||
impure fn finish_break_scan(ps p) {
|
||||
|
|
@ -125,7 +126,8 @@ impure fn finish_break_scan(ps p) {
|
|||
p.col += width;
|
||||
}
|
||||
p.scandepth = 0u;
|
||||
for (token t in _vec.shift[token](p.buffered)) {add_token(p, t);}
|
||||
_vec.shift[token](p.buffered);
|
||||
for (token t in p.buffered) { add_token(p, t); }
|
||||
}
|
||||
|
||||
impure fn start_scan(ps p, token tok) {
|
||||
|
|
|
|||
|
|
@ -717,7 +717,7 @@ fn escape_str(str st, char to_escape) -> str {
|
|||
case ('\\') {out += "\\\\";}
|
||||
case (?cur) {
|
||||
if (cur == to_escape) {out += "\\";}
|
||||
out += cur as u8;
|
||||
_str.push_byte(out, cur as u8);
|
||||
}
|
||||
}
|
||||
i += 1u;
|
||||
|
|
|
|||
|
|
@ -68,15 +68,6 @@ fn istr(int i) -> str {
|
|||
ret _int.to_str(i, 10u);
|
||||
}
|
||||
|
||||
|
||||
// FIXME: Weird bug. Due to the way we auto-deref + in +=, we can't append a
|
||||
// boxed value to a vector-of-boxes using +=. Best to figure out a way to fix
|
||||
// this. Deref-on-demand or something? It's a hazard of the ambiguity between
|
||||
// single-element and vector append.
|
||||
fn append[T](&mutable vec[T] v, &T t) {
|
||||
v += t;
|
||||
}
|
||||
|
||||
//
|
||||
// Local Variables:
|
||||
// mode: rust
|
||||
|
|
|
|||
|
|
@ -111,6 +111,11 @@ fn unsafe_from_bytes(vec[u8] v) -> str {
|
|||
ret rustrt.str_from_vec(v);
|
||||
}
|
||||
|
||||
fn unsafe_from_byte(u8 u) -> str {
|
||||
ret rustrt.str_from_vec(vec(u));
|
||||
}
|
||||
|
||||
|
||||
fn refcount(str s) -> uint {
|
||||
auto r = rustrt.refcount[u8](s);
|
||||
if (r == dbg.const_refcount) {
|
||||
|
|
@ -190,7 +195,6 @@ fn starts_with(str haystack, str needle) -> bool {
|
|||
ret eq(substr(haystack, 0u, needle_len), needle);
|
||||
}
|
||||
|
||||
|
||||
fn ends_with(str haystack, str needle) -> bool {
|
||||
let uint haystack_len = byte_len(haystack);
|
||||
let uint needle_len = byte_len(needle);
|
||||
|
|
@ -206,34 +210,60 @@ fn ends_with(str haystack, str needle) -> bool {
|
|||
needle);
|
||||
}
|
||||
|
||||
|
||||
fn substr(str s, uint begin, uint len) -> str {
|
||||
let str accum = "";
|
||||
let uint i = begin;
|
||||
while (i < begin+len) {
|
||||
accum += s.(i);
|
||||
accum += unsafe_from_byte(s.(i));
|
||||
i += 1u;
|
||||
}
|
||||
ret accum;
|
||||
}
|
||||
|
||||
fn shift_byte(&mutable str s) -> u8 {
|
||||
auto len = byte_len(s);
|
||||
check(len > 0u);
|
||||
auto b = s.(0);
|
||||
s = substr(s, 1u, len - 1u);
|
||||
ret b;
|
||||
}
|
||||
|
||||
fn pop_byte(&mutable str s) -> u8 {
|
||||
auto len = byte_len(s);
|
||||
check(len > 0u);
|
||||
auto b = s.(len - 1u);
|
||||
s = substr(s, 0u, len - 1u);
|
||||
ret b;
|
||||
}
|
||||
|
||||
fn push_byte(&mutable str s, u8 b) {
|
||||
s += unsafe_from_byte(b);
|
||||
}
|
||||
|
||||
fn unshift_byte(&mutable str s, u8 b) {
|
||||
auto res = alloc(byte_len(s) + 1u);
|
||||
res += unsafe_from_byte(b);
|
||||
res += s;
|
||||
s = res;
|
||||
}
|
||||
|
||||
fn split(str s, u8 sep) -> vec[str] {
|
||||
let vec[str] v = vec();
|
||||
let str accum = "";
|
||||
let bool ends_with_sep = false;
|
||||
for (u8 c in s) {
|
||||
if (c == sep) {
|
||||
v += accum;
|
||||
v += vec(accum);
|
||||
accum = "";
|
||||
ends_with_sep = true;
|
||||
} else {
|
||||
accum += c;
|
||||
accum += unsafe_from_byte(c);
|
||||
ends_with_sep = false;
|
||||
}
|
||||
}
|
||||
if (_str.byte_len(accum) != 0u ||
|
||||
ends_with_sep) {
|
||||
v += accum;
|
||||
v += vec(accum);
|
||||
}
|
||||
ret v;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ fn to_str(mutable uint n, uint radix) -> str
|
|||
|
||||
let str s = "";
|
||||
while (n != 0u) {
|
||||
s += digit(n % radix) as u8;
|
||||
s += _str.unsafe_from_byte(digit(n % radix) as u8);
|
||||
n /= radix;
|
||||
}
|
||||
|
||||
|
|
@ -69,7 +69,7 @@ fn to_str(mutable uint n, uint radix) -> str
|
|||
let uint len = _str.byte_len(s);
|
||||
while (len != 0u) {
|
||||
len -= 1u;
|
||||
s1 += s.(len);
|
||||
s1 += _str.unsafe_from_byte(s.(len));
|
||||
}
|
||||
ret s1;
|
||||
|
||||
|
|
|
|||
|
|
@ -103,28 +103,32 @@ fn slice[T](vec[T] v, uint start, uint end) -> vec[T] {
|
|||
ret result;
|
||||
}
|
||||
|
||||
fn shift[T](vec[T] v) -> vec[T] {
|
||||
check(len[T](v) > 0u);
|
||||
ret slice[T](v, 1u, len[T](v));
|
||||
fn shift[T](&mutable vec[T] v) -> T {
|
||||
auto ln = len[T](v);
|
||||
check(ln > 0u);
|
||||
auto e = v.(0);
|
||||
v = slice[T](v, 1u, ln);
|
||||
ret e;
|
||||
}
|
||||
|
||||
fn pop[T](vec[T] v) -> vec[T] {
|
||||
check(len[T](v) > 0u);
|
||||
ret slice[T](v, 0u, len[T](v) - 1u);
|
||||
fn pop[T](&mutable vec[T] v) -> T {
|
||||
auto ln = len[T](v);
|
||||
check(ln > 0u);
|
||||
ln -= 1u;
|
||||
auto e = v.(ln);
|
||||
v = slice[T](v, 0u, ln);
|
||||
ret e;
|
||||
}
|
||||
|
||||
fn push[T](vec[T] v, &T t) -> vec[T] {
|
||||
v += t;
|
||||
ret v;
|
||||
fn push[T](&mutable vec[T] v, &T t) {
|
||||
v += vec(t);
|
||||
}
|
||||
|
||||
fn unshift[T](vec[T] v, &T t) -> vec[T] {
|
||||
fn unshift[T](&mutable vec[T] v, &T t) {
|
||||
auto res = alloc[T](len[T](v) + 1u);
|
||||
res += t;
|
||||
for (T t_ in v) {
|
||||
res += t_;
|
||||
}
|
||||
ret res;
|
||||
res += vec(t);
|
||||
res += v;
|
||||
v = res;
|
||||
}
|
||||
|
||||
fn grow[T](&mutable vec[T] v, int n, &T initval) {
|
||||
|
|
@ -152,7 +156,7 @@ fn map2[T,U,V](&operator2[T,U,V] f, &vec[T] v0, &vec[U] v1) -> vec[V] {
|
|||
let vec[V] u = alloc[V](v0_len);
|
||||
auto i = 0u;
|
||||
while (i < v0_len) {
|
||||
u += f(v0.(i), v1.(i));
|
||||
u += vec(f(v0.(i), v1.(i)));
|
||||
i += 1u;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,8 +38,18 @@ impure fn list_dir(path p) -> vec[str] {
|
|||
let vec[str] full_paths = vec();
|
||||
for (str filename in os_fs.list_dir(p)) {
|
||||
if (!_str.eq(filename, ".")) {if (!_str.eq(filename, "..")) {
|
||||
full_paths = _vec.push[str](full_paths, p + filename);
|
||||
_vec.push[str](full_paths, p + filename);
|
||||
}}
|
||||
}
|
||||
ret full_paths;
|
||||
}
|
||||
|
||||
|
||||
// Local Variables:
|
||||
// mode: rust;
|
||||
// fill-column: 78;
|
||||
// indent-tabs-mode: nil
|
||||
// c-basic-offset: 4
|
||||
// buffer-file-coding-system: utf-8-unix
|
||||
// compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
|
||||
// End:
|
||||
|
|
|
|||
|
|
@ -10,10 +10,19 @@ impure fn list_dir(str path) -> vec[str] {
|
|||
while (true) {
|
||||
auto ent = os.libc.readdir(dir);
|
||||
if (ent as int == 0) {break;}
|
||||
result = _vec.push[str](result, rustrt.rust_dirent_filename(ent));
|
||||
_vec.push[str](result, rustrt.rust_dirent_filename(ent));
|
||||
}
|
||||
os.libc.closedir(dir);
|
||||
ret result;
|
||||
}
|
||||
|
||||
const char path_sep = '/';
|
||||
|
||||
// Local Variables:
|
||||
// mode: rust;
|
||||
// fill-column: 78;
|
||||
// indent-tabs-mode: nil
|
||||
// c-basic-offset: 4
|
||||
// buffer-file-coding-system: utf-8-unix
|
||||
// compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
|
||||
// End:
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ native "rust" mod rustrt {
|
|||
fn argvec(str prog, vec[str] args) -> vec[sbuf] {
|
||||
auto argptrs = vec(_str.buf(prog));
|
||||
for (str arg in args) {
|
||||
argptrs = _vec.push[sbuf](argptrs, _str.buf(arg));
|
||||
_vec.push[sbuf](argptrs, _str.buf(arg));
|
||||
}
|
||||
argptrs = _vec.push[sbuf](argptrs, 0 as sbuf);
|
||||
_vec.push[sbuf](argptrs, 0 as sbuf);
|
||||
ret argptrs;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -169,10 +169,11 @@ fn mk_sha1() -> sha1 {
|
|||
|
||||
let vec[u8] res = vec();
|
||||
for (u32 hpart in st.h) {
|
||||
res += (hpart >> 24u32) & 0xFFu32 as u8;
|
||||
res += (hpart >> 16u32) & 0xFFu32 as u8;
|
||||
res += (hpart >> 8u32) & 0xFFu32 as u8;
|
||||
res += hpart & 0xFFu32 as u8;
|
||||
auto a = (hpart >> 24u32) & 0xFFu32 as u8;
|
||||
auto b = (hpart >> 16u32) & 0xFFu32 as u8;
|
||||
auto c = (hpart >> 8u32) & 0xFFu32 as u8;
|
||||
auto d = (hpart & 0xFFu32 as u8);
|
||||
res += vec(a,b,c,d);
|
||||
}
|
||||
ret res;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,38 +5,38 @@ type lteq[T] = fn(&T a, &T b) -> bool;
|
|||
|
||||
fn merge_sort[T](lteq[T] le, vec[T] v) -> vec[T] {
|
||||
|
||||
fn merge[T](lteq[T] le, vec[T] a, vec[T] b) -> vec[T] {
|
||||
let vec[T] res = vec();
|
||||
let uint a_len = len[T](a);
|
||||
let uint a_ix = 0u;
|
||||
let uint b_len = len[T](b);
|
||||
let uint b_ix = 0u;
|
||||
while (a_ix < a_len && b_ix < b_len) {
|
||||
if (le(a.(a_ix), b.(b_ix))) {
|
||||
res += a.(a_ix);
|
||||
a_ix += 1u;
|
||||
} else {
|
||||
res += b.(b_ix);
|
||||
b_ix += 1u;
|
||||
}
|
||||
fn merge[T](lteq[T] le, vec[T] a, vec[T] b) -> vec[T] {
|
||||
let vec[T] res = vec();
|
||||
let uint a_len = len[T](a);
|
||||
let uint a_ix = 0u;
|
||||
let uint b_len = len[T](b);
|
||||
let uint b_ix = 0u;
|
||||
while (a_ix < a_len && b_ix < b_len) {
|
||||
if (le(a.(a_ix), b.(b_ix))) {
|
||||
res += vec(a.(a_ix));
|
||||
a_ix += 1u;
|
||||
} else {
|
||||
res += vec(b.(b_ix));
|
||||
b_ix += 1u;
|
||||
}
|
||||
}
|
||||
res += slice[T](a, a_ix, a_len);
|
||||
res += slice[T](b, b_ix, b_len);
|
||||
ret res;
|
||||
}
|
||||
res += slice[T](a, a_ix, a_len);
|
||||
res += slice[T](b, b_ix, b_len);
|
||||
ret res;
|
||||
}
|
||||
|
||||
let uint v_len = len[T](v);
|
||||
let uint v_len = len[T](v);
|
||||
|
||||
if (v_len <= 1u) {
|
||||
ret v;
|
||||
}
|
||||
if (v_len <= 1u) {
|
||||
ret v;
|
||||
}
|
||||
|
||||
let uint mid = v_len / 2u;
|
||||
let vec[T] a = slice[T](v, 0u, mid);
|
||||
let vec[T] b = slice[T](v, mid, v_len);
|
||||
ret merge[T](le,
|
||||
merge_sort[T](le, a),
|
||||
merge_sort[T](le, b));
|
||||
let uint mid = v_len / 2u;
|
||||
let vec[T] a = slice[T](v, 0u, mid);
|
||||
let vec[T] b = slice[T](v, mid, v_len);
|
||||
ret merge[T](le,
|
||||
merge_sort[T](le, a),
|
||||
merge_sort[T](le, b));
|
||||
}
|
||||
|
||||
// Local Variables:
|
||||
|
|
|
|||
|
|
@ -34,6 +34,17 @@ auth _str = unsafe;
|
|||
auth _vec = unsafe;
|
||||
auth _task = unsafe;
|
||||
|
||||
|
||||
// FIXME: impure on these will infect caller in a way that is totally
|
||||
// beyond reason, if the caller's mutated-argument doesn't escape;
|
||||
// 'impure' needs work.
|
||||
auth _str.unshift_byte = impure;
|
||||
auth _str.shift_byte = impure;
|
||||
auth _str.pop_byte = impure;
|
||||
auth _vec.shift = impure;
|
||||
auth _vec.unshift = impure;
|
||||
auth _vec.pop = impure;
|
||||
|
||||
auth dbg = unsafe;
|
||||
|
||||
auth _uint.next_power_of_two = unsafe;
|
||||
|
|
|
|||
|
|
@ -8,3 +8,12 @@ impure fn list_dir(str path) -> vec[str] {
|
|||
}
|
||||
|
||||
const char path_sep = '\\';
|
||||
|
||||
// Local Variables:
|
||||
// mode: rust;
|
||||
// fill-column: 78;
|
||||
// indent-tabs-mode: nil
|
||||
// c-basic-offset: 4
|
||||
// buffer-file-coding-system: utf-8-unix
|
||||
// compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
|
||||
// End:
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ case (1) {
|
|||
b += ns;
|
||||
}
|
||||
else {
|
||||
b += t.(i);
|
||||
_str.push_byte(b, t.(i));
|
||||
}
|
||||
i += 1u;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ case (1) {
|
|||
b += ns;
|
||||
}
|
||||
else {
|
||||
b += t.(i);
|
||||
_str.push_byte(b, t.(i));
|
||||
}
|
||||
i += 1u;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ fn make_cumulative(vec[aminoacids] aa) -> vec[aminoacids] {
|
|||
let vec[aminoacids] ans = vec();
|
||||
for (aminoacids a in aa) {
|
||||
cp += a._1;
|
||||
ans += tup(a._0, cp);
|
||||
ans += vec(tup(a._0, cp));
|
||||
}
|
||||
ret ans;
|
||||
}
|
||||
|
|
@ -59,7 +59,7 @@ fn make_random_fasta(str id, str desc, vec[aminoacids] genelist, int n) {
|
|||
auto rng = myrandom(std.rand.mk_rng().next());
|
||||
let str op = "";
|
||||
for each (uint i in _uint.range(0u, n as uint)) {
|
||||
op += select_random(rng.next(100u32), genelist) as u8;
|
||||
_str.push_byte(op, select_random(rng.next(100u32), genelist) as u8);
|
||||
if (_str.byte_len(op) >= LINE_LENGTH()) {
|
||||
log(op);
|
||||
op = "";
|
||||
|
|
@ -76,7 +76,7 @@ fn make_repeat_fasta(str id, str desc, str s, int n) {
|
|||
let uint sl = _str.byte_len(s);
|
||||
for each (uint i in _uint.range(0u, n as uint)) {
|
||||
|
||||
op += s.(i % sl);
|
||||
_str.push_byte(op, s.(i % sl));
|
||||
if (_str.byte_len(op) >= LINE_LENGTH()) {
|
||||
log(op);
|
||||
op = "";
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
fn main() {
|
||||
auto v = vec(1,2,3);
|
||||
v += 4;
|
||||
v += 5;
|
||||
check (v.(3) == 4);
|
||||
check (v.(4) == 5);
|
||||
|
||||
auto s = "hello";
|
||||
log s;
|
||||
s += 'z' as u8;
|
||||
s += 'y' as u8;
|
||||
log s;
|
||||
check (s.(5) == 'z' as u8);
|
||||
check (s.(6) == 'y' as u8);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue