@@ -52,6 +52,7 @@ static string const g_strExperimentalViaIR = "experimental-via-ir";
52
52
static string const g_strGas = " gas" ;
53
53
static string const g_strHelp = " help" ;
54
54
static string const g_strImportAst = " import-ast" ;
55
+ static string const g_strImportEvmAssemblerJson = " import-asm-json" ;
55
56
static string const g_strInputFile = " input-file" ;
56
57
static string const g_strYul = " yul" ;
57
58
static string const g_strYulDialect = " yul-dialect" ;
@@ -139,6 +140,7 @@ static map<InputMode, string> const g_inputModeName = {
139
140
{InputMode::StandardJson, " standard JSON" },
140
141
{InputMode::Linker, " linker" },
141
142
{InputMode::LanguageServer, " language server (LSP)" },
143
+ {InputMode::CompilerWithEvmAssemblyJsonImport, " assembler (EVM ASM JSON import)" },
142
144
};
143
145
144
146
void CommandLineParser::checkMutuallyExclusive (vector<string> const & _optionNames)
@@ -463,6 +465,13 @@ void CommandLineParser::parseOutputSelection()
463
465
CompilerOutputs::componentName (&CompilerOutputs::ewasm),
464
466
CompilerOutputs::componentName (&CompilerOutputs::ewasmIR),
465
467
};
468
+ static set<string> const evmAssemblyJsonImportModeOutputs = {
469
+ CompilerOutputs::componentName (&CompilerOutputs::asm_),
470
+ CompilerOutputs::componentName (&CompilerOutputs::binary),
471
+ CompilerOutputs::componentName (&CompilerOutputs::binaryRuntime),
472
+ CompilerOutputs::componentName (&CompilerOutputs::opcodes),
473
+ CompilerOutputs::componentName (&CompilerOutputs::asmJson),
474
+ };
466
475
467
476
switch (_mode)
468
477
{
@@ -474,6 +483,8 @@ void CommandLineParser::parseOutputSelection()
474
483
case InputMode::Compiler:
475
484
case InputMode::CompilerWithASTImport:
476
485
return util::contains (compilerModeOutputs, _outputName);
486
+ case InputMode::CompilerWithEvmAssemblyJsonImport:
487
+ return util::contains (evmAssemblyJsonImportModeOutputs, _outputName);
477
488
case InputMode::Assembler:
478
489
return util::contains (assemblerModeOutputs, _outputName);
479
490
case InputMode::StandardJson:
@@ -652,6 +663,10 @@ General Information)").c_str(),
652
663
" Supported Inputs is the output of the --" + g_strStandardJSON + " or the one produced by "
653
664
" --" + g_strCombinedJson + " " + CombinedJsonRequests::componentName (&CombinedJsonRequests::ast)).c_str ()
654
665
)
666
+ (
667
+ g_strImportEvmAssemblerJson.c_str (),
668
+ " Import EVM Assembly JSON, assumes input holds the EVM Assembly in JSON format."
669
+ )
655
670
(
656
671
g_strLSP.c_str (),
657
672
" Switch to language server mode (\" LSP\" ). Allows the compiler to be used as an analysis backend "
@@ -912,6 +927,8 @@ void CommandLineParser::processArgs()
912
927
m_options.input .mode = InputMode::Linker;
913
928
else if (m_args.count (g_strImportAst) > 0 )
914
929
m_options.input .mode = InputMode::CompilerWithASTImport;
930
+ else if (m_args.count (g_strImportEvmAssemblerJson) > 0 )
931
+ m_options.input .mode = InputMode::CompilerWithEvmAssemblyJsonImport;
915
932
else
916
933
m_options.input .mode = InputMode::Compiler;
917
934
@@ -977,9 +994,27 @@ void CommandLineParser::processArgs()
977
994
for (auto & option: conflictingWithStopAfter)
978
995
checkMutuallyExclusive ({g_strStopAfter, option});
979
996
997
+ array<string, 11 > const conflictingWithAsmJsonImport{
998
+ CompilerOutputs::componentName (&CompilerOutputs::ir),
999
+ CompilerOutputs::componentName (&CompilerOutputs::irOptimized),
1000
+ CompilerOutputs::componentName (&CompilerOutputs::ewasm),
1001
+ CompilerOutputs::componentName (&CompilerOutputs::ewasmIR),
1002
+ g_strGas,
1003
+ CompilerOutputs::componentName (&CompilerOutputs::metadata),
1004
+ CompilerOutputs::componentName (&CompilerOutputs::natspecDev),
1005
+ CompilerOutputs::componentName (&CompilerOutputs::natspecUser),
1006
+ CompilerOutputs::componentName (&CompilerOutputs::signatureHashes),
1007
+ CompilerOutputs::componentName (&CompilerOutputs::storageLayout),
1008
+ CompilerOutputs::componentName (&CompilerOutputs::astCompactJson),
1009
+ };
1010
+
1011
+ for (auto & option: conflictingWithAsmJsonImport)
1012
+ checkMutuallyExclusive ({g_strImportEvmAssemblerJson, option});
1013
+
980
1014
if (
981
1015
m_options.input .mode != InputMode::Compiler &&
982
1016
m_options.input .mode != InputMode::CompilerWithASTImport &&
1017
+ m_options.input .mode != InputMode::CompilerWithEvmAssemblyJsonImport &&
983
1018
m_options.input .mode != InputMode::Assembler
984
1019
)
985
1020
{
@@ -1013,7 +1048,7 @@ void CommandLineParser::processArgs()
1013
1048
if (m_args.count (g_strRevertStrings))
1014
1049
{
1015
1050
string revertStringsString = m_args[g_strRevertStrings].as <string>();
1016
- std:: optional<RevertStrings> revertStrings = revertStringsFromString (revertStringsString);
1051
+ optional<RevertStrings> revertStrings = revertStringsFromString (revertStringsString);
1017
1052
if (!revertStrings)
1018
1053
solThrow (
1019
1054
CommandLineValidationError,
@@ -1107,7 +1142,7 @@ void CommandLineParser::processArgs()
1107
1142
if (m_args.count (g_strEVMVersion))
1108
1143
{
1109
1144
string versionOptionStr = m_args[g_strEVMVersion].as <string>();
1110
- std:: optional<langutil::EVMVersion> versionOption = langutil::EVMVersion::fromString (versionOptionStr);
1145
+ optional<langutil::EVMVersion> versionOption = langutil::EVMVersion::fromString (versionOptionStr);
1111
1146
if (!versionOption)
1112
1147
solThrow (CommandLineValidationError, " Invalid option for --" + g_strEVMVersion + " : " + versionOptionStr);
1113
1148
m_options.output .evmVersion = *versionOption;
@@ -1311,7 +1346,11 @@ void CommandLineParser::processArgs()
1311
1346
if (m_options.input .mode == InputMode::Compiler)
1312
1347
m_options.input .errorRecovery = (m_args.count (g_strErrorRecovery) > 0 );
1313
1348
1314
- solAssert (m_options.input .mode == InputMode::Compiler || m_options.input .mode == InputMode::CompilerWithASTImport);
1349
+ solAssert (
1350
+ m_options.input .mode == InputMode::Compiler ||
1351
+ m_options.input .mode == InputMode::CompilerWithASTImport ||
1352
+ m_options.input .mode == InputMode::CompilerWithEvmAssemblyJsonImport
1353
+ );
1315
1354
}
1316
1355
1317
1356
void CommandLineParser::parseCombinedJsonOption ()
0 commit comments