Merge pull request #6429 from ethereum/testSettings

Add settings framework for interactive tests.
This commit is contained in:
chriseth 2019-04-03 22:35:39 +02:00 committed by GitHub
commit 5b871f61a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
291 changed files with 739 additions and 369 deletions

View File

@ -17,76 +17,80 @@
#include <test/TestCase.h>
#include <libdevcore/StringUtils.h>
#include <boost/algorithm/cxx11/none_of.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/trim.hpp>
#include <boost/range/adaptor/map.hpp>
#include <stdexcept>
#include <iostream>
using namespace dev;
using namespace solidity;
using namespace dev::solidity::test;
using namespace std;
void TestCase::printUpdatedSettings(ostream& _stream, const string& _linePrefix, const bool)
{
if (m_validatedSettings.empty())
return;
_stream << _linePrefix << "// ====" << endl;
for (auto const& setting: m_validatedSettings)
_stream << _linePrefix << "// " << setting.first << ": " << setting.second << endl;
}
bool TestCase::isTestFilename(boost::filesystem::path const& _filename)
{
string extension = _filename.extension().string();
return (extension == ".sol" || extension == ".yul") &&
!boost::starts_with(_filename.string(), "~") &&
!boost::starts_with(_filename.string(), ".");
!boost::starts_with(_filename.string(), ".");
}
bool TestCase::supportedForEVMVersion(langutil::EVMVersion _evmVersion) const
bool TestCase::validateSettings(langutil::EVMVersion)
{
return boost::algorithm::none_of(m_evmVersionRules, [&](auto const& rule) { return !rule(_evmVersion); });
if (!m_settings.empty())
throw runtime_error(
"Unknown setting(s): " +
joinHumanReadable(m_settings | boost::adaptors::map_keys)
);
return true;
}
string TestCase::parseSource(istream& _stream)
string TestCase::parseSourceAndSettings(istream& _stream)
{
string source;
string line;
static string const settingsDelimiter("// ====");
static string const delimiter("// ----");
static string const evmVersion("// EVMVersion: ");
bool isTop = true;
bool sourcePart = true;
while (getline(_stream, line))
{
if (boost::algorithm::starts_with(line, delimiter))
break;
else
{
if (isTop && boost::algorithm::starts_with(line, evmVersion))
{
string versionString = line.substr(evmVersion.size() + 1);
auto version = langutil::EVMVersion::fromString(versionString);
if (!version)
throw runtime_error("Invalid EVM version: \"" + versionString + "\"");
switch (line.at(evmVersion.size()))
{
case '>':
m_evmVersionRules.emplace_back([version](langutil::EVMVersion _version) {
return version < _version;
});
break;
case '<':
m_evmVersionRules.emplace_back([version](langutil::EVMVersion _version) {
return _version < version;
});
break;
case '=':
m_evmVersionRules.emplace_back([version](langutil::EVMVersion _version) {
return _version == version;
});
break;
case '!':
m_evmVersionRules.emplace_back([version](langutil::EVMVersion _version) {
return !(_version == version);
});
break;
}
}
else
isTop = false;
else if (boost::algorithm::starts_with(line, settingsDelimiter))
sourcePart = false;
else if (sourcePart)
source += line + "\n";
else if (boost::algorithm::starts_with(line, "// "))
{
size_t colon = line.find(':');
if (colon == string::npos)
throw runtime_error(string("Expected \":\" inside setting."));
string key = line.substr(3, colon - 3);
string value = line.substr(colon + 1);
boost::algorithm::trim(key);
boost::algorithm::trim(value);
m_settings[key] = value;
}
else
throw runtime_error(string("Expected \"//\" or \"// ---\" to terminate settings and source."));
}
return source;
}
@ -96,3 +100,35 @@ void TestCase::expect(string::iterator& _it, string::iterator _end, string::valu
throw runtime_error(string("Invalid test expectation. Expected: \"") + _c + "\".");
++_it;
}
bool EVMVersionRestrictedTestCase::validateSettings(langutil::EVMVersion _evmVersion)
{
if (!m_settings.count("EVMVersion"))
return true;
string versionString = m_settings["EVMVersion"];
m_validatedSettings["EVMVersion"] = versionString;
m_settings.erase("EVMVersion");
if (!TestCase::validateSettings(_evmVersion))
return false;
if (versionString.empty())
return true;
char comparator = versionString.front();
versionString = versionString.substr(1);
boost::optional<langutil::EVMVersion> version = langutil::EVMVersion::fromString(versionString);
if (!version)
throw runtime_error("Invalid EVM version: \"" + versionString + "\"");
switch (comparator)
{
case '>': return version < _evmVersion;
case '<': return _evmVersion < version;
case '=': return _evmVersion == version;
case '!': return !(_evmVersion == version);
}
throw runtime_error(string{"Invalid EVM comparator: \""} + comparator + "\"");
return false; // not reached
}

View File

@ -26,6 +26,7 @@
#include <memory>
#include <string>
#include <vector>
#include <map>
namespace dev
{
@ -42,7 +43,9 @@ namespace test
} \
while (false)
/** Common superclass of SyntaxTest and SemanticsTest. */
/**
* Common superclass of anything that can be run via isoltest.
*/
class TestCase
{
public:
@ -68,17 +71,23 @@ public:
/// If @arg _formatted is true, color-coding may be used to indicate
/// error locations in the contract, if applicable.
virtual void printSource(std::ostream &_stream, std::string const &_linePrefix = "", bool const _formatted = false) const = 0;
/// Outputs the updated settings.
virtual void printUpdatedSettings(std::ostream &_stream, std::string const &_linePrefix = "", bool const _formatted = false);
/// Outputs test expectations to @arg _stream that match the actual results of the test.
/// Each line of output is prefixed with @arg _linePrefix.
virtual void printUpdatedExpectations(std::ostream& _stream, std::string const& _linePrefix) const = 0;
static bool isTestFilename(boost::filesystem::path const& _filename);
/// Returns true, if the test case is supported for EVM version @arg _evmVersion, false otherwise.
bool supportedForEVMVersion(langutil::EVMVersion _evmVersion) const;
/// Validates the settings, i.e. moves them from m_settings to m_validatedSettings.
/// Throws a runtime exception if any setting is left at this class (i.e. unknown setting).
/// Returns true, if the test case is supported in the current environment and false
/// otherwise which causes this test to be skipped.
/// This might check e.g. for restrictions on the EVM version.
virtual bool validateSettings(langutil::EVMVersion /*_evmVersion*/);
protected:
std::string parseSource(std::istream& _file);
std::string parseSourceAndSettings(std::istream& _file);
static void expect(std::string::iterator& _it, std::string::iterator _end, std::string::value_type _c);
template<typename IteratorType>
@ -94,10 +103,19 @@ protected:
while (_it != _end && *_it == '/')
++_it;
}
private:
std::vector<std::function<bool(langutil::EVMVersion)>> m_evmVersionRules;
/// Parsed settings.
std::map<std::string, std::string> m_settings;
/// Updated settings after validation.
std::map<std::string, std::string> m_validatedSettings;
};
class EVMVersionRestrictedTestCase: public TestCase
{
public:
/// Returns true, if the test case is supported for EVM version @arg _evmVersion, false otherwise.
bool validateSettings(langutil::EVMVersion _evmVersion) override;
};
}
}
}

