diff options
| author | Patrick Walton <[email protected]> | 2010-12-03 18:12:51 -0800 |
|---|---|---|
| committer | Patrick Walton <[email protected]> | 2010-12-03 18:13:15 -0800 |
| commit | 2e119698b7354b6fd2b96dccfeea821bc538d8f1 (patch) | |
| tree | 7a828b7929bde526d650d4c822b406fa75fa634a /src/comp/front | |
| parent | Parse layer and effect annotations. (diff) | |
| download | rust-2e119698b7354b6fd2b96dccfeea821bc538d8f1.tar.xz rust-2e119698b7354b6fd2b96dccfeea821bc538d8f1.zip | |
rustc: Add def ids to variant arguments so we can turn them into function arguments later
Diffstat (limited to 'src/comp/front')
| -rw-r--r-- | src/comp/front/ast.rs | 3 | ||||
| -rw-r--r-- | src/comp/front/parser.rs | 18 |
2 files changed, 11 insertions, 10 deletions
diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index f4bfc7a2..e7695e0b 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -198,7 +198,8 @@ tag mod_index_entry { type _mod = rec(vec[@item] items, hashmap[ident,mod_index_entry] index); -type variant = rec(str name, vec[@ty] args, def_id id, ann ann); +type variant_arg = rec(@ty ty, def_id id); +type variant = rec(str name, vec[variant_arg] args, def_id id, ann ann); type item = spanned[item_]; tag item_ { diff --git a/src/comp/front/parser.rs b/src/comp/front/parser.rs index ba0631ed..879cb2c0 100644 --- a/src/comp/front/parser.rs +++ b/src/comp/front/parser.rs @@ -1271,19 +1271,19 @@ impure fn parse_item_tag(parser p) -> @ast.item { case (token.IDENT(?name)) { p.bump(); - auto args; + let vec[ast.variant_arg] args = vec(); alt (p.peek()) { case (token.LPAREN) { auto f = parse_ty; - auto tys = parse_seq[@ast.ty](token.LPAREN, - token.RPAREN, - some(token.COMMA), - f, p); - args = tys.node; - } - case (_) { - args = vec(); + auto arg_tys = parse_seq[@ast.ty](token.LPAREN, + token.RPAREN, + some(token.COMMA), + f, p); + for (@ast.ty ty in arg_tys.node) { + args += vec(rec(ty=ty, id=p.next_def_id())); + } } + case (_) { /* empty */ } } expect(p, token.SEMI); |