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 {
}
}
+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
}
}
}
+ 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;
}
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) {
}
+// 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('(');
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: