@@ -391,10 +391,23 @@ bool CompilerStack::parse()
391
391
void CompilerStack::importEvmAssemblyJson (map<string, Json::Value> const & _sources)
392
392
{
393
393
solAssert (_sources.size () == 1 , " " );
394
+ solAssert (m_sources.empty (), " " );
395
+ solAssert (m_sourceOrder.empty (), " " );
394
396
if (m_stackState != Empty)
395
397
solThrow (CompilerError, " Must call importEvmAssemblyJson only before the SourcesSet state." );
396
398
397
- m_evmAssemblyJson[_sources.begin ()->first ] = _sources.begin ()->second ;
399
+ Json::Value jsonValue = _sources.begin ()->second ;
400
+ if (jsonValue.isMember (" sourceList" ))
401
+ {
402
+ for (auto const & item: jsonValue[" sourceList" ])
403
+ {
404
+ Source source;
405
+ source.charStream = std::make_shared<CharStream>(item.asString (), " " );
406
+ m_sources.emplace (std::make_pair (item.asString (), source));
407
+ m_sourceOrder.push_back (&m_sources[item.asString ()]);
408
+ }
409
+ }
410
+ m_evmAssemblyJson[_sources.begin ()->first ] = jsonValue;
398
411
m_importedSources = true ;
399
412
m_stackState = SourcesSet;
400
413
}
@@ -608,6 +621,9 @@ bool CompilerStack::parseAndAnalyze(State _stopAfter)
608
621
{
609
622
m_stopAfter = _stopAfter;
610
623
624
+ if (!m_evmAssemblyJson.empty ())
625
+ return true ;
626
+
611
627
bool success = parse ();
612
628
if (m_stackState >= m_stopAfter)
613
629
return success;
@@ -962,20 +978,27 @@ Json::Value CompilerStack::assemblyJSON(string const& _contractName) const
962
978
963
979
vector<string> CompilerStack::sourceNames () const
964
980
{
965
- vector<string> names;
966
- for (auto const & s: m_sources)
967
- names.push_back (s.first );
981
+ map<string, unsigned > indices = sourceIndices ();
982
+ vector<string> names (indices.size ());
983
+ for (auto const & s: indices)
984
+ names[s.second ] = s.first ;
968
985
return names;
969
986
}
970
987
971
988
map<string, unsigned > CompilerStack::sourceIndices () const
972
989
{
973
990
map<string, unsigned > indices;
974
991
unsigned index = 0 ;
975
- for (auto const & s: m_sources)
976
- indices[s.first ] = index++;
977
- solAssert (!indices.count (CompilerContext::yulUtilityFileName ()), " " );
978
- indices[CompilerContext::yulUtilityFileName ()] = index++;
992
+ if (m_evmAssemblyJson.empty ())
993
+ {
994
+ for (auto const & s: m_sources)
995
+ indices[s.first ] = index++;
996
+ solAssert (!indices.count (CompilerContext::yulUtilityFileName ()), " " );
997
+ indices[CompilerContext::yulUtilityFileName ()] = index++;
998
+ }
999
+ else
1000
+ for (auto const & s: m_sourceOrder)
1001
+ indices[s->charStream ->source ()] = index++;
979
1002
return indices;
980
1003
}
981
1004
0 commit comments