rustc: Move AST constraints to interior vectors

This commit is contained in:
Patrick Walton 2011-07-06 16:12:39 -07:00
parent c83782f500
commit f164d7779a
4 changed files with 17 additions and 16 deletions

View File

@ -337,7 +337,7 @@ type ty_method_ =
ty_arg[] inputs,
@ty output,
controlflow cf,
vec[@constr] constrs);
(@constr)[] constrs);
type ty_field = spanned[ty_field_];
@ -403,11 +403,11 @@ tag ty_ {
ty_chan(@ty);
ty_tup(mt[]);
ty_rec(ty_field[]);
ty_fn(proto, ty_arg[], @ty, controlflow, vec[@constr]);
ty_fn(proto, ty_arg[], @ty, controlflow, (@constr)[]);
ty_obj(ty_method[]);
ty_path(path, node_id);
ty_type;
ty_constr(@ty, vec[@constr]);
ty_constr(@ty, (@constr)[]);
}
@ -442,7 +442,7 @@ type fn_decl =
@ty output,
purity purity,
controlflow cf,
vec[@constr] constraints);
(@constr)[] constraints);
tag purity {
pure_fn; // declared with "pred"

View File

@ -175,8 +175,8 @@ fn noop_fold_native_item(&@native_item ni, ast_fold fld) -> @native_item {
rec(inputs=map(fold_arg, fdec.inputs),
output=fld.fold_ty(fdec.output),
purity=fdec.purity, cf=fdec.cf,
constraints=map(fld.fold_constr,
fdec.constraints)),
constraints=ivec::map(fld.fold_constr,
fdec.constraints)),
typms)
}
},
@ -450,11 +450,12 @@ fn noop_fold_constr(&constr_ c, ast_fold fld) -> constr_ {
fn noop_fold_fn(&_fn f, ast_fold fld) -> _fn {
auto fold_arg = bind fold_arg_(_, fld);
ret rec(decl= rec(inputs=map(fold_arg, f.decl.inputs),
ret rec(decl= rec(inputs=vec::map(fold_arg, f.decl.inputs),
output=fld.fold_ty(f.decl.output),
purity=f.decl.purity,
cf=f.decl.cf,
constraints=map(fld.fold_constr, f.decl.constraints)),
constraints=ivec::map(fld.fold_constr,
f.decl.constraints)),
proto = f.proto,
body = fld.fold_block(f.body));
}

View File

@ -363,17 +363,17 @@ fn parse_ty_constr(&vec[ast::arg] fn_args, &parser p) -> @ast::constr {
// Use the args list to translate each bound variable
// mentioned in a constraint to an arg index.
// Seems weird to do this in the parser, but I'm not sure how else to.
fn parse_constrs(&vec[ast::arg] args, &parser p) ->
ast::spanned[vec[@ast::constr]] {
fn parse_constrs(&vec[ast::arg] args, &parser p)
-> ast::spanned[(@ast::constr)[]] {
auto lo = p.get_lo_pos();
auto hi = p.get_hi_pos();
let vec[@ast::constr] constrs = [];
let (@ast::constr)[] constrs = ~[];
if (p.peek() == token::COLON) {
p.bump();
while (true) {
auto constr = parse_ty_constr(args, p);
hi = constr.span.hi;
vec::push(constrs, constr);
constrs += ~[constr];
if (p.peek() == token::COMMA) { p.bump(); } else { break; }
}
}
@ -1799,7 +1799,7 @@ fn parse_dtor(&parser p) -> @ast::method {
cf=ast::return,
// I guess dtors can't have constraints?
constraints=[]);
constraints=~[]);
let ast::_fn f = rec(decl=d, proto=ast::proto_fn, body=b);
let ast::method_ m =
rec(ident="drop", meth=f, id=p.get_id());
@ -1844,7 +1844,7 @@ fn parse_item_res(&parser p, ast::layer lyr, &ast::attribute[] attrs) ->
output=@spanned(lo, lo, ast::ty_nil),
purity=ast::impure_fn,
cf=ast::return,
constraints=[]);
constraints=~[]);
auto f = rec(decl=decl, proto=ast::proto_fn, body=dtor);
ret mk_item(p, lo, dtor.span.hi, ident,
ast::item_res(f, p.get_id(), ty_params, p.get_id()), attrs);

View File

@ -1235,7 +1235,7 @@ fn print_mt(&ps s, &ast::mt mt) {
fn print_ty_fn(&ps s, &ast::proto proto, &option::t[str] id,
&ast::ty_arg[] inputs, &@ast::ty output,
&ast::controlflow cf, &vec[@ast::constr] constrs) {
&ast::controlflow cf, &(@ast::constr)[] constrs) {
ibox(s, indent_unit);
if (proto == ast::proto_fn) {
word(s.s, "fn");
@ -1488,7 +1488,7 @@ fn ast_constr_to_str(&@ast::constr c) -> str {
constr_args_to_str(uint_to_str, cag_ivec);
}
fn ast_constrs_str(&vec[@ast::constr] constrs) -> str {
fn ast_constrs_str(&(@ast::constr)[] constrs) -> str {
auto s = "";
auto colon = true;
for (@ast::constr c in constrs) {