mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
C++ namespace cleanup (except tests).
This commit is contained in:
committed by
Daniel Kirchner
parent
8385256bdc
commit
6b23412fae
@@ -30,8 +30,9 @@
|
||||
#include <variant>
|
||||
|
||||
using namespace std;
|
||||
using namespace dev;
|
||||
using namespace yul;
|
||||
using namespace solidity;
|
||||
using namespace solidity::yul;
|
||||
using namespace solidity::util;
|
||||
|
||||
using Representation = ConstantOptimiser::Representation;
|
||||
|
||||
@@ -46,24 +47,24 @@ struct MiniEVMInterpreter
|
||||
return std::visit(*this, _expr);
|
||||
}
|
||||
|
||||
u256 eval(dev::eth::Instruction _instr, vector<Expression> const& _arguments)
|
||||
u256 eval(evmasm::Instruction _instr, vector<Expression> const& _arguments)
|
||||
{
|
||||
vector<u256> args;
|
||||
for (auto const& arg: _arguments)
|
||||
args.emplace_back(eval(arg));
|
||||
switch (_instr)
|
||||
{
|
||||
case eth::Instruction::ADD:
|
||||
case evmasm::Instruction::ADD:
|
||||
return args.at(0) + args.at(1);
|
||||
case eth::Instruction::SUB:
|
||||
case evmasm::Instruction::SUB:
|
||||
return args.at(0) - args.at(1);
|
||||
case eth::Instruction::MUL:
|
||||
case evmasm::Instruction::MUL:
|
||||
return args.at(0) * args.at(1);
|
||||
case eth::Instruction::EXP:
|
||||
case evmasm::Instruction::EXP:
|
||||
return exp256(args.at(0), args.at(1));
|
||||
case eth::Instruction::SHL:
|
||||
case evmasm::Instruction::SHL:
|
||||
return args.at(0) > 255 ? 0 : (args.at(1) << unsigned(args.at(0)));
|
||||
case eth::Instruction::NOT:
|
||||
case evmasm::Instruction::NOT:
|
||||
return ~args.at(0);
|
||||
default:
|
||||
yulAssert(false, "Invalid operation generated in constant optimizer.");
|
||||
@@ -107,7 +108,7 @@ void ConstantOptimiser::visit(Expression& _e)
|
||||
ASTModifier::visit(_e);
|
||||
}
|
||||
|
||||
Expression const* RepresentationFinder::tryFindRepresentation(dev::u256 const& _value)
|
||||
Expression const* RepresentationFinder::tryFindRepresentation(u256 const& _value)
|
||||
{
|
||||
if (_value < 0x10000)
|
||||
return nullptr;
|
||||
@@ -119,14 +120,14 @@ Expression const* RepresentationFinder::tryFindRepresentation(dev::u256 const& _
|
||||
return repr.expression.get();
|
||||
}
|
||||
|
||||
Representation const& RepresentationFinder::findRepresentation(dev::u256 const& _value)
|
||||
Representation const& RepresentationFinder::findRepresentation(u256 const& _value)
|
||||
{
|
||||
if (m_cache.count(_value))
|
||||
return m_cache.at(_value);
|
||||
|
||||
Representation routine = represent(_value);
|
||||
|
||||
if (dev::bytesRequired(~_value) < dev::bytesRequired(_value))
|
||||
if (bytesRequired(~_value) < bytesRequired(_value))
|
||||
// Negated is shorter to represent
|
||||
routine = min(move(routine), represent("not"_yulstring, findRepresentation(~_value)));
|
||||
|
||||
@@ -175,7 +176,7 @@ Representation const& RepresentationFinder::findRepresentation(dev::u256 const&
|
||||
return m_cache[_value] = move(routine);
|
||||
}
|
||||
|
||||
Representation RepresentationFinder::represent(dev::u256 const& _value) const
|
||||
Representation RepresentationFinder::represent(u256 const& _value) const
|
||||
{
|
||||
Representation repr;
|
||||
repr.expression = make_unique<Expression>(Literal{m_location, LiteralKind::Number, YulString{formatNumber(_value)}, {}});
|
||||
|
||||
Reference in New Issue
Block a user