From b54e7e45069a84e9e9ee6ef3431f733d96d93586 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Mon, 8 Aug 2011 15:53:31 -0700 Subject: Add new arg-passing mode 'move' denoted with '-T'. Translate as pass-by-value, doesn't deinit source yet nor get proper analysis in typestate, alias passes. --- src/comp/syntax/ast.rs | 2 +- src/comp/syntax/parse/parser.rs | 2 ++ src/comp/syntax/print/pprust.rs | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) (limited to 'src/comp/syntax') diff --git a/src/comp/syntax/ast.rs b/src/comp/syntax/ast.rs index 5b0787a5fc4..be27e9c2dec 100644 --- a/src/comp/syntax/ast.rs +++ b/src/comp/syntax/ast.rs @@ -249,7 +249,7 @@ fn unop_to_str(op: unop) -> str { } } -tag mode { val; alias(bool); } +tag mode { val; alias(bool); move; } type stmt = spanned[stmt_]; diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs index f0b25eb9a53..133b3c41bc7 100644 --- a/src/comp/syntax/parse/parser.rs +++ b/src/comp/syntax/parse/parser.rs @@ -597,6 +597,8 @@ fn parse_arg(p: &parser) -> ast::arg { expect(p, token::COLON); if eat(p, token::BINOP(token::AND)) { m = ast::alias(eat_word(p, "mutable")); + } else if eat(p, token::BINOP(token::MINUS)) { + m = ast::move; } let t: @ast::ty = parse_ty(p); ret {mode: m, ty: t, ident: i, id: p.get_id()}; diff --git a/src/comp/syntax/print/pprust.rs b/src/comp/syntax/print/pprust.rs index dab764c5baa..79fe8a9f8a4 100644 --- a/src/comp/syntax/print/pprust.rs +++ b/src/comp/syntax/print/pprust.rs @@ -1191,6 +1191,7 @@ fn print_alias(s: &ps, m: ast::mode) { alt m { ast::alias(true) { word_space(s, "&mutable"); } ast::alias(false) { word(s.s, "&"); } + ast::move. { word(s.s, "-"); } ast::val. { } } } -- cgit 1.4.1-3-g733a5