aboutsummaryrefslogtreecommitdiffstats
path: root/CommandLineInterface.cpp
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-05-07 18:39:35 +0800
committerchriseth <c@ethdev.com>2015-05-07 18:39:35 +0800
commit3b6bd194b0f822cde1899daf7ec1a026f5a86609 (patch)
tree328accdc7a8adf4a67e8ad2247b164db4c5bb525 /CommandLineInterface.cpp
parent01ec30338851142a397fbb53b2959b0822d2cc76 (diff)
parent16e468460fab786ddcdff7944e993bd852166f25 (diff)
downloaddexon-solidity-3b6bd194b0f822cde1899daf7ec1a026f5a86609.tar
dexon-solidity-3b6bd194b0f822cde1899daf7ec1a026f5a86609.tar.gz
dexon-solidity-3b6bd194b0f822cde1899daf7ec1a026f5a86609.tar.bz2
dexon-solidity-3b6bd194b0f822cde1899daf7ec1a026f5a86609.tar.lz
dexon-solidity-3b6bd194b0f822cde1899daf7ec1a026f5a86609.tar.xz
dexon-solidity-3b6bd194b0f822cde1899daf7ec1a026f5a86609.tar.zst
dexon-solidity-3b6bd194b0f822cde1899daf7ec1a026f5a86609.zip
Merge pull request #1810 from chriseth/sol_gasEstimator
Structural gas estimator.
Diffstat (limited to 'CommandLineInterface.cpp')
-rw-r--r--CommandLineInterface.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/CommandLineInterface.cpp b/CommandLineInterface.cpp
index e6f03a2e..944c8f68 100644
--- a/CommandLineInterface.cpp
+++ b/CommandLineInterface.cpp
@@ -42,6 +42,7 @@
#include <libsolidity/Exceptions.h>
#include <libsolidity/CompilerStack.h>
#include <libsolidity/SourceReferenceFormatter.h>
+#include <libsolidity/StructuralGasEstimator.h>
using namespace std;
namespace po = boost::program_options;
@@ -464,6 +465,17 @@ void CommandLineInterface::handleAst(string const& _argStr)
// do we need AST output?
if (m_args.count(_argStr))
{
+ StructuralGasEstimator gasEstimator;
+ vector<ASTNode const*> asts;
+ for (auto const& sourceCode: m_sourceCodes)
+ asts.push_back(&m_compiler->getAST(sourceCode.first));
+ map<ASTNode const*, eth::GasMeter::GasConsumption> gasCosts;
+ if (m_compiler->getRuntimeAssemblyItems())
+ gasCosts = gasEstimator.breakToStatementLevel(
+ gasEstimator.performEstimation(*m_compiler->getRuntimeAssemblyItems(), asts),
+ asts
+ );
+
auto choice = m_args[_argStr].as<OutputType>();
if (outputToStdout(choice))
{
@@ -473,7 +485,11 @@ void CommandLineInterface::handleAst(string const& _argStr)
cout << endl << "======= " << sourceCode.first << " =======" << endl;
if (_argStr == g_argAstStr)
{
- ASTPrinter printer(m_compiler->getAST(sourceCode.first), sourceCode.second);
+ ASTPrinter printer(
+ m_compiler->getAST(sourceCode.first),
+ sourceCode.second,
+ gasCosts
+ );
printer.print(cout);
}
else