View File

@ -105,7 +105,7 @@ int registerTests(
{
stringstream errorStream;
auto testCase = _testCaseCreator(config);
if (testCase->supportedForEVMVersion(dev::test::Options::get().evmVersion()))
if (testCase->validateSettings(dev::test::Options::get().evmVersion()))
if (!testCase->run(errorStream))
BOOST_ERROR("Test expectation mismatch.\n" + errorStream.str());
}

View File

@ -43,7 +43,7 @@ SemanticTest::SemanticTest(string const& _filename, string const& _ipcPath, lang
soltestAssert(file, "Cannot open test contract: \"" + _filename + "\".");
file.exceptions(ios::badbit);
m_source = parseSource(file);
m_source = parseSourceAndSettings(file);
parseExpectations(file);
}

View File

@ -40,7 +40,7 @@ namespace test
* section from the given file. This comment section should define a set of functions to be called
* and an expected result they return after being executed.
*/
class SemanticTest: public SolidityExecutionFramework, public TestCase
class SemanticTest: public SolidityExecutionFramework, public EVMVersionRestrictedTestCase
{
public:
static std::unique_ptr<TestCase> create(Config const& _options)

View File

@ -59,7 +59,7 @@ SyntaxTest::SyntaxTest(string const& _filename, langutil::EVMVersion _evmVersion
BOOST_THROW_EXCEPTION(runtime_error("Cannot open test contract: \"" + _filename + "\"."));
file.exceptions(ios::badbit);
m_source = parseSource(file);
m_source = parseSourceAndSettings(file);
m_expectations = parseExpectations(file);
}

View File

@ -50,7 +50,7 @@ struct SyntaxTestError
};
class SyntaxTest: AnalysisFramework, public TestCase
class SyntaxTest: AnalysisFramework, public EVMVersionRestrictedTestCase
{
public:
static std::unique_ptr<TestCase> create(Config const& _config)

View File

@ -0,0 +1,9 @@
contract C {
function f(uint x) public returns (uint y) {
assembly { y := shl(2, x) }
}
}
// ====
// EVMVersion: >byzantium
// ----
// f(uint256): 7 -> 28

View File

@ -78,19 +78,23 @@ YulOptimizerTest::YulOptimizerTest(string const& _filename)
m_optimizerStep = std::prev(std::prev(path.end()))->string();
ifstream file(_filename);
if (!file)
BOOST_THROW_EXCEPTION(runtime_error("Cannot open test case: \"" + _filename + "\"."));
soltestAssert(file, "Cannot open test contract: \"" + _filename + "\".");
file.exceptions(ios::badbit);
string line;
while (getline(file, line))
m_source = parseSourceAndSettings(file);
if (m_settings.count("yul"))
{
if (boost::algorithm::starts_with(line, "// ----"))
break;
if (m_source.empty() && boost::algorithm::starts_with(line, "// yul"))
m_yul = true;
m_source += line + "\n";
m_yul = true;
m_validatedSettings["yul"] = "true";
m_settings.erase("yul");
}
if (m_settings.count("step"))
{
m_validatedSettings["step"] = m_settings["step"];
m_settings.erase("step");
}
string line;
while (getline(file, line))
if (boost::algorithm::starts_with(line, "// "))
m_expectation += line.substr(3) + "\n";
@ -266,8 +270,22 @@ bool YulOptimizerTest::run(ostream& _stream, string const& _linePrefix, bool con
return false;
}
m_obtainedResult = m_optimizerStep + "\n" + AsmPrinter{m_yul}(*m_ast) + "\n";
m_obtainedResult = AsmPrinter{m_yul}(*m_ast) + "\n";
bool success = true;
if (m_optimizerStep != m_validatedSettings["step"])
{
string nextIndentLevel = _linePrefix + " ";
AnsiColorized(_stream, _formatted, {formatting::BOLD, formatting::CYAN}) <<
_linePrefix <<
"Invalid optimizer step. Given: \"" <<
m_validatedSettings["step"] <<
"\", should be: \"" <<
m_optimizerStep <<
"\"." <<
endl;
success = false;
}
if (m_expectation != m_obtainedResult)
{
string nextIndentLevel = _linePrefix + " ";
@ -276,9 +294,9 @@ bool YulOptimizerTest::run(ostream& _stream, string const& _linePrefix, bool con
printIndented(_stream, m_expectation, nextIndentLevel);
AnsiColorized(_stream, _formatted, {formatting::BOLD, formatting::CYAN}) << _linePrefix << "Obtained result:" << endl;
printIndented(_stream, m_obtainedResult, nextIndentLevel);
return false;
success = false;
}
return true;
return success;
}
void YulOptimizerTest::printSource(ostream& _stream, string const& _linePrefix, bool const) const
@ -286,6 +304,12 @@ void YulOptimizerTest::printSource(ostream& _stream, string const& _linePrefix,
printIndented(_stream, m_source, _linePrefix);
}
void YulOptimizerTest::printUpdatedSettings(ostream& _stream, const string& _linePrefix, const bool _formatted)
{
m_validatedSettings["step"] = m_optimizerStep;
EVMVersionRestrictedTestCase::printUpdatedSettings(_stream, _linePrefix, _formatted);
}
void YulOptimizerTest::printUpdatedExpectations(ostream& _stream, string const& _linePrefix) const
{
printIndented(_stream, m_obtainedResult, _linePrefix);

View File

@ -38,7 +38,7 @@ namespace yul
namespace test
{
class YulOptimizerTest: public dev::solidity::test::TestCase
class YulOptimizerTest: public dev::solidity::test::EVMVersionRestrictedTestCase
{
public:
static std::unique_ptr<TestCase> create(Config const& _config)
@ -51,6 +51,7 @@ public:
bool run(std::ostream& _stream, std::string const& _linePrefix = "", bool const _formatted = false) override;
void printSource(std::ostream& _stream, std::string const &_linePrefix = "", bool const _formatted = false) const override;
void printUpdatedSettings(std::ostream &_stream, std::string const &_linePrefix = "", bool const _formatted = false) override;
void printUpdatedExpectations(std::ostream& _stream, std::string const& _linePrefix) const override;
private:

View File

@ -8,8 +8,9 @@
}
let z := mload(2)
}
// ====
// step: blockFlattener
// ----
// blockFlattener
// {
// let _1 := mload(0)
// let f_a := mload(1)

View File

@ -3,8 +3,9 @@
a := add(a, 1)
}
}
// ====
// step: blockFlattener
// ----
// blockFlattener
// {
// for {
// let a := 1

View File

@ -8,8 +8,9 @@
}
let t := add(3, 9)
}
// ====
// step: blockFlattener
// ----
// blockFlattener
// {
// if add(mload(7), sload(mload(3)))
// {

