diff options
author | Lefteris Karapetsas <lefteris@refu.co> | 2015-02-11 23:37:46 +0800 |
---|---|---|
committer | Lefteris Karapetsas <lefteris@refu.co> | 2015-02-14 06:16:14 +0800 |
commit | c3a9ae0b0657861c8cc27f60358b0bfe99ed05ae (patch) | |
tree | 695fbc92111b1853fdee6500c92e55555666759f /Types.cpp | |
parent | 86e1d671cc4ed9b89576c80e16e58a8019115068 (diff) | |
download | dexon-solidity-c3a9ae0b0657861c8cc27f60358b0bfe99ed05ae.tar.gz dexon-solidity-c3a9ae0b0657861c8cc27f60358b0bfe99ed05ae.tar.zst dexon-solidity-c3a9ae0b0657861c8cc27f60358b0bfe99ed05ae.zip |
Introducing EnumType and some Parser tests
Diffstat (limited to 'Types.cpp')
-rw-r--r-- | Types.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
@@ -662,6 +662,37 @@ u256 StructType::getStorageOffsetOfMember(string const& _name) const BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Storage offset of non-existing member requested.")); } +TypePointer EnumType::unaryOperatorResult(Token::Value _operator) const +{ + return _operator == Token::Delete ? make_shared<VoidType>() : TypePointer(); +} + +bool EnumType::operator==(Type const& _other) const +{ + if (_other.getCategory() != getCategory()) + return false; + EnumType const& other = dynamic_cast<EnumType const&>(_other); + return other.m_enum == m_enum; +} + +string EnumType::toString() const +{ + return string("enum ") + m_enum.getName(); +} + +MemberList const& EnumType::getMembers() const +{ + // We need to lazy-initialize it because of recursive references. + if (!m_members) + { + map<string, shared_ptr<Type const>> members; + for (ASTPointer<EnumDeclaration> const& enumValue: m_enum.getMembers()) + members.insert(make_pair(enumValue->getName(), make_shared<EnumType>(m_enum))); + m_members.reset(new MemberList(members)); + } + return *m_members; +} + FunctionType::FunctionType(FunctionDefinition const& _function, bool _isInternal): m_location(_isInternal ? Location::Internal : Location::External), m_isConstant(_function.isDeclaredConst()), |