Implement enough support for pointer to get an identity function working.

上级 4bd5f834
......@@ -615,6 +615,7 @@ fn mt_to_str(&ctxt cx, &mt m) -> str {
case (ty_char) { s += "char"; }
case (ty_str) { s += "str"; }
case (ty_box(?tm)) { s += "@" + mt_to_str(cx, tm); }
case (ty_ptr(?tm)) { s += "*" + mt_to_str(cx, tm); }
case (ty_vec(?tm)) { s += "vec[" + mt_to_str(cx, tm) + "]"; }
case (ty_port(?t)) { s += "port[" + ty_to_str(cx, t) + "]"; }
case (ty_chan(?t)) { s += "chan[" + ty_to_str(cx, t) + "]"; }
......@@ -781,6 +782,10 @@ fn fold_ty(&ctxt cx, ty_fold fld, t ty_0) -> t {
ty = copy_cname(cx, mk_box(cx, rec(ty=fold_ty(cx, fld, tm.ty),
mut=tm.mut)), ty);
}
case (ty_ptr(?tm)) {
ty = copy_cname(cx, mk_ptr(cx, rec(ty=fold_ty(cx, fld, tm.ty),
mut=tm.mut)), ty);
}
case (ty_vec(?tm)) {
ty = copy_cname(cx, mk_vec(cx, rec(ty=fold_ty(cx, fld, tm.ty),
mut=tm.mut)), ty);
......@@ -978,6 +983,7 @@ fn type_is_scalar(&ctxt cx, &t ty) -> bool {
case (ty_char) { ret true; }
case (ty_type) { ret true; }
case (ty_native) { ret true; }
case (ty_ptr(_)) { ret true; }
case (_) { ret false; }
}
}
......
fn f(*int a) {
fn f(*int a) -> *int {
ret a;
}
fn g(*int a) -> *int {
auto b = f(a);
ret b;
}
fn main(vec[str] args) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册