aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--AST.cpp9
-rw-r--r--AST.h9
-rw-r--r--Types.cpp9
3 files changed, 10 insertions, 17 deletions
diff --git a/AST.cpp b/AST.cpp
index cdbfb4e9..0c56cb7a 100644
--- a/AST.cpp
+++ b/AST.cpp
@@ -110,14 +110,9 @@ void FunctionDefinition::checkTypeRequirements()
m_body->checkTypeRequirements();
}
-std::string FunctionDefinition::getCanonicalSignature()
+string FunctionDefinition::getCanonicalSignature() const
{
- auto parameters = getParameters();
- std::string ret = getName() + "(";
-
- for (auto it = parameters.cbegin(); it != parameters.cend(); ++it)
- ret += (*it)->getType()->toString() + (it + 1 == parameters.end() ? "" : ",");
- return ret + ")";
+ return getName() + FunctionType(*this).getCanonicalSignature();
}
void Block::checkTypeRequirements()
diff --git a/AST.h b/AST.h
index 32cc23a5..8493d432 100644
--- a/AST.h
+++ b/AST.h
@@ -277,11 +277,10 @@ 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();
+ /// @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:
bool m_isPublic;
diff --git a/Types.cpp b/Types.cpp
index 640a34ca..7a4c45c6 100644
--- a/Types.cpp
+++ b/Types.cpp
@@ -452,13 +452,12 @@ unsigned FunctionType::getSizeOnStack() const
}
}
-std::string FunctionType::getCanonicalSignature() const
+string FunctionType::getCanonicalSignature() const
{
- auto parameters = getParameterTypes();
- std::string ret = "NAME("; //TODO: how to get function name from FunctionType
+ string ret = "(";
- for (auto it = parameters.cbegin(); it != parameters.cend(); ++it)
- ret += (*it)->toString() + (it + 1 == m_parameterTypes.end() ? "" : ",");
+ for (auto it = m_parameterTypes.cbegin(); it != m_parameterTypes.cend(); ++it)
+ ret += (*it)->toString() + (it + 1 == m_parameterTypes.cend() ? "" : ",");
return ret + ")";
}