diff options
author | John Hodge <tpg@mutabah.net> | 2016-08-22 20:03:11 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-08-22 20:03:11 +0800 |
commit | 2f9acf36cfd475dc48b7a46e4cdff1b284529a79 (patch) | |
tree | 50b25571223d37ad30430d573a6857b846941598 /src/ast/ast.hpp | |
parent | 96621f217b750115c01457d79a74f9676164b463 (diff) | |
download | mrust-2f9acf36cfd475dc48b7a46e4cdff1b284529a79.tar.gz |
AST+HIR - Save decoded receiver type for methods
Diffstat (limited to 'src/ast/ast.hpp')
-rw-r--r-- | src/ast/ast.hpp | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/src/ast/ast.hpp b/src/ast/ast.hpp index 93b68604..b5fd07ea 100644 --- a/src/ast/ast.hpp +++ b/src/ast/ast.hpp @@ -147,38 +147,49 @@ class Function {
public:
typedef ::std::vector< ::std::pair<AST::Pattern,TypeRef> > Arglist;
+
+ enum class Receiver {
+ Free,
+ Value,
+ BorrowOwned,
+ BorrowUnique,
+ BorrowShared,
+ //RawMut,
+ //RawConst,
+ //Box,
+ };
private:
- ::std::string m_lifetime;
+ Span m_span;
+ //::std::string m_lifetime;
+ Receiver m_receiver;
GenericParams m_params;
Expr m_code;
TypeRef m_rettype;
Arglist m_args;
public:
- Function()
+ Function():
+ m_receiver(Receiver::Free)
{}
Function(const Function&) = delete;
- Function(Function&&) noexcept = default;
+ Function& operator=(const Function&) = delete;
+ Function(Function&&) = default;
Function& operator=(Function&&) = default;
- Function(GenericParams params, TypeRef ret_type, Arglist args):
- m_params( move(params) ),
- m_rettype( move(ret_type) ),
- m_args( move(args) )
- {
- }
+ Function(Span sp, GenericParams params, TypeRef ret_type, Arglist args);
void set_code(Expr code) { m_code = ::std::move(code); }
- void set_self_lifetime(::std::string s) { m_lifetime = s; }
const GenericParams& params() const { return m_params; }
+ GenericParams& params() { return m_params; }
const Expr& code() const { return m_code; }
+ Expr& code() { return m_code; }
const TypeRef& rettype() const { return m_rettype; }
+ TypeRef& rettype() { return m_rettype; }
const Arglist& args() const { return m_args; }
+ Arglist& args() { return m_args; }
+
+ Receiver receiver() const { return m_receiver; }
- GenericParams& params() { return m_params; }
- Expr& code() { return m_code; }
- TypeRef& rettype() { return m_rettype; }
- Arglist& args() { return m_args; }
};
class Trait
|