aboutsummaryrefslogtreecommitdiffstats
path: root/Types.cpp
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-07-01 03:08:34 +0800
committerchriseth <c@ethdev.com>2015-07-03 23:25:30 +0800
commite2d6e34f9c37488179ba5e3e9ae5dbe106bd57f0 (patch)
treeccb6bfd31cbd2d2a25e6866ed7a0ed86ce1eaf22 /Types.cpp
parent6059d2075075885e60e1ee63f37985ccbddab7d9 (diff)
downloaddexon-solidity-e2d6e34f9c37488179ba5e3e9ae5dbe106bd57f0.tar.gz
dexon-solidity-e2d6e34f9c37488179ba5e3e9ae5dbe106bd57f0.tar.zst
dexon-solidity-e2d6e34f9c37488179ba5e3e9ae5dbe106bd57f0.zip
Struct constructors.
Diffstat (limited to 'Types.cpp')
-rw-r--r--Types.cpp30
1 files changed, 22 insertions, 8 deletions
diff --git a/Types.cpp b/Types.cpp
index ef70f0e0..96cf3f7e 100644
--- a/Types.cpp
+++ b/Types.cpp
@@ -30,11 +30,8 @@
#include <libsolidity/AST.h>
using namespace std;
-
-namespace dev
-{
-namespace solidity
-{
+using namespace dev;
+using namespace dev::solidity;
void StorageOffsets::computeOffsets(TypePointers const& _types)
{
@@ -1067,6 +1064,26 @@ TypePointer StructType::copyForLocation(DataLocation _location, bool _isPointer)
return copy;
}
+FunctionTypePointer StructType::constructorType() const
+{
+ TypePointers paramTypes;
+ strings paramNames;
+ for (auto const& member: getMembers())
+ {
+ if (!member.type->canLiveOutsideStorage())
+ continue;
+ paramNames.push_back(member.name);
+ paramTypes.push_back(copyForLocationIfReference(DataLocation::Memory, member.type));
+ }
+ return make_shared<FunctionType>(
+ paramTypes,
+ TypePointers{copyForLocation(DataLocation::Memory, false)},
+ paramNames,
+ strings(),
+ FunctionType::Location::Internal
+ );
+}
+
pair<u256, unsigned> const& StructType::getStorageOffsetsOfMember(string const& _name) const
{
auto const* offsets = getMembers().getMemberStorageOffset(_name);
@@ -1695,6 +1712,3 @@ string MagicType::toString(bool) const
BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Unknown kind of magic."));
}
}
-
-}
-}