View File

@ -14,8 +14,9 @@
a := add(a, c)
}
}
// ====
// step: blockFlattener
// ----
// blockFlattener
// {
// let a := 3
// let b := 4

View File

@ -5,8 +5,9 @@
default { a := 3 { a := 4 } }
a := 5
}
// ====
// step: blockFlattener
// ----
// blockFlattener
// {
// let a := 1
// switch calldataload(0)

View File

@ -5,8 +5,9 @@
}
mstore(1, codesize())
}
// ====
// step: commonSubexpressionEliminator
// ----
// commonSubexpressionEliminator
// {
// let a := 1
// let b := codesize()

View File

@ -3,8 +3,9 @@
if b { b := 1 }
let c := 1
}
// ====
// step: commonSubexpressionEliminator
// ----
// commonSubexpressionEliminator
// {
// let b := 1
// if b

View File

@ -23,8 +23,9 @@
p_1 := add(array, _22)
}
}
// ====
// step: commonSubexpressionEliminator
// ----
// commonSubexpressionEliminator
// {
// let _13 := 0x20
// let _14 := allocate(_13)

View File

@ -23,8 +23,9 @@
let _11 := array_index_access(x, _10)
mstore(_11, _9)
}
// ====
// step: commonSubexpressionEliminator
// ----
// commonSubexpressionEliminator
// {
// function allocate(size) -> p
// {

