Skip to content

Commit ee54fa5

Browse files
committed
Implement enough support for pointer to get an identity function working.
1 parent 4bd5f83 commit ee54fa5

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/comp/middle/ty.rs

+6
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,7 @@ fn ty_to_str(&ctxt cx, &t typ) -> str {
615615
case (ty_char) { s += "char"; }
616616
case (ty_str) { s += "str"; }
617617
case (ty_box(?tm)) { s += "@" + mt_to_str(cx, tm); }
618+
case (ty_ptr(?tm)) { s += "*" + mt_to_str(cx, tm); }
618619
case (ty_vec(?tm)) { s += "vec[" + mt_to_str(cx, tm) + "]"; }
619620
case (ty_port(?t)) { s += "port[" + ty_to_str(cx, t) + "]"; }
620621
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 {
781782
ty = copy_cname(cx, mk_box(cx, rec(ty=fold_ty(cx, fld, tm.ty),
782783
mut=tm.mut)), ty);
783784
}
785+
case (ty_ptr(?tm)) {
786+
ty = copy_cname(cx, mk_ptr(cx, rec(ty=fold_ty(cx, fld, tm.ty),
787+
mut=tm.mut)), ty);
788+
}
784789
case (ty_vec(?tm)) {
785790
ty = copy_cname(cx, mk_vec(cx, rec(ty=fold_ty(cx, fld, tm.ty),
786791
mut=tm.mut)), ty);
@@ -978,6 +983,7 @@ fn type_is_scalar(&ctxt cx, &t ty) -> bool {
978983
case (ty_char) { ret true; }
979984
case (ty_type) { ret true; }
980985
case (ty_native) { ret true; }
986+
case (ty_ptr(_)) { ret true; }
981987
case (_) { ret false; }
982988
}
983989
}

src/test/run-pass/type-ptr.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
fn f(*int a) {
1+
fn f(*int a) -> *int {
2+
ret a;
3+
}
4+
5+
fn g(*int a) -> *int {
6+
auto b = f(a);
7+
ret b;
28
}
39

410
fn main(vec[str] args) {

0 commit comments

Comments
 (0)