diff options
author | Liana Husikyan <liana@ethdev.com> | 2015-03-24 01:08:45 +0800 |
---|---|---|
committer | Liana Husikyan <liana@ethdev.com> | 2015-03-25 20:59:46 +0800 |
commit | 701b34fbeb1bd08445aad55f82672d35343f5a44 (patch) | |
tree | c279a47bba724163fc3f5d78e5a8f1742be4e45e | |
parent | e3ea90e997caf1d316252ad16ecb14c4d6163da5 (diff) | |
download | dexon-solidity-701b34fbeb1bd08445aad55f82672d35343f5a44.tar dexon-solidity-701b34fbeb1bd08445aad55f82672d35343f5a44.tar.gz dexon-solidity-701b34fbeb1bd08445aad55f82672d35343f5a44.tar.bz2 dexon-solidity-701b34fbeb1bd08445aad55f82672d35343f5a44.tar.lz dexon-solidity-701b34fbeb1bd08445aad55f82672d35343f5a44.tar.xz dexon-solidity-701b34fbeb1bd08445aad55f82672d35343f5a44.tar.zst dexon-solidity-701b34fbeb1bd08445aad55f82672d35343f5a44.zip |
renamed getCanonicalSignature
added externalTypes instead of types for interface functions
added simple test
todo
testing
-rw-r--r-- | AST.cpp | 11 | ||||
-rw-r--r-- | AST.h | 2 | ||||
-rw-r--r-- | ExpressionCompiler.cpp | 2 | ||||
-rw-r--r-- | InterfaceHandler.cpp | 4 | ||||
-rw-r--r-- | Types.cpp | 8 | ||||
-rw-r--r-- | Types.h | 4 |
6 files changed, 17 insertions, 14 deletions
@@ -88,7 +88,7 @@ void ContractDefinition::checkTypeRequirements() if (hashes.count(hash)) BOOST_THROW_EXCEPTION(createTypeError( std::string("Function signature hash collision for ") + - it.second->getCanonicalSignature())); + it.second->externalTypes())); hashes.insert(hash); } } @@ -192,7 +192,7 @@ vector<pair<FixedHash<4>, FunctionTypePointer>> const& ContractDefinition::getIn if (functionsSeen.count(f->getName()) == 0 && f->isPartOfExternalInterface()) { functionsSeen.insert(f->getName()); - FixedHash<4> hash(dev::sha3(f->getCanonicalSignature())); + FixedHash<4> hash(dev::sha3(f->externalTypes())); m_interfaceFunctionList->push_back(make_pair(hash, make_shared<FunctionType>(*f, false))); } @@ -200,8 +200,9 @@ vector<pair<FixedHash<4>, FunctionTypePointer>> const& ContractDefinition::getIn if (functionsSeen.count(v->getName()) == 0 && v->isPartOfExternalInterface()) { FunctionType ftype(*v); + solAssert(v->getType().get(), ""); functionsSeen.insert(v->getName()); - FixedHash<4> hash(dev::sha3(ftype.getCanonicalSignature(v->getName()))); + FixedHash<4> hash(dev::sha3(ftype.externalTypes(v->getName()))); m_interfaceFunctionList->push_back(make_pair(hash, make_shared<FunctionType>(*v))); } } @@ -319,9 +320,9 @@ void FunctionDefinition::checkTypeRequirements() m_body->checkTypeRequirements(); } -string FunctionDefinition::getCanonicalSignature() const +string FunctionDefinition::externalTypes() const { - return FunctionType(*this).getCanonicalSignature(getName()); + return FunctionType(*this).externalTypes(getName()); } bool VariableDeclaration::isLValue() const @@ -424,7 +424,7 @@ public: /// @returns the canonical signature of the function /// That consists of the name of the function followed by the types of the /// arguments separated by commas all enclosed in parentheses without any spaces. - std::string getCanonicalSignature() const; + std::string externalTypes() const; private: bool m_isConstructor; diff --git a/ExpressionCompiler.cpp b/ExpressionCompiler.cpp index da762147..288af398 100644 --- a/ExpressionCompiler.cpp +++ b/ExpressionCompiler.cpp @@ -544,7 +544,7 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall) } if (!event.isAnonymous()) { - m_context << u256(h256::Arith(dev::sha3(function.getCanonicalSignature(event.getName())))); + m_context << u256(h256::Arith(dev::sha3(function.externalTypes(event.getName())))); ++numIndexed; } solAssert(numIndexed <= 4, "Too many indexed arguments."); diff --git a/InterfaceHandler.cpp b/InterfaceHandler.cpp index 406d1e24..e09e55cb 100644 --- a/InterfaceHandler.cpp +++ b/InterfaceHandler.cpp @@ -129,7 +129,7 @@ std::unique_ptr<std::string> InterfaceHandler::getUserDocumentation(ContractDefi if (!m_notice.empty()) {// since @notice is the only user tag if missing function should not appear user["notice"] = Json::Value(m_notice); - methods[it.second->getCanonicalSignature()] = user; + methods[it.second->externalTypes()] = user; } } } @@ -185,7 +185,7 @@ std::unique_ptr<std::string> InterfaceHandler::getDevDocumentation(ContractDefin method["return"] = m_return; if (!method.empty()) // add the function, only if we have any documentation to add - methods[it.second->getCanonicalSignature()] = method; + methods[it.second->externalTypes()] = method; } } doc["methods"] = methods; @@ -1127,7 +1127,7 @@ MemberList const& FunctionType::getMembers() const } } -string FunctionType::getCanonicalSignature(std::string const& _name) const +string FunctionType::externalTypes(std::string const& _name) const { std::string funcName = _name; if (_name == "") @@ -1138,8 +1138,10 @@ string FunctionType::getCanonicalSignature(std::string const& _name) const string ret = funcName + "("; for (auto it = m_parameterTypes.cbegin(); it != m_parameterTypes.cend(); ++it) - ret += (*it)->toString() + (it + 1 == m_parameterTypes.cend() ? "" : ","); - + { + solAssert(!!(*it)->externalType(), "Parameter should have external type"); + ret += (*it)->externalType()->toString() + (it + 1 == m_parameterTypes.cend() ? "" : ","); + } return ret + ")"; } @@ -550,10 +550,10 @@ public: virtual MemberList const& getMembers() const override; Location const& getLocation() const { return m_location; } - /// @returns the canonical signature of this function type given the function name + /// @returns the external type of this function type given the function name /// If @a _name is not provided (empty string) then the @c m_declaration member of the /// function type is used - std::string getCanonicalSignature(std::string const& _name = "") const; + std::string externalTypes(std::string const& _name = "") const; Declaration const& getDeclaration() const { solAssert(m_declaration, "Requested declaration from a FunctionType that has none"); |