From 2f9acf36cfd475dc48b7a46e4cdff1b284529a79 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Mon, 22 Aug 2016 20:03:11 +0800 Subject: AST+HIR - Save decoded receiver type for methods --- src/hir/from_ast.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/hir/from_ast.cpp') diff --git a/src/hir/from_ast.cpp b/src/hir/from_ast.cpp index 4fe9759c..6a43b790 100644 --- a/src/hir/from_ast.cpp +++ b/src/hir/from_ast.cpp @@ -891,13 +891,31 @@ namespace { } ::HIR::Function LowerHIR_Function(::HIR::ItemPath p, const ::AST::Function& f) { + static Span sp; + DEBUG(p); ::std::vector< ::std::pair< ::HIR::Pattern, ::HIR::TypeRef > > args; for(const auto& arg : f.args()) args.push_back( ::std::make_pair( LowerHIR_Pattern(arg.first), LowerHIR_Type(arg.second) ) ); + auto receiver = ::HIR::Function::Receiver::Free; + + switch( f.receiver() ) + { + #define _(N) case ::AST::Function::Receiver::N: receiver = ::HIR::Function::Receiver::N; break; + _(Free) + _(Value) + _(BorrowOwned) + _(BorrowUnique) + _(BorrowShared) + //case ::AST::Function::Receiver::Box: + // break; + #undef _ + } + // TODO: ABI and unsafety/constness return ::HIR::Function { + receiver, "rust", false, false, LowerHIR_GenericParams(f.params(), nullptr), // TODO: If this is a method, then it can add the Self: Sized bound mv$(args), -- cgit v1.2.3