aboutsummaryrefslogtreecommitdiffstats
path: root/solc
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-04-10 21:52:13 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-04-13 09:17:40 +0800
commit328f2b0a8efa41d0343b4df022ce1106a5984fb4 (patch)
tree3490917ec27de4034eef4f37f1861be919456f47 /solc
parentd90fd439e2e96551018b4f90ec073cf7e9b6e4d9 (diff)
downloaddexon-solidity-328f2b0a8efa41d0343b4df022ce1106a5984fb4.tar
dexon-solidity-328f2b0a8efa41d0343b4df022ce1106a5984fb4.tar.gz
dexon-solidity-328f2b0a8efa41d0343b4df022ce1106a5984fb4.tar.bz2
dexon-solidity-328f2b0a8efa41d0343b4df022ce1106a5984fb4.tar.lz
dexon-solidity-328f2b0a8efa41d0343b4df022ce1106a5984fb4.tar.xz
dexon-solidity-328f2b0a8efa41d0343b4df022ce1106a5984fb4.tar.zst
dexon-solidity-328f2b0a8efa41d0343b4df022ce1106a5984fb4.zip
Use new gasEstimate in CLI
Diffstat (limited to 'solc')
-rw-r--r--solc/CommandLineInterface.cpp72
1 files changed, 39 insertions, 33 deletions
diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp
index f0b73152..90cc4769 100644
--- a/solc/CommandLineInterface.cpp
+++ b/solc/CommandLineInterface.cpp
@@ -315,49 +315,55 @@ void CommandLineInterface::handleMeta(DocumentationType _type, string const& _co
void CommandLineInterface::handleGasEstimation(string const& _contract)
{
- using Gas = GasEstimator::GasConsumption;
- if (!m_compiler->assemblyItems(_contract) && !m_compiler->runtimeAssemblyItems(_contract))
- return;
+ Json::Value estimates = m_compiler->gasEstimates(_contract);
cout << "Gas estimation:" << endl;
- if (eth::AssemblyItems const* items = m_compiler->assemblyItems(_contract))
+
+ if (estimates["creation"].isObject())
{
- Gas gas = GasEstimator::functionalEstimation(*items);
- u256 bytecodeSize(m_compiler->runtimeObject(_contract).bytecode.size());
+ Json::Value creation = estimates["creation"];
cout << "construction:" << endl;
- cout << " " << gas << " + " << (bytecodeSize * eth::GasCosts::createDataGas) << " = ";
- gas += bytecodeSize * eth::GasCosts::createDataGas;
- cout << gas << endl;
+ if (creation["executionCost"].isNull())
+ cout << " infinite";
+ else
+ cout << " " << creation["executionCost"];
+ if (creation["codeDepositCost"].isNull())
+ cout << " + infinite";
+ else
+ cout << " + " << creation["codeDepositCost"];
+ if (creation["totalCost"].isNull())
+ cout << " = infinite";
+ else
+ cout << " = " << creation["totalCost"] << endl;
}
- if (eth::AssemblyItems const* items = m_compiler->runtimeAssemblyItems(_contract))
+
+ if (estimates["external"].isObject())
{
- ContractDefinition const& contract = m_compiler->contractDefinition(_contract);
+ Json::Value externalFunctions = estimates["external"];
cout << "external:" << endl;
- for (auto it: contract.interfaceFunctions())
- {
- string sig = it.second->externalSignature();
- GasEstimator::GasConsumption gas = GasEstimator::functionalEstimation(*items, sig);
- cout << " " << sig << ":\t" << gas << endl;
- }
- if (contract.fallbackFunction())
+ for (auto const& name: externalFunctions.getMemberNames())
{
- GasEstimator::GasConsumption gas = GasEstimator::functionalEstimation(*items, "INVALID");
- cout << " fallback:\t" << gas << endl;
+ if (name.empty())
+ cout << " fallback:\t";
+ else
+ cout << " " << name << ":\t";
+ if (externalFunctions[name].isNull())
+ cout << "infinite" << endl;
+ else
+ cout << externalFunctions[name] << endl;
}
+ }
+
+ if (estimates["internal"].isObject())
+ {
+ Json::Value internalFunctions = estimates["internal"];
cout << "internal:" << endl;
- for (auto const& it: contract.definedFunctions())
+ for (auto const& name: internalFunctions.getMemberNames())
{
- if (it->isPartOfExternalInterface() || it->isConstructor())
- continue;
- size_t entry = m_compiler->functionEntryPoint(_contract, *it);
- GasEstimator::GasConsumption gas = GasEstimator::GasConsumption::infinite();
- if (entry > 0)
- gas = GasEstimator::functionalEstimation(*items, entry, *it);
- FunctionType type(*it);
- cout << " " << it->name() << "(";
- auto paramTypes = type.parameterTypes();
- for (auto it = paramTypes.begin(); it != paramTypes.end(); ++it)
- cout << (*it)->toString() << (it + 1 == paramTypes.end() ? "" : ",");
- cout << "):\t" << gas << endl;
+ cout << " " << name << ":\t";
+ if (internalFunctions[name].isNull())
+ cout << "infinite" << endl;
+ else
+ cout << internalFunctions[name] << endl;
}
}
}