mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Remove "using namespace" from header and move Instruction to dev::eth.
This commit is contained in:
@@ -27,8 +27,6 @@
|
||||
using namespace std;
|
||||
using namespace dev;
|
||||
using namespace yul;
|
||||
using namespace dev::solidity;
|
||||
|
||||
|
||||
void ASTWalker::operator()(FunctionalInstruction const& _instr)
|
||||
{
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
using namespace std;
|
||||
using namespace dev;
|
||||
using namespace yul;
|
||||
using namespace dev::solidity;
|
||||
|
||||
YulString Disambiguator::translateIdentifier(YulString _originalName)
|
||||
{
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
using namespace std;
|
||||
using namespace dev;
|
||||
using namespace yul;
|
||||
using namespace dev::solidity;
|
||||
|
||||
void EquivalentFunctionCombiner::run(Block& _ast)
|
||||
{
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
using namespace std;
|
||||
using namespace dev;
|
||||
using namespace yul;
|
||||
using namespace solidity;
|
||||
|
||||
void EquivalentFunctionDetector::operator()(FunctionDefinition const& _fun)
|
||||
{
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
using namespace std;
|
||||
using namespace dev;
|
||||
using namespace yul;
|
||||
using namespace dev::solidity;
|
||||
|
||||
void ExpressionInliner::run()
|
||||
{
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
using namespace std;
|
||||
using namespace dev;
|
||||
using namespace yul;
|
||||
using namespace dev::solidity;
|
||||
|
||||
void ExpressionJoiner::operator()(FunctionalInstruction& _instruction)
|
||||
{
|
||||
|
||||
@@ -30,8 +30,6 @@
|
||||
using namespace std;
|
||||
using namespace dev;
|
||||
using namespace yul;
|
||||
using namespace dev::solidity;
|
||||
|
||||
|
||||
void ExpressionSimplifier::visit(Expression& _expression)
|
||||
{
|
||||
|
||||
@@ -34,7 +34,6 @@ using namespace std;
|
||||
using namespace dev;
|
||||
using namespace langutil;
|
||||
using namespace yul;
|
||||
using namespace dev::solidity;
|
||||
|
||||
void ExpressionSplitter::operator()(FunctionalInstruction& _instruction)
|
||||
{
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
using namespace std;
|
||||
using namespace dev;
|
||||
using namespace yul;
|
||||
using namespace dev::solidity;
|
||||
|
||||
FullInliner::FullInliner(Block& _ast, NameDispenser& _dispenser):
|
||||
m_ast(_ast), m_nameDispenser(_dispenser)
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
using namespace std;
|
||||
using namespace dev;
|
||||
using namespace yul;
|
||||
using namespace dev::solidity;
|
||||
|
||||
|
||||
void FunctionGrouper::operator()(Block& _block)
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
using namespace std;
|
||||
using namespace dev;
|
||||
using namespace yul;
|
||||
using namespace dev::solidity;
|
||||
|
||||
void FunctionHoister::operator()(Block& _block)
|
||||
{
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
using namespace std;
|
||||
using namespace dev;
|
||||
using namespace yul;
|
||||
using namespace dev::solidity;
|
||||
|
||||
void MainFunction::operator()(Block& _block)
|
||||
{
|
||||
|
||||
@@ -99,12 +99,11 @@ void CodeCost::operator()(FunctionCall const& _funCall)
|
||||
|
||||
void CodeCost::operator()(FunctionalInstruction const& _instr)
|
||||
{
|
||||
using namespace dev::solidity;
|
||||
yulAssert(m_cost >= 1, "Should assign cost one in visit(Expression).");
|
||||
Tier gasPriceTier = instructionInfo(_instr.instruction).gasPriceTier;
|
||||
if (gasPriceTier < Tier::VeryLow)
|
||||
dev::eth::Tier gasPriceTier = dev::eth::instructionInfo(_instr.instruction).gasPriceTier;
|
||||
if (gasPriceTier < dev::eth::Tier::VeryLow)
|
||||
m_cost -= 1;
|
||||
else if (gasPriceTier < Tier::High)
|
||||
else if (gasPriceTier < dev::eth::Tier::High)
|
||||
m_cost += 1;
|
||||
else
|
||||
m_cost += 49;
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
using namespace std;
|
||||
using namespace dev;
|
||||
using namespace yul;
|
||||
using namespace dev::solidity;
|
||||
|
||||
void RedundantAssignEliminator::operator()(Identifier const& _identifier)
|
||||
{
|
||||
|
||||
@@ -27,12 +27,10 @@
|
||||
|
||||
#include <libdevcore/CommonData.h>
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace dev;
|
||||
using namespace langutil;
|
||||
using namespace yul;
|
||||
using namespace dev::solidity;
|
||||
|
||||
void SSATransform::operator()(Identifier& _identifier)
|
||||
{
|
||||
|
||||
@@ -30,11 +30,12 @@
|
||||
|
||||
using namespace std;
|
||||
using namespace dev;
|
||||
using namespace dev::eth;
|
||||
using namespace langutil;
|
||||
using namespace yul;
|
||||
|
||||
|
||||
SimplificationRule<Pattern> const* SimplificationRules::findFirstMatch(
|
||||
SimplificationRule<yul::Pattern> const* SimplificationRules::findFirstMatch(
|
||||
Expression const& _expr,
|
||||
Dialect const& _dialect,
|
||||
map<YulString, Expression const*> const& _ssaValues
|
||||
@@ -59,7 +60,7 @@ SimplificationRule<Pattern> const* SimplificationRules::findFirstMatch(
|
||||
|
||||
bool SimplificationRules::isInitialized() const
|
||||
{
|
||||
return !m_rules[uint8_t(solidity::Instruction::ADD)].empty();
|
||||
return !m_rules[uint8_t(dev::eth::Instruction::ADD)].empty();
|
||||
}
|
||||
|
||||
void SimplificationRules::addRules(vector<SimplificationRule<Pattern>> const& _rules)
|
||||
@@ -93,7 +94,7 @@ SimplificationRules::SimplificationRules()
|
||||
assertThrow(isInitialized(), OptimizerException, "Rule list not properly initialized.");
|
||||
}
|
||||
|
||||
Pattern::Pattern(solidity::Instruction _instruction, vector<Pattern> const& _arguments):
|
||||
yul::Pattern::Pattern(dev::eth::Instruction _instruction, vector<Pattern> const& _arguments):
|
||||
m_kind(PatternKind::Operation),
|
||||
m_instruction(_instruction),
|
||||
m_arguments(_arguments)
|
||||
@@ -187,7 +188,7 @@ bool Pattern::matches(
|
||||
return true;
|
||||
}
|
||||
|
||||
solidity::Instruction Pattern::instruction() const
|
||||
dev::eth::Instruction Pattern::instruction() const
|
||||
{
|
||||
assertThrow(m_kind == PatternKind::Operation, OptimizerException, "");
|
||||
return m_instruction;
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <libevmasm/ExpressionClasses.h>
|
||||
#include <libevmasm/SimplificationRule.h>
|
||||
|
||||
#include <libyul/AsmDataForward.h>
|
||||
@@ -47,7 +46,7 @@ public:
|
||||
/// @returns a pointer to the first matching pattern and sets the match
|
||||
/// groups accordingly.
|
||||
/// @param _ssaValues values of variables that are assigned exactly once.
|
||||
static SimplificationRule<Pattern> const* findFirstMatch(
|
||||
static dev::eth::SimplificationRule<Pattern> const* findFirstMatch(
|
||||
Expression const& _expr,
|
||||
Dialect const& _dialect,
|
||||
std::map<YulString, Expression const*> const& _ssaValues
|
||||
@@ -57,13 +56,13 @@ public:
|
||||
/// by the constructor, but we had some issues with static initialization.
|
||||
bool isInitialized() const;
|
||||
private:
|
||||
void addRules(std::vector<SimplificationRule<Pattern>> const& _rules);
|
||||
void addRule(SimplificationRule<Pattern> const& _rule);
|
||||
void addRules(std::vector<dev::eth::SimplificationRule<Pattern>> const& _rules);
|
||||
void addRule(dev::eth::SimplificationRule<Pattern> const& _rule);
|
||||
|
||||
void resetMatchGroups() { m_matchGroups.clear(); }
|
||||
|
||||
std::map<unsigned, Expression const*> m_matchGroups;
|
||||
std::vector<SimplificationRule<Pattern>> m_rules[256];
|
||||
std::vector<dev::eth::SimplificationRule<Pattern>> m_rules[256];
|
||||
};
|
||||
|
||||
enum class PatternKind
|
||||
@@ -88,7 +87,7 @@ public:
|
||||
// Matches a specific constant value.
|
||||
Pattern(dev::u256 const& _value): m_kind(PatternKind::Constant), m_data(std::make_shared<dev::u256>(_value)) {}
|
||||
// Matches a given instruction with given arguments
|
||||
Pattern(dev::solidity::Instruction _instruction, std::vector<Pattern> const& _arguments = {});
|
||||
Pattern(dev::eth::Instruction _instruction, std::vector<Pattern> const& _arguments = {});
|
||||
/// Sets this pattern to be part of the match group with the identifier @a _group.
|
||||
/// Inside one rule, all patterns in the same match group have to match expressions from the
|
||||
/// same expression equivalence class.
|
||||
@@ -105,7 +104,7 @@ public:
|
||||
/// @returns the data of the matched expression if this pattern is part of a match group.
|
||||
dev::u256 d() const;
|
||||
|
||||
dev::solidity::Instruction instruction() const;
|
||||
dev::eth::Instruction instruction() const;
|
||||
|
||||
/// Turns this pattern into an actual expression. Should only be called
|
||||
/// for patterns resulting from an action, i.e. with match groups assigned.
|
||||
@@ -115,7 +114,7 @@ private:
|
||||
Expression const& matchGroupValue() const;
|
||||
|
||||
PatternKind m_kind = PatternKind::Any;
|
||||
dev::solidity::Instruction m_instruction; ///< Only valid if m_kind is Operation
|
||||
dev::eth::Instruction m_instruction; ///< Only valid if m_kind is Operation
|
||||
std::shared_ptr<dev::u256> m_data; ///< Only valid if m_kind is Constant
|
||||
std::vector<Pattern> m_arguments;
|
||||
unsigned m_matchGroup = 0;
|
||||
|
||||
@@ -36,7 +36,7 @@ ExpressionStatement makePopExpressionStatement(langutil::SourceLocation const& _
|
||||
{
|
||||
return {_location, FunctionalInstruction{
|
||||
_location,
|
||||
solidity::Instruction::POP,
|
||||
dev::eth::Instruction::POP,
|
||||
{std::move(_expression)}
|
||||
}};
|
||||
}
|
||||
@@ -105,7 +105,7 @@ OptionalStatements reduceSingleCaseSwitch(Switch& _switchStmt)
|
||||
std::move(_switchStmt.location),
|
||||
make_unique<Expression>(FunctionalInstruction{
|
||||
std::move(loc),
|
||||
solidity::Instruction::EQ,
|
||||
dev::eth::Instruction::EQ,
|
||||
{std::move(*switchCase.value), std::move(*_switchStmt.expression)}
|
||||
}),
|
||||
std::move(switchCase.body)
|
||||
|
||||
@@ -85,7 +85,7 @@ void UnusedPruner::operator()(Block& _block)
|
||||
// instead of `pop`.
|
||||
statement = ExpressionStatement{varDecl.location, FunctionalInstruction{
|
||||
varDecl.location,
|
||||
solidity::Instruction::POP,
|
||||
dev::eth::Instruction::POP,
|
||||
{*std::move(varDecl.value)}
|
||||
}};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user