aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLefteris Karapetsas <lefteris@refu.co>2015-01-07 09:27:05 +0800
committerLefteris Karapetsas <lefteris@refu.co>2015-01-07 09:27:05 +0800
commit24d7bdd3a9b9014e1e58dbe44f501fbfdec564c5 (patch)
treec0ef3cf3e2f99bf10383aaafcd3c6144d3d12723
parentb2aa3baded2a81420f371569ec58c60f0ce3f841 (diff)
downloaddexon-solidity-24d7bdd3a9b9014e1e58dbe44f501fbfdec564c5.tar.gz
dexon-solidity-24d7bdd3a9b9014e1e58dbe44f501fbfdec564c5.tar.zst
dexon-solidity-24d7bdd3a9b9014e1e58dbe44f501fbfdec564c5.zip
FunctionType also gets CanonicalSignature
- also using iterators in the signature creation function
-rw-r--r--AST.cpp14
-rw-r--r--Types.cpp11
-rw-r--r--Types.h1
3 files changed, 15 insertions, 11 deletions
diff --git a/AST.cpp b/AST.cpp
index fd8f45a7..cdbfb4e9 100644
--- a/AST.cpp
+++ b/AST.cpp
@@ -114,18 +114,10 @@ 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 += ",";
- }
- i++;
- }
- ret += ")";
- return ret;
+ for (auto it = parameters.cbegin(); it != parameters.cend(); ++it)
+ ret += (*it)->getType()->toString() + (it + 1 == parameters.end() ? "" : ",");
+ return ret + ")";
}
void Block::checkTypeRequirements()
diff --git a/Types.cpp b/Types.cpp
index 71319c3a..640a34ca 100644
--- a/Types.cpp
+++ b/Types.cpp
@@ -452,6 +452,17 @@ unsigned FunctionType::getSizeOnStack() const
}
}
+std::string FunctionType::getCanonicalSignature() const
+{
+ auto parameters = getParameterTypes();
+ std::string ret = "NAME("; //TODO: how to get function name from FunctionType
+
+ for (auto it = parameters.cbegin(); it != parameters.cend(); ++it)
+ ret += (*it)->toString() + (it + 1 == m_parameterTypes.end() ? "" : ",");
+
+ return ret + ")";
+}
+
bool MappingType::operator==(Type const& _other) const
{
if (_other.getCategory() != getCategory())
diff --git a/Types.h b/Types.h
index 48539a1d..0fe685b8 100644
--- a/Types.h
+++ b/Types.h
@@ -325,6 +325,7 @@ public:
virtual unsigned getSizeOnStack() const override;
Location const& getLocation() const { return m_location; }
+ std::string getCanonicalSignature() const;
private:
TypePointers m_parameterTypes;