aboutsummaryrefslogtreecommitdiffstats
path: root/Types.h
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-05-28 22:20:50 +0800
committerchriseth <c@ethdev.com>2015-05-28 22:20:50 +0800
commit6949ce97e43a7198180188209fe4a09ca9744f50 (patch)
treee714ef3967a3e87769a3b846d06f7a5b25fcbb25 /Types.h
parentf7e3568c6202b940394097f147e0c4e6ffe7fe9c (diff)
downloaddexon-solidity-6949ce97e43a7198180188209fe4a09ca9744f50.tar.gz
dexon-solidity-6949ce97e43a7198180188209fe4a09ca9744f50.tar.zst
dexon-solidity-6949ce97e43a7198180188209fe4a09ca9744f50.zip
Re-introduce string type.
Diffstat (limited to 'Types.h')
-rw-r--r--Types.h22
1 files changed, 16 insertions, 6 deletions
diff --git a/Types.h b/Types.h
index a69df964..65f6e447 100644
--- a/Types.h
+++ b/Types.h
@@ -367,10 +367,10 @@ public:
virtual Category getCategory() const override { return Category::Array; }
- /// Constructor for a byte array ("bytes")
- explicit ArrayType(Location _location):
+ /// Constructor for a byte array ("bytes") and string.
+ explicit ArrayType(Location _location, bool _isString = false):
m_location(_location),
- m_isByteArray(true),
+ m_arrayKind(_isString ? ArrayKind::String : ArrayKind::Bytes),
m_baseType(std::make_shared<FixedBytesType>(1))
{}
/// Constructor for a dynamically sized array type ("type[]")
@@ -394,11 +394,17 @@ public:
virtual u256 getStorageSize() const override;
virtual unsigned getSizeOnStack() const override;
virtual std::string toString() const override;
- virtual MemberList const& getMembers() const override { return s_arrayTypeMemberList; }
+ virtual MemberList const& getMembers() const override
+ {
+ return isString() ? EmptyMemberList : s_arrayTypeMemberList;
+ }
virtual TypePointer externalType() const override;
Location getLocation() const { return m_location; }
- bool isByteArray() const { return m_isByteArray; }
+ /// @returns true if this is a byte array or a string
+ bool isByteArray() const { return m_arrayKind != ArrayKind::Ordinary; }
+ /// @returns true if this is a string
+ bool isString() const { return m_arrayKind == ArrayKind::String; }
TypePointer const& getBaseType() const { solAssert(!!m_baseType, ""); return m_baseType;}
u256 const& getLength() const { return m_length; }
@@ -407,8 +413,12 @@ public:
std::shared_ptr<ArrayType> copyForLocation(Location _location) const;
private:
+ /// String is interpreted as a subtype of Bytes.
+ enum class ArrayKind { Ordinary, Bytes, String };
+
Location m_location;
- bool m_isByteArray = false; ///< Byte arrays ("bytes") have different semantics from ordinary arrays.
+ ///< Byte arrays ("bytes") and strings have different semantics from ordinary arrays.
+ ArrayKind m_arrayKind = ArrayKind::Ordinary;
TypePointer m_baseType;
bool m_hasDynamicLength = true;
u256 m_length;