View File

@ -2,8 +2,9 @@
let a := mload(1)
let b := mload(1)
}
// ====
// step: commonSubexpressionEliminator
// ----
// commonSubexpressionEliminator
// {
// let a := mload(1)
// let b := mload(1)

View File

@ -2,8 +2,9 @@
let a := gas()
let b := gas()
}
// ====
// step: commonSubexpressionEliminator
// ----
// commonSubexpressionEliminator
// {
// let a := gas()
// let b := gas()

View File

@ -11,8 +11,9 @@
datacopy("abc", x, y)
mstore(a, x)
}
// ====
// step: commonSubexpressionEliminator
// ----
// commonSubexpressionEliminator
// {
// let r := "abc"
// let a := datasize("abc")

View File

@ -10,8 +10,9 @@
mstore(0, calldataload(0))
mstore(0, x)
}
// ====
// step: commonSubexpressionEliminator
// ----
// commonSubexpressionEliminator
// {
// let a := 10
// let x := 20

View File

@ -1,5 +1,6 @@
{ }
// ====
// step: commonSubexpressionEliminator
// ----
// commonSubexpressionEliminator
// {
// }

View File

@ -2,8 +2,9 @@
let a := mul(1, codesize())
let b := mul(1, codesize())
}
// ====
// step: commonSubexpressionEliminator
// ----
// commonSubexpressionEliminator
// {
// let a := mul(1, codesize())
// let b := a

View File

@ -9,8 +9,9 @@
let b := 0
sstore(a, b)
}
// ====
// step: commonSubexpressionEliminator
// ----
// commonSubexpressionEliminator
// {
// function f() -> x
// {

View File

