mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Small issues with Canonical Function Signature
- Also added an extra test
This commit is contained in:
parent
24d7bdd3a9
commit
df0dce584d
9
AST.cpp
9
AST.cpp
@ -110,14 +110,9 @@ void FunctionDefinition::checkTypeRequirements()
|
|||||||
m_body->checkTypeRequirements();
|
m_body->checkTypeRequirements();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string FunctionDefinition::getCanonicalSignature()
|
string FunctionDefinition::getCanonicalSignature() const
|
||||||
{
|
{
|
||||||
auto parameters = getParameters();
|
return getName() + FunctionType(*this).getCanonicalSignature();
|
||||||
std::string ret = getName() + "(";
|
|
||||||
|
|
||||||
for (auto it = parameters.cbegin(); it != parameters.cend(); ++it)
|
|
||||||
ret += (*it)->getType()->toString() + (it + 1 == parameters.end() ? "" : ",");
|
|
||||||
return ret + ")";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Block::checkTypeRequirements()
|
void Block::checkTypeRequirements()
|
||||||
|
9
AST.h
9
AST.h
@ -277,11 +277,10 @@ 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
|
/// @returns the canonical signature of the function
|
||||||
/// That consists of the name of the function followed by the
|
/// That consists of the name of the function followed by the types of the
|
||||||
/// types of the arguments separated by commas all enclosed in parentheses
|
/// arguments separated by commas all enclosed in parentheses without any spaces.
|
||||||
/// without any spaces
|
std::string getCanonicalSignature() const;
|
||||||
std::string getCanonicalSignature();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_isPublic;
|
bool m_isPublic;
|
||||||
|
@ -452,13 +452,12 @@ unsigned FunctionType::getSizeOnStack() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string FunctionType::getCanonicalSignature() const
|
string FunctionType::getCanonicalSignature() const
|
||||||
{
|
{
|
||||||
auto parameters = getParameterTypes();
|
string ret = "(";
|
||||||
std::string ret = "NAME("; //TODO: how to get function name from FunctionType
|
|
||||||
|
|
||||||
for (auto it = parameters.cbegin(); it != parameters.cend(); ++it)
|
for (auto it = m_parameterTypes.cbegin(); it != m_parameterTypes.cend(); ++it)
|
||||||
ret += (*it)->toString() + (it + 1 == m_parameterTypes.end() ? "" : ",");
|
ret += (*it)->toString() + (it + 1 == m_parameterTypes.cend() ? "" : ",");
|
||||||
|
|
||||||
return ret + ")";
|
return ret + ")";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user