mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Make Dialect const.
This commit is contained in:
@@ -43,7 +43,7 @@ using namespace yul;
|
||||
|
||||
namespace
|
||||
{
|
||||
shared_ptr<Dialect> defaultDialect(bool _yul)
|
||||
shared_ptr<Dialect const> defaultDialect(bool _yul)
|
||||
{
|
||||
return _yul ? yul::Dialect::yul() : yul::EVMDialect::strictAssemblyForEVM(dev::test::Options::get().evmVersion());
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace test
|
||||
namespace
|
||||
{
|
||||
|
||||
bool parse(string const& _source, std::shared_ptr<Dialect> _dialect, ErrorReporter& errorReporter)
|
||||
bool parse(string const& _source, std::shared_ptr<Dialect const> _dialect, ErrorReporter& errorReporter)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -73,7 +73,7 @@ bool parse(string const& _source, std::shared_ptr<Dialect> _dialect, ErrorReport
|
||||
return false;
|
||||
}
|
||||
|
||||
boost::optional<Error> parseAndReturnFirstError(string const& _source, shared_ptr<Dialect> _dialect, bool _allowWarnings = true)
|
||||
boost::optional<Error> parseAndReturnFirstError(string const& _source, shared_ptr<Dialect const> _dialect, bool _allowWarnings = true)
|
||||
{
|
||||
ErrorList errors;
|
||||
ErrorReporter errorReporter(errors);
|
||||
@@ -98,12 +98,12 @@ boost::optional<Error> parseAndReturnFirstError(string const& _source, shared_pt
|
||||
return {};
|
||||
}
|
||||
|
||||
bool successParse(std::string const& _source, shared_ptr<Dialect> _dialect = Dialect::yul(), bool _allowWarnings = true)
|
||||
bool successParse(std::string const& _source, shared_ptr<Dialect const> _dialect = Dialect::yul(), bool _allowWarnings = true)
|
||||
{
|
||||
return !parseAndReturnFirstError(_source, _dialect, _allowWarnings);
|
||||
}
|
||||
|
||||
Error expectError(std::string const& _source, shared_ptr<Dialect> _dialect = Dialect::yul(), bool _allowWarnings = false)
|
||||
Error expectError(std::string const& _source, shared_ptr<Dialect const> _dialect = Dialect::yul(), bool _allowWarnings = false)
|
||||
{
|
||||
|
||||
auto error = parseAndReturnFirstError(_source, _dialect, _allowWarnings);
|
||||
@@ -548,7 +548,7 @@ BOOST_AUTO_TEST_CASE(builtins_parser)
|
||||
BuiltinFunction f;
|
||||
};
|
||||
|
||||
shared_ptr<Dialect> dialect = make_shared<SimpleDialect>();
|
||||
shared_ptr<Dialect const> dialect = make_shared<SimpleDialect>();
|
||||
CHECK_ERROR_DIALECT("{ let builtin := 6 }", ParserError, "Cannot use builtin function name \"builtin\" as identifier name.", dialect);
|
||||
CHECK_ERROR_DIALECT("{ function builtin() {} }", ParserError, "Cannot use builtin function name \"builtin\" as identifier name.", dialect);
|
||||
CHECK_ERROR_DIALECT("{ builtin := 6 }", ParserError, "Cannot assign to builtin function \"builtin\".", dialect);
|
||||
@@ -567,7 +567,7 @@ BOOST_AUTO_TEST_CASE(builtins_analysis)
|
||||
BuiltinFunction f{"builtin"_yulstring, vector<Type>(2), vector<Type>(3), false, false};
|
||||
};
|
||||
|
||||
shared_ptr<Dialect> dialect = make_shared<SimpleDialect>();
|
||||
shared_ptr<Dialect const> dialect = make_shared<SimpleDialect>();
|
||||
BOOST_CHECK(successParse("{ let a, b, c := builtin(1, 2) }", dialect));
|
||||
CHECK_ERROR_DIALECT("{ let a, b, c := builtin(1) }", TypeError, "Function expects 2 arguments but got 1", dialect);
|
||||
CHECK_ERROR_DIALECT("{ let a, b := builtin(1, 2) }", DeclarationError, "Variable count mismatch: 2 variables and 3 values.", dialect);
|
||||
|
||||
@@ -132,7 +132,7 @@ string YulInterpreterTest::interpret()
|
||||
state.maxTraceSize = 10000;
|
||||
state.maxSteps = 10000;
|
||||
state.maxMemSize = 0x20000000;
|
||||
shared_ptr<Dialect> dialect(EVMDialect::strictAssemblyForEVMObjects(langutil::EVMVersion{}));
|
||||
shared_ptr<Dialect const> dialect(EVMDialect::strictAssemblyForEVMObjects(langutil::EVMVersion{}));
|
||||
Interpreter interpreter(state, *dialect);
|
||||
try
|
||||
{
|
||||
|
||||
@@ -66,7 +66,7 @@ private:
|
||||
std::string m_optimizerStep;
|
||||
std::string m_expectation;
|
||||
|
||||
std::shared_ptr<Dialect> m_dialect;
|
||||
std::shared_ptr<Dialect const> m_dialect;
|
||||
std::shared_ptr<Block> m_ast;
|
||||
std::shared_ptr<AsmAnalysisInfo> m_analysisInfo;
|
||||
std::string m_obtainedResult;
|
||||
|
||||
@@ -215,7 +215,7 @@ public:
|
||||
private:
|
||||
ErrorList m_errors;
|
||||
shared_ptr<yul::Block> m_ast;
|
||||
shared_ptr<Dialect> m_dialect{EVMDialect::strictAssemblyForEVMObjects(EVMVersion{})};
|
||||
shared_ptr<Dialect const> m_dialect{EVMDialect::strictAssemblyForEVMObjects(EVMVersion{})};
|
||||
shared_ptr<AsmAnalysisInfo> m_analysisInfo;
|
||||
shared_ptr<NameDispenser> m_nameDispenser;
|
||||
};
|
||||
|
||||
@@ -88,7 +88,7 @@ void interpret(string const& _source)
|
||||
InterpreterState state;
|
||||
state.maxTraceSize = 10000;
|
||||
state.maxMemSize = 0x20000000;
|
||||
shared_ptr<Dialect> dialect(EVMDialect::strictAssemblyForEVMObjects(langutil::EVMVersion{}));
|
||||
shared_ptr<Dialect const> dialect(EVMDialect::strictAssemblyForEVMObjects(langutil::EVMVersion{}));
|
||||
Interpreter interpreter(state, *dialect);
|
||||
try
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user