diff options
author | Christian <c@ethdev.com> | 2014-11-24 20:23:58 +0800 |
---|---|---|
committer | Christian <c@ethdev.com> | 2014-11-24 20:24:03 +0800 |
commit | 6e6b85b58a478a7e2bc0f8bee976df97f9861b91 (patch) | |
tree | 19902870438bb0cdb76e161bd5f26319676c4600 /Types.cpp | |
parent | 5d75263ff15aadfcacd35334cbab396cce65d260 (diff) | |
download | dexon-solidity-6e6b85b58a478a7e2bc0f8bee976df97f9861b91.tar.gz dexon-solidity-6e6b85b58a478a7e2bc0f8bee976df97f9861b91.tar.zst dexon-solidity-6e6b85b58a478a7e2bc0f8bee976df97f9861b91.zip |
Access to blockchain data.
Diffstat (limited to 'Types.cpp')
-rw-r--r-- | Types.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
@@ -333,5 +333,55 @@ bool TypeType::operator==(Type const& _other) const return *getActualType() == *other.getActualType(); } +MagicType::MagicType(MagicType::Kind _kind): + m_kind(_kind) +{ + switch (m_kind) + { + case Kind::BLOCK: + m_members = MemberList({{"coinbase", make_shared<IntegerType const>(0, IntegerType::Modifier::ADDRESS)}, + {"timestamp", make_shared<IntegerType const>(256)}, + {"prevhash", make_shared<IntegerType const>(256, IntegerType::Modifier::HASH)}, + {"difficulty", make_shared<IntegerType const>(256)}, + {"number", make_shared<IntegerType const>(256)}, + {"gaslimit", make_shared<IntegerType const>(256)}}); + break; + case Kind::MSG: + m_members = MemberList({{"sender", make_shared<IntegerType const>(0, IntegerType::Modifier::ADDRESS)}, + {"value", make_shared<IntegerType const>(256)}}); + break; + case Kind::TX: + m_members = MemberList({{"origin", make_shared<IntegerType const>(0, IntegerType::Modifier::ADDRESS)}, + {"gas", make_shared<IntegerType const>(256)}, + {"gasprice", make_shared<IntegerType const>(256)}}); + break; + default: + BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Unknown kind of magic.")); + } +} + +bool MagicType::operator==(Type const& _other) const +{ + if (_other.getCategory() != getCategory()) + return false; + MagicType const& other = dynamic_cast<MagicType const&>(_other); + return other.m_kind == m_kind; +} + +string MagicType::toString() const +{ + switch (m_kind) + { + case Kind::BLOCK: + return "block"; + case Kind::MSG: + return "msg"; + case Kind::TX: + return "tx"; + default: + BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Unknown kind of magic.")); + } +} + } } |