mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Make Dialect const.
This commit is contained in:
parent
9a387380b3
commit
570db164c9
@ -70,7 +70,7 @@ bool AsmAnalyzer::analyze(Block const& _block)
|
|||||||
}
|
}
|
||||||
|
|
||||||
AsmAnalysisInfo AsmAnalyzer::analyzeStrictAssertCorrect(
|
AsmAnalysisInfo AsmAnalyzer::analyzeStrictAssertCorrect(
|
||||||
shared_ptr<Dialect> _dialect,
|
shared_ptr<Dialect const> _dialect,
|
||||||
Block const& _ast
|
Block const& _ast
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
@ -60,7 +60,7 @@ public:
|
|||||||
AsmAnalysisInfo& _analysisInfo,
|
AsmAnalysisInfo& _analysisInfo,
|
||||||
langutil::ErrorReporter& _errorReporter,
|
langutil::ErrorReporter& _errorReporter,
|
||||||
boost::optional<langutil::Error::Type> _errorTypeForLoose,
|
boost::optional<langutil::Error::Type> _errorTypeForLoose,
|
||||||
std::shared_ptr<Dialect> _dialect,
|
std::shared_ptr<Dialect const> _dialect,
|
||||||
ExternalIdentifierAccess::Resolver const& _resolver = ExternalIdentifierAccess::Resolver()
|
ExternalIdentifierAccess::Resolver const& _resolver = ExternalIdentifierAccess::Resolver()
|
||||||
):
|
):
|
||||||
m_resolver(_resolver),
|
m_resolver(_resolver),
|
||||||
@ -76,7 +76,7 @@ public:
|
|||||||
bool analyze(Block const& _block);
|
bool analyze(Block const& _block);
|
||||||
|
|
||||||
static AsmAnalysisInfo analyzeStrictAssertCorrect(
|
static AsmAnalysisInfo analyzeStrictAssertCorrect(
|
||||||
std::shared_ptr<Dialect> _dialect,
|
std::shared_ptr<Dialect const> _dialect,
|
||||||
Block const& _ast
|
Block const& _ast
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ private:
|
|||||||
AsmAnalysisInfo& m_info;
|
AsmAnalysisInfo& m_info;
|
||||||
langutil::ErrorReporter& m_errorReporter;
|
langutil::ErrorReporter& m_errorReporter;
|
||||||
langutil::EVMVersion m_evmVersion;
|
langutil::EVMVersion m_evmVersion;
|
||||||
std::shared_ptr<Dialect> m_dialect;
|
std::shared_ptr<Dialect const> m_dialect;
|
||||||
boost::optional<langutil::Error::Type> m_errorTypeForLoose;
|
boost::optional<langutil::Error::Type> m_errorTypeForLoose;
|
||||||
ForLoop const* m_currentForLoop = nullptr;
|
ForLoop const* m_currentForLoop = nullptr;
|
||||||
};
|
};
|
||||||
|
@ -44,7 +44,7 @@ public:
|
|||||||
None, ForLoopPre, ForLoopPost, ForLoopBody
|
None, ForLoopPre, ForLoopPost, ForLoopBody
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit Parser(langutil::ErrorReporter& _errorReporter, std::shared_ptr<Dialect> _dialect):
|
explicit Parser(langutil::ErrorReporter& _errorReporter, std::shared_ptr<Dialect const> _dialect):
|
||||||
ParserBase(_errorReporter), m_dialect(std::move(_dialect)) {}
|
ParserBase(_errorReporter), m_dialect(std::move(_dialect)) {}
|
||||||
|
|
||||||
/// Parses an inline assembly block starting with `{` and ending with `}`.
|
/// Parses an inline assembly block starting with `{` and ending with `}`.
|
||||||
@ -97,7 +97,7 @@ protected:
|
|||||||
static bool isValidNumberLiteral(std::string const& _literal);
|
static bool isValidNumberLiteral(std::string const& _literal);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<Dialect> m_dialect;
|
std::shared_ptr<Dialect const> m_dialect;
|
||||||
ForLoopComponent m_currentForLoopComponent = ForLoopComponent::None;
|
ForLoopComponent m_currentForLoopComponent = ForLoopComponent::None;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ using namespace yul;
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
shared_ptr<Dialect> languageToDialect(AssemblyStack::Language _language, EVMVersion _version)
|
shared_ptr<Dialect const> languageToDialect(AssemblyStack::Language _language, EVMVersion _version)
|
||||||
{
|
{
|
||||||
switch (_language)
|
switch (_language)
|
||||||
{
|
{
|
||||||
@ -124,7 +124,7 @@ bool AssemblyStack::analyzeParsed(Object& _object)
|
|||||||
|
|
||||||
void AssemblyStack::compileEVM(AbstractAssembly& _assembly, bool _evm15, bool _optimize) const
|
void AssemblyStack::compileEVM(AbstractAssembly& _assembly, bool _evm15, bool _optimize) const
|
||||||
{
|
{
|
||||||
shared_ptr<EVMDialect> dialect;
|
shared_ptr<EVMDialect const> dialect;
|
||||||
|
|
||||||
if (m_language == Language::Assembly)
|
if (m_language == Language::Assembly)
|
||||||
dialect = EVMDialect::looseAssemblyForEVM(m_evmVersion);
|
dialect = EVMDialect::looseAssemblyForEVM(m_evmVersion);
|
||||||
@ -184,7 +184,7 @@ MachineAssemblyObject AssemblyStack::assemble(Machine _machine) const
|
|||||||
case Machine::eWasm:
|
case Machine::eWasm:
|
||||||
{
|
{
|
||||||
solAssert(m_language == Language::EWasm, "");
|
solAssert(m_language == Language::EWasm, "");
|
||||||
shared_ptr<Dialect> dialect = languageToDialect(m_language, EVMVersion{});
|
shared_ptr<Dialect const> dialect = languageToDialect(m_language, EVMVersion{});
|
||||||
|
|
||||||
MachineAssemblyObject object;
|
MachineAssemblyObject object;
|
||||||
object.assembly = EWasmObjectCompiler::compile(*m_parserResult, *dialect);
|
object.assembly = EWasmObjectCompiler::compile(*m_parserResult, *dialect);
|
||||||
|
@ -33,7 +33,7 @@ using namespace yul;
|
|||||||
using namespace dev;
|
using namespace dev;
|
||||||
|
|
||||||
map<YulString, int> CompilabilityChecker::run(
|
map<YulString, int> CompilabilityChecker::run(
|
||||||
shared_ptr<Dialect> _dialect,
|
shared_ptr<Dialect const> _dialect,
|
||||||
Block const& _ast,
|
Block const& _ast,
|
||||||
bool _optimizeStackAllocation
|
bool _optimizeStackAllocation
|
||||||
)
|
)
|
||||||
@ -44,7 +44,8 @@ map<YulString, int> CompilabilityChecker::run(
|
|||||||
solAssert(_dialect->flavour == AsmFlavour::Strict, "");
|
solAssert(_dialect->flavour == AsmFlavour::Strict, "");
|
||||||
|
|
||||||
solAssert(dynamic_cast<EVMDialect const*>(_dialect.get()), "");
|
solAssert(dynamic_cast<EVMDialect const*>(_dialect.get()), "");
|
||||||
shared_ptr<NoOutputEVMDialect> noOutputDialect = make_shared<NoOutputEVMDialect>(dynamic_pointer_cast<EVMDialect>(_dialect));
|
shared_ptr<NoOutputEVMDialect const> noOutputDialect =
|
||||||
|
make_shared<NoOutputEVMDialect>(dynamic_pointer_cast<EVMDialect const>(_dialect));
|
||||||
BuiltinContext builtinContext;
|
BuiltinContext builtinContext;
|
||||||
|
|
||||||
yul::AsmAnalysisInfo analysisInfo =
|
yul::AsmAnalysisInfo analysisInfo =
|
||||||
|
@ -40,7 +40,7 @@ class CompilabilityChecker
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static std::map<YulString, int> run(
|
static std::map<YulString, int> run(
|
||||||
std::shared_ptr<Dialect> _dialect,
|
std::shared_ptr<Dialect const> _dialect,
|
||||||
Block const& _ast,
|
Block const& _ast,
|
||||||
bool _optimizeStackAllocation
|
bool _optimizeStackAllocation
|
||||||
);
|
);
|
||||||
|
@ -64,7 +64,7 @@ struct Dialect: boost::noncopyable
|
|||||||
Dialect(AsmFlavour _flavour): flavour(_flavour) {}
|
Dialect(AsmFlavour _flavour): flavour(_flavour) {}
|
||||||
virtual ~Dialect() = default;
|
virtual ~Dialect() = default;
|
||||||
|
|
||||||
static std::shared_ptr<Dialect> yul()
|
static std::shared_ptr<Dialect const> yul()
|
||||||
{
|
{
|
||||||
// Will have to add builtins later.
|
// Will have to add builtins later.
|
||||||
return std::make_shared<Dialect>(AsmFlavour::Yul);
|
return std::make_shared<Dialect>(AsmFlavour::Yul);
|
||||||
|
@ -47,7 +47,7 @@ class ObjectParser: public langutil::ParserBase
|
|||||||
public:
|
public:
|
||||||
explicit ObjectParser(
|
explicit ObjectParser(
|
||||||
langutil::ErrorReporter& _errorReporter,
|
langutil::ErrorReporter& _errorReporter,
|
||||||
std::shared_ptr<Dialect> _dialect
|
std::shared_ptr<Dialect const> _dialect
|
||||||
):
|
):
|
||||||
ParserBase(_errorReporter), m_dialect(std::move(_dialect)) {}
|
ParserBase(_errorReporter), m_dialect(std::move(_dialect)) {}
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ private:
|
|||||||
YulString parseUniqueName(Object const* _containingObject);
|
YulString parseUniqueName(Object const* _containingObject);
|
||||||
void addNamedSubObject(Object& _container, YulString _name, std::shared_ptr<ObjectNode> _subObject);
|
void addNamedSubObject(Object& _container, YulString _name, std::shared_ptr<ObjectNode> _subObject);
|
||||||
|
|
||||||
std::shared_ptr<Dialect> m_dialect;
|
std::shared_ptr<Dialect const> m_dialect;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -184,7 +184,7 @@ void CodeGenerator::assemble(
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
EthAssemblyAdapter assemblyAdapter(_assembly);
|
EthAssemblyAdapter assemblyAdapter(_assembly);
|
||||||
shared_ptr<EVMDialect> dialect = EVMDialect::strictAssemblyForEVM(_evmVersion);
|
shared_ptr<EVMDialect const> dialect = EVMDialect::strictAssemblyForEVM(_evmVersion);
|
||||||
BuiltinContext builtinContext;
|
BuiltinContext builtinContext;
|
||||||
CodeTransform transform(
|
CodeTransform transform(
|
||||||
assemblyAdapter,
|
assemblyAdapter,
|
||||||
|
@ -138,22 +138,22 @@ BuiltinFunctionForEVM const* EVMDialect::builtin(YulString _name) const
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_ptr<EVMDialect> EVMDialect::looseAssemblyForEVM(langutil::EVMVersion _version)
|
shared_ptr<EVMDialect const> 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(langutil::EVMVersion _version)
|
shared_ptr<EVMDialect const> 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(langutil::EVMVersion _version)
|
shared_ptr<EVMDialect const> 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(langutil::EVMVersion _version)
|
shared_ptr<EVMDialect const> EVMDialect::yulForEVM(langutil::EVMVersion _version)
|
||||||
{
|
{
|
||||||
return make_shared<EVMDialect>(AsmFlavour::Yul, false, _version);
|
return make_shared<EVMDialect>(AsmFlavour::Yul, false, _version);
|
||||||
}
|
}
|
||||||
|
@ -66,10 +66,10 @@ struct EVMDialect: public Dialect
|
|||||||
/// @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(langutil::EVMVersion _version);
|
static std::shared_ptr<EVMDialect const> looseAssemblyForEVM(langutil::EVMVersion _version);
|
||||||
static std::shared_ptr<EVMDialect> strictAssemblyForEVM(langutil::EVMVersion _version);
|
static std::shared_ptr<EVMDialect const> strictAssemblyForEVM(langutil::EVMVersion _version);
|
||||||
static std::shared_ptr<EVMDialect> strictAssemblyForEVMObjects(langutil::EVMVersion _version);
|
static std::shared_ptr<EVMDialect const> strictAssemblyForEVMObjects(langutil::EVMVersion _version);
|
||||||
static std::shared_ptr<EVMDialect> yulForEVM(langutil::EVMVersion _version);
|
static std::shared_ptr<EVMDialect const> yulForEVM(langutil::EVMVersion _version);
|
||||||
|
|
||||||
langutil::EVMVersion evmVersion() const { return m_evmVersion; }
|
langutil::EVMVersion evmVersion() const { return m_evmVersion; }
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
using namespace yul;
|
using namespace yul;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
void EVMObjectCompiler::compile(Object& _object, AbstractAssembly& _assembly, EVMDialect& _dialect, bool _evm15, bool _optimize)
|
void EVMObjectCompiler::compile(Object& _object, AbstractAssembly& _assembly, EVMDialect const& _dialect, bool _evm15, bool _optimize)
|
||||||
{
|
{
|
||||||
EVMObjectCompiler compiler(_assembly, _dialect, _evm15);
|
EVMObjectCompiler compiler(_assembly, _dialect, _evm15);
|
||||||
compiler.run(_object, _optimize);
|
compiler.run(_object, _optimize);
|
||||||
|
@ -29,16 +29,16 @@ struct EVMDialect;
|
|||||||
class EVMObjectCompiler
|
class EVMObjectCompiler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void compile(Object& _object, AbstractAssembly& _assembly, EVMDialect& _dialect, bool _evm15, bool _optimize);
|
static void compile(Object& _object, AbstractAssembly& _assembly, EVMDialect const& _dialect, bool _evm15, bool _optimize);
|
||||||
private:
|
private:
|
||||||
EVMObjectCompiler(AbstractAssembly& _assembly, EVMDialect& _dialect, bool _evm15):
|
EVMObjectCompiler(AbstractAssembly& _assembly, EVMDialect const& _dialect, bool _evm15):
|
||||||
m_assembly(_assembly), m_dialect(_dialect), m_evm15(_evm15)
|
m_assembly(_assembly), m_dialect(_dialect), m_evm15(_evm15)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void run(Object& _object, bool _optimize);
|
void run(Object& _object, bool _optimize);
|
||||||
|
|
||||||
AbstractAssembly& m_assembly;
|
AbstractAssembly& m_assembly;
|
||||||
EVMDialect& m_dialect;
|
EVMDialect const& m_dialect;
|
||||||
bool m_evm15 = false;
|
bool m_evm15 = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ AbstractAssembly::SubID NoOutputAssembly::appendData(bytes const&)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
NoOutputEVMDialect::NoOutputEVMDialect(shared_ptr<EVMDialect> const& _copyFrom):
|
NoOutputEVMDialect::NoOutputEVMDialect(shared_ptr<EVMDialect const> const& _copyFrom):
|
||||||
EVMDialect(_copyFrom->flavour, _copyFrom->providesObjectAccess(), _copyFrom->evmVersion())
|
EVMDialect(_copyFrom->flavour, _copyFrom->providesObjectAccess(), _copyFrom->evmVersion())
|
||||||
{
|
{
|
||||||
for (auto& fun: m_functions)
|
for (auto& fun: m_functions)
|
||||||
|
@ -81,7 +81,7 @@ private:
|
|||||||
*/
|
*/
|
||||||
struct NoOutputEVMDialect: public EVMDialect
|
struct NoOutputEVMDialect: public EVMDialect
|
||||||
{
|
{
|
||||||
explicit NoOutputEVMDialect(std::shared_ptr<EVMDialect> const& _copyFrom);
|
explicit NoOutputEVMDialect(std::shared_ptr<EVMDialect const> const& _copyFrom);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
using namespace yul;
|
using namespace yul;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
string EWasmObjectCompiler::compile(Object& _object, Dialect& _dialect)
|
string EWasmObjectCompiler::compile(Object& _object, Dialect const& _dialect)
|
||||||
{
|
{
|
||||||
EWasmObjectCompiler compiler(_dialect);
|
EWasmObjectCompiler compiler(_dialect);
|
||||||
return compiler.run(_object);
|
return compiler.run(_object);
|
||||||
|
@ -30,15 +30,15 @@ struct Dialect;
|
|||||||
class EWasmObjectCompiler
|
class EWasmObjectCompiler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static std::string compile(Object& _object, Dialect& _dialect);
|
static std::string compile(Object& _object, Dialect const& _dialect);
|
||||||
private:
|
private:
|
||||||
EWasmObjectCompiler(Dialect& _dialect):
|
EWasmObjectCompiler(Dialect const& _dialect):
|
||||||
m_dialect(_dialect)
|
m_dialect(_dialect)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
std::string run(Object& _object);
|
std::string run(Object& _object);
|
||||||
|
|
||||||
Dialect& m_dialect;
|
Dialect const& m_dialect;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename ASTNode>
|
template <typename ASTNode>
|
||||||
void eliminateVariables(shared_ptr<Dialect> const& _dialect, ASTNode& _node, size_t _numVariables)
|
void eliminateVariables(shared_ptr<Dialect const> const& _dialect, ASTNode& _node, size_t _numVariables)
|
||||||
{
|
{
|
||||||
RematCandidateSelector selector{*_dialect};
|
RematCandidateSelector selector{*_dialect};
|
||||||
selector(_node);
|
selector(_node);
|
||||||
@ -133,7 +133,7 @@ void eliminateVariables(shared_ptr<Dialect> const& _dialect, ASTNode& _node, siz
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool StackCompressor::run(
|
bool StackCompressor::run(
|
||||||
shared_ptr<Dialect> const& _dialect,
|
shared_ptr<Dialect const> const& _dialect,
|
||||||
Block& _ast,
|
Block& _ast,
|
||||||
bool _optimizeStackAllocation,
|
bool _optimizeStackAllocation,
|
||||||
size_t _maxIterations
|
size_t _maxIterations
|
||||||
|
@ -42,7 +42,7 @@ public:
|
|||||||
/// Try to remove local variables until the AST is compilable.
|
/// Try to remove local variables until the AST is compilable.
|
||||||
/// @returns true if it was successful.
|
/// @returns true if it was successful.
|
||||||
static bool run(
|
static bool run(
|
||||||
std::shared_ptr<Dialect> const& _dialect,
|
std::shared_ptr<Dialect const> const& _dialect,
|
||||||
Block& _ast,
|
Block& _ast,
|
||||||
bool _optimizeStackAllocation,
|
bool _optimizeStackAllocation,
|
||||||
size_t _maxIterations
|
size_t _maxIterations
|
||||||
|
@ -58,7 +58,7 @@ using namespace dev;
|
|||||||
using namespace yul;
|
using namespace yul;
|
||||||
|
|
||||||
void OptimiserSuite::run(
|
void OptimiserSuite::run(
|
||||||
shared_ptr<Dialect> const& _dialect,
|
shared_ptr<Dialect const> const& _dialect,
|
||||||
Block& _ast,
|
Block& _ast,
|
||||||
AsmAnalysisInfo const& _analysisInfo,
|
AsmAnalysisInfo const& _analysisInfo,
|
||||||
bool _optimizeStackAllocation,
|
bool _optimizeStackAllocation,
|
||||||
|
@ -39,7 +39,7 @@ class OptimiserSuite
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void run(
|
static void run(
|
||||||
std::shared_ptr<Dialect> const& _dialect,
|
std::shared_ptr<Dialect const> const& _dialect,
|
||||||
Block& _ast,
|
Block& _ast,
|
||||||
AsmAnalysisInfo const& _analysisInfo,
|
AsmAnalysisInfo const& _analysisInfo,
|
||||||
bool _optimizeStackAllocation,
|
bool _optimizeStackAllocation,
|
||||||
|
@ -43,7 +43,7 @@ using namespace yul;
|
|||||||
|
|
||||||
namespace
|
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());
|
return _yul ? yul::Dialect::yul() : yul::EVMDialect::strictAssemblyForEVM(dev::test::Options::get().evmVersion());
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ namespace test
|
|||||||
namespace
|
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
|
try
|
||||||
{
|
{
|
||||||
@ -73,7 +73,7 @@ bool parse(string const& _source, std::shared_ptr<Dialect> _dialect, ErrorReport
|
|||||||
return false;
|
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;
|
ErrorList errors;
|
||||||
ErrorReporter errorReporter(errors);
|
ErrorReporter errorReporter(errors);
|
||||||
@ -98,12 +98,12 @@ boost::optional<Error> parseAndReturnFirstError(string const& _source, shared_pt
|
|||||||
return {};
|
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);
|
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);
|
auto error = parseAndReturnFirstError(_source, _dialect, _allowWarnings);
|
||||||
@ -548,7 +548,7 @@ BOOST_AUTO_TEST_CASE(builtins_parser)
|
|||||||
BuiltinFunction f;
|
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("{ 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("{ 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);
|
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};
|
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));
|
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, 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);
|
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.maxTraceSize = 10000;
|
||||||
state.maxSteps = 10000;
|
state.maxSteps = 10000;
|
||||||
state.maxMemSize = 0x20000000;
|
state.maxMemSize = 0x20000000;
|
||||||
shared_ptr<Dialect> dialect(EVMDialect::strictAssemblyForEVMObjects(langutil::EVMVersion{}));
|
shared_ptr<Dialect const> dialect(EVMDialect::strictAssemblyForEVMObjects(langutil::EVMVersion{}));
|
||||||
Interpreter interpreter(state, *dialect);
|
Interpreter interpreter(state, *dialect);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -66,7 +66,7 @@ private:
|
|||||||
std::string m_optimizerStep;
|
std::string m_optimizerStep;
|
||||||
std::string m_expectation;
|
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<Block> m_ast;
|
||||||
std::shared_ptr<AsmAnalysisInfo> m_analysisInfo;
|
std::shared_ptr<AsmAnalysisInfo> m_analysisInfo;
|
||||||
std::string m_obtainedResult;
|
std::string m_obtainedResult;
|
||||||
|
@ -215,7 +215,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
ErrorList m_errors;
|
ErrorList m_errors;
|
||||||
shared_ptr<yul::Block> m_ast;
|
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<AsmAnalysisInfo> m_analysisInfo;
|
||||||
shared_ptr<NameDispenser> m_nameDispenser;
|
shared_ptr<NameDispenser> m_nameDispenser;
|
||||||
};
|
};
|
||||||
|
@ -88,7 +88,7 @@ void interpret(string const& _source)
|
|||||||
InterpreterState state;
|
InterpreterState state;
|
||||||
state.maxTraceSize = 10000;
|
state.maxTraceSize = 10000;
|
||||||
state.maxMemSize = 0x20000000;
|
state.maxMemSize = 0x20000000;
|
||||||
shared_ptr<Dialect> dialect(EVMDialect::strictAssemblyForEVMObjects(langutil::EVMVersion{}));
|
shared_ptr<Dialect const> dialect(EVMDialect::strictAssemblyForEVMObjects(langutil::EVMVersion{}));
|
||||||
Interpreter interpreter(state, *dialect);
|
Interpreter interpreter(state, *dialect);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user