From 5e875ee072134f867203c920d723f08b08ec67ab Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Tue, 6 Jan 2015 17:42:38 +0100 Subject: Creating the canonical signature of a function, for later use in the ABI --- AST.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'AST.cpp') diff --git a/AST.cpp b/AST.cpp index 1fa6d8f6..62952521 100644 --- a/AST.cpp +++ b/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 const& member: parameters) + { + ret += member->getType()->toString(); + if (i != parameters.size()) { + ret += ","; + } + } + ret += ")"; + return ret; +} + void Block::checkTypeRequirements() { for (shared_ptr const& statement: m_statements) -- cgit From b2aa3baded2a81420f371569ec58c60f0ce3f841 Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Wed, 7 Jan 2015 02:07:34 +0100 Subject: Test for the Canonical Signature of a function --- AST.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'AST.cpp') diff --git a/AST.cpp b/AST.cpp index 62952521..fd8f45a7 100644 --- a/AST.cpp +++ b/AST.cpp @@ -122,6 +122,7 @@ std::string FunctionDefinition::getCanonicalSignature() if (i != parameters.size()) { ret += ","; } + i++; } ret += ")"; return ret; -- cgit From 24d7bdd3a9b9014e1e58dbe44f501fbfdec564c5 Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Wed, 7 Jan 2015 02:27:05 +0100 Subject: FunctionType also gets CanonicalSignature - also using iterators in the signature creation function --- AST.cpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'AST.cpp') 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 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() -- cgit From df0dce584d2d1aacf3d33658b0540f243b3adb81 Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Wed, 7 Jan 2015 10:45:59 +0100 Subject: Small issues with Canonical Function Signature - Also added an extra test --- AST.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'AST.cpp') 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() -- cgit