diff options
author | Lefteris Karapetsas <lefteris@refu.co> | 2015-01-23 00:40:22 +0800 |
---|---|---|
committer | Lefteris Karapetsas <lefteris@refu.co> | 2015-01-29 04:46:16 +0800 |
commit | 3cc04923015cc3f40ad285fba5ed71464bd9ff2a (patch) | |
tree | 5d32036c4a1aa893348af4e907f8b1453bd4b3e3 /Types.cpp | |
parent | 9759eec2da1d75c70b8cd3eff3fe1bffade6854d (diff) | |
download | dexon-solidity-3cc04923015cc3f40ad285fba5ed71464bd9ff2a.tar.gz dexon-solidity-3cc04923015cc3f40ad285fba5ed71464bd9ff2a.tar.zst dexon-solidity-3cc04923015cc3f40ad285fba5ed71464bd9ff2a.zip |
Work in progress for state variable accessors
- Changed the code so that a generic declaration with the combination of
a function type can be used wherer a function definition was used
before
- Since using an std::pair everywhere is really tiring with this commit
I am in the process of abstracting it into a function
Diffstat (limited to 'Types.cpp')
-rw-r--r-- | Types.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
@@ -489,7 +489,7 @@ MemberList const& ContractType::getMembers() const map<string, shared_ptr<Type const>> members(IntegerType::AddressMemberList.begin(), IntegerType::AddressMemberList.end()); for (auto const& it: m_contract.getInterfaceFunctions()) - members[it.second->getName()] = make_shared<FunctionType>(*it.second, false); + members[it.second.second->getName()] = make_shared<FunctionType>(*it.second.second, false); m_members.reset(new MemberList(members)); } return *m_members; @@ -512,7 +512,7 @@ u256 ContractType::getFunctionIdentifier(string const& _functionName) const { auto interfaceFunctions = m_contract.getInterfaceFunctions(); for (auto it = interfaceFunctions.cbegin(); it != interfaceFunctions.cend(); ++it) - if (it->second->getName() == _functionName) + if (it->second.second->getName() == _functionName) return FixedHash<4>::Arith(it->first); return Invalid256; @@ -593,6 +593,19 @@ FunctionType::FunctionType(FunctionDefinition const& _function, bool _isInternal swap(retParams, m_returnParameterTypes); } +FunctionType::FunctionType(VariableDeclaration const& _varDecl): + m_location(Location::INTERNAL) +{ + TypePointers params; + TypePointers retParams; + // for now, no input parameters LTODO: change for some things like mapping + params.reserve(0); + retParams.reserve(1); + retParams.push_back(_varDecl.getType()); + swap(params, m_parameterTypes); + swap(retParams, m_returnParameterTypes); +} + bool FunctionType::operator==(Type const& _other) const { if (_other.getCategory() != getCategory()) @@ -672,9 +685,9 @@ MemberList const& FunctionType::getMembers() const } } -string FunctionType::getCanonicalSignature() const +string FunctionType::getCanonicalSignature(std::string const& _name) const { - string ret = "("; + string ret = _name + "("; for (auto it = m_parameterTypes.cbegin(); it != m_parameterTypes.cend(); ++it) ret += (*it)->toString() + (it + 1 == m_parameterTypes.cend() ? "" : ","); |