aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLefteris Karapetsas <lefteris@refu.co>2015-01-07 00:42:38 +0800
committerLefteris Karapetsas <lefteris@refu.co>2015-01-07 00:42:38 +0800
commit5e875ee072134f867203c920d723f08b08ec67ab (patch)
treece5530aecabffc652b02f80851c1bfe5a9b2d797
parentca733fd31900691bf58522f49811ceb0a00f9042 (diff)
downloaddexon-solidity-5e875ee072134f867203c920d723f08b08ec67ab.tar
dexon-solidity-5e875ee072134f867203c920d723f08b08ec67ab.tar.gz
dexon-solidity-5e875ee072134f867203c920d723f08b08ec67ab.tar.bz2
dexon-solidity-5e875ee072134f867203c920d723f08b08ec67ab.tar.lz
dexon-solidity-5e875ee072134f867203c920d723f08b08ec67ab.tar.xz
dexon-solidity-5e875ee072134f867203c920d723f08b08ec67ab.tar.zst
dexon-solidity-5e875ee072134f867203c920d723f08b08ec67ab.zip
Creating the canonical signature of a function, for later use in the ABI
-rw-r--r--AST.cpp17
-rw-r--r--AST.h6
2 files changed, 23 insertions, 0 deletions
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<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)
diff --git a/AST.h b/AST.h
index b7c3dc6c..32cc23a5 100644
--- a/AST.h
+++ b/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;