2018-10-09 13:43:55 +00:00
|
|
|
/*
|
|
|
|
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 <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2018-11-25 00:02:32 +00:00
|
|
|
#include <test/TestCase.h>
|
2018-10-09 13:43:55 +00:00
|
|
|
|
2019-09-23 14:32:50 +00:00
|
|
|
#include <libyul/optimiser/OptimiserStep.h>
|
|
|
|
#include <libyul/optimiser/NameDispenser.h>
|
|
|
|
|
|
|
|
#include <libyul/YulString.h>
|
|
|
|
|
|
|
|
#include <set>
|
|
|
|
#include <memory>
|
|
|
|
|
2018-11-14 16:11:55 +00:00
|
|
|
namespace langutil
|
|
|
|
{
|
|
|
|
class Scanner;
|
|
|
|
class Error;
|
|
|
|
using ErrorList = std::vector<std::shared_ptr<Error const>>;
|
|
|
|
}
|
2018-10-09 13:43:55 +00:00
|
|
|
|
2018-11-21 11:42:34 +00:00
|
|
|
namespace yul
|
2018-10-09 13:43:55 +00:00
|
|
|
{
|
|
|
|
struct AsmAnalysisInfo;
|
|
|
|
struct Block;
|
2018-12-20 17:55:32 +00:00
|
|
|
struct Dialect;
|
2018-10-09 13:43:55 +00:00
|
|
|
}
|
2018-11-21 11:42:34 +00:00
|
|
|
|
2018-10-15 09:58:51 +00:00
|
|
|
namespace yul
|
2018-10-09 13:43:55 +00:00
|
|
|
{
|
|
|
|
namespace test
|
|
|
|
{
|
|
|
|
|
2019-04-01 13:31:48 +00:00
|
|
|
class YulOptimizerTest: public dev::solidity::test::EVMVersionRestrictedTestCase
|
2018-10-09 13:43:55 +00:00
|
|
|
{
|
|
|
|
public:
|
2019-02-06 11:10:05 +00:00
|
|
|
static std::unique_ptr<TestCase> create(Config const& _config)
|
2018-10-09 13:43:55 +00:00
|
|
|
{
|
2019-02-06 11:10:05 +00:00
|
|
|
return std::unique_ptr<TestCase>(new YulOptimizerTest(_config.filename));
|
2018-10-09 13:43:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
explicit YulOptimizerTest(std::string const& _filename);
|
|
|
|
|
2019-05-07 13:33:22 +00:00
|
|
|
TestResult run(std::ostream& _stream, std::string const& _linePrefix = "", bool const _formatted = false) override;
|
2018-10-09 13:43:55 +00:00
|
|
|
|
|
|
|
void printSource(std::ostream& _stream, std::string const &_linePrefix = "", bool const _formatted = false) const override;
|
2019-04-01 14:33:46 +00:00
|
|
|
void printUpdatedSettings(std::ostream &_stream, std::string const &_linePrefix = "", bool const _formatted = false) override;
|
2018-10-09 13:43:55 +00:00
|
|
|
void printUpdatedExpectations(std::ostream& _stream, std::string const& _linePrefix) const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void printIndented(std::ostream& _stream, std::string const& _output, std::string const& _linePrefix = "") const;
|
|
|
|
bool parse(std::ostream& _stream, std::string const& _linePrefix, bool const _formatted);
|
|
|
|
void disambiguate();
|
2019-09-23 14:32:50 +00:00
|
|
|
void updateContext();
|
2018-10-09 13:43:55 +00:00
|
|
|
|
2018-11-30 13:34:08 +00:00
|
|
|
static void printErrors(std::ostream& _stream, langutil::ErrorList const& _errors);
|
2018-10-09 13:43:55 +00:00
|
|
|
|
|
|
|
std::string m_source;
|
|
|
|
bool m_yul = false;
|
|
|
|
std::string m_optimizerStep;
|
|
|
|
std::string m_expectation;
|
|
|
|
|
2019-05-16 08:56:56 +00:00
|
|
|
Dialect const* m_dialect = nullptr;
|
2019-09-23 14:32:50 +00:00
|
|
|
std::set<YulString> m_reservedIdentifiers;
|
|
|
|
std::unique_ptr<NameDispenser> m_nameDispenser;
|
|
|
|
std::unique_ptr<OptimiserStepContext> m_context;
|
|
|
|
|
2018-11-21 11:42:34 +00:00
|
|
|
std::shared_ptr<Block> m_ast;
|
|
|
|
std::shared_ptr<AsmAnalysisInfo> m_analysisInfo;
|
2018-10-09 13:43:55 +00:00
|
|
|
std::string m_obtainedResult;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|