Skip to content

Commit 05cf011

Browse files
committed
---
yaml --- r: 4542 b: refs/heads/master c: 19424df h: refs/heads/master v: v3
1 parent f5d7ac1 commit 05cf011

File tree

8 files changed

+50
-25
lines changed

8 files changed

+50
-25
lines changed

[refs]

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: a8a4d4ec056b68ac25a04ea020cdc674527a76df
2+
refs/heads/master: 19424dfab6cf0432477396e73dea567678a715b8

trunk/src/comp/metadata/tydecode.rs

+1
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ fn parse_ty(st: @pstate, sd: str_def) -> ty::t {
215215
ret ty::mk_param(st.tcx, parse_int(st) as uint, k);
216216
}
217217
'@' { ret ty::mk_box(st.tcx, parse_mt(st, sd)); }
218+
'~' { ret ty::mk_uniq(st.tcx, parse_ty(st, sd)); }
218219
'*' { ret ty::mk_ptr(st.tcx, parse_mt(st, sd)); }
219220
'V' { ret ty::mk_vec(st.tcx, parse_mt(st, sd)); }
220221
'I' { ret ty::mk_ivec(st.tcx, parse_mt(st, sd)); }

trunk/src/comp/metadata/tyencode.rs

+1
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ fn enc_sty(w: &ioivec::writer, cx: &@ctxt, st: &ty::sty) {
121121
w.write_char(']');
122122
}
123123
ty::ty_box(mt) { w.write_char('@'); enc_mt(w, cx, mt); }
124+
ty::ty_uniq(t) { w.write_char('~'); enc_ty(w, cx, t); }
124125
ty::ty_ptr(mt) { w.write_char('*'); enc_mt(w, cx, mt); }
125126
ty::ty_vec(mt) { w.write_char('V'); enc_mt(w, cx, mt); }
126127
ty::ty_ivec(mt) { w.write_char('I'); enc_mt(w, cx, mt); }

trunk/src/comp/middle/alias.rs

