diff options
author | Lefteris Karapetsas <lefteris@refu.co> | 2015-10-13 22:55:59 +0800 |
---|---|---|
committer | Lefteris Karapetsas <lefteris@refu.co> | 2015-10-15 16:52:30 +0800 |
commit | a521843f6b0bf019a19d9a377f4bbbc473083151 (patch) | |
tree | b8d2d294cccefceadc0c8582adbfcdee72b13ebc /libsolidity/Types.cpp | |
parent | 3287cd464fc6b73ba5da2a94030ab202370f647a (diff) | |
download | dexon-solidity-a521843f6b0bf019a19d9a377f4bbbc473083151.tar.gz dexon-solidity-a521843f6b0bf019a19d9a377f4bbbc473083151.tar.zst dexon-solidity-a521843f6b0bf019a19d9a377f4bbbc473083151.zip |
Implement Dynamic array push and fix test
Still a work in progress. There is a disturbance in the stack at the
moment and that's why there are some cout statements left for debugging.
Diffstat (limited to 'libsolidity/Types.cpp')
-rw-r--r-- | libsolidity/Types.cpp | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/libsolidity/Types.cpp b/libsolidity/Types.cpp index c800e288..371a3456 100644 --- a/libsolidity/Types.cpp +++ b/libsolidity/Types.cpp @@ -858,6 +858,28 @@ string ArrayType::canonicalName(bool _addDataLocation) const return ret; } +MemberList const& ArrayType::members() const +{ + if (!m_members) + { + MemberList::MemberMap members; + if (!isString()) + { + members.push_back({"length", make_shared<IntegerType>(256)}); + if (isDynamicallySized() && location() == DataLocation::Storage) + members.push_back({"push", make_shared<FunctionType>( + TypePointers{baseType()}, + TypePointers{make_shared<IntegerType>(256)}, + strings{string()}, + strings{string()}, + isByteArray() ? FunctionType::Location::ByteArrayPush : FunctionType::Location::ArrayPush + )}); + } + m_members.reset(new MemberList(members)); + } + return *m_members; +} + TypePointer ArrayType::encodingType() const { if (location() == DataLocation::Storage) @@ -913,8 +935,6 @@ TypePointer ArrayType::copyForLocation(DataLocation _location, bool _isPointer) return copy; } -const MemberList ArrayType::s_arrayTypeMemberList({{"length", make_shared<IntegerType>(256)}}); - bool ContractType::operator==(Type const& _other) const { if (_other.category() != category()) @@ -1422,6 +1442,8 @@ unsigned FunctionType::sizeOnStack() const size = 1; else if (location == Location::Internal) size = 1; + else if (location == Location::ArrayPush || location == Location::ByteArrayPush) + size = 1; if (m_gasSet) size++; if (m_valueSet) |