@ -5,8 +5,9 @@
let b
mstore(sub(a, b), 7)
}
// ====
// step: commonSubexpressionEliminator
// ----
// commonSubexpressionEliminator
// {
// let a
// let b

View File

@ -12,8 +12,9 @@
a := b
mstore(2, a)
}
// ====
// step: commonSubexpressionEliminator
// ----
// commonSubexpressionEliminator
// {
// let a := mload(0)
// let b := add(a, 7)

View File

@ -13,8 +13,9 @@
}
}
// ====
// step: deadCodeEliminator
// ----
// deadCodeEliminator
// {
// for {
// let a := 20

View File

@ -14,8 +14,9 @@
}
}
// ====
// step: deadCodeEliminator
// ----
// deadCodeEliminator
// {
// for {
// let a := 20

View File

@ -14,8 +14,9 @@
}
}
// ====
// step: deadCodeEliminator
// ----
// deadCodeEliminator
// {
// for {
// let a := 20

View File

@ -15,8 +15,9 @@
}
}
// ====
// step: deadCodeEliminator
// ----
// deadCodeEliminator
// {
// let b := 20
// revert(0, 0)

View File

@ -15,8 +15,9 @@
}
}
// ====
// step: deadCodeEliminator
// ----
// deadCodeEliminator
// {
// let b := 20
// stop()

View File

@ -12,8 +12,9 @@
pop(add(1, 1))
}
// ====
// step: deadCodeEliminator
// ----
// deadCodeEliminator
// {
// fun()
// revert(0, 0)

View File

@ -12,8 +12,9 @@
y := 10 }
}
// ====
// step: deadCodeEliminator
// ----
// deadCodeEliminator
// {
// let y := mload(0)
// switch y

View File

@ -4,8 +4,9 @@
}
mstore(0, 0)
}
// ====
// step: deadCodeEliminator
// ----
// deadCodeEliminator
// {
// {
// revert(0, 0)

View File

@ -12,8 +12,9 @@
}
}
// ====
// step: deadCodeEliminator
// ----
// deadCodeEliminator
// {
// for {
// let a := 20

View File

@ -12,8 +12,9 @@
}
}
// ====
// step: deadCodeEliminator
// ----
// deadCodeEliminator
// {
// for {
// let a := 20

View File

@ -15,8 +15,9 @@
stop()
}
// ====
// step: deadCodeEliminator
// ----
// deadCodeEliminator
// {
// let b := 20
// for {

View File

@ -1,4 +1,3 @@
// yul
{
{ let a:u256, b:u256 }
{
@ -7,8 +6,10 @@
}
}
}
// ====
// step: disambiguator
// yul: true
// ----
// disambiguator
// {
// {
// let a:u256, b:u256

View File

@ -1,4 +1,3 @@
// yul
{
{ let a:u256, b:u256, c:u256, d:u256, f:u256 }
{
@ -7,8 +6,10 @@
}
}
}
// ====
// step: disambiguator
// yul: true
// ----
// disambiguator
// {
// {
// let a:u256, b:u256, c:u256, d:u256, f:u256

View File

@ -1,4 +1,3 @@
// yul
{
{ let a:u256, b:u256, c:u256 }
{
@ -6,8 +5,10 @@
if a { let b:bool := a }
}
}
// ====
// step: disambiguator
// yul: true
// ----
// disambiguator
// {
// {
// let a:u256, b:u256, c:u256

View File

@ -1,7 +1,8 @@
// yul
{ { let aanteuhdaoneudbrgkjiuaothduiathudaoeuh:u256 } { let aanteuhdaoneudbrgkjiuaothduiathudaoeuh:u256 } }
// ====
// step: disambiguator
// yul: true
// ----
// disambiguator
// {
// {
// let aanteuhdaoneudbrgkjiuaothduiathudaoeuh:u256

View File

@ -1,5 +1,6 @@
{ }
// ====
// step: disambiguator
// ----
// disambiguator
// {
// }

View File

@ -1,6 +1,7 @@
// yul
{ }
// ====
// step: disambiguator
// yul: true
// ----
// disambiguator
// {
// }

View File

@ -1,4 +1,3 @@
// yul
{
{ let a:u256, b:u256, c:u256 }
{
@ -8,8 +7,10 @@
default { let c:u256 := a }
}
}
// ====
// step: disambiguator
// yul: true
// ----
// disambiguator
// {
// {
// let a:u256, b:u256, c:u256

