mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-10 22:13:27 +00:00
rustc: Migrate core AST types to interior vectors
This commit is contained in:
parent
aad0bcc8d5
commit
c83782f500
@ -334,7 +334,7 @@ type ty_arg_ = rec(mode mode, @ty ty);
|
|||||||
type ty_method_ =
|
type ty_method_ =
|
||||||
rec(proto proto,
|
rec(proto proto,
|
||||||
ident ident,
|
ident ident,
|
||||||
vec[ty_arg] inputs,
|
ty_arg[] inputs,
|
||||||
@ty output,
|
@ty output,
|
||||||
controlflow cf,
|
controlflow cf,
|
||||||
vec[@constr] constrs);
|
vec[@constr] constrs);
|
||||||
@ -402,9 +402,9 @@ tag ty_ {
|
|||||||
ty_port(@ty);
|
ty_port(@ty);
|
||||||
ty_chan(@ty);
|
ty_chan(@ty);
|
||||||
ty_tup(mt[]);
|
ty_tup(mt[]);
|
||||||
ty_rec(vec[ty_field]);
|
ty_rec(ty_field[]);
|
||||||
ty_fn(proto, vec[ty_arg], @ty, controlflow, vec[@constr]);
|
ty_fn(proto, ty_arg[], @ty, controlflow, vec[@constr]);
|
||||||
ty_obj(vec[ty_method]);
|
ty_obj(ty_method[]);
|
||||||
ty_path(path, node_id);
|
ty_path(path, node_id);
|
||||||
ty_type;
|
ty_type;
|
||||||
ty_constr(@ty, vec[@constr]);
|
ty_constr(@ty, vec[@constr]);
|
||||||
|
@ -258,8 +258,8 @@ fn parse_ty_fn(ast::proto proto, &parser p, uint lo) -> ast::ty_ {
|
|||||||
}
|
}
|
||||||
auto lo = p.get_lo_pos();
|
auto lo = p.get_lo_pos();
|
||||||
auto inputs =
|
auto inputs =
|
||||||
parse_seq(token::LPAREN, token::RPAREN, some(token::COMMA),
|
parse_seq_ivec(token::LPAREN, token::RPAREN, some(token::COMMA),
|
||||||
parse_fn_input_ty, p);
|
parse_fn_input_ty, p);
|
||||||
auto constrs = parse_constrs([], p);
|
auto constrs = parse_constrs([], p);
|
||||||
let @ast::ty output;
|
let @ast::ty output;
|
||||||
auto cf = ast::return;
|
auto cf = ast::return;
|
||||||
@ -308,7 +308,7 @@ fn parse_ty_obj(&parser p, &mutable uint hi) -> ast::ty_ {
|
|||||||
fail;
|
fail;
|
||||||
}
|
}
|
||||||
auto f = parse_method_sig;
|
auto f = parse_method_sig;
|
||||||
auto meths = parse_seq(token::LBRACE, token::RBRACE, none, f, p);
|
auto meths = parse_seq_ivec(token::LBRACE, token::RBRACE, none, f, p);
|
||||||
hi = meths.span.hi;
|
hi = meths.span.hi;
|
||||||
ret ast::ty_obj(meths.node);
|
ret ast::ty_obj(meths.node);
|
||||||
}
|
}
|
||||||
@ -526,8 +526,8 @@ fn parse_ty(&parser p) -> @ast::ty {
|
|||||||
t = ast::ty_tup(elems.node);
|
t = ast::ty_tup(elems.node);
|
||||||
} else if (eat_word(p, "rec")) {
|
} else if (eat_word(p, "rec")) {
|
||||||
auto elems =
|
auto elems =
|
||||||
parse_seq(token::LPAREN, token::RPAREN, some(token::COMMA),
|
parse_seq_ivec(token::LPAREN, token::RPAREN, some(token::COMMA),
|
||||||
parse_ty_field, p);
|
parse_ty_field, p);
|
||||||
hi = elems.span.hi;
|
hi = elems.span.hi;
|
||||||
t = ast::ty_rec(elems.node);
|
t = ast::ty_rec(elems.node);
|
||||||
} else if (eat_word(p, "fn")) {
|
} else if (eat_word(p, "fn")) {
|
||||||
|
@ -237,6 +237,26 @@ fn commasep_cmnt[IN](&ps s, breaks b, vec[IN] elts, fn(&ps, &IN) op,
|
|||||||
end(s);
|
end(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Remove me.
|
||||||
|
fn commasep_cmnt_ivec[IN](&ps s, breaks b, &IN[] elts, fn(&ps, &IN) op,
|
||||||
|
fn(&IN) -> codemap::span get_span) {
|
||||||
|
box(s, 0u, b);
|
||||||
|
auto len = ivec::len[IN](elts);
|
||||||
|
auto i = 0u;
|
||||||
|
for (IN elt in elts) {
|
||||||
|
maybe_print_comment(s, get_span(elt).hi);
|
||||||
|
op(s, elt);
|
||||||
|
i += 1u;
|
||||||
|
if (i < len) {
|
||||||
|
word(s.s, ",");
|
||||||
|
maybe_print_trailing_comment(s, get_span(elt),
|
||||||
|
some(get_span(elts.(i)).hi));
|
||||||
|
space_if_not_hardbreak(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end(s);
|
||||||
|
}
|
||||||
|
|
||||||
fn commasep_exprs(&ps s, breaks b, vec[@ast::expr] exprs) {
|
fn commasep_exprs(&ps s, breaks b, vec[@ast::expr] exprs) {
|
||||||
fn expr_span(&@ast::expr expr) -> codemap::span { ret expr.span; }
|
fn expr_span(&@ast::expr expr) -> codemap::span { ret expr.span; }
|
||||||
commasep_cmnt(s, b, exprs, print_expr, expr_span);
|
commasep_cmnt(s, b, exprs, print_expr, expr_span);
|
||||||
@ -315,7 +335,7 @@ fn print_type(&ps s, &ast::ty ty) {
|
|||||||
end(s);
|
end(s);
|
||||||
}
|
}
|
||||||
fn get_span(&ast::ty_field f) -> codemap::span { ret f.span; }
|
fn get_span(&ast::ty_field f) -> codemap::span { ret f.span; }
|
||||||
commasep_cmnt(s, consistent, fields, print_field, get_span);
|
commasep_cmnt_ivec(s, consistent, fields, print_field, get_span);
|
||||||
pclose(s);
|
pclose(s);
|
||||||
}
|
}
|
||||||
case (ast::ty_fn(?proto, ?inputs, ?output, ?cf, ?constrs)) {
|
case (ast::ty_fn(?proto, ?inputs, ?output, ?cf, ?constrs)) {
|
||||||
@ -1214,7 +1234,7 @@ fn print_mt(&ps s, &ast::mt mt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn print_ty_fn(&ps s, &ast::proto proto, &option::t[str] id,
|
fn print_ty_fn(&ps s, &ast::proto proto, &option::t[str] id,
|
||||||
&vec[ast::ty_arg] inputs, &@ast::ty output,
|
&ast::ty_arg[] inputs, &@ast::ty output,
|
||||||
&ast::controlflow cf, &vec[@ast::constr] constrs) {
|
&ast::controlflow cf, &vec[@ast::constr] constrs) {
|
||||||
ibox(s, indent_unit);
|
ibox(s, indent_unit);
|
||||||
if (proto == ast::proto_fn) {
|
if (proto == ast::proto_fn) {
|
||||||
@ -1230,7 +1250,7 @@ fn print_ty_fn(&ps s, &ast::proto proto, &option::t[str] id,
|
|||||||
print_alias(s, input.node.mode);
|
print_alias(s, input.node.mode);
|
||||||
print_type(s, *input.node.ty);
|
print_type(s, *input.node.ty);
|
||||||
}
|
}
|
||||||
commasep(s, inconsistent, inputs, print_arg);
|
commasep_ivec(s, inconsistent, inputs, print_arg);
|
||||||
pclose(s);
|
pclose(s);
|
||||||
maybe_print_comment(s, output.span.lo);
|
maybe_print_comment(s, output.span.lo);
|
||||||
if (output.node != ast::ty_nil) {
|
if (output.node != ast::ty_nil) {
|
||||||
|
Loading…
Reference in New Issue
Block a user