mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Use std::array.
This commit is contained in:
parent
c3e5fe6a12
commit
c731ae92ca
@ -31,7 +31,7 @@ using namespace dev;
|
||||
using namespace dev::eth;
|
||||
using namespace dev::solidity;
|
||||
|
||||
map<ASTNode const*, GasMeter::GasConsumption[2]> StructuralGasEstimator::performEstimation(
|
||||
StructuralGasEstimator::ASTGasConsumptionSelfAccumulated StructuralGasEstimator::performEstimation(
|
||||
AssemblyItems const& _items,
|
||||
vector<ASTNode const*> const& _ast
|
||||
)
|
||||
@ -42,7 +42,7 @@ map<ASTNode const*, GasMeter::GasConsumption[2]> StructuralGasEstimator::perform
|
||||
for (auto const& item: _items)
|
||||
particularCosts[item.getLocation()] += meter.estimateMax(item);
|
||||
|
||||
map<ASTNode const*, GasMeter::GasConsumption[2]> gasCosts;
|
||||
ASTGasConsumptionSelfAccumulated gasCosts;
|
||||
auto onNode = [&](ASTNode const& _node)
|
||||
{
|
||||
gasCosts[&_node][0] = gasCosts[&_node][1] = particularCosts[_node.getLocation()];
|
||||
@ -60,7 +60,7 @@ map<ASTNode const*, GasMeter::GasConsumption[2]> StructuralGasEstimator::perform
|
||||
}
|
||||
|
||||
map<ASTNode const*, GasMeter::GasConsumption> StructuralGasEstimator::breakToStatementLevel(
|
||||
map<ASTNode const*, GasMeter::GasConsumption[2]> const& _gasCosts,
|
||||
ASTGasConsumptionSelfAccumulated const& _gasCosts,
|
||||
vector<ASTNode const*> const& _roots
|
||||
)
|
||||
{
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <array>
|
||||
#include <libsolidity/ASTForward.h>
|
||||
#include <libevmasm/GasMeter.h>
|
||||
#include <libevmasm/Assembly.h>
|
||||
@ -37,11 +38,13 @@ class StructuralGasEstimator
|
||||
{
|
||||
public:
|
||||
using ASTGasConsumption = std::map<ASTNode const*, eth::GasMeter::GasConsumption>;
|
||||
using ASTGasConsumptionSelfAccumulated =
|
||||
std::map<ASTNode const*, std::array<eth::GasMeter::GasConsumption, 2>>;
|
||||
|
||||
/// Estimates the gas consumption for every assembly item in the given assembly and stores
|
||||
/// it by source location.
|
||||
/// @returns a mapping from each AST node to a pair of its particular and syntactically accumulated gas costs.
|
||||
std::map<ASTNode const*, eth::GasMeter::GasConsumption[2]> performEstimation(
|
||||
ASTGasConsumptionSelfAccumulated performEstimation(
|
||||
eth::AssemblyItems const& _items,
|
||||
std::vector<ASTNode const*> const& _ast
|
||||
);
|
||||
@ -50,7 +53,7 @@ public:
|
||||
/// 1. source locations of statements that do not contain other statements
|
||||
/// 2. maximal source locations that do not overlap locations coming from the first rule
|
||||
ASTGasConsumption breakToStatementLevel(
|
||||
std::map<ASTNode const*, eth::GasMeter::GasConsumption[2]> const& _gasCosts,
|
||||
ASTGasConsumptionSelfAccumulated const& _gasCosts,
|
||||
std::vector<ASTNode const*> const& _roots
|
||||
);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user