Make Dialect const.

This commit is contained in:
chriseth
2019-05-16 21:51:54 +02:00
parent 9a387380b3
commit 570db164c9
27 changed files with 51 additions and 50 deletions
+1 -1
View File
@@ -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());
}
+6 -6
View File
@@ -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);
+1 -1
View File
@@ -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
{
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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;
};
+1 -1
View File
@@ -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
{