+5
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,9 @@ fn expr_root(cx: &ctx, ex: @ast::expr, autoderef: bool) ->
537537
ds += ~[@{mut: mt.mut != ast::imm, kind: unbox, outer_t: t}];
538538
t = mt.ty;
539539
}
540+
ty::ty_uniq(mt) {
541+
ds += ~[@{mut: false, kind: unbox, outer_t: t}];
542+
}
540543
ty::ty_res(_, inner, tps) {
541544
ds += ~[@{mut: false, kind: unbox, outer_t: t}];
542545
t = ty::substitute_type_params(cx.tcx, tps, inner);
@@ -603,6 +606,7 @@ fn expr_root(cx: &ctx, ex: @ast::expr, autoderef: bool) ->
603606
let mut = false;
604607
alt ty::struct(cx.tcx, base_t) {
605608
ty::ty_box(mt) { mut = mt.mut != ast::imm; }
609+
ty::ty_uniq(_) { }
606610
ty::ty_res(_, _, _) { }
607611
ty::ty_tag(_, _) { }
608612
ty::ty_ptr(mt) { mut = mt.mut != ast::imm; }
@@ -665,6 +669,7 @@ fn ty_can_unsafely_include(cx: &ctx, needle: ty::t, haystack: ty::t,
665669
ty::ty_box(mt) | ty::ty_vec(mt) | ty::ty_ptr(mt) {
666670
ret helper(tcx, needle, mt.ty, get_mut(mut, mt));
667671
}
672+
ty::ty_uniq(t) { ret helper(tcx, needle, t, false); }
668673
ty::ty_rec(fields) {
669674
for f: ty::field in fields {
670675
if helper(tcx, needle, f.mt.ty, get_mut(mut, f.mt)) {

trunk/src/comp/middle/shape.rs

+5
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ const shape_fn : u8 = 18u8;
6767
const shape_obj : u8 = 19u8;
6868
const shape_res : u8 = 20u8;
6969
const shape_var : u8 = 21u8;
70+
const shape_uniq : u8 = 22u8;
7071

7172
// FIXME: This is a bad API in trans_common.
7273
fn C_u8(n : u8) -> ValueRef { ret trans_common::C_u8(n as uint); }
@@ -342,6 +343,10 @@ fn shape_of(ccx : &@crate_ctxt, t : ty::t) -> [u8] {
342343
s += ~[shape_box];
343344
add_substr(s, shape_of(ccx, mt.ty));
344345
}
346+
ty::ty_uniq(subt) {
347+
s += ~[shape_uniq];
348+
add_substr(s, shape_of(ccx, subt));
349+
}
345350
ty::ty_vec(mt) {
346351
s += ~[shape_evec];
347352
add_bool(s, ty::type_is_pod(ccx.tcx, mt.ty));

trunk/src/comp/middle/trans.rs

+8
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ fn type_of_inner(cx: &@crate_ctxt, sp: &span, t: &ty::t) -> TypeRef {
217217
ty::ty_istr. { llty = T_ivec(T_i8()); }
218218
ty::ty_tag(did, _) { llty = type_of_tag(cx, sp, did, t); }
219219
ty::ty_box(mt) { llty = T_ptr(T_box(type_of_inner(cx, sp, mt.ty))); }
220+
ty::ty_uniq(t) { llty = T_ptr(type_of_inner(cx, sp, t)); }
220221
ty::ty_vec(mt) { llty = T_ptr(T_vec(type_of_inner(cx, sp, mt.ty))); }
221222
ty::ty_ivec(mt) {
222223
if ty::type_has_dynamic_size(cx.tcx, mt.ty) {
@@ -476,6 +477,7 @@ fn simplify_type(ccx: &@crate_ctxt, typ: &ty::t) -> ty::t {
476477
fn simplifier(ccx: @crate_ctxt, typ: ty::t) -> ty::t {
477478
alt ty::struct(ccx.tcx, typ) {
478479
ty::ty_box(_) { ret ty::mk_imm_box(ccx.tcx, ty::mk_nil(ccx.tcx)); }
480+
ty::ty_uniq(_) { ret ty::mk_uniq(ccx.tcx, ty::mk_nil(ccx.tcx)); }
479481
ty::ty_vec(_) { ret ty::mk_imm_vec(ccx.tcx, ty::mk_nil(ccx.tcx)); }
480482
ty::ty_fn(_, _, _, _, _) {
481483
ret ty::mk_imm_tup(ccx.tcx,
@@ -1303,6 +1305,9 @@ fn make_free_glue(cx: &@block_ctxt, v0: ValueRef, t: &ty::t) {
13031305
let rs = drop_ty(cx, body_val, body_ty);
13041306
trans_non_gc_free(rs.bcx, v)
13051307
}
1308+
ty::ty_uniq(_) {
1309+
fail "free uniq unimplemented";
1310+
}
13061311
ty::ty_port(_) {
13071312
let v = cx.build.Load(v0);
13081313
cx.build.Call(bcx_ccx(cx).upcalls.del_port,
@@ -1402,6 +1407,7 @@ fn make_drop_glue(cx: &@block_ctxt, v0: ValueRef, t: &ty::t) {
14021407
maybe_free_ivec_heap_part(rslt.bcx, v1, tm.ty)
14031408
}
14041409
ty::ty_box(_) { decr_refcnt_maybe_free(cx, v0, v0, t) }
1410+
ty::ty_uniq(_) { fail "drop uniq unimplemented"; }
14051411
ty::ty_port(_) { decr_refcnt_maybe_free(cx, v0, v0, t) }
14061412
ty::ty_chan(_) {
14071413
let ptr = cx.build.Load(v0);
@@ -3257,6 +3263,7 @@ fn autoderef(cx: &@block_ctxt, v: ValueRef, t: &ty::t) -> result_t {
32573263
v1 = cx.build.PointerCast(body, T_ptr(llty));
32583264
} else { v1 = body; }
32593265
}
3266+
ty::ty_uniq(t) { fail "autoderef uniq unimplemented"; }
32603267
ty::ty_res(did, inner, tps) {
32613268
t1 = ty::substitute_type_params(ccx.tcx, tps, inner);
32623269
v1 = cx.build.GEP(v1, ~[C_int(0), C_int(1)]);
@@ -4077,6 +4084,7 @@ fn trans_lval_gen(cx: &@block_ctxt, e: &@ast::expr) -> lval_result {
40774084
~[C_int(0),
40784085
C_int(abi::box_rc_field_body)])
40794086
}
4087+
ty::ty_uniq(_) { fail "uniq lval translation unimplemented" }
40804088
ty::ty_res(_, _, _) {
40814089
sub.bcx.build.InBoundsGEP(sub.val, ~[C_int(0), C_int(1)])
40824090
}

trunk/src/comp/middle/ty.rs

+27-23
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ export mk_tag;
8989
export mk_task;
9090
export mk_type;
9191
export mk_uint;
92+
export mk_uniq;
9293
export mk_var;
9394
export mk_vec;
9495
export mk_iter_body_fn;
@@ -147,6 +148,7 @@ export ty_tag;
147148
export ty_task;
148149
export ty_type;
149150
export ty_uint;
151+
export ty_uniq;
150152
export ty_var;
151153
export ty_var_id;
152154
export ty_vec;
@@ -265,6 +267,7 @@ tag sty {
265267
ty_istr;
266268
ty_tag(def_id, [t]);
267269
ty_box(mt);
270+
ty_uniq(t);
268271
ty_vec(mt);
269272
ty_ivec(mt);
270273
ty_ptr(mt);
@@ -471,6 +474,7 @@ fn mk_raw_ty(cx: &ctxt, st: &sty, in_cname: &option::t[str]) -> @raw_t {
471474
for tt: t in tys { derive_flags_t(cx, has_params, has_vars, tt); }
472475
}
473476
ty_box(m) { derive_flags_mt(cx, has_params, has_vars, m); }
477+
ty_uniq(tt) { derive_flags_t(cx, has_params, has_vars, tt); }
474478
ty_vec(m) { derive_flags_mt(cx, has_params, has_vars, m); }
475479
ty_ivec(m) { derive_flags_mt(cx, has_params, has_vars, m); }
476480
ty_ptr(m) { derive_flags_mt(cx, has_params, has_vars, m); }
@@ -558,6 +562,8 @@ fn mk_tag(cx: &ctxt, did: &ast::def_id, tys: &[t]) -> t {
558562

559563
fn mk_box(cx: &ctxt, tm: &mt) -> t { ret gen_ty(cx, ty_box(tm)); }
560564

565+
fn mk_uniq(cx: &ctxt, typ: &t) -> t { ret gen_ty(cx, ty_uniq(typ)); }
566+
561567
fn mk_ptr(cx: &ctxt, tm: &mt) -> t { ret gen_ty(cx, ty_ptr(tm)); }
562568

563569
fn mk_imm_box(cx: &ctxt, ty: &t) -> t {
@@ -728,36 +734,20 @@ fn fold_ty(cx: &ctxt, fld: fold_mode, ty_0: t) -> t {
728734
ty_native(_) {/* no-op */ }
729735
ty_task. {/* no-op */ }
730736
ty_box(tm) {
731-
ty =
732-
copy_cname(cx,
733-
mk_box(cx, {ty: fold_ty(cx, fld, tm.ty), mut: tm.mut}),
734-
ty);
737+
ty = mk_box(cx, {ty: fold_ty(cx, fld, tm.ty), mut: tm.mut});
735738
}
739+
ty_uniq(subty) { ty = mk_uniq(cx, fold_ty(cx, fld, subty)); }
736740
ty_ptr(tm) {
737-
ty =
738-
copy_cname(cx,
739-
mk_ptr(cx, {ty: fold_ty(cx, fld, tm.ty), mut: tm.mut}),
740-
ty);
741+
ty = mk_ptr(cx, {ty: fold_ty(cx, fld, tm.ty), mut: tm.mut});
741742
}
742743
ty_vec(tm) {
743-
ty =
744-
copy_cname(cx,
745-
mk_vec(cx, {ty: fold_ty(cx, fld, tm.ty), mut: tm.mut}),
746-
ty);
744+
ty = mk_vec(cx, {ty: fold_ty(cx, fld, tm.ty), mut: tm.mut});
747745
}
748746
ty_ivec(tm) {
749-
ty =
750-
copy_cname(cx,
751-
mk_ivec(cx,
752-
{ty: fold_ty(cx, fld, tm.ty), mut: tm.mut}),
753-
ty);
754-
}
755-
ty_port(subty) {
756-
ty = copy_cname(cx, mk_port(cx, fold_ty(cx, fld, subty)), ty);
757-
}
758-
ty_chan(subty) {
759-
ty = copy_cname(cx, mk_chan(cx, fold_ty(cx, fld, subty)), ty);
747+
ty = mk_ivec(cx, {ty: fold_ty(cx, fld, tm.ty), mut: tm.mut});
760748
}
749+
ty_port(subty) { ty = mk_port(cx, fold_ty(cx, fld, subty)); }
750+
ty_chan(subty) { ty = mk_chan(cx, fold_ty(cx, fld, subty)); }
761751
ty_tag(tid, subtys) {
762752
let new_subtys: [t] = ~[];
763753
for subty: t in subtys { new_subtys += ~[fold_ty(cx, fld, subty)]; }
@@ -2494,6 +2484,20 @@ mod unify {
24942484
_ { ret ures_err(terr_mismatch); }
24952485
}
24962486
}
2487+
ty::ty_uniq(expected_sub) {
2488+
alt struct(cx.tcx, actual) {
2489+
ty::ty_uniq(actual_sub) {
2490+
let result = unify_step(cx, expected_sub, actual_sub);
2491+
alt result {
2492+
ures_ok(result_sub) {
2493+
ret ures_ok(mk_uniq(cx.tcx, result_sub));
2494+
}
2495+
_ { ret result; }
2496+
}
2497+
}
2498+
_ { ret ures_err(terr_mismatch); }
2499+
}
2500+
}
24972501
ty::ty_vec(expected_mt) {
24982502
alt struct(cx.tcx, actual) {
24992503
ty::ty_vec(actual_mt) {

trunk/src/comp/util/ppaux.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,9 @@ fn ty_to_str(cx: &ctxt, typ: &t) -> str {
9191
ty_str. { s += "str"; }
9292
ty_istr. { s += "istr"; }
9393
ty_box(tm) { s += "@" + mt_to_str(cx, tm); }
94+
ty_uniq(t) { s += "~" + ty_to_str(cx, t); }
9495
ty_vec(tm) { s += "vec[" + mt_to_str(cx, tm) + "]"; }
95-
ty_ivec(tm) { s += "ivec[" + mt_to_str(cx, tm) + "]"; }
96+
ty_ivec(tm) { s += "[" + mt_to_str(cx, tm) + "]"; }
9697
ty_port(t) { s += "port[" + ty_to_str(cx, t) + "]"; }
9798
ty_chan(t) { s += "chan[" + ty_to_str(cx, t) + "]"; }
9899
ty_type. { s += "type"; }

0 commit comments

Comments
 (0)