rustc: Write interior vecs and strings into the metadata and add logic for them in ty_to_str

This commit is contained in:
Patrick Walton 2011-06-09 18:00:11 -07:00
parent ab3635eebe
commit 60706f1e35
3 changed files with 21 additions and 15 deletions

View File

@ -159,6 +159,7 @@ fn parse_ty(@pstate st, str_def sd) -> ty::t {
}
case ('c') { ret ty::mk_char(st.tcx); }
case ('s') { ret ty::mk_str(st.tcx); }
case ('S') { ret ty::mk_istr(st.tcx); }
case ('t') {
assert (next(st) as char == '[');
auto def = parse_def(st, sd);
@ -173,6 +174,7 @@ fn parse_ty(@pstate st, str_def sd) -> ty::t {
case ('@') { ret ty::mk_box(st.tcx, parse_mt(st, sd)); }
case ('*') { ret ty::mk_ptr(st.tcx, parse_mt(st, sd)); }
case ('V') { ret ty::mk_vec(st.tcx, parse_mt(st, sd)); }
case ('I') { ret ty::mk_ivec(st.tcx, parse_mt(st, sd)); }
case ('a') { ret ty::mk_task(st.tcx); }
case ('P') { ret ty::mk_port(st.tcx, parse_ty(st, sd)); }
case ('C') { ret ty::mk_chan(st.tcx, parse_ty(st, sd)); }

View File

@ -174,6 +174,7 @@ fn enc_sty(&io::writer w, &@ctxt cx, &ty::sty st) {
}
case (ty::ty_char) {w.write_char('c');}
case (ty::ty_str) {w.write_char('s');}
case (ty::ty_istr) {w.write_char('S');}
case (ty::ty_tag(?def,?tys)) {
w.write_str("t[");
w.write_str(cx.ds(def));
@ -186,6 +187,7 @@ fn enc_sty(&io::writer w, &@ctxt cx, &ty::sty st) {
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_ivec(?mt)) {w.write_char('I'); 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); }
case (ty::ty_tup(?mts)) {

View File

@ -96,22 +96,24 @@ fn mt_to_str(&ctxt cx, &mt m) -> str {
auto s = "";
alt (struct(cx, typ)) {
case (ty_native) { s += "native"; }
case (ty_nil) { s += "()"; }
case (ty_bot) { s += "_|_"; }
case (ty_bool) { s += "bool"; }
case (ty_int) { s += "int"; }
case (ty_float) { s += "float"; }
case (ty_uint) { s += "uint"; }
case (ty_native) { s += "native"; }
case (ty_nil) { s += "()"; }
case (ty_bot) { s += "_|_"; }
case (ty_bool) { s += "bool"; }
case (ty_int) { s += "int"; }
case (ty_float) { s += "float"; }
case (ty_uint) { s += "uint"; }
case (ty_machine(?tm)) { s += common::ty_mach_to_str(tm); }
case (ty_char) { s += "char"; }
case (ty_str) { s += "str"; }
case (ty_box(?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) + "]"; }
case (ty_type) { s += "type"; }
case (ty_task) { s += "task"; }
case (ty_char) { s += "char"; }
case (ty_str) { s += "str"; }
case (ty_istr) { s += "istr"; }
case (ty_box(?tm)) { s += "@" + mt_to_str(cx, tm); }
case (ty_vec(?tm)) { s += "vec[" + mt_to_str(cx, tm) + "]"; }
case (ty_ivec(?tm)) { s += "ivec[" + 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) + "]"; }
case (ty_type) { s += "type"; }
case (ty_task) { s += "task"; }
case (ty_tup(?elems)) {
auto f = bind mt_to_str(cx, _);