Browse Source

Creating the canonical signature of a function, for later use in the ABI

cl-refactor
Lefteris Karapetsas 10 years ago
parent
commit
c2b194d4c3
  1. 17
      libsolidity/AST.cpp
  2. 6
      libsolidity/AST.h

17
libsolidity/AST.cpp

@ -110,6 +110,23 @@ void FunctionDefinition::checkTypeRequirements()
m_body->checkTypeRequirements();
}
std::string FunctionDefinition::getCanonicalSignature()
{
auto parameters = getParameters();
std::string ret = getName() + "(";
unsigned int i = 1;
for (ASTPointer<VariableDeclaration> const& member: parameters)
{
ret += member->getType()->toString();
if (i != parameters.size()) {
ret += ",";
}
}
ret += ")";
return ret;
}
void Block::checkTypeRequirements()
{
for (shared_ptr<Statement> const& statement: m_statements)

6
libsolidity/AST.h

@ -277,6 +277,12 @@ public:
/// Checks that all parameters have allowed types and calls checkTypeRequirements on the body.
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();
private:
bool m_isPublic;
ASTPointer<ParameterList> m_parameters;

Loading…
Cancel
Save