diff options
author | John Hodge <tpg@mutabah.net> | 2016-03-10 11:13:10 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-03-10 11:13:10 +0800 |
commit | b0e44483f1f598d6e3aa5ca8b325560a843f162f (patch) | |
tree | 3371073789c717ce14f3c556f236a9d8aa7f692f /src/types.cpp | |
parent | ce771e31b4cd157a87e7ec6531d625a895228ebf (diff) | |
download | mrust-b0e44483f1f598d6e3aa5ca8b325560a843f162f.tar.gz |
AST - Clean up MetaItems/MetaItem
Diffstat (limited to 'src/types.cpp')
-rw-r--r-- | src/types.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/types.cpp b/src/types.cpp index 33bf38f8..b056bf94 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -95,6 +95,30 @@ Ordering Type_Function::ord(const Type_Function& x) const return (*m_rettype).ord( *x.m_rettype ); } +TypeRef::TypeRef(const TypeRef& other) +{ + switch( other.m_data.tag() ) + { + #define _COPY(VAR) case TypeData::TAG_##VAR: m_data = TypeData::make_##VAR(other.m_data.as_##VAR()); break; + #define _CLONE(VAR, code...) case TypeData::TAG_##VAR: { auto& old = other.m_data.as_##VAR(); m_data = TypeData::make_##VAR(code); } break; + _COPY(None) + _COPY(Any) + case TypeData::TAG_Macro: throw ::std::runtime_error("Copying an unexpanded type macro"); + _COPY(Unit) + _COPY(Primitive) + _COPY(Function) + _COPY(Tuple) + _CLONE(Borrow, { old.is_mut, box$(TypeRef(*old.inner)) }) + _CLONE(Pointer, { old.is_mut, box$(TypeRef(*old.inner)) }) + _CLONE(Array, { box$(TypeRef(*old.inner)), old.size }) + _COPY(Generic) + _COPY(Path) + _COPY(TraitObject) + #undef _COPY + #undef _CLONE + } +} + /// Replace this type reference with a dereferenced version bool TypeRef::deref(bool is_implicit) { |