Boilerplate for pointers. Sorry for missing this on the first patch.

This commit is contained in:
Rafael Ávila de Espíndola 2011-06-03 15:02:58 -04:00
parent 18b63865ce
commit ba74c6cfdc
5 changed files with 20 additions and 0 deletions

View File

@ -174,6 +174,7 @@ mod Encode {
w.write_char(']');
}
case (ty::ty_box(?mt)) {w.write_char('@'); enc_mt(w, cx, mt); }
case (ty::ty_ptr(?mt)) {w.write_char('*'); enc_mt(w, cx, mt); }
case (ty::ty_vec(?mt)) {w.write_char('V'); enc_mt(w, cx, mt); }
case (ty::ty_port(?t)) {w.write_char('P'); enc_ty(w, cx, t); }
case (ty::ty_chan(?t)) {w.write_char('C'); enc_ty(w, cx, t); }

View File

@ -882,6 +882,9 @@ fn type_of_inner(&@crate_ctxt cx, &span sp, &ty::t t) -> TypeRef {
case (ty::ty_vec(?mt)) {
llty = T_ptr(T_vec(type_of_inner(cx, sp, mt.ty)));
}
case (ty::ty_ptr(?mt)) {
llty = T_ptr(type_of_inner(cx, sp, mt.ty));
}
case (ty::ty_port(?t)) {
llty = T_ptr(T_port(type_of_inner(cx, sp, t)));
}

View File

@ -109,6 +109,7 @@ tag sty {
ty_tag(ast::def_id, vec[t]);
ty_box(mt);
ty_vec(mt);
ty_ptr(mt);
ty_port(t);
ty_chan(t);
ty_task;
@ -436,6 +437,10 @@ fn mk_box(&ctxt cx, &mt tm) -> t {
ret gen_ty(cx, ty_box(tm));
}
fn mk_ptr(&ctxt cx, &mt tm) -> t {
ret gen_ty(cx, ty_ptr(tm));
}
fn mk_imm_box(&ctxt cx, &t ty) -> t {
ret mk_box(cx, rec(ty=ty, mut=ast::imm));
}
@ -1225,6 +1230,7 @@ fn hash_type_structure(&sty st) -> uint {
case (ty_type) { ret 32u; }
case (ty_native) { ret 33u; }
case (ty_bot) { ret 34u; }
case (ty_ptr(?mt)) { ret hash_subty(35u, mt.ty); }
}
}
@ -1356,6 +1362,12 @@ fn equal_type_structures(&sty a, &sty b) -> bool {
case (_) { ret false; }
}
}
case (ty_ptr(?mt_a)) {
alt (b) {
case (ty_ptr(?mt_b)) { ret equal_mt(mt_a, mt_b); }
case (_) { ret false; }
}
}
case (ty_port(?t_a)) {
alt (b) {
case (ty_port(?t_b)) { ret eq_ty(t_a, t_b); }

View File

@ -284,6 +284,9 @@ fn ast_ty_to_ty(&ty::ctxt tcx, &ty_getter getter, &@ast::ty ast_ty) -> ty::t {
case (ast::ty_vec(?mt)) {
typ = ty::mk_vec(tcx, ast_mt_to_mt(tcx, getter, mt));
}
case (ast::ty_ptr(?mt)) {
typ = ty::mk_ptr(tcx, ast_mt_to_mt(tcx, getter, mt));
}
case (ast::ty_task) { typ = ty::mk_task(tcx); }
case (ast::ty_port(?t)) {
typ = ty::mk_port(tcx, ast_ty_to_ty(tcx, getter, t));

View File

@ -156,6 +156,7 @@ fn walk_ty(&ast_visitor v, @ast::ty t) {
case (ast::ty_str) {}
case (ast::ty_box(?mt)) { walk_ty(v, mt.ty); }
case (ast::ty_vec(?mt)) { walk_ty(v, mt.ty); }
case (ast::ty_ptr(?mt)) { walk_ty(v, mt.ty); }
case (ast::ty_task) {}
case (ast::ty_port(?t)) { walk_ty(v, t); }
case (ast::ty_chan(?t)) { walk_ty(v, t); }