diff options
author | Lefteris Karapetsas <lefteris@refu.co> | 2015-01-29 23:39:30 +0800 |
---|---|---|
committer | Lefteris Karapetsas <lefteris@refu.co> | 2015-01-30 00:11:13 +0800 |
commit | 005100c4867f133e86a2675be0dd9370fed3e191 (patch) | |
tree | d41b83ef3066a24b94a152b9e7866db5f35eff2a /AST.cpp | |
parent | 77384af827d7d941620552c4f5f740c3b7c576ef (diff) | |
download | dexon-solidity-005100c4867f133e86a2675be0dd9370fed3e191.tar.gz dexon-solidity-005100c4867f133e86a2675be0dd9370fed3e191.tar.zst dexon-solidity-005100c4867f133e86a2675be0dd9370fed3e191.zip |
Contract Interface Functions now return FunctionType
- Enchanced Function Type by declaration so that it can provide all the
required information at each place interface functions are consumed
- Changed all places where interface functions was used.
- Simplified Mix's FunctionDefinition code
Diffstat (limited to 'AST.cpp')
-rw-r--r-- | AST.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
@@ -66,24 +66,25 @@ void ContractDefinition::checkTypeRequirements() // check for hash collisions in function signatures set<FixedHash<4>> hashes; - for (auto const& hashAndFunction: getInterfaceFunctionList()) + for (auto const& it: getInterfaceFunctionList()) { - FixedHash<4> const& hash = std::get<0>(hashAndFunction); + FixedHash<4> const& hash = it.first; if (hashes.count(hash)) BOOST_THROW_EXCEPTION(createTypeError( std::string("Function signature hash collision for ") + - std::get<1>(hashAndFunction)->getCanonicalSignature(std::get<2>(hashAndFunction)->getName()))); + it.second->getCanonicalSignature())); hashes.insert(hash); } } -map<FixedHash<4>, FunctionDescription> ContractDefinition::getInterfaceFunctions() const +map<FixedHash<4>, std::shared_ptr<FunctionType const>> ContractDefinition::getInterfaceFunctions() const { auto exportedFunctionList = getInterfaceFunctionList(); - map<FixedHash<4>, FunctionDescription> exportedFunctions; + map<FixedHash<4>, std::shared_ptr<FunctionType const>> exportedFunctions; for (auto const& it: exportedFunctionList) - exportedFunctions.insert(make_pair(std::get<0>(it), FunctionDescription(std::get<1>(it), std::get<2>(it)))); + // exportedFunctions.insert(make_pair(std::get<0>(it), FunctionDescription(std::get<1>(it), std::get<2>(it)))); + exportedFunctions.insert(it); solAssert(exportedFunctionList.size() == exportedFunctions.size(), "Hash collision at Function Definition Hash calculation"); @@ -138,12 +139,12 @@ void ContractDefinition::checkIllegalOverrides() const } } -vector<tuple<FixedHash<4>, std::shared_ptr<FunctionType const>, Declaration const*>> const& ContractDefinition::getInterfaceFunctionList() const +vector<pair<FixedHash<4>, shared_ptr<FunctionType const>>> const& ContractDefinition::getInterfaceFunctionList() const { if (!m_interfaceFunctionList) { set<string> functionsSeen; - m_interfaceFunctionList.reset(new vector<tuple<FixedHash<4>, std::shared_ptr<FunctionType const>, Declaration const*>>()); + m_interfaceFunctionList.reset(new vector<pair<FixedHash<4>, shared_ptr<FunctionType const>>>()); for (ContractDefinition const* contract: getLinearizedBaseContracts()) { for (ASTPointer<FunctionDefinition> const& f: contract->getDefinedFunctions()) @@ -151,7 +152,7 @@ vector<tuple<FixedHash<4>, std::shared_ptr<FunctionType const>, Declaration cons { functionsSeen.insert(f->getName()); FixedHash<4> hash(dev::sha3(f->getCanonicalSignature())); - m_interfaceFunctionList->push_back(make_tuple(hash, make_shared<FunctionType>(*f, false), f.get())); + m_interfaceFunctionList->push_back(make_pair(hash, make_shared<FunctionType>(*f, false))); } for (ASTPointer<VariableDeclaration> const& v: contract->getStateVariables()) @@ -160,7 +161,7 @@ vector<tuple<FixedHash<4>, std::shared_ptr<FunctionType const>, Declaration cons FunctionType ftype(*v); functionsSeen.insert(v->getName()); FixedHash<4> hash(dev::sha3(ftype.getCanonicalSignature(v->getName()))); - m_interfaceFunctionList->push_back(make_tuple(hash, make_shared<FunctionType>(*v), v.get())); + m_interfaceFunctionList->push_back(make_pair(hash, make_shared<FunctionType>(*v))); } } } |