about summary refs log tree commit diff
path: root/src/comp/syntax
diff options
context:
space:
mode:
authorGraydon Hoare <graydon@mozilla.com>2011-08-08 15:53:31 -0700
committerGraydon Hoare <graydon@mozilla.com>2011-08-08 15:53:41 -0700
commitb54e7e45069a84e9e9ee6ef3431f733d96d93586 (patch)
tree67ec4b8273da05a6f16ff6255fdb5422219631d6 /src/comp/syntax
parent3dda9aabf217d59881970f847b06338d417f6f6f (diff)
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.
Diffstat (limited to 'src/comp/syntax')
-rw-r--r--src/comp/syntax/ast.rs2
-rw-r--r--src/comp/syntax/parse/parser.rs2
-rw-r--r--src/comp/syntax/print/pprust.rs1
3 files changed, 4 insertions, 1 deletions
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. { }
     }
 }