@@ -92,7 +92,7 @@ using namespace solidity::langutil;
92
92
namespace
93
93
{
94
94
95
- std::vector <frontend::InputMode> ValidInputModes{
95
+ std::set <frontend::InputMode> ValidInputModes{
96
96
frontend::InputMode::Compiler,
97
97
frontend::InputMode::CompilerWithASTImport,
98
98
frontend::InputMode::CompilerWithEvmAssemblyJsonImport
@@ -172,7 +172,7 @@ static bool coloredOutput(CommandLineOptions const& _options)
172
172
173
173
void CommandLineInterface::handleBinary (string const & _contract)
174
174
{
175
- solAssert (any_of (m_options.input .mode , ValidInputModes) );
175
+ solAssert (ValidInputModes. count (m_options.input .mode ) == 1 );
176
176
177
177
if (m_options.compiler .outputs .binary )
178
178
{
@@ -198,7 +198,7 @@ void CommandLineInterface::handleBinary(string const& _contract)
198
198
199
199
void CommandLineInterface::handleOpcode (string const & _contract)
200
200
{
201
- solAssert (any_of (m_options.input .mode , ValidInputModes) );
201
+ solAssert (ValidInputModes. count (m_options.input .mode ) == 1 );
202
202
203
203
if (!m_options.output .dir .empty ())
204
204
createFile (m_compiler->filesystemFriendlyName (_contract) + " .opcode" , evmasm::disassemble (m_compiler->object (_contract).bytecode ));
@@ -212,7 +212,7 @@ void CommandLineInterface::handleOpcode(string const& _contract)
212
212
213
213
void CommandLineInterface::handleIR (string const & _contractName)
214
214
{
215
- solAssert (any_of (m_options.input .mode , ValidInputModes) );
215
+ solAssert (ValidInputModes. count (m_options.input .mode ) == 1 );
216
216
217
217
if (!m_options.compiler .outputs .ir )
218
218
return ;
@@ -228,7 +228,7 @@ void CommandLineInterface::handleIR(string const& _contractName)
228
228
229
229
void CommandLineInterface::handleIROptimized (string const & _contractName)
230
230
{
231
- solAssert (any_of (m_options.input .mode , ValidInputModes) );
231
+ solAssert (ValidInputModes. count (m_options.input .mode ) == 1 );
232
232
233
233
if (!m_options.compiler .outputs .irOptimized )
234
234
return ;
@@ -244,7 +244,7 @@ void CommandLineInterface::handleIROptimized(string const& _contractName)
244
244
245
245
void CommandLineInterface::handleEwasm (string const & _contractName)
246
246
{
247
- solAssert (any_of (m_options.input .mode , ValidInputModes) );
247
+ solAssert (ValidInputModes. count (m_options.input .mode ) == 1 );
248
248
249
249
if (!m_options.compiler .outputs .ewasm )
250
250
return ;
@@ -267,7 +267,7 @@ void CommandLineInterface::handleEwasm(string const& _contractName)
267
267
268
268
void CommandLineInterface::handleBytecode (string const & _contract)
269
269
{
270
- solAssert (any_of (m_options.input .mode , ValidInputModes) );
270
+ solAssert (ValidInputModes. count (m_options.input .mode ) == 1 );
271
271
272
272
if (m_options.compiler .outputs .opcodes )
273
273
handleOpcode (_contract);
@@ -277,7 +277,7 @@ void CommandLineInterface::handleBytecode(string const& _contract)
277
277
278
278
void CommandLineInterface::handleSignatureHashes (string const & _contract)
279
279
{
280
- solAssert (any_of (m_options.input .mode , ValidInputModes) );
280
+ solAssert (ValidInputModes. count (m_options.input .mode ) == 1 );
281
281
282
282
if (!m_options.compiler .outputs .signatureHashes )
283
283
return ;
@@ -309,7 +309,7 @@ void CommandLineInterface::handleSignatureHashes(string const& _contract)
309
309
310
310
void CommandLineInterface::handleMetadata (string const & _contract)
311
311
{
312
- solAssert (any_of (m_options.input .mode , ValidInputModes) );
312
+ solAssert (ValidInputModes. count (m_options.input .mode ) == 1 );
313
313
314
314
if (!m_options.compiler .outputs .metadata )
315
315
return ;
@@ -323,7 +323,7 @@ void CommandLineInterface::handleMetadata(string const& _contract)
323
323
324
324
void CommandLineInterface::handleABI (string const & _contract)
325
325
{
326
- solAssert (any_of (m_options.input .mode , ValidInputModes) );
326
+ solAssert (ValidInputModes. count (m_options.input .mode ) == 1 );
327
327
328
328
if (!m_options.compiler .outputs .abi )
329
329
return ;
@@ -337,7 +337,7 @@ void CommandLineInterface::handleABI(string const& _contract)
337
337
338
338
void CommandLineInterface::handleStorageLayout (string const & _contract)
339
339
{
340
- solAssert (any_of (m_options.input .mode , ValidInputModes) );
340
+ solAssert (ValidInputModes. count (m_options.input .mode ) == 1 );
341
341
342
342
if (!m_options.compiler .outputs .storageLayout )
343
343
return ;
@@ -351,7 +351,7 @@ void CommandLineInterface::handleStorageLayout(string const& _contract)
351
351
352
352
void CommandLineInterface::handleNatspec (bool _natspecDev, string const & _contract)
353
353
{
354
- solAssert (any_of (m_options.input .mode , ValidInputModes) );
354
+ solAssert (ValidInputModes. count (m_options.input .mode ) == 1 );
355
355
356
356
bool enabled = false ;
357
357
std::string suffix;
@@ -394,7 +394,7 @@ void CommandLineInterface::handleNatspec(bool _natspecDev, string const& _contra
394
394
395
395
void CommandLineInterface::handleGasEstimation (string const & _contract)
396
396
{
397
- solAssert (any_of (m_options.input .mode , ValidInputModes) );
397
+ solAssert (ValidInputModes. count (m_options.input .mode ) == 1 );
398
398
399
399
Json::Value estimates = m_compiler->gasEstimates (_contract);
400
400
sout () << " Gas estimation:" << endl;
@@ -438,7 +438,7 @@ void CommandLineInterface::readInputFiles()
438
438
{
439
439
solAssert (!m_standardJsonInput.has_value ());
440
440
441
- if (any_of (m_options. input . mode , {InputMode::Help, InputMode::License, InputMode::Version}) )
441
+ if (std::set<InputMode> {InputMode::Help, InputMode::License, InputMode::Version}. count (m_options. input . mode ) == 1 )
442
442
return ;
443
443
444
444
m_fileReader.setBasePath (m_options.input .basePath );
@@ -706,7 +706,7 @@ void CommandLineInterface::printLicense()
706
706
707
707
void CommandLineInterface::compile ()
708
708
{
709
- solAssert (any_of (m_options.input .mode , ValidInputModes) );
709
+ solAssert (ValidInputModes. count (m_options.input .mode ) == 1 );
710
710
711
711
m_compiler = make_unique<CompilerStack>(m_fileReader.reader ());
712
712
@@ -824,7 +824,7 @@ void CommandLineInterface::compile()
824
824
825
825
void CommandLineInterface::handleCombinedJSON ()
826
826
{
827
- solAssert (any_of (m_options.input .mode , ValidInputModes) );
827
+ solAssert (ValidInputModes. count (m_options.input .mode ) == 1 );
828
828
829
829
if (!m_options.compiler .combinedJsonRequests .has_value ())
830
830
return ;
@@ -916,7 +916,7 @@ void CommandLineInterface::handleCombinedJSON()
916
916
917
917
void CommandLineInterface::handleAst ()
918
918
{
919
- solAssert (any_of (m_options.input .mode , ValidInputModes) );
919
+ solAssert (ValidInputModes. count (m_options.input .mode ) == 1 );
920
920
921
921
if (!m_options.compiler .outputs .astCompactJson )
922
922
return ;
@@ -1141,7 +1141,7 @@ void CommandLineInterface::assemble(yul::YulStack::Language _language, yul::YulS
1141
1141
serr () << " No binary representation found." << endl;
1142
1142
}
1143
1143
1144
- solAssert (any_of ( _targetMachine, { yul::YulStack::Machine::Ewasm, yul::YulStack::Machine::EVM}) );
1144
+ solAssert (_targetMachine == yul::YulStack::Machine::Ewasm || _targetMachine == yul::YulStack::Machine::EVM, " " );
1145
1145
if (
1146
1146
(_targetMachine == yul::YulStack::Machine::EVM && m_options.compiler .outputs .asm_ ) ||
1147
1147
(_targetMachine == yul::YulStack::Machine::Ewasm && m_options.compiler .outputs .ewasm )
@@ -1158,7 +1158,7 @@ void CommandLineInterface::assemble(yul::YulStack::Language _language, yul::YulS
1158
1158
1159
1159
void CommandLineInterface::outputCompilationResults ()
1160
1160
{
1161
- solAssert (any_of (m_options.input .mode , ValidInputModes) );
1161
+ solAssert (ValidInputModes. count (m_options.input .mode ) == 1 );
1162
1162
1163
1163
handleCombinedJSON ();
1164
1164
0 commit comments