View File

@ -1,7 +1,8 @@
// yul
{ { let a:u256 } { let a:u256 } }
// ====
// step: disambiguator
// yul: true
// ----
// disambiguator
// {
// {
// let a:u256

View File

@ -1,7 +1,8 @@
// yul
{ { let a:u256 let a_1:u256 } { let a:u256 } }
// ====
// step: disambiguator
// yul: true
// ----
// disambiguator
// {
// {
// let a:u256

View File

@ -1,4 +1,3 @@
// yul
{
{ let c:u256 let b:u256 }
function f(a:u256, c:u256) -> b:u256 { let x:u256 }
@ -6,8 +5,10 @@
let a:u256 let x:u256
}
}
// ====
// step: disambiguator
// yul: true
// ----
// disambiguator
// {
// {
// let c:u256

View File

@ -54,8 +54,9 @@
}
}
}
// ====
// step: equivalentFunctionCombiner
// ----
// equivalentFunctionCombiner
// {
// pop(f(1, 2, 3))
// pop(f(4, 5, 6))

View File

@ -4,8 +4,9 @@
function f() { mstore(1, mload(0)) }
function g() { mstore(1, mload(0)) }
}
// ====
// step: equivalentFunctionCombiner
// ----
// equivalentFunctionCombiner
// {
// f()
// f()

View File

@ -4,8 +4,9 @@
function f() -> b { let a := mload(0) b := a }
function g() -> a { let b := mload(0) a := b }
}
// ====
// step: equivalentFunctionCombiner
// ----
// equivalentFunctionCombiner
// {
// pop(f())
// pop(f())

View File

@ -4,8 +4,9 @@
function f(x) { switch x case 0 { mstore(0, 42) } case 1 { mstore(1, 42) } }
function g(x) { switch x case 1 { mstore(1, 42) } case 0 { mstore(0, 42) } }
}
// ====
// step: equivalentFunctionCombiner
// ----
// equivalentFunctionCombiner
// {
// f(0)
// f(1)

View File

@ -2,8 +2,9 @@
function f(a) -> x { x := add(a, a) }
let y := f(calldatasize())
}
// ====
// step: expressionInliner
// ----
// expressionInliner
// {
// function f(a) -> x
// {

View File

@ -3,8 +3,9 @@
function g(b, c) -> y { y := mul(mload(c), f(b)) }
let y := g(calldatasize(), 7)
}
// ====
// step: expressionInliner
// ----
// expressionInliner
// {
// function f(a) -> x
// {

View File

@ -3,8 +3,9 @@
function g(b, s) -> y { y := f(b, f(s, s)) }
let y := g(calldatasize(), 7)
}
// ====
// step: expressionInliner
// ----
// expressionInliner
// {
// function f(a, r) -> x
// {

View File

@ -3,8 +3,9 @@
function f(a) -> x { x := a }
let y := f(mload(2))
}
// ====
// step: expressionInliner
// ----
// expressionInliner
// {
// function f(a) -> x
// {

View File

@ -6,8 +6,9 @@
function h() -> z { mstore(0, 4) z := mload(0) }
let r := f(g(), h())
}
// ====
// step: expressionInliner
// ----
// expressionInliner
// {
// function f(a, b) -> x
// {

View File

@ -1,10 +1,11 @@
// yul
{
function f() -> x:u256 { x := 2:u256 }
let y:u256 := f()
}
// ====
// step: expressionInliner
// yul: true
// ----
// expressionInliner
// {
// function f() -> x:u256
// {

View File

@ -1,10 +1,11 @@
// yul
{
function f(a:u256) -> x:u256 { x := a }
let y:u256 := f(7:u256)
}
// ====
// step: expressionInliner
// yul: true
// ----
// expressionInliner
// {
// function f(a:u256) -> x:u256
// {

View File

@ -10,8 +10,9 @@
let z := 3
let t := add(z, 9)
}
// ====
// step: expressionJoiner
// ----
// expressionJoiner
// {
// if add(mload(7), sload(mload(3)))
// {

View File

@ -4,8 +4,9 @@
let x := mul(add(b, a), mload(2))
sstore(x, 3)
}
// ====
// step: expressionJoiner
// ----
// expressionJoiner
// {
// let a := mload(3)
// let b := mload(6)

View File

