mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #738 from LefterisJP/sol_abiFunctionHash
Canonical Function signature creation in solidity
This commit is contained in:
commit
53e38b3ac9
5
AST.cpp
5
AST.cpp
@ -110,6 +110,11 @@ void FunctionDefinition::checkTypeRequirements()
|
|||||||
m_body->checkTypeRequirements();
|
m_body->checkTypeRequirements();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string FunctionDefinition::getCanonicalSignature() const
|
||||||
|
{
|
||||||
|
return getName() + FunctionType(*this).getCanonicalSignature();
|
||||||
|
}
|
||||||
|
|
||||||
void Block::checkTypeRequirements()
|
void Block::checkTypeRequirements()
|
||||||
{
|
{
|
||||||
for (shared_ptr<Statement> const& statement: m_statements)
|
for (shared_ptr<Statement> const& statement: m_statements)
|
||||||
|
5
AST.h
5
AST.h
@ -277,6 +277,11 @@ public:
|
|||||||
/// Checks that all parameters have allowed types and calls checkTypeRequirements on the body.
|
/// Checks that all parameters have allowed types and calls checkTypeRequirements on the body.
|
||||||
void checkTypeRequirements();
|
void checkTypeRequirements();
|
||||||
|
|
||||||
|
/// @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;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_isPublic;
|
bool m_isPublic;
|
||||||
ASTPointer<ParameterList> m_parameters;
|
ASTPointer<ParameterList> m_parameters;
|
||||||
|
10
Types.cpp
10
Types.cpp
@ -484,6 +484,16 @@ unsigned FunctionType::getSizeOnStack() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string FunctionType::getCanonicalSignature() const
|
||||||
|
{
|
||||||
|
string ret = "(";
|
||||||
|
|
||||||
|
for (auto it = m_parameterTypes.cbegin(); it != m_parameterTypes.cend(); ++it)
|
||||||
|
ret += (*it)->toString() + (it + 1 == m_parameterTypes.cend() ? "" : ",");
|
||||||
|
|
||||||
|
return ret + ")";
|
||||||
|
}
|
||||||
|
|
||||||
bool MappingType::operator==(Type const& _other) const
|
bool MappingType::operator==(Type const& _other) const
|
||||||
{
|
{
|
||||||
if (_other.getCategory() != getCategory())
|
if (_other.getCategory() != getCategory())
|
||||||
|
1
Types.h
1
Types.h
@ -338,6 +338,7 @@ public:
|
|||||||
virtual unsigned getSizeOnStack() const override;
|
virtual unsigned getSizeOnStack() const override;
|
||||||
|
|
||||||
Location const& getLocation() const { return m_location; }
|
Location const& getLocation() const { return m_location; }
|
||||||
|
std::string getCanonicalSignature() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TypePointers m_parameterTypes;
|
TypePointers m_parameterTypes;
|
||||||
|
Loading…
Reference in New Issue
Block a user