rustc: Implement type walking and comparison glue for unsafe pointers

This commit is contained in:
Patrick Walton 2011-06-16 17:05:59 -07:00
parent b84fffaa4e
commit e50c918e6b
2 changed files with 25 additions and 0 deletions

View File

@ -2314,6 +2314,9 @@ fn make_scalar_cmp_glue(&@block_ctxt cx, ValueRef lhs, ValueRef rhs, &ty::t t,
trans_fail(cx, none[common::span],
"attempt to compare values of type native");
}
case (ty::ty_ptr(_)) {
f(unsigned_int);
}
case (_) {
// Should never get here, because t is scalar.

View File

@ -505,6 +505,7 @@ fn walk_ty(&ctxt cx, ty_walk walker, t ty) {
case (ty_box(?tm)) { walk_ty(cx, walker, tm.ty); }
case (ty_vec(?tm)) { walk_ty(cx, walker, tm.ty); }
case (ty_ivec(?tm)) { walk_ty(cx, walker, tm.ty); }
case (ty_ptr(?tm)) { walk_ty(cx, walker, tm.ty); }
case (ty_port(?subty)) { walk_ty(cx, walker, subty); }
case (ty_chan(?subty)) { walk_ty(cx, walker, subty); }
case (ty_tag(?tid, ?subtys)) {
@ -2088,6 +2089,27 @@ mod unify {
case (_) { ret ures_err(terr_mismatch); }
}
}
case (ty::ty_ptr(?expected_mt)) {
alt (struct(cx.tcx, actual)) {
case (ty::ty_ptr(?actual_mt)) {
auto mut;
alt (unify_mut(expected_mt.mut, actual_mt.mut)) {
case (none) { ret ures_err(terr_vec_mutability); }
case (some(?m)) { mut = m; }
}
auto result =
unify_step(cx, expected_mt.ty, actual_mt.ty);
alt (result) {
case (ures_ok(?result_sub)) {
auto mt = rec(ty=result_sub, mut=mut);
ret ures_ok(mk_ptr(cx.tcx, mt));
}
case (_) { ret result; }
}
}
case (_) { ret ures_err(terr_mismatch); }
}
}
case (ty::ty_port(?expected_sub)) {
alt (struct(cx.tcx, actual)) {
case (ty::ty_port(?actual_sub)) {