aboutsummaryrefslogtreecommitdiffstats
path: root/CommandLineInterface.cpp
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-05-26 17:27:59 +0800
committerchriseth <c@ethdev.com>2015-05-26 17:27:59 +0800
commitb6fa534868fdf631dd432574008f2a3faadd41ca (patch)
tree40acb91079edb0d920eb627e4614c0dcabf58d46 /CommandLineInterface.cpp
parentfdbce582ab6f6028f4bf3081f1ce24ddc2473ea2 (diff)
downloaddexon-solidity-b6fa534868fdf631dd432574008f2a3faadd41ca.tar
dexon-solidity-b6fa534868fdf631dd432574008f2a3faadd41ca.tar.gz
dexon-solidity-b6fa534868fdf631dd432574008f2a3faadd41ca.tar.bz2
dexon-solidity-b6fa534868fdf631dd432574008f2a3faadd41ca.tar.lz
dexon-solidity-b6fa534868fdf631dd432574008f2a3faadd41ca.tar.xz
dexon-solidity-b6fa534868fdf631dd432574008f2a3faadd41ca.tar.zst
dexon-solidity-b6fa534868fdf631dd432574008f2a3faadd41ca.zip
Gas estimation for internal functions.
Diffstat (limited to 'CommandLineInterface.cpp')
-rw-r--r--CommandLineInterface.cpp28
1 files changed, 24 insertions, 4 deletions
diff --git a/CommandLineInterface.cpp b/CommandLineInterface.cpp
index c86938f8..8129f60c 100644
--- a/CommandLineInterface.cpp
+++ b/CommandLineInterface.cpp
@@ -258,18 +258,38 @@ void CommandLineInterface::handleGasEstimation(string const& _contract)
{
Gas gas = GasEstimator::functionalEstimation(*items);
u256 bytecodeSize(m_compiler->getRuntimeBytecode(_contract).size());
- cout << "[construction]:\t";
- cout << gas << " + " << (bytecodeSize * eth::c_createDataGas) << " = ";
+ cout << "construction:" << endl;
+ cout << " " << gas << " + " << (bytecodeSize * eth::c_createDataGas) << " = ";
gas += bytecodeSize * eth::c_createDataGas;
cout << gas << endl;
}
if (eth::AssemblyItems const* items = m_compiler->getRuntimeAssemblyItems(_contract))
- for (auto it: m_compiler->getContractDefinition(_contract).getInterfaceFunctions())
+ {
+ ContractDefinition const& contract = m_compiler->getContractDefinition(_contract);
+ cout << "external:" << endl;
+ for (auto it: contract.getInterfaceFunctions())
{
string sig = it.second->externalSignature();
GasEstimator::GasConsumption gas = GasEstimator::functionalEstimation(*items, sig);
- cout << sig << ":\t" << gas << endl;
+ cout << " " << sig << ":\t" << gas << endl;
}
+ cout << "internal:" << endl;
+ for (auto const& it: contract.getDefinedFunctions())
+ {
+ if (it->isPartOfExternalInterface() || it->isConstructor())
+ continue;
+ size_t entry = m_compiler->getFunctionEntryPoint(_contract, *it);
+ GasEstimator::GasConsumption gas = GasEstimator::GasConsumption::infinite();
+ if (entry > 0)
+ gas = GasEstimator::functionalEstimation(*items, entry, *it);
+ FunctionType type(*it);
+ cout << " " << it->getName() << "(";
+ auto end = type.getParameterTypes().end();
+ for (auto it = type.getParameterTypes().begin(); it != end; ++it)
+ cout << (*it)->toString() << (it + 1 == end ? "" : ",");
+ cout << "):\t" << gas << endl;
+ }
+ }
}
bool CommandLineInterface::parseArguments(int argc, char** argv)