summaryrefslogtreecommitdiff
path: root/src/ast/types.cpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2018-05-20 22:01:59 +0800
committerJohn Hodge <tpg@mutabah.net>2018-05-20 22:01:59 +0800
commitde9ecd7a2d70359b34e77ded57e5aa9284345ac5 (patch)
tree29ab42c6c06960720bd67f0b8ebaec807ad0284e /src/ast/types.cpp
parent134be5198993096ab5216b6d52a8937430c733b0 (diff)
downloadmrust-de9ecd7a2d70359b34e77ded57e5aa9284345ac5.tar.gz
AST - Refactor lifetime/HRB handling
Diffstat (limited to 'src/ast/types.cpp')
-rw-r--r--src/ast/types.cpp33
1 files changed, 31 insertions, 2 deletions
diff --git a/src/ast/types.cpp b/src/ast/types.cpp
index af99f3d7..8065a3ba 100644
--- a/src/ast/types.cpp
+++ b/src/ast/types.cpp
@@ -141,6 +141,15 @@ TypeRef TypeRef::clone() const
throw "";
}
+Ordering Type_TraitPath::ord(const Type_TraitPath& x) const
+{
+ Ordering rv;
+
+ rv = ::ord( this->path, x.path );
+ if(rv != OrdEqual) return rv;
+
+ return rv;
+}
Ordering TypeRef::ord(const TypeRef& x) const
{
Ordering rv;
@@ -277,7 +286,8 @@ void TypeRef::print(::std::ostream& os, bool is_debug/*=false*/) const
for( const auto& it : ent.traits ) {
if( &it != &ent.traits.front() )
os << "+";
- it.print_pretty(os, true, is_debug);
+ os << it.hrbs;
+ it.path.print_pretty(os, true, is_debug);
}
os << ")";
)
@@ -286,7 +296,8 @@ void TypeRef::print(::std::ostream& os, bool is_debug/*=false*/) const
for( const auto& it : ent.traits ) {
if( &it != &ent.traits.front() )
os << "+";
- it.print_pretty(os, true, is_debug);
+ os << it.hrbs;
+ it.path.print_pretty(os, true, is_debug);
}
os << "";
)
@@ -303,3 +314,21 @@ void TypeRef::print(::std::ostream& os, bool is_debug/*=false*/) const
return os;
}
+namespace AST {
+ ::std::ostream& operator<<(::std::ostream& os, const LifetimeRef& x) {
+ if( x.m_binding == LifetimeRef::BINDING_STATIC ) {
+ os << "'static";
+ }
+ else if( x.m_binding == LifetimeRef::BINDING_INFER ) {
+ os << "'_";
+ }
+ else {
+ os << "'" << x.m_name;
+ if( x.m_binding != LifetimeRef::BINDING_UNBOUND ) {
+ os << "/*" << x.m_binding << "*/";
+ }
+ }
+ return os;
+ }
+}
+