Add enough tyencode stuff to stop faulting when we hit error messages.

This commit is contained in:
Graydon Hoare 2012-04-10 18:32:51 -07:00
parent aeca5bae90
commit 9d7e4aefee
2 changed files with 45 additions and 2 deletions

View File

@ -6,6 +6,8 @@ import syntax::ast_util;
import syntax::ast_util::respan;
import middle::ty;
import std::map::hashmap;
import driver::session;
import session::session;
export parse_ty_data, parse_def_id, parse_ident;
export parse_bounds_data;
@ -176,6 +178,10 @@ fn parse_proto(c: char) -> ast::proto {
}
}
fn parse_vstore(st: @pstate) -> ty::vstore {
st.tcx.sess.unimpl("tydecode::parse_vstore");
}
fn parse_ty(st: @pstate, conv: conv_did) -> ty::t {
alt check next(st) {
'n' { ret ty::mk_nil(st.tcx); }
@ -231,6 +237,15 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t {
'~' { ret ty::mk_uniq(st.tcx, parse_mt(st, conv)); }
'*' { ret ty::mk_ptr(st.tcx, parse_mt(st, conv)); }
'I' { ret ty::mk_vec(st.tcx, parse_mt(st, conv)); }
'V' {
let mt = parse_mt(st, conv);
let v = parse_vstore(st);
ret ty::mk_evec(st.tcx, mt, v);
}
'v' {
let v = parse_vstore(st);
ret ty::mk_estr(st.tcx, v);
}
'R' {
assert (next(st) == '[');
let mut fields: [ty::field] = [];

View File

@ -145,6 +145,27 @@ fn enc_region(w: io::writer, r: ty::region) {
}
}
}
fn enc_vstore(w: io::writer, v: ty::vstore) {
w.write_char('/');
alt v {
ty::vstore_fixed(u) {
w.write_uint(u);
w.write_char('|');
}
ty::vstore_uniq {
w.write_char('~');
}
ty::vstore_box {
w.write_char('@');
}
ty::vstore_slice(r) {
w.write_char('&');
enc_region(w, r);
}
}
}
fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) {
alt st {
ty::ty_nil { w.write_char('n'); }
@ -176,7 +197,6 @@ fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) {
ty_f64 { w.write_str("MF"); }
}
}
ty::ty_estr(_) { cx.tcx.sess.unimpl("tyencode::enc_sty on estr"); }
ty::ty_str { w.write_char('S'); }
ty::ty_enum(def, tys) {
w.write_str("t[");
@ -205,7 +225,15 @@ fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) {
enc_region(w, r);
enc_mt(w, cx, mt);
}
ty::ty_evec(_, _) { cx.tcx.sess.unimpl("tyencode::enc_sty on evec"); }
ty::ty_evec(mt, v) {
w.write_char('V');
enc_mt(w, cx, mt);
enc_vstore(w, v);
}
ty::ty_estr(v) {
w.write_char('v');
enc_vstore(w, v);
}
ty::ty_vec(mt) { w.write_char('I'); enc_mt(w, cx, mt); }
ty::ty_rec(fields) {
w.write_str("R[");