| 1340 | } |
| 1341 | |
| 1342 | Json StandardCompiler::importEVMAssembly(StandardCompiler::InputsAndSettings _inputsAndSettings) |
| 1343 | { |
| 1344 | solAssert(_inputsAndSettings.language == "EVMAssembly"); |
| 1345 | solAssert(_inputsAndSettings.sources.empty()); |
| 1346 | solAssert(_inputsAndSettings.jsonSources.size() == 1); |
| 1347 | solAssert(_inputsAndSettings.experimental); |
| 1348 | |
| 1349 | if (!isBinaryRequested(_inputsAndSettings.outputSelection)) |
| 1350 | return Json::object(); |
| 1351 | |
| 1352 | evmasm::EVMAssemblyStack stack( |
| 1353 | _inputsAndSettings.evmVersion, |
| 1354 | _inputsAndSettings.eofVersion, |
| 1355 | evmasm::Assembly::OptimiserSettings::translateSettings( |
| 1356 | _inputsAndSettings.optimiserSettings |
| 1357 | ) |
| 1358 | ); |
| 1359 | std::string const& sourceName = _inputsAndSettings.jsonSources.begin()->first; // result of structured binding can only be used within lambda from C++20 on. |
| 1360 | Json const& sourceJson = _inputsAndSettings.jsonSources.begin()->second; |
| 1361 | try |
| 1362 | { |
| 1363 | stack.analyze(sourceName, sourceJson); |
| 1364 | stack.assemble(); |
| 1365 | } |
| 1366 | catch (evmasm::AssemblyImportException const& e) |
| 1367 | { |
| 1368 | return formatFatalError(Error::Type::Exception, "Assembly import error: " + std::string(e.what())); |
| 1369 | } |
| 1370 | catch (...) |
| 1371 | { |
| 1372 | return formatError( |
| 1373 | Error::Type::Exception, |
| 1374 | "general", |
| 1375 | "Unknown exception during assembly import: " + boost::current_exception_diagnostic_information() |
| 1376 | ); |
| 1377 | } |
| 1378 | if (!stack.compilationSuccessful()) |
| 1379 | return Json::object(); |
| 1380 | |
| 1381 | // EVM |
| 1382 | bool const wildcardMatchesExperimental = false; |
| 1383 | Json evmData; |
| 1384 | if (isArtifactRequested(_inputsAndSettings.outputSelection, sourceName, "", "evm.assembly", wildcardMatchesExperimental)) |
| 1385 | evmData["assembly"] = stack.assemblyString(sourceName, {}); |
| 1386 | if (isArtifactRequested(_inputsAndSettings.outputSelection, sourceName, "", "evm.legacyAssembly", wildcardMatchesExperimental)) |
| 1387 | evmData["legacyAssembly"] = stack.assemblyJSON(sourceName); |
| 1388 | |
| 1389 | if (isArtifactRequested( |
| 1390 | _inputsAndSettings.outputSelection, |
| 1391 | sourceName, |
| 1392 | "", |
| 1393 | evmObjectComponents("bytecode"), |
| 1394 | wildcardMatchesExperimental |
| 1395 | )) |
| 1396 | { |
| 1397 | auto const evmCreationArtifactRequested = [&](std::string const& _element) { |
| 1398 | return isArtifactRequested(_inputsAndSettings.outputSelection, sourceName, "", "evm.bytecode." + _element, wildcardMatchesExperimental); |
| 1399 | }; |
nothing calls this directly
no test coverage detected