@@ -532,31 +532,29 @@ std::pair<std::shared_ptr<Assembly>, std::vector<std::string>> Assembly::fromJSO
532
532
" Member 'sourceList' may only be present in the root JSON object."
533
533
);
534
534
535
- std::shared_ptr<Assembly> result = std::make_shared<Assembly>(langutil:: EVMVersion() , _level == 0 , " " );
536
- std::vector<std::string> sourceList ;
535
+ auto result = std::make_shared<Assembly>(EVMVersion{} , _level == 0 /* _creation */ , " " /* _name */ );
536
+ std::vector<std::string> parsedSourceList ;
537
537
if (_json.isMember (" sourceList" ))
538
538
{
539
539
solAssert (_level == 0 );
540
540
solAssert (_sourceList.empty ());
541
541
for (Json::Value const & sourceName: _json[" sourceList" ])
542
542
{
543
543
solRequire (
544
- std::find (sourceList .begin (), sourceList .end (), sourceName.asString ()) == sourceList .end (),
544
+ std::find (parsedSourceList .begin (), parsedSourceList .end (), sourceName.asString ()) == parsedSourceList .end (),
545
545
AssemblyImportException,
546
546
" Items in 'sourceList' array are not unique."
547
547
);
548
- sourceList .emplace_back (sourceName.asString ());
548
+ parsedSourceList .emplace_back (sourceName.asString ());
549
549
}
550
550
}
551
- else
552
- sourceList = _sourceList;
553
551
554
552
solRequire (_json.isMember (" .code" ), AssemblyImportException, " Member '.code' is missing." );
555
553
solRequire (_json[" .code" ].isArray (), AssemblyImportException, " Member '.code' is not an array." );
556
554
for (Json::Value const & codeItem: _json[" .code" ])
557
555
solRequire (codeItem.isObject (), AssemblyImportException, " The '.code' array contains an item that is not an object." );
558
556
559
- result->importAssemblyItemsFromJSON (_json[" .code" ], sourceList );
557
+ result->importAssemblyItemsFromJSON (_json[" .code" ], _level == 0 ? parsedSourceList : _sourceList );
560
558
561
559
if (_json[" .auxdata" ])
562
560
{
@@ -605,8 +603,9 @@ std::pair<std::shared_ptr<Assembly>, std::vector<std::string>> Assembly::fromJSO
605
603
606
604
if (result->m_subs .size () <= index)
607
605
result->m_subs .resize (index + 1 );
608
- std::shared_ptr<Assembly> subassembly ( Assembly::fromJSON (dataItem, sourceList , _level + 1 ). first );
606
+ auto [ subassembly, emptySourceList] = Assembly::fromJSON (dataItem, _level == 0 ? parsedSourceList : _sourceList , _level + 1 );
609
607
solAssert (subassembly);
608
+ solAssert (emptySourceList.empty ());
610
609
result->m_subs [index] = subassembly;
611
610
}
612
611
else
@@ -615,7 +614,7 @@ std::pair<std::shared_ptr<Assembly>, std::vector<std::string>> Assembly::fromJSO
615
614
}
616
615
if (_level == 0 )
617
616
result->updatePaths ();
618
- return std::make_pair (result, sourceList );
617
+ return std::make_pair (result, _level == 0 ? parsedSourceList : std::vector<std::string>{} );
619
618
}
620
619
621
620
void Assembly::updatePaths (std::vector<Assembly*> const & _parents, std::vector<size_t > const & _absolutePathFromRoot)
0 commit comments