From 2e119698b7354b6fd2b96dccfeea821bc538d8f1 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Fri, 3 Dec 2010 18:12:51 -0800 Subject: rustc: Add def ids to variant arguments so we can turn them into function arguments later --- src/comp/front/ast.rs | 3 ++- src/comp/front/parser.rs | 18 +++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) (limited to 'src/comp/front') 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); -- cgit v1.2.3