aboutsummaryrefslogtreecommitdiffstats
path: root/Types.h
diff options
context:
space:
mode:
authorChristian <c@ethdev.com>2014-11-11 00:31:09 +0800
committerChristian <c@ethdev.com>2014-11-14 21:08:14 +0800
commit46dd62982084dfe5712292b88047d2a58e0a420e (patch)
treefda7b3871e7de54cbb4cdab8cf3add6ff6090f42 /Types.h
parentc4a65cf6888f6b15fa7740b6db5d9dae8f18b7ba (diff)
downloaddexon-solidity-46dd62982084dfe5712292b88047d2a58e0a420e.tar.gz
dexon-solidity-46dd62982084dfe5712292b88047d2a58e0a420e.tar.zst
dexon-solidity-46dd62982084dfe5712292b88047d2a58e0a420e.zip
Mapping types.
Diffstat (limited to 'Types.h')
-rw-r--r--Types.h15
1 files changed, 13 insertions, 2 deletions
diff --git a/Types.h b/Types.h
index 607ee3a6..b9bb74db 100644
--- a/Types.h
+++ b/Types.h
@@ -35,7 +35,7 @@ namespace dev
namespace solidity
{
-// @todo realMxN, string<N>, mapping
+// @todo realMxN, string<N>
/**
* Abstract base class that forms the root of the type hierarchy.
@@ -78,6 +78,8 @@ public:
/// @returns number of bytes required to hold this value in storage.
/// For dynamically "allocated" types, it returns the size of the statically allocated head,
virtual u256 getStorageSize() const { return 1; }
+ /// Returns false if the type cannot live outside the storage, i.e. if it includes some mapping.
+ virtual bool canLiveOutsideStorage() const { return true; }
virtual std::string toString() const = 0;
virtual u256 literalValue(Literal const&) const
@@ -182,6 +184,8 @@ public:
virtual bool operator==(Type const& _other) const override;
virtual u256 getStorageSize() const;
+ //@todo it can, if its members can
+ virtual bool canLiveOutsideStorage() const { return false; }
virtual std::string toString() const override { return "struct{...}"; }
private:
@@ -202,6 +206,7 @@ public:
virtual bool operator==(Type const& _other) const override;
virtual std::string toString() const override { return "function(...)returns(...)"; }
virtual u256 getStorageSize() const { BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Storage size of non-storable function type requested.")); }
+ virtual bool canLiveOutsideStorage() const { return false; }
private:
FunctionDefinition const& m_function;
@@ -214,11 +219,15 @@ class MappingType: public Type
{
public:
virtual Category getCategory() const override { return Category::MAPPING; }
- MappingType() {}
+ MappingType(std::shared_ptr<Type const> _keyType, std::shared_ptr<Type const> _valueType):
+ m_keyType(_keyType), m_valueType(_valueType) {}
virtual bool operator==(Type const& _other) const override;
virtual std::string toString() const override { return "mapping(...=>...)"; }
+ virtual bool canLiveOutsideStorage() const { return false; }
+ std::shared_ptr<Type const> getKeyType() const { return m_keyType; }
+ std::shared_ptr<Type const> getValueType() const { return m_valueType; }
private:
std::shared_ptr<Type const> m_keyType;
std::shared_ptr<Type const> m_valueType;
@@ -236,6 +245,7 @@ public:
virtual std::string toString() const override { return "void"; }
virtual u256 getStorageSize() const { BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Storage size of non-storable void type requested.")); }
+ virtual bool canLiveOutsideStorage() const { return false; }
};
/**
@@ -252,6 +262,7 @@ public:
virtual bool operator==(Type const& _other) const override;
virtual u256 getStorageSize() const { BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Storage size of non-storable type type requested.")); }
+ virtual bool canLiveOutsideStorage() const { return false; }
virtual std::string toString() const override { return "type(" + m_actualType->toString() + ")"; }
private: