mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
OptimiserSuite: Define NonStepAbbreviations and use it for extra sanity checks
This commit is contained in:
parent
5a515240ac
commit
e2c0e6331c
@ -67,6 +67,7 @@
|
||||
|
||||
#include <libsolutil/CommonData.h>
|
||||
|
||||
#include <boost/range/adaptor/map.hpp>
|
||||
#include <boost/range/algorithm_ext/erase.hpp>
|
||||
|
||||
using namespace std;
|
||||
@ -235,6 +236,12 @@ map<string, char> const& OptimiserSuite::stepNameToAbbreviationMap()
|
||||
{VarDeclInitializer::name, 'd'},
|
||||
};
|
||||
yulAssert(lookupTable.size() == allSteps().size(), "");
|
||||
yulAssert((
|
||||
util::convertContainer<set<char>>(string(NonStepAbbreviations)) -
|
||||
util::convertContainer<set<char>>(lookupTable | boost::adaptors::map_values)
|
||||
).size() == string(NonStepAbbreviations).size(),
|
||||
"Step abbreviation conflicts with a character reserved for another syntactic element"
|
||||
);
|
||||
|
||||
return lookupTable;
|
||||
}
|
||||
@ -265,6 +272,10 @@ void OptimiserSuite::runSequence(string const& _stepAbbreviations, Block& _ast)
|
||||
insideLoop = false;
|
||||
break;
|
||||
default:
|
||||
yulAssert(
|
||||
string(NonStepAbbreviations).find(abbreviation) == string::npos,
|
||||
"Unhandled syntactic element in the abbreviation sequence"
|
||||
);
|
||||
assertThrow(
|
||||
stepAbbreviationToNameMap().find(abbreviation) != stepAbbreviationToNameMap().end(),
|
||||
OptimizerException,
|
||||
|
@ -47,6 +47,10 @@ class OptimiserSuite
|
||||
public:
|
||||
static constexpr size_t MaxRounds = 12;
|
||||
|
||||
/// Special characters that do not represent optimiser steps but are allowed in abbreviation sequences.
|
||||
/// Some of them (like whitespace) are ignored, others (like brackets) are a part of the syntax.
|
||||
static constexpr char NonStepAbbreviations[] = " \n[]";
|
||||
|
||||
enum class Debug
|
||||
{
|
||||
None,
|
||||
|
Loading…
Reference in New Issue
Block a user