diff options
author | John Hodge <tpg@ucc.asn.au> | 2018-06-03 14:57:05 +0800 |
---|---|---|
committer | John Hodge <tpg@ucc.asn.au> | 2018-06-03 14:57:05 +0800 |
commit | bf8f8b4b4a9fe273451be59f68acafbe61968b83 (patch) | |
tree | 82993550cb3c88de0edbd55d79e4ea8e8cefffac /src/ast/types.cpp | |
parent | 39b3cf53798683e496804f8322da2254b10850f4 (diff) | |
parent | a7fb27789a2b34543851d207120e2c0001ee9c27 (diff) | |
download | mrust-bf8f8b4b4a9fe273451be59f68acafbe61968b83.tar.gz |
Merge branch 'master' of https://github.com/thepowersgang/mrustc
Diffstat (limited to 'src/ast/types.cpp')
-rw-r--r-- | src/ast/types.cpp | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/src/ast/types.cpp b/src/ast/types.cpp index af99f3d7..98bc6ee1 100644 --- a/src/ast/types.cpp +++ b/src/ast/types.cpp @@ -128,7 +128,7 @@ TypeRef TypeRef::clone() const _COPY(Primitive) _COPY(Function) _CLONE(Tuple, { H::clone_ty_vec(old.inner_types) }) - _CLONE(Borrow, { old.is_mut, box$(old.inner->clone()) }) + _CLONE(Borrow, { AST::LifetimeRef(old.lifetime), old.is_mut, box$(old.inner->clone()) }) _CLONE(Pointer, { old.is_mut, box$(old.inner->clone()) }) _CLONE(Array, { box$(old.inner->clone()), old.size }) _COPY(Generic) @@ -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; + } +} + |