EVMVersion in langutil namespace instead of solidity

This commit is contained in:
Leonardo Alt 2019-02-25 15:29:57 +01:00
parent 52ee955fba
commit 2405b2151a
30 changed files with 72 additions and 75 deletions

View File

@ -107,7 +107,7 @@ public:
bool runDeduplicate = false; bool runDeduplicate = false;
bool runCSE = false; bool runCSE = false;
bool runConstantOptimiser = false; bool runConstantOptimiser = false;
solidity::EVMVersion evmVersion; langutil::EVMVersion evmVersion;
/// This specifies an estimate on how often each opcode in this assembly will be executed, /// This specifies an estimate on how often each opcode in this assembly will be executed,
/// i.e. use a small value to optimise for size and a large value to optimise for runtime gas usage. /// i.e. use a small value to optimise for size and a large value to optimise for runtime gas usage.
size_t expectedExecutionsPerDeployment = 200; size_t expectedExecutionsPerDeployment = 200;
@ -121,7 +121,7 @@ public:
/// @a _runs specifes an estimate on how often each opcode in this assembly will be executed, /// @a _runs specifes an estimate on how often each opcode in this assembly will be executed,
/// i.e. use a small value to optimise for size and a large value to optimise for runtime. /// i.e. use a small value to optimise for size and a large value to optimise for runtime.
/// If @a _enable is not set, will perform some simple peephole optimizations. /// If @a _enable is not set, will perform some simple peephole optimizations.
Assembly& optimise(bool _enable, EVMVersion _evmVersion, bool _isCreation = true, size_t _runs = 200); Assembly& optimise(bool _enable, langutil::EVMVersion _evmVersion, bool _isCreation = true, size_t _runs = 200);
/// Create a text representation of the assembly. /// Create a text representation of the assembly.
std::string assemblyString( std::string assemblyString(

View File

@ -29,7 +29,7 @@ using namespace dev::eth;
unsigned ConstantOptimisationMethod::optimiseConstants( unsigned ConstantOptimisationMethod::optimiseConstants(
bool _isCreation, bool _isCreation,
size_t _runs, size_t _runs,
solidity::EVMVersion _evmVersion, langutil::EVMVersion _evmVersion,
Assembly& _assembly Assembly& _assembly
) )
{ {

View File

@ -52,7 +52,7 @@ public:
static unsigned optimiseConstants( static unsigned optimiseConstants(
bool _isCreation, bool _isCreation,
size_t _runs, size_t _runs,
solidity::EVMVersion _evmVersion, langutil::EVMVersion _evmVersion,
Assembly& _assembly Assembly& _assembly
); );
@ -64,7 +64,7 @@ protected:
bool isCreation; ///< Whether this is called during contract creation or runtime. bool isCreation; ///< Whether this is called during contract creation or runtime.
size_t runs; ///< Estimated number of calls per opcode oven the lifetime of the contract. size_t runs; ///< Estimated number of calls per opcode oven the lifetime of the contract.
size_t multiplicity; ///< Number of times the constant appears in the code. size_t multiplicity; ///< Number of times the constant appears in the code.
solidity::EVMVersion evmVersion; ///< Version of the EVM langutil::EVMVersion evmVersion; ///< Version of the EVM
}; };
explicit ConstantOptimisationMethod(Params const& _params, u256 const& _value): explicit ConstantOptimisationMethod(Params const& _params, u256 const& _value):

View File

@ -47,24 +47,24 @@ namespace GasCosts
static unsigned const tier5Gas = 10; static unsigned const tier5Gas = 10;
static unsigned const tier6Gas = 20; static unsigned const tier6Gas = 20;
static unsigned const tier7Gas = 0; static unsigned const tier7Gas = 0;
inline unsigned extCodeGas(EVMVersion _evmVersion) inline unsigned extCodeGas(langutil::EVMVersion _evmVersion)
{ {
return _evmVersion >= EVMVersion::tangerineWhistle() ? 700 : 20; return _evmVersion >= langutil::EVMVersion::tangerineWhistle() ? 700 : 20;
} }
inline unsigned balanceGas(EVMVersion _evmVersion) inline unsigned balanceGas(langutil::EVMVersion _evmVersion)
{ {
return _evmVersion >= EVMVersion::tangerineWhistle() ? 400 : 20; return _evmVersion >= langutil::EVMVersion::tangerineWhistle() ? 400 : 20;
} }
static unsigned const expGas = 10; static unsigned const expGas = 10;
inline unsigned expByteGas(EVMVersion _evmVersion) inline unsigned expByteGas(langutil::EVMVersion _evmVersion)
{ {
return _evmVersion >= EVMVersion::spuriousDragon() ? 50 : 10; return _evmVersion >= langutil::EVMVersion::spuriousDragon() ? 50 : 10;
} }
static unsigned const keccak256Gas = 30; static unsigned const keccak256Gas = 30;
static unsigned const keccak256WordGas = 6; static unsigned const keccak256WordGas = 6;
inline unsigned sloadGas(EVMVersion _evmVersion) inline unsigned sloadGas(langutil::EVMVersion _evmVersion)
{ {
return _evmVersion >= EVMVersion::tangerineWhistle() ? 200 : 50; return _evmVersion >= langutil::EVMVersion::tangerineWhistle() ? 200 : 50;
} }
static unsigned const sstoreSetGas = 20000; static unsigned const sstoreSetGas = 20000;
static unsigned const sstoreResetGas = 5000; static unsigned const sstoreResetGas = 5000;
@ -74,16 +74,16 @@ namespace GasCosts
static unsigned const logDataGas = 8; static unsigned const logDataGas = 8;
static unsigned const logTopicGas = 375; static unsigned const logTopicGas = 375;
static unsigned const createGas = 32000; static unsigned const createGas = 32000;
inline unsigned callGas(EVMVersion _evmVersion) inline unsigned callGas(langutil::EVMVersion _evmVersion)
{ {
return _evmVersion >= EVMVersion::tangerineWhistle() ? 700 : 40; return _evmVersion >= langutil::EVMVersion::tangerineWhistle() ? 700 : 40;
} }
static unsigned const callStipend = 2300; static unsigned const callStipend = 2300;
static unsigned const callValueTransferGas = 9000; static unsigned const callValueTransferGas = 9000;
static unsigned const callNewAccountGas = 25000; static unsigned const callNewAccountGas = 25000;
inline unsigned selfdestructGas(EVMVersion _evmVersion) inline unsigned selfdestructGas(langutil::EVMVersion _evmVersion)
{ {
return _evmVersion >= EVMVersion::tangerineWhistle() ? 5000 : 0; return _evmVersion >= langutil::EVMVersion::tangerineWhistle() ? 5000 : 0;
} }
static unsigned const selfdestructRefundGas = 24000; static unsigned const selfdestructRefundGas = 24000;
static unsigned const memoryGas = 3; static unsigned const memoryGas = 3;
@ -122,7 +122,7 @@ public:
}; };
/// Constructs a new gas meter given the current state. /// Constructs a new gas meter given the current state.
GasMeter(std::shared_ptr<KnownState> const& _state, solidity::EVMVersion _evmVersion, u256 const& _largestMemoryAccess = 0): GasMeter(std::shared_ptr<KnownState> const& _state, langutil::EVMVersion _evmVersion, u256 const& _largestMemoryAccess = 0):
m_state(_state), m_evmVersion(_evmVersion), m_largestMemoryAccess(_largestMemoryAccess) {} m_state(_state), m_evmVersion(_evmVersion), m_largestMemoryAccess(_largestMemoryAccess) {}
/// @returns an upper bound on the gas consumed by the given instruction and updates /// @returns an upper bound on the gas consumed by the given instruction and updates
@ -152,7 +152,7 @@ private:
GasConsumption memoryGas(int _stackPosOffset, int _stackPosSize); GasConsumption memoryGas(int _stackPosOffset, int _stackPosSize);
std::shared_ptr<KnownState> m_state; std::shared_ptr<KnownState> m_state;
EVMVersion m_evmVersion; langutil::EVMVersion m_evmVersion;
/// Largest point where memory was accessed since the creation of this object. /// Largest point where memory was accessed since the creation of this object.
u256 m_largestMemoryAccess; u256 m_largestMemoryAccess;
}; };

