提交 41212792 编写于 作者: T Tim Chevalier

Add missing case in tyencode for ty_constr

Fixes the Windoze breakage, I hope.
上级 1a2a8b6b
......@@ -82,6 +82,23 @@ fn parse_constrs(@pstate st, str_def sd) -> (@ty::constr)[] {
ret rslt;
}
// FIXME less copy-and-paste
fn parse_ty_constrs(@pstate st, str_def sd) -> (@ty::type_constr)[] {
let (@ty::type_constr)[] rslt = ~[];
alt (peek(st) as char) {
case (':') {
do {
next(st);
let @ty::type_constr one = parse_constr[path](st, sd,
parse_ty_constr_arg);
rslt += ~[one];
} while (peek(st) as char == ';')
}
case (_) { }
}
ret rslt;
}
fn parse_path(@pstate st, str_def sd) -> ast::path {
let ast::ident[] idents = ~[];
fn is_last(char c) -> bool {
......@@ -136,6 +153,19 @@ fn parse_constr_arg(@pstate st, str_def sd) -> ast::fn_constr_arg {
}
}
fn parse_ty_constr_arg(@pstate st, str_def sd)
-> ast::constr_arg_general_[path] {
alt (peek(st) as char) {
case ('*') {
st.pos += 1u;
ret ast::carg_base;
}
case (?c) {
ret ast::carg_ident(parse_path(st, sd));
}
}
}
fn parse_constr[T](@pstate st, str_def sd, arg_parser[T] pser)
-> @ty::constr_general[T] {
auto sp = rec(lo=0u,hi=0u); // FIXME: use a real span
......@@ -294,6 +324,13 @@ fn parse_ty(@pstate st, str_def sd) -> ty::t {
}
}
}
case ('A') {
assert (next(st) as char == '[');
auto tt = parse_ty(st, sd);
auto tcs = parse_ty_constrs(st, sd);
assert (next(st) as char == ']');
ret ty::mk_constr(st.tcx, tt, tcs);
}
case (?c) {
log_err "unexpected char in type string: ";
log_err c;
......
......@@ -191,6 +191,14 @@ fn enc_sty(&ioivec::writer w, &@ctxt cx, &ty::sty st) {
}
case (ty::ty_type) { w.write_char('Y'); }
case (ty::ty_task) { w.write_char('a'); }
case (ty::ty_constr(?ty, ?cs)) {
w.write_str("A[");
enc_ty(w, cx, ty);
for (@ty::type_constr tc in cs) {
enc_ty_constr(w, cx, tc);
}
w.write_char(']');
}
}
}
fn enc_proto(&ioivec::writer w, proto proto) {
......@@ -229,6 +237,7 @@ fn enc_ty_fn(&ioivec::writer w, &@ctxt cx, &ty::arg[] args, &ty::t out,
}
// FIXME less copy-and-paste
fn enc_constr(&ioivec::writer w, &@ctxt cx, &@ty::constr c) {
w.write_str(path_to_str(c.node.path));
w.write_char('(');
......@@ -248,6 +257,25 @@ fn enc_constr(&ioivec::writer w, &@ctxt cx, &@ty::constr c) {
w.write_char(')');
}
fn enc_ty_constr(&ioivec::writer w, &@ctxt cx, &@ty::type_constr c) {
w.write_str(path_to_str(c.node.path));
w.write_char('(');
w.write_str(cx.ds(c.node.id));
w.write_char('|');
auto semi = false;
for (@ty::ty_constr_arg a in c.node.args) {
if (semi) { w.write_char(';'); } else { semi = true; }
alt (a.node) {
case (carg_base) { w.write_char('*'); }
case (carg_ident(?p)) {
w.write_str(path_to_str(p));
}
case (carg_lit(?l)) { w.write_str(lit_to_str(l)); }
}
}
w.write_char(')');
}
//
// Local Variables:
......
......@@ -122,6 +122,7 @@
export ty_chan;
export ty_char;
export ty_constr;
export ty_constr_arg;
export ty_float;
export ty_fn;
export ty_fn_abi;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册