parent
4d088bd528
commit
1b3023e4d0
@ -216,7 +216,7 @@ fn parse_ty(st: @pstate, sd: str_def) -> ty::t {
|
||||
ret ty::mk_param(st.tcx, parse_int(st) as uint, k);
|
||||
}
|
||||
'@' { ret ty::mk_box(st.tcx, parse_mt(st, sd)); }
|
||||
'~' { ret ty::mk_uniq(st.tcx, parse_ty(st, sd)); }
|
||||
'~' { ret ty::mk_uniq(st.tcx, parse_mt(st, sd)); }
|
||||
'*' { ret ty::mk_ptr(st.tcx, parse_mt(st, sd)); }
|
||||
'I' { ret ty::mk_vec(st.tcx, parse_mt(st, sd)); }
|
||||
'R' {
|
||||
|
@ -123,7 +123,7 @@ fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) {
|
||||
w.write_char(']');
|
||||
}
|
||||
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_uniq(mt) { w.write_char('~'); enc_mt(w, cx, mt); }
|
||||
ty::ty_ptr(mt) { w.write_char('*'); enc_mt(w, cx, mt); }
|
||||
ty::ty_vec(mt) { w.write_char('I'); enc_mt(w, cx, mt); }
|
||||
ty::ty_rec(fields) {
|
||||
|
@ -559,10 +559,9 @@ fn ty_can_unsafely_include(cx: ctx, needle: unsafe_ty, haystack: ty::t,
|
||||
}
|
||||
ret false;
|
||||
}
|
||||
ty::ty_box(mt) | ty::ty_ptr(mt) {
|
||||
ty::ty_box(mt) | ty::ty_ptr(mt) | ty::ty_uniq(mt) {
|
||||
ret helper(tcx, needle, mt.ty, get_mut(mut, mt));
|
||||
}
|
||||
ty::ty_uniq(t) { ret helper(tcx, needle, t, false); }
|
||||
ty::ty_rec(fields) {
|
||||
for f: ty::field in fields {
|
||||
if helper(tcx, needle, f.mt.ty, get_mut(mut, f.mt)) {
|
||||
@ -619,7 +618,7 @@ fn copy_is_expensive(tcx: ty::ctxt, ty: ty::t) -> bool {
|
||||
ty::ty_fn(_, _, _, _, _) | ty::ty_native_fn(_, _, _) |
|
||||
ty::ty_obj(_) { 4u }
|
||||
ty::ty_str. | ty::ty_vec(_) | ty::ty_param(_, _) { 50u }
|
||||
ty::ty_uniq(t) { 1u + score_ty(tcx, t) }
|
||||
ty::ty_uniq(mt) { 1u + score_ty(tcx, mt.ty) }
|
||||
ty::ty_tag(_, ts) | ty::ty_tup(ts) {
|
||||
let sum = 0u;
|
||||
for t in ts { sum += score_ty(tcx, t); }
|
||||
|
@ -23,7 +23,7 @@ fn expr_root(tcx: ty::ctxt, ex: @expr, autoderef: bool) ->
|
||||
t = mt.ty;
|
||||
}
|
||||
ty::ty_uniq(mt) {
|
||||
ds += [@{mut: false, kind: unbox, outer_t: t}];
|
||||
ds += [@{mut: mt.mut != imm, kind: unbox, outer_t: t}];
|
||||
}
|
||||
ty::ty_res(_, inner, tps) {
|
||||
ds += [@{mut: false, kind: unbox, outer_t: t}];
|
||||
|
@ -370,9 +370,9 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t, ty_param_map: [uint]) -> [u8] {
|
||||
s += [shape_box];
|
||||
add_substr(s, shape_of(ccx, mt.ty, ty_param_map));
|
||||
}
|
||||
ty::ty_uniq(subt) {
|
||||
ty::ty_uniq(mt) {
|
||||
s += [shape_uniq];
|
||||
add_substr(s, shape_of(ccx, subt, ty_param_map));
|
||||
add_substr(s, shape_of(ccx, mt.ty, ty_param_map));
|
||||
}
|
||||
ty::ty_vec(mt) {
|
||||
s += [shape_vec];
|
||||
|
@ -162,9 +162,10 @@ fn type_of_inner(cx: @crate_ctxt, sp: span, t: ty::t)
|
||||
let mt_ty = mt.ty;
|
||||
check non_ty_var(cx, mt_ty);
|
||||
T_ptr(T_box(type_of_inner(cx, sp, mt_ty))) }
|
||||
ty::ty_uniq(t) {
|
||||
check non_ty_var(cx, t);
|
||||
T_ptr(type_of_inner(cx, sp, t)) }
|
||||
ty::ty_uniq(mt) {
|
||||
let mt_ty = mt.ty;
|
||||
check non_ty_var(cx, mt_ty);
|
||||
T_ptr(type_of_inner(cx, sp, mt_ty)) }
|
||||
ty::ty_vec(mt) {
|
||||
let mt_ty = mt.ty;
|
||||
if ty::type_has_dynamic_size(cx.tcx, mt_ty) {
|
||||
@ -478,7 +479,9 @@ fn simplify_type(ccx: @crate_ctxt, typ: ty::t) -> ty::t {
|
||||
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_uniq(_) {
|
||||
ret ty::mk_imm_uniq(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)),
|
||||
@ -1313,7 +1316,7 @@ fn make_free_glue(bcx: @block_ctxt, v0: ValueRef, t: ty::t) {
|
||||
trans_non_gc_free(bcx, v)
|
||||
} else { bcx }
|
||||
}
|
||||
ty::ty_uniq(content_t) {
|
||||
ty::ty_uniq(content_mt) {
|
||||
let free_cx = new_sub_block_ctxt(bcx, "uniq_free");
|
||||
let next_cx = new_sub_block_ctxt(bcx, "uniq_free_next");
|
||||
let vptr = Load(bcx, v0);
|
||||
@ -1321,7 +1324,7 @@ fn make_free_glue(bcx: @block_ctxt, v0: ValueRef, t: ty::t) {
|
||||
CondBr(bcx, null_test, next_cx.llbb, free_cx.llbb);
|
||||
|
||||
let bcx = free_cx;
|
||||
let bcx = drop_ty(bcx, vptr, content_t);
|
||||
let bcx = drop_ty(bcx, vptr, content_mt.ty);
|
||||
let bcx = trans_shared_free(bcx, vptr);
|
||||
Store(bcx, C_null(val_ty(vptr)), v0);
|
||||
Br(bcx, next_cx.llbb);
|
||||
|
@ -65,6 +65,7 @@ export mk_ctxt;
|
||||
export mk_float;
|
||||
export mk_fn;
|
||||
export mk_imm_box;
|
||||
export mk_imm_uniq;
|
||||
export mk_mut_ptr;
|
||||
export mk_int;
|
||||
export mk_str;
|
||||
@ -251,7 +252,7 @@ tag sty {
|
||||
ty_str;
|
||||
ty_tag(def_id, [t]);
|
||||
ty_box(mt);
|
||||
ty_uniq(t);
|
||||
ty_uniq(mt);
|
||||
ty_vec(mt);
|
||||
ty_ptr(mt);
|
||||
ty_rec([field]);
|
||||
@ -448,7 +449,7 @@ fn mk_raw_ty(cx: ctxt, st: sty, _in_cname: option::t<str>) -> @raw_t {
|
||||
for tt: t in tys { derive_flags_t(cx, has_params, has_vars, tt); }
|
||||
}
|
||||
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_uniq(m) { derive_flags_mt(cx, has_params, has_vars, m); }
|
||||
ty_vec(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) {
|
||||
@ -534,7 +535,11 @@ fn mk_tag(cx: ctxt, did: ast::def_id, tys: [t]) -> t {
|
||||
|
||||
fn mk_box(cx: ctxt, tm: mt) -> t { ret gen_ty(cx, ty_box(tm)); }
|
||||
|
||||
fn mk_uniq(cx: ctxt, typ: t) -> t { ret gen_ty(cx, ty_uniq(typ)); }
|
||||
fn mk_uniq(cx: ctxt, tm: mt) -> t { ret gen_ty(cx, ty_uniq(tm)); }
|
||||
|
||||
fn mk_imm_uniq(cx: ctxt, ty: t) -> t {
|
||||
ret mk_uniq(cx, {ty: ty, mut: ast::imm});
|
||||
}
|
||||
|
||||
fn mk_ptr(cx: ctxt, tm: mt) -> t { ret gen_ty(cx, ty_ptr(tm)); }
|
||||
|
||||
@ -643,7 +648,7 @@ fn walk_ty(cx: ctxt, walker: ty_walk, ty: t) {
|
||||
ty_constr(sub, _) { walk_ty(cx, walker, sub); }
|
||||
ty_var(_) {/* no-op */ }
|
||||
ty_param(_, _) {/* no-op */ }
|
||||
ty_uniq(sub) { walk_ty(cx, walker, sub); }
|
||||
ty_uniq(tm) { walk_ty(cx, walker, tm.ty); }
|
||||
}
|
||||
walker(ty);
|
||||
}
|
||||
@ -678,7 +683,9 @@ fn fold_ty(cx: ctxt, fld: fold_mode, ty_0: t) -> t {
|
||||
ty_box(tm) {
|
||||
ty = mk_box(cx, {ty: fold_ty(cx, fld, tm.ty), mut: tm.mut});
|
||||
}
|
||||
ty_uniq(subty) { ty = mk_uniq(cx, fold_ty(cx, fld, subty)); }
|
||||
ty_uniq(tm) {
|
||||
ty = mk_uniq(cx, {ty: fold_ty(cx, fld, tm.ty), mut: tm.mut});
|
||||
}
|
||||
ty_ptr(tm) {
|
||||
ty = mk_ptr(cx, {ty: fold_ty(cx, fld, tm.ty), mut: tm.mut});
|
||||
}
|
||||
@ -1420,7 +1427,7 @@ fn hash_type_structure(st: sty) -> uint {
|
||||
for c: @type_constr in cs { h += h << 5u + hash_type_constr(h, c); }
|
||||
ret h;
|
||||
}
|
||||
ty_uniq(t) { let h = 37u; h += h << 5u + hash_ty(t); ret h; }
|
||||
ty_uniq(mt) { let h = 37u; h += h << 5u + hash_ty(mt.ty); ret h; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -2184,13 +2191,20 @@ mod unify {
|
||||
_ { ret ures_err(terr_mismatch); }
|
||||
}
|
||||
}
|
||||
ty::ty_uniq(expected_sub) {
|
||||
ty::ty_uniq(expected_mt) {
|
||||
alt struct(cx.tcx, actual) {
|
||||
ty::ty_uniq(actual_sub) {
|
||||
let result = unify_step(cx, expected_sub, actual_sub);
|
||||
ty::ty_uniq(actual_mt) {
|
||||
let mut = expected_mt.mut;
|
||||
// FIXME (409) Write a test then uncomment
|
||||
/*alt unify_mut(expected_mt.mut, actual_mt.mut) {
|
||||
none. { ret ures_err(terr_box_mutability); }
|
||||
some(m) { mut = m; }
|
||||
}*/
|
||||
let result = unify_step(cx, expected_mt.ty, actual_mt.ty);
|
||||
alt result {
|
||||
ures_ok(result_sub) {
|
||||
ret ures_ok(mk_uniq(cx.tcx, result_sub));
|
||||
ures_ok(result_mt) {
|
||||
let mt = {ty: result_mt, mut: mut};
|
||||
ret ures_ok(mk_uniq(cx.tcx, mt));
|
||||
}
|
||||
_ { ret result; }
|
||||
}
|
||||
|
@ -286,7 +286,7 @@ fn ast_ty_to_ty(tcx: ty::ctxt, getter: ty_getter, ast_ty: @ast::ty) -> ty::t {
|
||||
typ = ty::mk_box(tcx, ast_mt_to_mt(tcx, getter, mt));
|
||||
}
|
||||
ast::ty_uniq(mt) {
|
||||
typ = ty::mk_uniq(tcx, ast_ty_to_ty(tcx, getter, mt.ty));
|
||||
typ = ty::mk_uniq(tcx, ast_mt_to_mt(tcx, getter, mt));
|
||||
}
|
||||
ast::ty_vec(mt) {
|
||||
typ = ty::mk_vec(tcx, ast_mt_to_mt(tcx, getter, mt));
|
||||
@ -1720,12 +1720,12 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
|
||||
alt unop {
|
||||
ast::box(mut) { oper_t = ty::mk_box(tcx, {ty: oper_t, mut: mut}); }
|
||||
ast::uniq(mut) {
|
||||
oper_t = ty::mk_uniq(tcx, oper_t);
|
||||
oper_t = ty::mk_uniq(tcx, {ty: oper_t, mut: mut});
|
||||
}
|
||||
ast::deref. {
|
||||
alt structure_of(fcx, expr.span, oper_t) {
|
||||
ty::ty_box(inner) { oper_t = inner.ty; }
|
||||
ty::ty_uniq(inner) { oper_t = inner; }
|
||||
ty::ty_uniq(inner) { oper_t = inner.ty; }
|
||||
ty::ty_res(_, inner, _) { oper_t = inner; }
|
||||
ty::ty_tag(id, tps) {
|
||||
let variants = ty::tag_variants(tcx, id);
|
||||
|
@ -101,7 +101,7 @@ fn ty_to_str(cx: ctxt, typ: t) -> str {
|
||||
ty_char. { "char" }
|
||||
ty_str. { "str" }
|
||||
ty_box(tm) { "@" + mt_to_str(cx, tm) }
|
||||
ty_uniq(t) { "~" + ty_to_str(cx, t) }
|
||||
ty_uniq(tm) { "~" + mt_to_str(cx, tm) }
|
||||
ty_vec(tm) { "[" + mt_to_str(cx, tm) + "]" }
|
||||
ty_type. { "type" }
|
||||
ty_rec(elems) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user