View File

@ -27,7 +27,7 @@ using namespace std;
using namespace dev; using namespace dev;
using namespace dev::eth; using namespace dev::eth;
PathGasMeter::PathGasMeter(AssemblyItems const& _items, solidity::EVMVersion _evmVersion): PathGasMeter::PathGasMeter(AssemblyItems const& _items, langutil::EVMVersion _evmVersion):
m_items(_items), m_evmVersion(_evmVersion) m_items(_items), m_evmVersion(_evmVersion)
{ {
for (size_t i = 0; i < m_items.size(); ++i) for (size_t i = 0; i < m_items.size(); ++i)

View File

@ -53,13 +53,13 @@ struct GasPath
class PathGasMeter class PathGasMeter
{ {
public: public:
explicit PathGasMeter(AssemblyItems const& _items, solidity::EVMVersion _evmVersion); explicit PathGasMeter(AssemblyItems const& _items, langutil::EVMVersion _evmVersion);
GasMeter::GasConsumption estimateMax(size_t _startIndex, std::shared_ptr<KnownState> const& _state); GasMeter::GasConsumption estimateMax(size_t _startIndex, std::shared_ptr<KnownState> const& _state);
static GasMeter::GasConsumption estimateMax( static GasMeter::GasConsumption estimateMax(
AssemblyItems const& _items, AssemblyItems const& _items,
solidity::EVMVersion _evmVersion, langutil::EVMVersion _evmVersion,
size_t _startIndex, size_t _startIndex,
std::shared_ptr<KnownState> const& _state std::shared_ptr<KnownState> const& _state
) )
@ -81,7 +81,7 @@ private:
std::map<size_t, GasMeter::GasConsumption> m_highestGasUsagePerJumpdest; std::map<size_t, GasMeter::GasConsumption> m_highestGasUsagePerJumpdest;
std::map<u256, size_t> m_tagPositions; std::map<u256, size_t> m_tagPositions;
AssemblyItems const& m_items; AssemblyItems const& m_items;
solidity::EVMVersion m_evmVersion; langutil::EVMVersion m_evmVersion;
}; };
} }

