/*
This file is part of solidity.
solidity is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
solidity is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with solidity. If not, see .
*/
/**
* Unit tests for KnowledgeBase
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
using namespace solidity::langutil;
namespace solidity::yul::test
{
class KnowledgeBaseTest
{
protected:
KnowledgeBase constructKnowledgeBase(string const& _source)
{
ErrorList errorList;
shared_ptr analysisInfo;
std::tie(m_object, analysisInfo) = yul::test::parse(_source, m_dialect, errorList);
BOOST_REQUIRE(m_object && errorList.empty() && m_object->code);
NameDispenser dispenser(m_dialect, *m_object->code);
std::set reserved;
OptimiserStepContext context{m_dialect, dispenser, reserved, 0};
CommonSubexpressionEliminator::run(context, *m_object->code);
m_ssaValues(*m_object->code);
for (auto const& [name, expression]: m_ssaValues.values())
m_values[name].value = expression;
return KnowledgeBase([this](YulString _var) { return util::valueOrNullptr(m_values, _var); });
}
EVMDialect m_dialect{EVMVersion{}, true};
shared_ptr