Remove ast::ty_vec

This commit is contained in:
Brian Anderson 2011-08-18 11:46:52 -07:00
parent ec898244f7
commit c2d2dad093
12 changed files with 5 additions and 157 deletions

View File

@ -217,7 +217,6 @@ fn parse_ty(st: @pstate, sd: str_def) -> ty::t {
'@' { ret ty::mk_box(st.tcx, parse_mt(st, sd)); }
'~' { ret ty::mk_uniq(st.tcx, parse_ty(st, sd)); }
'*' { ret ty::mk_ptr(st.tcx, parse_mt(st, sd)); }
'V' { ret ty::mk_vec(st.tcx, parse_mt(st, sd)); }
'I' { ret ty::mk_ivec(st.tcx, parse_mt(st, sd)); }
'R' {
assert (next(st) as char == '[');

View File

@ -128,7 +128,6 @@ fn enc_sty(w: &io::writer, cx: &@ctxt, st: &ty::sty) {
ty::ty_box(mt) { w.write_char('@'); enc_mt(w, cx, mt); }
ty::ty_uniq(t) { w.write_char('~'); enc_ty(w, cx, t); }
ty::ty_ptr(mt) { w.write_char('*'); enc_mt(w, cx, mt); }
ty::ty_vec(mt) { w.write_char('V'); enc_mt(w, cx, mt); }
ty::ty_ivec(mt) { w.write_char('I'); enc_mt(w, cx, mt); }
ty::ty_rec(fields) {
w.write_str("R[");

View File

@ -364,7 +364,7 @@ fn check_for(cx: &ctx, local: &@ast::local, seq: &@ast::expr, blk: &ast::blk,
// If this is a mutable vector, don't allow it to be touched.
let seq_t = ty::expr_ty(cx.tcx, seq);
alt ty::struct(cx.tcx, seq_t) {
ty::ty_vec(mt) | ty::ty_ivec(mt) {
ty::ty_ivec(mt) {
if mt.mut != ast::imm { unsafe = ~[seq_t]; }
}
ty::ty_str. | ty::ty_istr. {/* no-op */ }
@ -584,12 +584,6 @@ fn maybe_auto_unbox(cx: &ctx, t: ty::t) -> {t: ty::t, ds: [deref]} {
ast::expr_index(base, _) {
let auto_unbox = maybe_auto_unbox(cx, ty::expr_ty(cx.tcx, base));
alt ty::struct(cx.tcx, auto_unbox.t) {
ty::ty_vec(mt) {
ds +=
~[@{mut: mt.mut != ast::imm,
kind: index,
outer_t: auto_unbox.t}];
}
ty::ty_ivec(mt) {
ds +=
~[@{mut: mt.mut != ast::imm,
@ -666,7 +660,7 @@ fn helper(tcx: &ty::ctxt, needle: ty::t, haystack: ty::t, mut: bool) ->
}
ret false;
}
ty::ty_box(mt) | ty::ty_vec(mt) | ty::ty_ptr(mt) {
ty::ty_box(mt) | ty::ty_ptr(mt) {
ret helper(tcx, needle, mt.ty, get_mut(mut, mt));
}
ty::ty_uniq(t) { ret helper(tcx, needle, t, false); }

View File

@ -130,7 +130,7 @@ fn type_is_gc_relevant(cx: &ty::ctxt, ty: &ty::t) -> bool {
ty::ty_ivec(tm) { ret type_is_gc_relevant(cx, tm.ty); }
ty::ty_constr(sub, _) { ret type_is_gc_relevant(cx, sub); }
ty::ty_str. | ty::ty_box(_) | ty::ty_uniq(_) | ty::ty_vec(_) |
ty::ty_str. | ty::ty_box(_) | ty::ty_uniq(_) |
ty::ty_fn(_,_,_,_,_) | ty::ty_native_fn(_,_,_) | ty::ty_obj(_) |
ty::ty_param(_,_) | ty::ty_res(_,_,_) { ret true; }

View File

@ -343,11 +343,6 @@ fn shape_of(ccx : &@crate_ctxt, t : ty::t) -> [u8] {
s += ~[shape_uniq];
add_substr(s, shape_of(ccx, subt));
}
ty::ty_vec(mt) {
s += ~[shape_evec];
add_bool(s, ty::type_is_pod(ccx.tcx, mt.ty));
add_substr(s, shape_of(ccx, mt.ty));
}
ty::ty_ivec(mt) {
s += ~[shape_ivec];
add_bool(s, ty::type_is_pod(ccx.tcx, mt.ty));

View File

@ -214,7 +214,6 @@ fn type_of_inner(cx: &@crate_ctxt, sp: &span, t: &ty::t) -> TypeRef {
ty::ty_tag(did, _) { llty = type_of_tag(cx, sp, did, t); }
ty::ty_box(mt) { llty = T_ptr(T_box(type_of_inner(cx, sp, mt.ty))); }
ty::ty_uniq(t) { llty = T_ptr(type_of_inner(cx, sp, t)); }
ty::ty_vec(mt) { llty = T_ptr(T_vec(type_of_inner(cx, sp, mt.ty))); }
ty::ty_ivec(mt) {
if ty::type_has_dynamic_size(cx.tcx, mt.ty) {
llty = T_opaque_ivec();
@ -501,7 +500,6 @@ fn simplifier(ccx: @crate_ctxt, typ: ty::t) -> ty::t {
alt ty::struct(ccx.tcx, typ) {
ty::ty_box(_) { ret ty::mk_imm_box(ccx.tcx, ty::mk_nil(ccx.tcx)); }
ty::ty_uniq(_) { ret ty::mk_uniq(ccx.tcx, ty::mk_nil(ccx.tcx)); }
ty::ty_vec(_) { ret ty::mk_imm_vec(ccx.tcx, ty::mk_nil(ccx.tcx)); }
ty::ty_fn(_, _, _, _, _) {
ret ty::mk_tup(ccx.tcx,
~[ty::mk_imm_box(ccx.tcx, ty::mk_nil(ccx.tcx)),
@ -1318,15 +1316,6 @@ fn make_free_glue(cx: &@block_ctxt, v0: ValueRef, t: &ty::t) {
rslt(cx, C_nil())
}
}
ty::ty_vec(_) {
let v = cx.build.Load(v0);
let rs = iter_sequence(cx, v, t, bind drop_ty(_, _, _));
if !bcx_ccx(cx).sess.get_opts().do_gc {
trans_non_gc_free(rs.bcx, v)
} else {
rslt(cx, C_nil())
}
}
ty::ty_box(body_mt) {
let v = cx.build.Load(v0);
let body =
@ -1430,7 +1419,6 @@ fn make_drop_glue(cx: &@block_ctxt, v0: ValueRef, t: &ty::t) {
let rs =
alt ty::struct(ccx.tcx, t) {
ty::ty_str. { decr_refcnt_maybe_free(cx, v0, v0, t) }
ty::ty_vec(_) { decr_refcnt_maybe_free(cx, v0, v0, t) }
ty::ty_ivec(tm) {
let v1;
if ty::type_has_dynamic_size(ccx.tcx, tm.ty) {
@ -1981,9 +1969,6 @@ fn iter_sequence_body(cx: @block_ctxt, v: ValueRef, elt_ty: &ty::t,
alt ty::struct(bcx_tcx(cx), t) {
ty::ty_vec(elt) {
ret iter_sequence_body(cx, v, elt.ty, f, false, false);
}
ty::ty_str. {
let et = ty::mk_mach(bcx_tcx(cx), ast::ty_u8);
ret iter_sequence_body(cx, v, et, f, true, false);
@ -4776,65 +4761,6 @@ fn trans_tup(cx: &@block_ctxt, elts: &[@ast::expr], id: ast::node_id)
ret rslt(bcx, tup_val);
}
fn trans_vec(cx: &@block_ctxt, args: &[@ast::expr], id: ast::node_id) ->
result {
let t = node_id_type(bcx_ccx(cx), id);
let unit_ty = t;
alt ty::struct(bcx_tcx(cx), t) {
ty::ty_vec(mt) { unit_ty = mt.ty; }
_ { bcx_ccx(cx).sess.bug("non-vec type in trans_vec"); }
}
let bcx = cx;
let unit_sz = size_of(bcx, unit_ty);
bcx = unit_sz.bcx;
let data_sz =
bcx.build.Mul(C_uint(std::vec::len::<@ast::expr>(args)), unit_sz.val);
// FIXME: pass tydesc properly.
let vec_val =
bcx.build.Call(bcx_ccx(bcx).upcalls.new_vec,
~[bcx.fcx.lltaskptr, data_sz,
C_null(T_ptr(bcx_ccx(bcx).tydesc_type))]);
let llty = type_of(bcx_ccx(bcx), bcx.sp, t);
vec_val = bcx.build.PointerCast(vec_val, llty);
add_clean_temp(bcx, vec_val, t);
let body = bcx.build.GEP(vec_val, ~[C_int(0), C_int(abi::vec_elt_data)]);
let pseudo_tup_ty =
ty::mk_tup(bcx_tcx(cx),
std::vec::init_elt::<ty::t>(unit_ty,
std::vec::len(args)));
let i: int = 0;
for e: @ast::expr in args {
let src = trans_lval(bcx, e);
bcx = src.res.bcx;
let dst_res = GEP_tup_like(bcx, pseudo_tup_ty, body, ~[0, i]);
bcx = dst_res.bcx;
// Cast the destination type to the source type. This is needed to
// make tags work, for a subtle combination of reasons:
//
// (1) "dst_res" above is derived from "body", which is in turn
// derived from "vec_val".
// (2) "vec_val" has the LLVM type "llty".
// (3) "llty" is the result of calling type_of() on a vector type.
// (4) For tags, type_of() returns a different type depending on
// on whether the tag is behind a box or not. Vector types are
// considered boxes.
// (5) "src_res" is derived from "unit_ty", which is not behind a box.
let dst_val;
if !ty::type_has_dynamic_size(bcx_tcx(cx), unit_ty) {
let llunit_ty = type_of(bcx_ccx(cx), bcx.sp, unit_ty);
dst_val = bcx.build.PointerCast(dst_res.val, T_ptr(llunit_ty));
} else { dst_val = dst_res.val; }
bcx = move_val_if_temp(bcx, INIT, dst_val, src, unit_ty).bcx;
i += 1;
}
let fill = bcx.build.GEP(vec_val, ~[C_int(0), C_int(abi::vec_elt_fill)]);
bcx.build.Store(data_sz, fill);
ret rslt(bcx, vec_val);
}
// TODO: Move me to ivec::
fn trans_ivec(bcx: @block_ctxt, args: &[@ast::expr], id: ast::node_id) ->
result {

View File

@ -89,7 +89,6 @@
export mk_uint;
export mk_uniq;
export mk_var;
export mk_vec;
export mk_iter_body_fn;
export mode;
export mo_val;
@ -147,7 +146,6 @@
export ty_uniq;
export ty_var;
export ty_var_id;
export ty_vec;
export ty_param_substs_opt_and_ty_to_monotype;
export ty_fn_args;
export type_constr;
@ -263,7 +261,6 @@ fn method_ty_to_fn_ty(cx: &ctxt, m: method) -> t {
ty_tag(def_id, [t]);
ty_box(mt);
ty_uniq(t);
ty_vec(mt);
ty_ivec(mt);
ty_ptr(mt);
ty_rec([field]);
@ -465,7 +462,6 @@ fn derive_flags_sig(cx: &ctxt, has_params: &mutable bool,
}
ty_box(m) { derive_flags_mt(cx, has_params, has_vars, m); }
ty_uniq(tt) { derive_flags_t(cx, has_params, has_vars, tt); }
ty_vec(m) { derive_flags_mt(cx, has_params, has_vars, m); }
ty_ivec(m) { derive_flags_mt(cx, has_params, has_vars, m); }
ty_ptr(m) { derive_flags_mt(cx, has_params, has_vars, m); }
ty_rec(flds) {
@ -567,14 +563,8 @@ fn mk_mut_ptr(cx: &ctxt, ty: &t) -> t {
ret mk_ptr(cx, {ty: ty, mut: ast::mut});
}
fn mk_vec(cx: &ctxt, tm: &mt) -> t { ret gen_ty(cx, ty_vec(tm)); }
fn mk_ivec(cx: &ctxt, tm: &mt) -> t { ret gen_ty(cx, ty_ivec(tm)); }
fn mk_imm_vec(cx: &ctxt, typ: &t) -> t {
ret gen_ty(cx, ty_vec({ty: typ, mut: ast::imm}));
}
fn mk_rec(cx: &ctxt, fs: &[field]) -> t { ret gen_ty(cx, ty_rec(fs)); }
fn mk_constr(cx: &ctxt, t: &t, cs: &[@type_constr]) -> t {
@ -644,7 +634,6 @@ fn walk_ty(cx: &ctxt, walker: ty_walk, ty: t) {
ty_type. {/* no-op */ }
ty_native(_) {/* no-op */ }
ty_box(tm) { walk_ty(cx, walker, tm.ty); }
ty_vec(tm) { walk_ty(cx, walker, tm.ty); }
ty_ivec(tm) { walk_ty(cx, walker, tm.ty); }
ty_ptr(tm) { walk_ty(cx, walker, tm.ty); }
ty_tag(tid, subtys) {
@ -719,9 +708,6 @@ fn fold_ty(cx: &ctxt, fld: fold_mode, ty_0: t) -> t {
ty_ptr(tm) {
ty = mk_ptr(cx, {ty: fold_ty(cx, fld, tm.ty), mut: tm.mut});
}
ty_vec(tm) {
ty = mk_vec(cx, {ty: fold_ty(cx, fld, tm.ty), mut: tm.mut});
}
ty_ivec(tm) {
ty = mk_ivec(cx, {ty: fold_ty(cx, fld, tm.ty), mut: tm.mut});
}
@ -860,7 +846,6 @@ fn type_is_sequence(cx: &ctxt, ty: &t) -> bool {
alt struct(cx, ty) {
ty_str. { ret true; }
ty_istr. { ret true; }
ty_vec(_) { ret true; }
ty_ivec(_) { ret true; }
_ { ret false; }
}
@ -877,10 +862,6 @@ fn type_is_str(cx: &ctxt, ty: &t) -> bool {
fn sequence_is_interior(cx: &ctxt, ty: &t) -> bool {
alt struct(cx, ty) {
// TODO: Or-patterns
ty::ty_vec(_) {
ret false;
}
ty::ty_str. { ret false; }
ty::ty_ivec(_) { ret true; }
ty::ty_istr. { ret true; }
@ -892,7 +873,6 @@ fn sequence_element_type(cx: &ctxt, ty: &t) -> t {
alt struct(cx, ty) {
ty_str. { ret mk_mach(cx, ast::ty_u8); }
ty_istr. { ret mk_mach(cx, ast::ty_u8); }
ty_vec(mt) { ret mt.ty; }
ty_ivec(mt) { ret mt.ty; }
_ { cx.sess.bug("sequence_element_type called on non-sequence value"); }
}
@ -929,7 +909,6 @@ fn type_is_box(cx: &ctxt, ty: &t) -> bool {
fn type_is_boxed(cx: &ctxt, ty: &t) -> bool {
alt struct(cx, ty) {
ty_str. { ret true; }
ty_vec(_) { ret true; }
ty_box(_) { ret true; }
_ { ret false; }
}
@ -1068,7 +1047,7 @@ fn type_kind(cx: &ctxt, ty: &t) -> ast::kind {
// Those with refcounts-to-inner raise pinned to shared,
// lower unique to shared. Therefore just set result to shared.
ty_box(mt) | ty_vec(mt) {
ty_box(mt) {
result = ast::kind_shared;
}
@ -1155,7 +1134,6 @@ fn type_has_dynamic_size(cx: &ctxt, ty: &t) -> bool {
ret false;
}
ty_box(_) { ret false; }
ty_vec(_) { ret false; }
ty_ivec(mt) { ret type_has_dynamic_size(cx, mt.ty); }
ty_ptr(_) { ret false; }
ty_rec(fields) {
@ -1272,7 +1250,6 @@ fn type_owns_heap_mem(cx: &ctxt, ty: &t) -> bool {
result = false;
}
ty_box(_) { result = false; }
ty_vec(_) { result = false; }
ty_fn(_, _, _, _, _) { result = false; }
ty_native_fn(_, _, _) { result = false; }
ty_obj(_) { result = false; }
@ -1326,7 +1303,7 @@ fn type_is_pod(cx : &ctxt, ty : &t) -> bool {
}
// Boxed types
ty_str. | ty_istr. | ty_box(_) | ty_vec(_) | ty_ivec(_) |
ty_str. | ty_istr. | ty_box(_) | ty_ivec(_) |
ty_fn(_,_,_,_,_) | ty_native_fn(_,_,_) | ty_obj(_) { result = false; }
// Structural types
@ -1489,7 +1466,6 @@ fn hash_fn(id: uint, args: &[arg], rty: &t) -> uint {
ret h;
}
ty_box(mt) { ret hash_subty(19u, mt.ty); }
ty_vec(mt) { ret hash_subty(20u, mt.ty); }
ty_ivec(mt) { ret hash_subty(21u, mt.ty); }
ty_rec(fields) {
let h = 26u;
@ -1651,9 +1627,6 @@ fn equal_def(did_a: &ast::def_id, did_b: &ast::def_id) -> bool {
ty_box(mt_a) {
alt b { ty_box(mt_b) { ret equal_mt(mt_a, mt_b); } _ { ret false; } }
}
ty_vec(mt_a) {
alt b { ty_vec(mt_b) { ret equal_mt(mt_a, mt_b); } _ { ret false; } }
}
ty_ivec(mt_a) {
alt b { ty_ivec(mt_b) { ret equal_mt(mt_a, mt_b); } _ { ret false; } }
}
@ -2502,26 +2475,6 @@ fn unify_step(cx: &@ctxt, expected: &t, actual: &t) -> result {
_ { ret ures_err(terr_mismatch); }
}
}
ty::ty_vec(expected_mt) {
alt struct(cx.tcx, actual) {
ty::ty_vec(actual_mt) {
let mut;
alt unify_mut(expected_mt.mut, actual_mt.mut) {
none. { ret ures_err(terr_vec_mutability); }
some(m) { mut = m; }
}
let result = unify_step(cx, expected_mt.ty, actual_mt.ty);
alt result {
ures_ok(result_sub) {
let mt = {ty: result_sub, mut: mut};
ret ures_ok(mk_vec(cx.tcx, mt));
}
_ { ret result; }
}
}
_ { ret ures_err(terr_mismatch); }
}
}
ty::ty_ivec(expected_mt) {
alt struct(cx.tcx, actual) {
ty::ty_ivec(actual_mt) {
@ -3055,7 +3008,6 @@ fn tycat(cx: &ctxt, ty: t) -> int {
ty_ptr(_) { tycat_int }
ty_str. { tycat_str }
ty_istr. { tycat_str }
ty_vec(_) { tycat_vec }
ty_ivec(_) { tycat_vec }
ty_rec(_) { tycat_struct }
ty_tup(_) { tycat_struct }

View File

@ -324,9 +324,6 @@ fn instantiate(tcx: &ty::ctxt, sp: &span, getter: &ty_getter,
ast::ty_box(mt) {
typ = ty::mk_box(tcx, ast_mt_to_mt(tcx, getter, mt));
}
ast::ty_vec(mt) {
typ = ty::mk_vec(tcx, ast_mt_to_mt(tcx, getter, mt));
}
ast::ty_ivec(mt) {
typ = ty::mk_ivec(tcx, ast_mt_to_mt(tcx, getter, mt));
}
@ -1989,7 +1986,6 @@ fn check_binop_type_compat(fcx: &@fn_ctxt, span: span, ty: ty::t,
let elt_ty;
let ety = expr_ty(tcx, seq);
alt structure_of(fcx, expr.span, ety) {
ty::ty_vec(vec_elt_ty) { elt_ty = vec_elt_ty.ty; }
ty::ty_str. { elt_ty = ty::mk_mach(tcx, ast::ty_u8); }
ty::ty_ivec(vec_elt_ty) { elt_ty = vec_elt_ty.ty; }
ty::ty_istr. { elt_ty = ty::mk_mach(tcx, ast::ty_u8); }
@ -2295,7 +2291,6 @@ fn get_node(f: &spanned<field>) -> field { f.node }
+ ty_to_str(tcx, idx_t));
}
alt structure_of(fcx, expr.span, base_t) {
ty::ty_vec(mt) { write::ty_only_fixup(fcx, id, mt.ty); }
ty::ty_ivec(mt) { write::ty_only_fixup(fcx, id, mt.ty); }
ty::ty_str. {
let typ = ty::mk_mach(tcx, ast::ty_u8);
@ -2658,14 +2653,6 @@ fn check_item(ccx: @crate_ctxt, it: &@ast::item) {
fn arg_is_argv_ty(tcx: &ty::ctxt, a: &ty::arg) -> bool {
alt ty::struct(tcx, a.ty) {
// FIXME: Remove after main takes only ivec
ty::ty_vec(mt) {
if mt.mut != ast::imm { ret false; }
alt ty::struct(tcx, mt.ty) {
ty::ty_str. { ret true; }
_ { ret false; }
}
}
ty::ty_ivec(mt) {
if mt.mut != ast::imm { ret false; }
alt ty::struct(tcx, mt.ty) {

View File

@ -439,7 +439,6 @@ fn ty_mach_to_str(tm: ty_mach) -> str {
ty_str;
ty_istr; // interior string
ty_box(mt);
ty_vec(mt);
ty_ivec(mt); // interior vector
ty_ptr(mt);
ty_task;

View File

@ -284,7 +284,6 @@ fn print_type(s: &ps, ty: &@ast::ty) {
ast::ty_str. { word(s.s, "str"); }
ast::ty_istr. { word(s.s, "istr"); }
ast::ty_box(mt) { word(s.s, "@"); print_mt(s, mt); }
ast::ty_vec(mt) { word(s.s, "vec<"); print_mt(s, mt); word(s.s, ">"); }
ast::ty_ivec(mt) {
word(s.s, "[");
alt mt.mut {

View File

@ -124,7 +124,6 @@ fn visit_ty<E>(t: &@ty, e: &E, v: &vt<E>) {
ty_str. {/* no-op */ }
ty_istr. {/* no-op */ }
ty_box(mt) { v.visit_ty(mt.ty, e, v); }
ty_vec(mt) { v.visit_ty(mt.ty, e, v); }
ty_ivec(mt) { v.visit_ty(mt.ty, e, v); }
ty_ptr(mt) { v.visit_ty(mt.ty, e, v); }
ty_port(t) { v.visit_ty(t, e, v); }

View File

@ -92,7 +92,6 @@ fn mt_to_str(cx: &ctxt, m: &mt) -> str {
ty_istr. { s += "istr"; }
ty_box(tm) { s += "@" + mt_to_str(cx, tm); }
ty_uniq(t) { s += "~" + ty_to_str(cx, t); }
ty_vec(tm) { s += "vec<" + mt_to_str(cx, tm) + ">"; }
ty_ivec(tm) { s += "[" + mt_to_str(cx, tm) + "]"; }
ty_type. { s += "type"; }
ty_rec(elems) {