Skip to content

Commit c14a256

Browse files
committed
---
yaml --- r: 14715 b: refs/heads/try c: 0e17cdb h: refs/heads/master i: 14713: 3bcd025 14711: 3c5e389 v: v3
1 parent 73b2c46 commit c14a256

File tree

7 files changed

+60
-6
lines changed

7 files changed

+60
-6
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: ebc1d3e7042f19ed836bf99e6ede10e4ad049776
5+
refs/heads/try: 0e17cdb627e460a7c4cf8efe285b56a46592e2eb
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/rustc/metadata/tyencode.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,19 @@ fn enc_mt(w: io::writer, cx: @ctxt, mt: ty::mt) {
9393
}
9494
enc_ty(w, cx, mt.ty);
9595
}
96+
fn enc_region(w: io::writer, cx: @ctxt, r: ty::region) {
97+
alt r {
98+
ty::re_named(did) {
99+
w.write_char('n'); w.write_str(cx.ds(did)); w.write_char('|');
100+
}
101+
ty::re_caller(did) {
102+
w.write_char('c'); w.write_str(cx.ds(did)); w.write_char('|');
103+
}
104+
ty::re_block(nid) {
105+
w.write_char('b'); w.write_int(nid); w.write_char('|');
106+
}
107+
}
108+
}
96109
fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) {
97110
alt st {
98111
ty::ty_nil { w.write_char('n'); }
@@ -147,6 +160,11 @@ fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) {
147160
ty::ty_box(mt) { w.write_char('@'); enc_mt(w, cx, mt); }
148161
ty::ty_uniq(mt) { w.write_char('~'); enc_mt(w, cx, mt); }
149162
ty::ty_ptr(mt) { w.write_char('*'); enc_mt(w, cx, mt); }
163+
ty::ty_rptr(r, mt) {
164+
w.write_char('&');
165+
enc_region(w, cx, r);
166+
enc_mt(w, cx, mt);
167+
}
150168
ty::ty_vec(mt) { w.write_char('I'); enc_mt(w, cx, mt); }
151169
ty::ty_rec(fields) {
152170
w.write_str("R[");

branches/try/src/rustc/middle/trans/shape.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ const shape_bare_fn: u8 = 27u8;
5959
const shape_tydesc: u8 = 28u8;
6060
const shape_send_tydesc: u8 = 29u8;
6161
const shape_class: u8 = 30u8;
62+
const shape_rptr: u8 = 31u8;
6263

6364
fn hash_res_info(ri: res_info) -> uint {
6465
let h = 5381u;
@@ -384,6 +385,10 @@ fn shape_of(ccx: crate_ctxt, t: ty::t, ty_param_map: [uint]) -> [u8] {
384385
}
385386
ty::ty_iface(_, _) { s += [shape_box_fn]; }
386387
ty::ty_class(_, _) { s += [shape_class]; }
388+
ty::ty_rptr(_, tm) {
389+
s += [shape_rptr];
390+
add_substr(s, shape_of(ccx, tm.ty, ty_param_map));
391+
}
387392
ty::ty_res(did, raw_subt, tps) {
388393
let subt = ty::substitute_type_params(ccx.tcx, tps, raw_subt);
389394
let ri = {did: did, t: subt};

branches/try/src/rustc/middle/trans/type_of.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,12 @@ fn type_of(cx: crate_ctxt, t: ty::t) -> TypeRef {
7878
}
7979
ty::ty_ptr(mt) {
8080
let mt_ty = mt.ty;
81-
T_ptr(type_of(cx, mt_ty)) }
81+
T_ptr(type_of(cx, mt_ty))
82+
}
83+
ty::ty_rptr(_, mt) {
84+
let mt_ty = mt.ty;
85+
T_ptr(type_of(cx, mt_ty))
86+
}
8287
ty::ty_rec(fields) {
8388
let tys: [TypeRef] = [];
8489
for f: ty::field in fields {

branches/try/src/rustc/middle/ty.rs

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ export ty_iface, mk_iface;
7878
export ty_res, mk_res;
7979
export ty_param, mk_param;
8080
export ty_ptr, mk_ptr, mk_mut_ptr, type_is_unsafe_ptr;
81+
export ty_rptr, mk_rptr;
8182
export ty_rec, mk_rec;
8283
export ty_enum, mk_enum, type_is_enum;
8384
export ty_tup, mk_tup;
@@ -87,6 +88,7 @@ export ty_uint, mk_uint, mk_mach_uint;
8788
export ty_uniq, mk_uniq, mk_imm_uniq, type_is_unique_box;
8889
export ty_var, mk_var;
8990
export ty_self, mk_self;
91+
export region, re_named, re_caller, re_block;
9092
export get, type_has_params, type_has_vars, type_id;
9193
export same_type;
9294
export ty_var_id;
@@ -218,6 +220,12 @@ type fn_ty = {proto: ast::proto,
218220
ret_style: ret_style,
219221
constraints: [@constr]};
220222

223+
enum region {
224+
re_named(def_id),
225+
re_caller(def_id),
226+
re_block(node_id)
227+
}
228+
221229
// NB: If you change this, you'll probably want to change the corresponding
222230
// AST structure in front/ast::rs as well.
223231
enum sty {
@@ -233,6 +241,7 @@ enum sty {
233241
ty_uniq(mt),
234242
ty_vec(mt),
235243
ty_ptr(mt),
244+
ty_rptr(region, mt),
236245
ty_rec([field]),
237246
ty_fn(fn_ty),
238247
ty_iface(def_id, [t]),
@@ -369,7 +378,7 @@ fn mk_t_with_id(cx: ctxt, st: sty, o_def_id: option<ast::def_id>) -> t {
369378
ty_enum(_, tys) | ty_iface(_, tys) | ty_class(_, tys) {
370379
for tt in tys { derive_flags(has_params, has_vars, tt); }
371380
}
372-
ty_box(m) | ty_uniq(m) | ty_vec(m) | ty_ptr(m) {
381+
ty_box(m) | ty_uniq(m) | ty_vec(m) | ty_ptr(m) | ty_rptr(_, m) {
373382
derive_flags(has_params, has_vars, m.ty);
374383
}
375384
ty_rec(flds) {
@@ -438,6 +447,8 @@ fn mk_imm_uniq(cx: ctxt, ty: t) -> t { mk_uniq(cx, {ty: ty,
438447

439448
fn mk_ptr(cx: ctxt, tm: mt) -> t { mk_t(cx, ty_ptr(tm)) }
440449

450+
fn mk_rptr(cx: ctxt, r: region, tm: mt) -> t { mk_t(cx, ty_rptr(r, tm)) }
451+
441452
fn mk_mut_ptr(cx: ctxt, ty: t) -> t { mk_ptr(cx, {ty: ty,
442453
mutbl: ast::m_mutbl}) }
443454

@@ -505,7 +516,9 @@ fn walk_ty(cx: ctxt, ty: t, f: fn(t)) {
505516
ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) |
506517
ty_str | ty_send_type | ty_type | ty_opaque_box |
507518
ty_opaque_closure_ptr(_) | ty_var(_) | ty_param(_, _) {}
508-
ty_box(tm) | ty_vec(tm) | ty_ptr(tm) { walk_ty(cx, tm.ty, f); }
519+
ty_box(tm) | ty_vec(tm) | ty_ptr(tm) | ty_rptr(_, tm) {
520+
walk_ty(cx, tm.ty, f);
521+
}
509522
ty_enum(_, subtys) | ty_iface(_, subtys) | ty_class(_, subtys)
510523
| ty_self(subtys) {
511524
for subty: t in subtys { walk_ty(cx, subty, f); }
@@ -1112,6 +1125,13 @@ fn hash_type_structure(st: sty) -> uint {
11121125
}
11131126
h
11141127
}
1128+
fn hash_region(r: region) -> uint {
1129+
alt r {
1130+
re_named(_) { 1u }
1131+
re_caller(_) { 2u }
1132+
re_block(_) { 3u }
1133+
}
1134+
}
11151135
alt st {
11161136
ty_nil { 0u } ty_bool { 1u }
11171137
ty_int(t) {
@@ -1158,6 +1178,10 @@ fn hash_type_structure(st: sty) -> uint {
11581178
ty_type { 32u }
11591179
ty_bot { 34u }
11601180
ty_ptr(mt) { hash_subty(35u, mt.ty) }
1181+
ty_rptr(region, mt) {
1182+
let h = (46u << 2u) + hash_region(region);
1183+
hash_subty(h, mt.ty)
1184+
}
11611185
ty_res(did, sub, tps) {
11621186
let h = hash_subty(hash_def(18u, did), sub);
11631187
hash_subtys(h, tps)

branches/try/src/rustc/middle/typeck.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,8 @@ fn ast_ty_to_ty(tcx: ty::ctxt, mode: mode, &&ast_ty: @ast::ty) -> ty::t {
319319
ast::ty_ptr(mt) {
320320
ty::mk_ptr(tcx, ast_mt_to_mt(tcx, mode, mt))
321321
}
322-
ast::ty_rptr(_,_) {
323-
fail "TODO: regions";
322+
ast::ty_rptr(_, mt) {
323+
ty::mk_rptr(tcx, ty::re_block(0), ast_mt_to_mt(tcx, mode, mt))
324324
}
325325
ast::ty_tup(fields) {
326326
let flds = vec::map(fields, bind ast_ty_to_ty(tcx, mode, _));

branches/try/src/serializer/serializer.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ impl serialize_methods for serialize_ctx {
258258
self.serialize_ty(t, v)
259259
}
260260
ty::ty_ptr(_) |
261+
ty::ty_rptr(_,_) |
261262
ty::ty_fn(_) |
262263
ty::ty_iface(_, _) |
263264
ty::ty_res(_, _, _) |
@@ -431,6 +432,7 @@ impl deserialize_methods for serialize_ctx {
431432
self.deserialize_ty(t)
432433
}
433434
ty::ty_ptr(_) |
435+
ty::ty_rptr(_,_) |
434436
ty::ty_fn(_) |
435437
ty::ty_iface(_, _) |
436438
ty::ty_res(_, _, _) |

0 commit comments

Comments
 (0)