View File

@ -25,9 +25,7 @@
#include <boost/optional.hpp> #include <boost/optional.hpp>
#include <boost/operators.hpp> #include <boost/operators.hpp>
namespace dev namespace langutil
{
namespace solidity
{ {
/** /**
@ -91,4 +89,3 @@ private:
} }
}

View File

@ -48,7 +48,7 @@ class TypeChecker: private ASTConstVisitor
{ {
public: public:
/// @param _errorReporter provides the error logging functionality. /// @param _errorReporter provides the error logging functionality.
TypeChecker(EVMVersion _evmVersion, langutil::ErrorReporter& _errorReporter): TypeChecker(langutil::EVMVersion _evmVersion, langutil::ErrorReporter& _errorReporter):
m_evmVersion(_evmVersion), m_evmVersion(_evmVersion),
m_errorReporter(_errorReporter) m_errorReporter(_errorReporter)
{} {}
@ -156,7 +156,7 @@ private:
ContractDefinition const* m_scope = nullptr; ContractDefinition const* m_scope = nullptr;
EVMVersion m_evmVersion; langutil::EVMVersion m_evmVersion;
/// Flag indicating whether we are currently inside an EmitStatement. /// Flag indicating whether we are currently inside an EmitStatement.
bool m_insideEmitStatement = false; bool m_insideEmitStatement = false;

View File

@ -50,7 +50,7 @@ using TypePointers = std::vector<TypePointer>;
class ABIFunctions class ABIFunctions
{ {
public: public:
explicit ABIFunctions(EVMVersion _evmVersion = EVMVersion{}) : m_evmVersion(_evmVersion) {} explicit ABIFunctions(langutil::EVMVersion _evmVersion = langutil::EVMVersion{}) : m_evmVersion(_evmVersion) {}
/// @returns name of an assembly function to ABI-encode values of @a _givenTypes /// @returns name of an assembly function to ABI-encode values of @a _givenTypes
/// into memory, converting the types to @a _targetTypes on the fly. /// into memory, converting the types to @a _targetTypes on the fly.
@ -286,7 +286,7 @@ private:
/// Map from function name to code for a multi-use function. /// Map from function name to code for a multi-use function.
std::map<std::string, std::string> m_requestedFunctions; std::map<std::string, std::string> m_requestedFunctions;
std::set<std::string> m_externallyUsedFunctions; std::set<std::string> m_externallyUsedFunctions;
EVMVersion m_evmVersion; langutil::EVMVersion m_evmVersion;
}; };
} }

View File

@ -34,7 +34,7 @@ namespace solidity {
class Compiler class Compiler
{ {
public: public:
explicit Compiler(EVMVersion _evmVersion = EVMVersion{}, bool _optimize = false, unsigned _runs = 200): explicit Compiler(langutil::EVMVersion _evmVersion = langutil::EVMVersion{}, bool _optimize = false, unsigned _runs = 200):
m_optimize(_optimize), m_optimize(_optimize),
m_optimizeRuns(_runs), m_optimizeRuns(_runs),
m_runtimeContext(_evmVersion), m_runtimeContext(_evmVersion),

View File

@ -50,7 +50,7 @@ class Compiler;
class CompilerContext class CompilerContext
{ {
public: public:
explicit CompilerContext(EVMVersion _evmVersion = EVMVersion{}, CompilerContext* _runtimeContext = nullptr): explicit CompilerContext(langutil::EVMVersion _evmVersion = langutil::EVMVersion{}, CompilerContext* _runtimeContext = nullptr):
m_asm(std::make_shared<eth::Assembly>()), m_asm(std::make_shared<eth::Assembly>()),
m_evmVersion(_evmVersion), m_evmVersion(_evmVersion),
m_runtimeContext(_runtimeContext), m_runtimeContext(_runtimeContext),
@ -60,7 +60,7 @@ public:
m_runtimeSub = size_t(m_asm->newSub(m_runtimeContext->m_asm).data()); m_runtimeSub = size_t(m_asm->newSub(m_runtimeContext->m_asm).data());
} }
EVMVersion const& evmVersion() const { return m_evmVersion; } langutil::EVMVersion const& evmVersion() const { return m_evmVersion; }
/// Update currently enabled set of experimental features. /// Update currently enabled set of experimental features.
void setExperimentalFeatures(std::set<ExperimentalFeature> const& _features) { m_experimentalFeatures = _features; } void setExperimentalFeatures(std::set<ExperimentalFeature> const& _features) { m_experimentalFeatures = _features; }
@ -305,7 +305,7 @@ private:
eth::AssemblyPointer m_asm; eth::AssemblyPointer m_asm;
/// Version of the EVM to compile against. /// Version of the EVM to compile against.
EVMVersion m_evmVersion; langutil::EVMVersion m_evmVersion;
/// Activated experimental features. /// Activated experimental features.
std::set<ExperimentalFeature> m_experimentalFeatures; std::set<ExperimentalFeature> m_experimentalFeatures;
/// Other already compiled contracts to be used in contract creation calls. /// Other already compiled contracts to be used in contract creation calls.

View File

@ -91,7 +91,7 @@ void CompilerStack::setRemappings(vector<Remapping> const& _remappings)
m_remappings = _remappings; m_remappings = _remappings;
} }
void CompilerStack::setEVMVersion(EVMVersion _version) void CompilerStack::setEVMVersion(langutil::EVMVersion _version)
{ {
solAssert(m_stackState < State::ParsingSuccessful, "Set EVM version after parsing."); solAssert(m_stackState < State::ParsingSuccessful, "Set EVM version after parsing.");
m_evmVersion = _version; m_evmVersion = _version;
@ -113,7 +113,7 @@ void CompilerStack::reset(bool _keepSources)
m_smtlib2Responses.clear(); m_smtlib2Responses.clear();
m_unhandledSMTLib2Queries.clear(); m_unhandledSMTLib2Queries.clear();
m_libraries.clear(); m_libraries.clear();
m_evmVersion = EVMVersion(); m_evmVersion = langutil::EVMVersion();
m_optimize = false; m_optimize = false;
m_optimizeRuns = 200; m_optimizeRuns = 200;
m_globalContext.reset(); m_globalContext.reset();

View File

@ -136,7 +136,7 @@ public:
/// Set the EVM version used before running compile. /// Set the EVM version used before running compile.
/// When called without an argument it will revert to the default version. /// When called without an argument it will revert to the default version.
void setEVMVersion(EVMVersion _version = EVMVersion{}); void setEVMVersion(langutil::EVMVersion _version = langutil::EVMVersion{});
/// Sets the list of requested contract names. If empty, no filtering is performed and every contract /// Sets the list of requested contract names. If empty, no filtering is performed and every contract
/// found in the supplied sources is compiled. Names are cleared iff @a _contractNames is missing. /// found in the supplied sources is compiled. Names are cleared iff @a _contractNames is missing.
@ -348,7 +348,7 @@ private:
ReadCallback::Callback m_readFile; ReadCallback::Callback m_readFile;
bool m_optimize = false; bool m_optimize = false;
unsigned m_optimizeRuns = 200; unsigned m_optimizeRuns = 200;
EVMVersion m_evmVersion; langutil::EVMVersion m_evmVersion;
std::set<std::string> m_requestedContractNames; std::set<std::string> m_requestedContractNames;
std::map<std::string, h160> m_libraries; std::map<std::string, h160> m_libraries;
/// list of path prefix remappings, e.g. mylibrary: github.com/ethereum = /usr/local/ethereum /// list of path prefix remappings, e.g. mylibrary: github.com/ethereum = /usr/local/ethereum

View File

@ -47,7 +47,7 @@ public:
using ASTGasConsumptionSelfAccumulated = using ASTGasConsumptionSelfAccumulated =
std::map<ASTNode const*, std::array<GasConsumption, 2>>; std::map<ASTNode const*, std::array<GasConsumption, 2>>;
explicit GasEstimator(EVMVersion _evmVersion): m_evmVersion(_evmVersion) {} explicit GasEstimator(langutil::EVMVersion _evmVersion): m_evmVersion(_evmVersion) {}
/// Estimates the gas consumption for every assembly item in the given assembly and stores /// Estimates the gas consumption for every assembly item in the given assembly and stores
/// it by source location. /// it by source location.
@ -84,7 +84,7 @@ public:
private: private:
/// @returns the set of AST nodes which are the finest nodes at their location. /// @returns the set of AST nodes which are the finest nodes at their location.
static std::set<ASTNode const*> finestNodesAtLocation(std::vector<ASTNode const*> const& _roots); static std::set<ASTNode const*> finestNodesAtLocation(std::vector<ASTNode const*> const& _roots);
EVMVersion m_evmVersion; langutil::EVMVersion m_evmVersion;
}; };
} }

View File

@ -490,7 +490,7 @@ Json::Value StandardCompiler::compileInternal(Json::Value const& _input)
{ {
if (!settings["evmVersion"].isString()) if (!settings["evmVersion"].isString())
return formatFatalError("JSONError", "evmVersion must be a string."); return formatFatalError("JSONError", "evmVersion must be a string.");
boost::optional<EVMVersion> version = EVMVersion::fromString(settings["evmVersion"].asString()); boost::optional<langutil::EVMVersion> version = langutil::EVMVersion::fromString(settings["evmVersion"].asString());
if (!version) if (!version)
return formatFatalError("JSONError", "Invalid EVM version requested."); return formatFatalError("JSONError", "Invalid EVM version requested.");
m_compilerStack.setEVMVersion(*version); m_compilerStack.setEVMVersion(*version);

View File

@ -121,7 +121,7 @@ private:
std::set<Scope::Variable const*> m_activeVariables; std::set<Scope::Variable const*> m_activeVariables;
AsmAnalysisInfo& m_info; AsmAnalysisInfo& m_info;
langutil::ErrorReporter& m_errorReporter; langutil::ErrorReporter& m_errorReporter;
dev::solidity::EVMVersion m_evmVersion; langutil::EVMVersion m_evmVersion;
std::shared_ptr<Dialect> m_dialect; std::shared_ptr<Dialect> m_dialect;
boost::optional<langutil::Error::Type> m_errorTypeForLoose; boost::optional<langutil::Error::Type> m_errorTypeForLoose;
}; };

View File

@ -58,7 +58,7 @@ public:
enum class Language { Yul, Assembly, StrictAssembly }; enum class Language { Yul, Assembly, StrictAssembly };
enum class Machine { EVM, EVM15, eWasm }; enum class Machine { EVM, EVM15, eWasm };
explicit AssemblyStack(dev::solidity::EVMVersion _evmVersion = dev::solidity::EVMVersion(), Language _language = Language::Assembly): explicit AssemblyStack(langutil::EVMVersion _evmVersion = langutil::EVMVersion(), Language _language = Language::Assembly):
m_language(_language), m_evmVersion(_evmVersion), m_errorReporter(m_errors) m_language(_language), m_evmVersion(_evmVersion), m_errorReporter(m_errors)
{} {}
@ -94,7 +94,7 @@ private:
void optimize(yul::Object& _object); void optimize(yul::Object& _object);
Language m_language = Language::Assembly; Language m_language = Language::Assembly;
dev::solidity::EVMVersion m_evmVersion; langutil::EVMVersion m_evmVersion;
std::shared_ptr<langutil::Scanner> m_scanner; std::shared_ptr<langutil::Scanner> m_scanner;

View File

@ -177,7 +177,7 @@ void CodeGenerator::assemble(
Block const& _parsedData, Block const& _parsedData,
AsmAnalysisInfo& _analysisInfo, AsmAnalysisInfo& _analysisInfo,
eth::Assembly& _assembly, eth::Assembly& _assembly,
dev::solidity::EVMVersion _evmVersion, langutil::EVMVersion _evmVersion,
ExternalIdentifierAccess const& _identifierAccess, ExternalIdentifierAccess const& _identifierAccess,
bool _useNamedLabelsForFunctions, bool _useNamedLabelsForFunctions,
bool _optimize bool _optimize

View File

@ -79,7 +79,7 @@ public:
Block const& _parsedData, Block const& _parsedData,
AsmAnalysisInfo& _analysisInfo, AsmAnalysisInfo& _analysisInfo,
dev::eth::Assembly& _assembly, dev::eth::Assembly& _assembly,
dev::solidity::EVMVersion _evmVersion, langutil::EVMVersion _evmVersion,
ExternalIdentifierAccess const& _identifierAccess = ExternalIdentifierAccess(), ExternalIdentifierAccess const& _identifierAccess = ExternalIdentifierAccess(),
bool _useNamedLabelsForFunctions = false, bool _useNamedLabelsForFunctions = false,
bool _optimize = false bool _optimize = false

View File

@ -37,7 +37,7 @@ using namespace yul;
using namespace dev::solidity; using namespace dev::solidity;
EVMDialect::EVMDialect(AsmFlavour _flavour, bool _objectAccess, EVMVersion _evmVersion): EVMDialect::EVMDialect(AsmFlavour _flavour, bool _objectAccess, langutil::EVMVersion _evmVersion):
Dialect{_flavour}, m_objectAccess(_objectAccess), m_evmVersion(_evmVersion) Dialect{_flavour}, m_objectAccess(_objectAccess), m_evmVersion(_evmVersion)
{ {
// The EVM instructions will be moved to builtins at some point. // The EVM instructions will be moved to builtins at some point.
@ -91,22 +91,22 @@ BuiltinFunctionForEVM const* EVMDialect::builtin(YulString _name) const
return nullptr; return nullptr;
} }
shared_ptr<EVMDialect> EVMDialect::looseAssemblyForEVM(EVMVersion _version) shared_ptr<EVMDialect> EVMDialect::looseAssemblyForEVM(langutil::EVMVersion _version)
{ {
return make_shared<EVMDialect>(AsmFlavour::Loose, false, _version); return make_shared<EVMDialect>(AsmFlavour::Loose, false, _version);
} }
shared_ptr<EVMDialect> EVMDialect::strictAssemblyForEVM(EVMVersion _version) shared_ptr<EVMDialect> EVMDialect::strictAssemblyForEVM(langutil::EVMVersion _version)
{ {
return make_shared<EVMDialect>(AsmFlavour::Strict, false, _version); return make_shared<EVMDialect>(AsmFlavour::Strict, false, _version);
} }
shared_ptr<EVMDialect> EVMDialect::strictAssemblyForEVMObjects(EVMVersion _version) shared_ptr<EVMDialect> EVMDialect::strictAssemblyForEVMObjects(langutil::EVMVersion _version)
{ {
return make_shared<EVMDialect>(AsmFlavour::Strict, true, _version); return make_shared<EVMDialect>(AsmFlavour::Strict, true, _version);
} }
shared_ptr<yul::EVMDialect> EVMDialect::yulForEVM(EVMVersion _version) shared_ptr<yul::EVMDialect> EVMDialect::yulForEVM(langutil::EVMVersion _version)
{ {
return make_shared<EVMDialect>(AsmFlavour::Yul, false, _version); return make_shared<EVMDialect>(AsmFlavour::Yul, false, _version);
} }

View File

@ -50,17 +50,17 @@ struct BuiltinFunctionForEVM: BuiltinFunction
*/ */
struct EVMDialect: public Dialect struct EVMDialect: public Dialect
{ {
EVMDialect(AsmFlavour _flavour, bool _objectAccess, dev::solidity::EVMVersion _evmVersion); EVMDialect(AsmFlavour _flavour, bool _objectAccess, langutil::EVMVersion _evmVersion);
/// @returns the builtin function of the given name or a nullptr if it is not a builtin function. /// @returns the builtin function of the given name or a nullptr if it is not a builtin function.
BuiltinFunctionForEVM const* builtin(YulString _name) const override; BuiltinFunctionForEVM const* builtin(YulString _name) const override;
static std::shared_ptr<EVMDialect> looseAssemblyForEVM(dev::solidity::EVMVersion _version); static std::shared_ptr<EVMDialect> looseAssemblyForEVM(langutil::EVMVersion _version);
static std::shared_ptr<EVMDialect> strictAssemblyForEVM(dev::solidity::EVMVersion _version); static std::shared_ptr<EVMDialect> strictAssemblyForEVM(langutil::EVMVersion _version);
static std::shared_ptr<EVMDialect> strictAssemblyForEVMObjects(dev::solidity::EVMVersion _version); static std::shared_ptr<EVMDialect> strictAssemblyForEVMObjects(langutil::EVMVersion _version);
static std::shared_ptr<EVMDialect> yulForEVM(dev::solidity::EVMVersion _version); static std::shared_ptr<EVMDialect> yulForEVM(langutil::EVMVersion _version);
dev::solidity::EVMVersion evmVersion() const { return m_evmVersion; } langutil::EVMVersion evmVersion() const { return m_evmVersion; }
bool providesObjectAccess() const { return m_objectAccess; } bool providesObjectAccess() const { return m_objectAccess; }
@ -80,7 +80,7 @@ protected:
); );
bool m_objectAccess; bool m_objectAccess;
dev::solidity::EVMVersion m_evmVersion; langutil::EVMVersion m_evmVersion;
Object const* m_currentObject = nullptr; Object const* m_currentObject = nullptr;
/// Mapping from named objects to abstract assembly sub IDs. /// Mapping from named objects to abstract assembly sub IDs.
std::map<YulString, AbstractAssembly::SubID> m_subIDs; std::map<YulString, AbstractAssembly::SubID> m_subIDs;

View File

@ -830,7 +830,7 @@ bool CommandLineInterface::processInput()
if (m_args.count(g_strEVMVersion)) if (m_args.count(g_strEVMVersion))
{ {
string versionOptionStr = m_args[g_strEVMVersion].as<string>(); string versionOptionStr = m_args[g_strEVMVersion].as<string>();
boost::optional<EVMVersion> versionOption = EVMVersion::fromString(versionOptionStr); boost::optional<langutil::EVMVersion> versionOption = langutil::EVMVersion::fromString(versionOptionStr);
if (!versionOption) if (!versionOption)
{ {
serr() << "Invalid option for --evm-version: " << versionOptionStr << endl; serr() << "Invalid option for --evm-version: " << versionOptionStr << endl;

View File

@ -108,7 +108,7 @@ private:
/// Solidity compiler stack /// Solidity compiler stack
std::unique_ptr<dev::solidity::CompilerStack> m_compiler; std::unique_ptr<dev::solidity::CompilerStack> m_compiler;
/// EVM version to use /// EVM version to use
EVMVersion m_evmVersion; langutil::EVMVersion m_evmVersion;
/// Whether or not to colorize diagnostics output. /// Whether or not to colorize diagnostics output.
bool m_coloredOutput = true; bool m_coloredOutput = true;
}; };

View File

@ -239,7 +239,7 @@ protected:
bytes data; bytes data;
}; };
solidity::EVMVersion m_evmVersion; langutil::EVMVersion m_evmVersion;
unsigned m_optimizeRuns = 200; unsigned m_optimizeRuns = 200;
bool m_optimize = false; bool m_optimize = false;
bool m_showMessages = false; bool m_showMessages = false;

View File

@ -59,16 +59,16 @@ Options::Options()
parse(suite.argc, suite.argv); parse(suite.argc, suite.argv);
} }
dev::solidity::EVMVersion Options::evmVersion() const langutil::EVMVersion Options::evmVersion() const
{ {
if (!evmVersionString.empty()) if (!evmVersionString.empty())
{ {
// We do this check as opposed to in the constructor because the BOOST_REQUIRE // We do this check as opposed to in the constructor because the BOOST_REQUIRE
// macros cannot yet be used in the constructor. // macros cannot yet be used in the constructor.
auto version = solidity::EVMVersion::fromString(evmVersionString); auto version = langutil::EVMVersion::fromString(evmVersionString);
BOOST_REQUIRE_MESSAGE(version, "Invalid EVM version: " + evmVersionString); BOOST_REQUIRE_MESSAGE(version, "Invalid EVM version: " + evmVersionString);
return *version; return *version;
} }
else else
return dev::solidity::EVMVersion(); return langutil::EVMVersion();
} }

View File

@ -37,7 +37,7 @@ struct Options: CommonOptions
bool showMessages = false; bool showMessages = false;
bool useABIEncoderV2 = false; bool useABIEncoderV2 = false;
solidity::EVMVersion evmVersion() const; langutil::EVMVersion evmVersion() const;
static Options const& get(); static Options const& get();

View File

@ -237,16 +237,16 @@ string RPCSession::personal_newAccount(string const& _password)
void RPCSession::test_setChainParams(vector<string> const& _accounts) void RPCSession::test_setChainParams(vector<string> const& _accounts)
{ {
string forks; string forks;
if (test::Options::get().evmVersion() >= solidity::EVMVersion::tangerineWhistle()) if (test::Options::get().evmVersion() >= langutil::EVMVersion::tangerineWhistle())
forks += "\"EIP150ForkBlock\": \"0x00\",\n"; forks += "\"EIP150ForkBlock\": \"0x00\",\n";
if (test::Options::get().evmVersion() >= solidity::EVMVersion::spuriousDragon()) if (test::Options::get().evmVersion() >= langutil::EVMVersion::spuriousDragon())
forks += "\"EIP158ForkBlock\": \"0x00\",\n"; forks += "\"EIP158ForkBlock\": \"0x00\",\n";
if (test::Options::get().evmVersion() >= solidity::EVMVersion::byzantium()) if (test::Options::get().evmVersion() >= langutil::EVMVersion::byzantium())
{ {
forks += "\"byzantiumForkBlock\": \"0x00\",\n"; forks += "\"byzantiumForkBlock\": \"0x00\",\n";
m_receiptHasStatusField = true; m_receiptHasStatusField = true;
} }
if (test::Options::get().evmVersion() >= solidity::EVMVersion::constantinople()) if (test::Options::get().evmVersion() >= langutil::EVMVersion::constantinople())
forks += "\"constantinopleForkBlock\": \"0x00\",\n"; forks += "\"constantinopleForkBlock\": \"0x00\",\n";
static string const c_configString = R"( static string const c_configString = R"(
{ {

View File

@ -762,7 +762,7 @@ BOOST_AUTO_TEST_CASE(complex_struct)
BOOST_AUTO_TEST_CASE(return_dynamic_types_cross_call_simple) BOOST_AUTO_TEST_CASE(return_dynamic_types_cross_call_simple)
{ {
if (m_evmVersion == EVMVersion::homestead()) if (m_evmVersion == langutil::EVMVersion::homestead())
return; return;
string sourceCode = R"( string sourceCode = R"(
@ -783,7 +783,7 @@ BOOST_AUTO_TEST_CASE(return_dynamic_types_cross_call_simple)
BOOST_AUTO_TEST_CASE(return_dynamic_types_cross_call_advanced) BOOST_AUTO_TEST_CASE(return_dynamic_types_cross_call_advanced)
{ {
if (m_evmVersion == EVMVersion::homestead()) if (m_evmVersion == langutil::EVMVersion::homestead())
return; return;
string sourceCode = R"( string sourceCode = R"(
@ -830,7 +830,7 @@ BOOST_AUTO_TEST_CASE(return_dynamic_types_cross_call_out_of_range)
)"; )";
BOTH_ENCODERS( BOTH_ENCODERS(
compileAndRun(sourceCode, 0, "C"); compileAndRun(sourceCode, 0, "C");
if (m_evmVersion == EVMVersion::homestead()) if (m_evmVersion == langutil::EVMVersion::homestead())
{ {
ABI_CHECK(callContractFunction("f(uint256)", 0x60), encodeArgs(true)); ABI_CHECK(callContractFunction("f(uint256)", 0x60), encodeArgs(true));
ABI_CHECK(callContractFunction("f(uint256)", 0x7f), encodeArgs(true)); ABI_CHECK(callContractFunction("f(uint256)", 0x7f), encodeArgs(true));

View File

@ -3080,7 +3080,7 @@ BOOST_AUTO_TEST_CASE(gasprice)
BOOST_AUTO_TEST_CASE(blockhash) BOOST_AUTO_TEST_CASE(blockhash)
{ {
// depending on the aleth version, this test only works for pre-constantinople // depending on the aleth version, this test only works for pre-constantinople
if (Options::get().evmVersion() < EVMVersion::constantinople()) if (Options::get().evmVersion() < langutil::EVMVersion::constantinople())
{ {
char const* sourceCode = R"( char const* sourceCode = R"(
contract C { contract C {

View File

@ -114,7 +114,7 @@ void FuzzerUtil::testConstantOptimizer(string const& _input, bool _quiet)
ConstantOptimisationMethod::optimiseConstants( ConstantOptimisationMethod::optimiseConstants(
isCreation, isCreation,
runs, runs,
EVMVersion{}, langutil::EVMVersion{},
tmp tmp
); );
} }