diff options
Diffstat (limited to 'src/ast/path.hpp')
-rw-r--r-- | src/ast/path.hpp | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/src/ast/path.hpp b/src/ast/path.hpp index b45767a2..7a67b93e 100644 --- a/src/ast/path.hpp +++ b/src/ast/path.hpp @@ -112,7 +112,7 @@ struct PathParams ::std::vector< ::std::string > m_lifetimes; ::std::vector< TypeRef > m_types; ::std::vector< ::std::pair< ::std::string, TypeRef> > m_assoc; - + PathParams(PathParams&& x) = default; PathParams(const PathParams& x); PathParams() {} @@ -121,16 +121,16 @@ struct PathParams m_types(mv$(tys)), m_assoc(mv$(a)) {} - + PathParams& operator=(PathParams&& x) = default; PathParams& operator=(const PathParams& x) = delete; - + bool is_empty() const { return m_lifetimes.empty() && m_types.empty() && m_assoc.empty(); } - + Ordering ord(const PathParams& x) const; - + friend ::std::ostream& operator<<(::std::ostream& os, const PathParams& x); }; @@ -142,13 +142,13 @@ public: PathNode() {} PathNode(::std::string name, PathParams args = {}); const ::std::string& name() const { return m_name; } - + const ::AST::PathParams& args() const { return m_params; } ::AST::PathParams& args() { return m_params; } - + Ordering ord(const PathNode& x) const; void print_pretty(::std::ostream& os, bool is_type_context) const; - + bool operator==(const PathNode& x) const { return ord(x) == OrdEqual; } friend ::std::ostream& operator<<(::std::ostream& os, const PathNode& pn); }; @@ -201,20 +201,20 @@ public: //DEBUG("Path, " << x); return *this; } - + Path(const Path& x); Path& operator=(const AST::Path&) = delete; - + // ABSOLUTE Path(::std::string crate, ::std::vector<PathNode> nodes): m_class( Class::make_Absolute({ mv$(crate), mv$(nodes)}) ) {} - + // UFCS struct TagUfcs {}; Path(TagUfcs, TypeRef type, ::std::vector<PathNode> nodes={}); Path(TagUfcs, TypeRef type, Path trait, ::std::vector<PathNode> nodes={}); - + // VARIABLE struct TagLocal {}; Path(TagLocal, ::std::string name): @@ -223,7 +223,7 @@ public: Path(::std::string name): m_class( Class::make_Local({ mv$(name) }) ) {} - + // RELATIVE struct TagRelative {}; Path(TagRelative, Ident::Hygiene hygiene, ::std::vector<PathNode> nodes): @@ -239,7 +239,7 @@ public: Path(TagSuper, unsigned int count, ::std::vector<PathNode> nodes): m_class( Class::make_Super({ count, mv$(nodes) }) ) {} - + //void set_crate(::std::string crate) { // if( m_crate == "" ) { // m_crate = crate; @@ -247,11 +247,11 @@ public: // } //} - + Class::Tag class_tag() const { return m_class.tag(); } - + Path operator+(PathNode pn) const { Path tmp = Path(*this); tmp.nodes().push_back( mv$(pn) ); @@ -274,7 +274,7 @@ public: nodes().push_back( mv$(node) ); m_binding = PathBinding(); } - + bool is_trivial() const { TU_MATCH_DEF(Class, (m_class), (e), ( @@ -288,11 +288,11 @@ public: ) ) } - + bool is_valid() const { return !m_class.is_Invalid(); } bool is_absolute() const { return m_class.is_Absolute(); } bool is_relative() const { return m_class.is_Relative() || m_class.is_Super() || m_class.is_Self(); } - + size_t size() const { TU_MATCH(Class, (m_class), (ent), (Invalid, assert(!m_class.is_Invalid()); throw ::std::runtime_error("Path::nodes() on Invalid"); ), @@ -308,11 +308,11 @@ public: //const ::std::string& crate() const { return m_crate; } bool is_concrete() const; - + bool is_bound() const { return !m_binding.is_Unbound(); } const PathBinding& binding() const { return m_binding; } void bind_variable(unsigned int slot); - + ::std::vector<PathNode>& nodes() { TU_MATCH(Class, (m_class), (ent), (Invalid, assert(!m_class.is_Invalid()); throw ::std::runtime_error("Path::nodes() on Invalid"); ), @@ -328,20 +328,20 @@ public: const ::std::vector<PathNode>& nodes() const { return ((Path*)this)->nodes(); } - + PathNode& operator[](int idx) { if(idx>=0) return nodes()[idx]; else return nodes()[size()+idx]; } const PathNode& operator[](int idx) const { return (*(Path*)this)[idx]; } - + Ordering ord(const Path& x) const; bool operator==(const Path& x) const { return ord(x) == OrdEqual; } bool operator!=(const Path& x) const { return ord(x) != OrdEqual; } bool operator<(const Path& x) const { return ord(x) != OrdLess; } - + void print_pretty(::std::ostream& os, bool is_type_context) const; friend ::std::ostream& operator<<(::std::ostream& os, const Path& path); private: static void resolve_args_nl(::std::vector<PathNode>& nodes, ::std::function<TypeRef(const char*)> fcn); - + void check_param_counts(const GenericParams& params, bool expect_params, PathNode& node); public: void bind_enum_var(const Enum& ent, const ::std::string& name, const ::std::vector<TypeRef>& args={}); @@ -349,7 +349,7 @@ public: (void)args; m_binding = PathBinding::make_Function({&ent}); } - + void bind(::AST::PathBinding pb) { m_binding = mv$(pb); } |