aboutsummaryrefslogtreecommitdiffstats
path: root/Types.cpp
diff options
context:
space:
mode:
authorChristian <c@ethdev.com>2015-02-11 00:53:43 +0800
committerChristian <c@ethdev.com>2015-02-12 18:33:10 +0800
commitadb434569c7f54a12dfbdc674b50a4a4baca59e4 (patch)
tree5ac29b6c5a670de2458004c03337f6334b63ef2c /Types.cpp
parent79aec95228f5c766daaa9d04a3800be99ded8015 (diff)
downloaddexon-solidity-adb434569c7f54a12dfbdc674b50a4a4baca59e4.tar.gz
dexon-solidity-adb434569c7f54a12dfbdc674b50a4a4baca59e4.tar.zst
dexon-solidity-adb434569c7f54a12dfbdc674b50a4a4baca59e4.zip
Dynamic copy to memory.
Diffstat (limited to 'Types.cpp')
-rw-r--r--Types.cpp31
1 files changed, 18 insertions, 13 deletions
diff --git a/Types.cpp b/Types.cpp
index 16674742..f43a3ffe 100644
--- a/Types.cpp
+++ b/Types.cpp
@@ -35,7 +35,7 @@ namespace dev
namespace solidity
{
-shared_ptr<Type const> Type::fromElementaryTypeName(Token::Value _typeToken)
+TypePointer Type::fromElementaryTypeName(Token::Value _typeToken)
{
solAssert(Token::isElementaryTypeName(_typeToken), "Elementary type name expected.");
@@ -64,7 +64,12 @@ shared_ptr<Type const> Type::fromElementaryTypeName(Token::Value _typeToken)
std::string(Token::toString(_typeToken)) + " to type."));
}
-shared_ptr<Type const> Type::fromUserDefinedTypeName(UserDefinedTypeName const& _typeName)
+TypePointer Type::fromElementaryTypeName(string const& _name)
+{
+ return fromElementaryTypeName(Token::fromIdentifierOrKeyword(_name));
+}
+
+TypePointer Type::fromUserDefinedTypeName(UserDefinedTypeName const& _typeName)
{
Declaration const* declaration = _typeName.getReferencedDeclaration();
if (StructDefinition const* structDef = dynamic_cast<StructDefinition const*>(declaration))
@@ -73,21 +78,21 @@ shared_ptr<Type const> Type::fromUserDefinedTypeName(UserDefinedTypeName const&
return make_shared<FunctionType>(*function);
else if (ContractDefinition const* contract = dynamic_cast<ContractDefinition const*>(declaration))
return make_shared<ContractType>(*contract);
- return shared_ptr<Type const>();
+ return TypePointer();
}
-shared_ptr<Type const> Type::fromMapping(Mapping const& _typeName)
+TypePointer Type::fromMapping(Mapping const& _typeName)
{
- shared_ptr<Type const> keyType = _typeName.getKeyType().toType();
+ TypePointer keyType = _typeName.getKeyType().toType();
if (!keyType)
BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Error resolving type name."));
- shared_ptr<Type const> valueType = _typeName.getValueType().toType();
+ TypePointer valueType = _typeName.getValueType().toType();
if (!valueType)
BOOST_THROW_EXCEPTION(_typeName.getValueType().createTypeError("Invalid type name"));
return make_shared<MappingType>(keyType, valueType);
}
-shared_ptr<Type const> Type::forLiteral(Literal const& _literal)
+TypePointer Type::forLiteral(Literal const& _literal)
{
switch (_literal.getToken())
{
@@ -561,8 +566,8 @@ MemberList const& ContractType::getMembers() const
if (!m_members)
{
// All address members and all interface functions
- map<string, shared_ptr<Type const>> members(IntegerType::AddressMemberList.begin(),
- IntegerType::AddressMemberList.end());
+ map<string, TypePointer> members(IntegerType::AddressMemberList.begin(),
+ IntegerType::AddressMemberList.end());
if (m_super)
{
for (ContractDefinition const* base: m_contract.getLinearizedBaseContracts())
@@ -617,14 +622,14 @@ bool StructType::operator==(Type const& _other) const
u256 StructType::getStorageSize() const
{
u256 size = 0;
- for (pair<string, shared_ptr<Type const>> const& member: getMembers())
+ for (pair<string, TypePointer> const& member: getMembers())
size += member.second->getStorageSize();
return max<u256>(1, size);
}
bool StructType::canLiveOutsideStorage() const
{
- for (pair<string, shared_ptr<Type const>> const& member: getMembers())
+ for (pair<string, TypePointer> const& member: getMembers())
if (!member.second->canLiveOutsideStorage())
return false;
return true;
@@ -640,7 +645,7 @@ MemberList const& StructType::getMembers() const
// We need to lazy-initialize it because of recursive references.
if (!m_members)
{
- map<string, shared_ptr<Type const>> members;
+ map<string, TypePointer> members;
for (ASTPointer<VariableDeclaration> const& variable: m_struct.getMembers())
members[variable->getName()] = variable->getType();
m_members.reset(new MemberList(members));
@@ -847,7 +852,7 @@ TypePointers FunctionType::parseElementaryTypeVector(strings const& _types)
TypePointers pointers;
pointers.reserve(_types.size());
for (string const& type: _types)
- pointers.push_back(Type::fromElementaryTypeName(Token::fromIdentifierOrKeyword(type)));
+ pointers.push_back(Type::fromElementaryTypeName(type));
return pointers;
}