@ -4,8 +4,9 @@
let x := mul(add(b, a), 2)
sstore(x, 3)
}
// ====
// step: expressionJoiner
// ----
// expressionJoiner
// {
// sstore(mul(add(mload(6), mload(2)), 2), 3)
// }

View File

@ -3,8 +3,9 @@
let a := mload(2)
let b := add(a, a)
}
// ====
// step: expressionJoiner
// ----
// expressionJoiner
// {
// let a := mload(2)
// let b := add(a, a)

View File

@ -7,8 +7,9 @@
let x := mul(a, add(2, b))
sstore(x, 3)
}
// ====
// step: expressionJoiner
// ----
// expressionJoiner
// {
// let a := mload(2)
// sstore(mul(a, add(2, mload(6))), 3)

View File

@ -4,8 +4,9 @@
let x := mul(add(a, b), 2)
sstore(x, 3)
}
// ====
// step: expressionJoiner
// ----
// expressionJoiner
// {
// let a := mload(2)
// sstore(mul(add(a, mload(6)), 2), 3)

View File

@ -11,8 +11,9 @@
}
sstore(x, 3)
}
// ====
// step: expressionJoiner
// ----
// expressionJoiner
// {
// let x := calldataload(mload(2))
// sstore(x, 3)

View File

@ -1,8 +1,9 @@
{
for { let b := mload(1) } b {} {}
}
// ====
// step: expressionJoiner
// ----
// expressionJoiner
// {
// for {
// let b := mload(1)

View File

@ -2,8 +2,9 @@
let a := mload(0)
for { } a {} {}
}
// ====
// step: expressionJoiner
// ----
// expressionJoiner
// {
// let a := mload(0)
// for {

View File

@ -5,8 +5,9 @@
x := add(a, 3)
}
}
// ====
// step: expressionJoiner
// ----
// expressionJoiner
// {
// function f(a) -> x
// {

View File

@ -4,8 +4,9 @@
let b := mload(a)
a := 4
}
// ====
// step: expressionJoiner
// ----
// expressionJoiner
// {
// let a := mload(2)
// let b := mload(a)

View File

@ -3,8 +3,9 @@
let x := calldataload(a)
sstore(x, 3)
}
// ====
// step: expressionJoiner
// ----
// expressionJoiner
// {
// sstore(calldataload(mload(2)), 3)
// }

View File

@ -5,8 +5,9 @@
let d := add(b, c)
sstore(d, 0)
}
// ====
// step: expressionJoiner
// ----
// expressionJoiner
// {
// let b := sload(mload(3))
// sstore(add(b, mload(7)), 0)

View File

@ -1,5 +1,6 @@
{ }
// ====
// step: expressionJoiner
// ----
// expressionJoiner
// {
// }

View File

@ -14,8 +14,9 @@
let z := 3
let t := add(z, 9)
}
// ====
// step: expressionJoiner
// ----
// expressionJoiner
// {
// switch add(mload(7), sload(mload(3)))
// case 3 {

View File

@ -5,8 +5,9 @@
let x := mul(add(c, b), a)
sstore(x, 3)
}
// ====
// step: expressionJoiner
// ----
// expressionJoiner
// {
// sstore(mul(add(mload(7), mload(6)), mload(2)), 3)
// }

View File

@ -3,8 +3,9 @@
let c, d := f()
let y := add(d, add(c, 7))
}
// ====
// step: expressionSimplifier
// ----
// expressionSimplifier
// {
// function f() -> x, z
// {

View File

@ -1,6 +1,7 @@
{ let a := add(7, sub(mload(0), 7)) }
// ====
// step: expressionSimplifier
// ----
// expressionSimplifier
// {
// let a := mload(0)
// }

View File

@ -1,6 +1,7 @@
{ let a := add(1, mul(3, 4)) }
// ====
// step: expressionSimplifier
// ----
// expressionSimplifier
// {
// let a := 13
// }

View File

@ -1,6 +1,7 @@
{ let a := sub(calldataload(0), calldataload(0)) }
// ====
// step: expressionSimplifier
// ----
// expressionSimplifier
// {
// let a := 0
// }

View File

@ -1,6 +1,7 @@
{ let a := sub(calldataload(1), calldataload(0)) }
// ====
// step: expressionSimplifier
// ----
// expressionSimplifier
// {
// let a := sub(calldataload(1), calldataload(0))
// }

View File

