diff options
author | John Hodge <tpg@mutabah.net> | 2016-08-24 19:46:08 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-08-24 19:46:08 +0800 |
commit | 17e187070ddb96356dd4c2607d3360fb4f0ac6e0 (patch) | |
tree | 0e72e5633a705700c5034af14e1bb560f48f6a92 /src | |
parent | 35ef3b33b3be9b03f693727706a2184a8c1b1e54 (diff) | |
download | mrust-17e187070ddb96356dd4c2607d3360fb4f0ac6e0.tar.gz |
AST - Hackily support `self: Box` syntax
Diffstat (limited to 'src')
-rw-r--r-- | src/ast/ast.cpp | 13 | ||||
-rw-r--r-- | src/ast/ast.hpp | 2 | ||||
-rw-r--r-- | src/hir/from_ast.cpp | 5 |
3 files changed, 17 insertions, 3 deletions
diff --git a/src/ast/ast.cpp b/src/ast/ast.cpp index f8d5598a..80182f85 100644 --- a/src/ast/ast.cpp +++ b/src/ast/ast.cpp @@ -316,6 +316,19 @@ Function::Function(Span sp, GenericParams params, TypeRef ret_type, Arglist args // Whups!
ERROR(sp, E0000, "Invalid receiver type - " << ty);
),
+ (Path,
+ TU_IFLET( ::AST::Path::Class, e.path.m_class, Relative, pe,
+ if( pe.nodes.size() == 1 && pe.nodes.front().name() == "Box" )
+ {
+ // HACK: Assumes that the param is Self or equivalent
+ m_receiver = Receiver::Box;
+ }
+ )
+
+ if( m_receiver == Receiver::Free ) {
+ ERROR(sp, E0000, "Invalid receiver type - " << ty);
+ }
+ ),
(Borrow,
if(e.is_mut) {
m_receiver = Receiver::BorrowUnique;
diff --git a/src/ast/ast.hpp b/src/ast/ast.hpp index b5fd07ea..1cd4d1ac 100644 --- a/src/ast/ast.hpp +++ b/src/ast/ast.hpp @@ -156,7 +156,7 @@ public: BorrowShared,
//RawMut,
//RawConst,
- //Box,
+ Box,
};
private:
diff --git a/src/hir/from_ast.cpp b/src/hir/from_ast.cpp index 053ad9b9..b7d1f77e 100644 --- a/src/hir/from_ast.cpp +++ b/src/hir/from_ast.cpp @@ -908,8 +908,9 @@ namespace { _(BorrowOwned) _(BorrowUnique) _(BorrowShared) - //case ::AST::Function::Receiver::Box: - // break; + case ::AST::Function::Receiver::Box: + TODO(sp, "Support `self: Box<Self>` receiver"); + break; #undef _ } |