@@ -409,41 +409,41 @@ Json::Value Assembly::assemblyJSON(map<string, unsigned> const& _sourceIndices,
409
409
return root;
410
410
}
411
411
412
- bool Assembly::loadFromAssemblyJSON (Json::Value const & _json, bool _loadSources /* = true */ )
412
+ std::shared_ptr<Assembly> Assembly::loadFromAssemblyJSON (Json::Value const & _json, std::vector<std::string> const & _sourceList /* = {} */ , bool _isCreation /* = true */ )
413
413
{
414
414
if (!_json[" .code" ].isArray ())
415
- return false ;
416
- bool success{true };
415
+ return {};
417
416
418
- if (_loadSources)
417
+ std::shared_ptr<Assembly> result = std::make_shared<Assembly>(_isCreation, " " );
418
+ vector<string> sourceList;
419
+ if (_sourceList.empty ())
419
420
{
420
- vector<string> sourceList;
421
421
if (_json.isMember (" sourceList" ))
422
422
for (auto const & it: _json[" sourceList" ])
423
423
sourceList.emplace_back (it.asString ());
424
- setSources (sourceList);
425
424
}
426
-
427
- addAssemblyItemsFromJSON (_json[" .code" ]);
425
+ else
426
+ sourceList = _sourceList;
427
+ result->setSources (sourceList);
428
+ result->addAssemblyItemsFromJSON (_json[" .code" ]);
428
429
if (_json[" .auxdata" ].isString ())
429
- m_auxiliaryData = fromHex (_json[" .auxdata" ].asString ());
430
+ result-> m_auxiliaryData = fromHex (_json[" .auxdata" ].asString ());
430
431
Json::Value const & data = _json[" .data" ];
431
432
for (Json::ValueConstIterator itr = data.begin (); itr != data.end (); itr++)
432
433
{
433
434
solAssert (itr.key ().isString (), " " );
434
435
std::string key = itr.key ().asString ();
435
436
Json::Value const & code = data[key];
436
437
if (code.isString ())
437
- m_data[h256 (fromHex (key))] = fromHex (code.asString ());
438
+ result-> m_data [h256 (fromHex (key))] = fromHex (code.asString ());
438
439
else
439
440
{
440
- shared_ptr<Assembly> subassembly = make_shared<Assembly>(false , " " );
441
- subassembly->setSources (sources ());
442
- success &= subassembly->loadFromAssemblyJSON (code, false );
443
- m_subs.emplace_back (subassembly);
441
+ std::shared_ptr<Assembly> subassembly (Assembly::loadFromAssemblyJSON (code, sourceList, /* isCreation = */ false ));
442
+ assertThrow (subassembly, AssemblyException, " " );
443
+ result->m_subs .emplace_back (std::make_shared<Assembly>(*subassembly));
444
444
}
445
445
}
446
- return success ;
446
+ return result ;
447
447
}
448
448
449
449
AssemblyItem Assembly::namedTag (string const & _name, size_t _params, size_t _returns, optional<uint64_t > _sourceID)
0 commit comments