aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/Types.cpp
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-09-11 01:40:07 +0800
committerchriseth <c@ethdev.com>2015-09-11 21:21:37 +0800
commit976c380b615f71c9e5b59c9b6bcadefbd79c086f (patch)
tree6ce25599b74529619f4421a9bd3db76eecb80b80 /libsolidity/Types.cpp
parenta9edc7b1a601747f96e47fe60a5fc10df489696f (diff)
downloaddexon-solidity-976c380b615f71c9e5b59c9b6bcadefbd79c086f.tar.gz
dexon-solidity-976c380b615f71c9e5b59c9b6bcadefbd79c086f.tar.zst
dexon-solidity-976c380b615f71c9e5b59c9b6bcadefbd79c086f.zip
Possibility to call library functions.
Diffstat (limited to 'libsolidity/Types.cpp')
-rw-r--r--libsolidity/Types.cpp38
1 files changed, 28 insertions, 10 deletions
diff --git a/libsolidity/Types.cpp b/libsolidity/Types.cpp
index d1c59ba5..5bc7cd43 100644
--- a/libsolidity/Types.cpp
+++ b/libsolidity/Types.cpp
@@ -971,7 +971,7 @@ MemberList const& ContractType::members() const
for (auto const& it: m_contract.interfaceFunctions())
members.push_back(MemberList::Member(
it.second->declaration().name(),
- it.second->asMemberFunction(),
+ it.second->asMemberFunction(false),
&it.second->declaration()
));
m_members.reset(new MemberList(members));
@@ -1538,7 +1538,7 @@ TypePointer FunctionType::copyAndSetGasOrValue(bool _setGas, bool _setValue) con
);
}
-FunctionTypePointer FunctionType::asMemberFunction() const
+FunctionTypePointer FunctionType::asMemberFunction(bool _inLibrary) const
{
TypePointers parameterTypes;
for (auto const& t: m_parameterTypes)
@@ -1563,7 +1563,7 @@ FunctionTypePointer FunctionType::asMemberFunction() const
returnParameterTypes,
m_parameterNames,
returnParameterNames,
- m_location,
+ _inLibrary ? Location::CallCode : m_location,
m_arbitraryParameters,
m_declaration,
m_gasSet,
@@ -1633,21 +1633,39 @@ u256 TypeType::storageSize() const
<< errinfo_comment("Storage size of non-storable type type requested."));
}
+unsigned TypeType::sizeOnStack() const
+{
+ if (auto contractType = dynamic_cast<ContractType const*>(m_actualType.get()))
+ if (contractType->contractDefinition().isLibrary())
+ return 1;
+ return 0;
+}
+
MemberList const& TypeType::members() const
{
// We need to lazy-initialize it because of recursive references.
if (!m_members)
{
MemberList::MemberMap members;
- if (m_actualType->category() == Category::Contract && m_currentContract != nullptr)
+ if (m_actualType->category() == Category::Contract)
{
ContractDefinition const& contract = dynamic_cast<ContractType const&>(*m_actualType).contractDefinition();
- vector<ContractDefinition const*> currentBases = m_currentContract->linearizedBaseContracts();
- if (find(currentBases.begin(), currentBases.end(), &contract) != currentBases.end())
- // We are accessing the type of a base contract, so add all public and protected
- // members. Note that this does not add inherited functions on purpose.
- for (Declaration const* decl: contract.inheritableMembers())
- members.push_back(MemberList::Member(decl->name(), decl->type(), decl));
+ if (contract.isLibrary())
+ for (auto const& it: contract.interfaceFunctions())
+ members.push_back(MemberList::Member(
+ it.second->declaration().name(),
+ it.second->asMemberFunction(true), // use callcode
+ &it.second->declaration()
+ ));
+ else if (m_currentContract != nullptr)
+ {
+ vector<ContractDefinition const*> currentBases = m_currentContract->linearizedBaseContracts();
+ if (find(currentBases.begin(), currentBases.end(), &contract) != currentBases.end())
+ // We are accessing the type of a base contract, so add all public and protected
+ // members. Note that this does not add inherited functions on purpose.
+ for (Declaration const* decl: contract.inheritableMembers())
+ members.push_back(MemberList::Member(decl->name(), decl->type(), decl));
+ }
}
else if (m_actualType->category() == Category::Enum)
{