diff options
author | Christian <c@ethdev.com> | 2014-12-10 01:46:18 +0800 |
---|---|---|
committer | Christian <c@ethdev.com> | 2014-12-10 23:30:20 +0800 |
commit | 130ff85e85de3ea8a9666f84843428a3a09b1aab (patch) | |
tree | afff06eddf204678b099dc9fae187a697e8debcc /Types.h | |
parent | e8b7d266641175039d40c344449409a60527156e (diff) | |
download | dexon-solidity-130ff85e85de3ea8a9666f84843428a3a09b1aab.tar.gz dexon-solidity-130ff85e85de3ea8a9666f84843428a3a09b1aab.tar.zst dexon-solidity-130ff85e85de3ea8a9666f84843428a3a09b1aab.zip |
String types.
Diffstat (limited to 'Types.h')
-rw-r--r-- | Types.h | 31 |
1 files changed, 30 insertions, 1 deletions
@@ -36,7 +36,7 @@ namespace dev namespace solidity { -// @todo realMxN, string<N> +// @todo realMxN, dynamic strings, text, arrays class Type; // forward using TypePointer = std::shared_ptr<Type const>; @@ -179,6 +179,35 @@ private: }; /** + * String type with fixed length, up to 32 bytes. + */ +class StaticStringType: public Type +{ +public: + virtual Category getCategory() const override { return Category::STRING; } + + /// @returns the smallest string type for the given literal or an empty pointer + /// if no type fits. + static std::shared_ptr<StaticStringType> smallestTypeForLiteral(std::string const& _literal); + + StaticStringType(int _bytes); + + virtual bool isImplicitlyConvertibleTo(Type const& _convertTo) const override; + virtual bool operator==(Type const& _other) const override; + + virtual unsigned getCalldataEncodedSize() const override { return m_bytes; } + virtual bool isValueType() const override { return true; } + + virtual std::string toString() const override { return "string" + dev::toString(m_bytes); } + virtual u256 literalValue(Literal const& _literal) const override; + + int getNumBytes() const { return m_bytes; } + +private: + int m_bytes; +}; + +/** * The boolean type. */ class BoolType: public Type |