From 17e187070ddb96356dd4c2607d3360fb4f0ac6e0 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Wed, 24 Aug 2016 19:46:08 +0800 Subject: AST - Hackily support `self: Box` syntax --- src/ast/ast.cpp | 13 +++++++++++++ src/ast/ast.hpp | 2 +- src/hir/from_ast.cpp | 5 +++-- 3 files changed, 17 insertions(+), 3 deletions(-) (limited to 'src') 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` receiver"); + break; #undef _ } -- cgit v1.2.3