@ -2,8 +2,9 @@
let a := mload(0)
let b := sub(a, a)
}
// ====
// step: expressionSimplifier
// ----
// expressionSimplifier
// {
// let a := mload(0)
// let b := 0

View File

@ -2,8 +2,9 @@
function f() -> a {}
let b := add(7, sub(f(), 7))
}
// ====
// step: expressionSimplifier
// ----
// expressionSimplifier
// {
// function f() -> a
// {

View File

@ -1,8 +1,9 @@
{
for { let a := 10 } iszero(eq(a, 0)) { a := add(a, 1) } {}
}
// ====
// step: expressionSimplifier
// ----
// expressionSimplifier
// {
// for {
// let a := 10

View File

@ -2,8 +2,9 @@
let a := mload(sub(7, 7))
let b := sub(a, 0)
}
// ====
// step: expressionSimplifier
// ----
// expressionSimplifier
// {
// let a := mload(0)
// let b := a

View File

@ -1,8 +1,9 @@
{
mstore(0, mod(calldataload(0), exp(2, 8)))
}
// ====
// step: expressionSimplifier
// ----
// expressionSimplifier
// {
// mstore(0, and(calldataload(0), 255))
// }

View File

@ -1,8 +1,9 @@
{
mstore(0, mod(calldataload(0), exp(2, 255)))
}
// ====
// step: expressionSimplifier
// ----
// expressionSimplifier
// {
// mstore(0, and(calldataload(0), 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff))
// }

View File

@ -2,8 +2,9 @@
function f(a) -> b { }
let c := sub(f(0), f(1))
}
// ====
// step: expressionSimplifier
// ----
// expressionSimplifier
// {
// function f(a) -> b
// {

View File

@ -3,8 +3,9 @@
function f2() -> b { }
let c := sub(f1(), f2())
}
// ====
// step: expressionSimplifier
// ----
// expressionSimplifier
// {
// function f1() -> a
// {

View File

@ -3,8 +3,9 @@
function f() -> a { }
let b := sub(f(), f())
}
// ====
// step: expressionSimplifier
// ----
// expressionSimplifier
// {
// function f() -> a
// {

View File

@ -3,8 +3,9 @@
{
let a := div(keccak256(0, 0), 0)
}
// ====
// step: expressionSimplifier
// ----
// expressionSimplifier
// {
// let a := div(keccak256(0, 0), 0)
// }

View File

@ -3,8 +3,9 @@
x := 0
mstore(0, add(7, x))
}
// ====
// step: expressionSimplifier
// ----
// expressionSimplifier
// {
// let x := mload(0)
// x := 0

View File

@ -4,8 +4,9 @@
let y := add(d, add(c, 7))
}
}
// ====
// step: expressionSimplifier
// ----
// expressionSimplifier
// {
// function f() -> c, d
// {

View File

@ -1,8 +1,9 @@
{
let a := add(0, mload(0))
}
// ====
// step: expressionSimplifier
// ----
// expressionSimplifier
// {
// let a := mload(0)
// }

View File

@ -1,5 +1,6 @@
{ }
// ====
// step: expressionSimplifier
// ----
// expressionSimplifier
// {
// }

View File

@ -3,8 +3,9 @@
let c, d
let y := add(d, add(c, 7))
}
// ====
// step: expressionSimplifier
// ----
// expressionSimplifier
// {
// let c, d
// let y := 7

View File

@ -4,8 +4,9 @@
let d
let y := add(d, add(c, 7))
}
// ====
// step: expressionSimplifier
// ----
// expressionSimplifier
// {
// let c
// let d

View File

@ -7,8 +7,9 @@
}
}
}
// ====
// step: expressionSplitter
// ----
// expressionSplitter
// {
// let _1 := 0
// let x := calldataload(_1)

View File

@ -5,8 +5,9 @@
}
sstore(x, f(mload(2), mload(2)))
}
// ====
// step: expressionSplitter
// ----
// expressionSplitter
// {
// let _1 := 3
// let _2 := 7

View File

@ -6,8 +6,9 @@
// datacopy is fine, though
datacopy(mload(0), mload(1), mload(2))
}
// ====
// step: expressionSplitter
// ----
// expressionSplitter
// {
// let x := dataoffset("abc")
// let y := datasize("abc")

Some files were not shown because too many files have changed in this diff Show More