diff options
author | Lefteris Karapetsas <lefteris@refu.co> | 2015-01-13 00:13:27 +0800 |
---|---|---|
committer | Lefteris Karapetsas <lefteris@refu.co> | 2015-01-13 00:13:27 +0800 |
commit | a253abf0623aec5ebbf8fa8b4ec3b00596c724ee (patch) | |
tree | 3a20356d72feb9c9428954540bdfc3838bb68b49 | |
parent | c5d14ce933e3f1d4814c73cbb6d7fe7062caaa06 (diff) | |
download | dexon-solidity-a253abf0623aec5ebbf8fa8b4ec3b00596c724ee.tar dexon-solidity-a253abf0623aec5ebbf8fa8b4ec3b00596c724ee.tar.gz dexon-solidity-a253abf0623aec5ebbf8fa8b4ec3b00596c724ee.tar.bz2 dexon-solidity-a253abf0623aec5ebbf8fa8b4ec3b00596c724ee.tar.lz dexon-solidity-a253abf0623aec5ebbf8fa8b4ec3b00596c724ee.tar.xz dexon-solidity-a253abf0623aec5ebbf8fa8b4ec3b00596c724ee.tar.zst dexon-solidity-a253abf0623aec5ebbf8fa8b4ec3b00596c724ee.zip |
Alethzero: Showing a contract's function's hashes at creation
-rw-r--r-- | CompilerStack.cpp | 18 | ||||
-rw-r--r-- | CompilerStack.h | 3 |
2 files changed, 21 insertions, 0 deletions
diff --git a/CompilerStack.cpp b/CompilerStack.cpp index 547e5fe2..f0d2e7f7 100644 --- a/CompilerStack.cpp +++ b/CompilerStack.cpp @@ -179,6 +179,24 @@ string const& CompilerStack::getMetadata(string const& _contractName, Documentat return *(*doc); } +std::string const CompilerStack::getFunctionHashes(std::string const& _contractName) +{ + if (!m_parseSuccessful) + BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Parsing was not successful.")); + + std::string ret = ""; + Contract const& contract = getContract(_contractName); + auto interfaceFunctions = contract.contract->getInterfaceFunctions(); + + for (auto const& it: interfaceFunctions) + { + ret += it.first.abridged(); + ret += " :"; + ret += it.second->getName() + "\n"; + } + return ret; +} + Scanner const& CompilerStack::getScanner(string const& _sourceName) const { return *getSource(_sourceName).scanner; diff --git a/CompilerStack.h b/CompilerStack.h index 6b60f1dd..da0adf57 100644 --- a/CompilerStack.h +++ b/CompilerStack.h @@ -93,6 +93,9 @@ public: /// Can be one of 4 types defined at @c DocumentationType std::string const& getMetadata(std::string const& _contractName, DocumentationType _type) const; + /// Convenience function to return all contract method hashes in a string + std::string const getFunctionHashes(std::string const& _contractName = ""); + /// @returns the previously used scanner, useful for counting lines during error reporting. Scanner const& getScanner(std::string const& _sourceName = "") const; /// @returns the parsed source unit with the supplied name. |