@@ -394,7 +394,7 @@ void CompilerStack::importEvmAssemblyJson(map<string, Json::Value> const& _sourc
394
394
if (m_stackState != Empty)
395
395
solThrow (CompilerError, " Must call importEvmAssemblyJson only before the SourcesSet state." );
396
396
397
- m_evmAssemblyJson = std::make_unique<Json::Value>( _sources.begin ()->second ) ;
397
+ m_evmAssemblyJson[_sources. begin ()-> first ] = _sources.begin ()->second ;
398
398
m_importedSources = true ;
399
399
m_stackState = SourcesSet;
400
400
}
@@ -654,58 +654,73 @@ bool CompilerStack::compile(State _stopAfter)
654
654
if (m_hasError)
655
655
solThrow (CompilerError, " Called compile with errors." );
656
656
657
- // Only compile contracts individually which have been requested.
658
- map<ContractDefinition const *, shared_ptr<Compiler const >> otherCompilers;
657
+ if (!m_evmAssemblyJson.empty ())
658
+ {
659
+ solAssert (m_importedSources, " " );
660
+ solAssert (m_evmAssemblyJson.size () == 1 , " " );
659
661
660
- for (Source const * source: m_sourceOrder)
661
- for (ASTPointer<ASTNode> const & node: source->ast ->nodes ())
662
- if (auto contract = dynamic_cast <ContractDefinition const *>(node.get ()))
663
- if (isRequestedContract (*contract))
664
- {
665
- try
662
+ string const evmAssemblyJsonSource = m_evmAssemblyJson.begin ()->first ;
663
+
664
+ m_contracts[evmAssemblyJsonSource].evmAssembly = make_shared<evmasm::Assembly>(evmAssemblyJsonSource);
665
+ m_contracts[evmAssemblyJsonSource].evmAssembly ->loadFromAssemblyJSON (m_evmAssemblyJson[evmAssemblyJsonSource]);
666
+ m_contracts[evmAssemblyJsonSource].object = m_contracts[evmAssemblyJsonSource].evmAssembly ->assemble ();
667
+
668
+ m_contracts[evmAssemblyJsonSource].evmRuntimeAssembly = make_shared<evmasm::Assembly>(evmAssemblyJsonSource);
669
+ m_contracts[evmAssemblyJsonSource].evmRuntimeAssembly ->loadFromAssemblyJSON (m_evmAssemblyJson[evmAssemblyJsonSource][" .data" ][" 0" ]);
670
+ m_contracts[evmAssemblyJsonSource].runtimeObject = m_contracts[evmAssemblyJsonSource].evmRuntimeAssembly ->assemble ();
671
+ }
672
+ else
673
+ {
674
+ // Only compile contracts individually which have been requested.
675
+ map<ContractDefinition const *, shared_ptr<Compiler const >> otherCompilers;
676
+
677
+ for (Source const * source: m_sourceOrder)
678
+ for (ASTPointer<ASTNode> const & node: source->ast ->nodes ())
679
+ if (auto contract = dynamic_cast <ContractDefinition const *>(node.get ()))
680
+ if (isRequestedContract (*contract))
666
681
{
667
- if (m_viaIR || m_generateIR || m_generateEwasm)
668
- generateIR (*contract);
669
- if (m_generateEvmBytecode)
682
+ try
670
683
{
671
- if (m_viaIR)
672
- generateEVMFromIR (*contract);
673
- else
674
- compileContract (*contract, otherCompilers);
684
+ if (m_viaIR || m_generateIR || m_generateEwasm)
685
+ generateIR (*contract);
686
+ if (m_generateEvmBytecode)
687
+ {
688
+ if (m_viaIR)
689
+ generateEVMFromIR (*contract);
690
+ else
691
+ compileContract (*contract, otherCompilers);
692
+ }
693
+ if (m_generateEwasm)
694
+ generateEwasm (*contract);
675
695
}
676
- if (m_generateEwasm)
677
- generateEwasm (*contract);
678
- }
679
- catch (Error const & _error)
680
- {
681
- if (_error.type () != Error::Type::CodeGenerationError)
682
- throw ;
683
- m_errorReporter.error (_error.errorId (), _error.type (), SourceLocation (), _error.what ());
684
- return false ;
685
- }
686
- catch (UnimplementedFeatureError const & _unimplementedError)
687
- {
688
- if (
689
- SourceLocation const * sourceLocation =
690
- boost::get_error_info<langutil::errinfo_sourceLocation>(_unimplementedError)
691
- )
696
+ catch (Error const & _error)
692
697
{
693
- string const * comment = _unimplementedError.comment ();
694
- m_errorReporter.error (
695
- 1834_error,
696
- Error::Type::CodeGenerationError,
697
- *sourceLocation,
698
- " Unimplemented feature error" +
699
- ((comment && !comment->empty ()) ? " : " + *comment : string{}) +
700
- " in " +
701
- _unimplementedError.lineInfo ()
702
- );
698
+ if (_error.type () != Error::Type::CodeGenerationError)
699
+ throw ;
700
+ m_errorReporter.error (_error.errorId (), _error.type (), SourceLocation (), _error.what ());
703
701
return false ;
704
702
}
705
- else
706
- throw ;
703
+ catch (UnimplementedFeatureError const & _unimplementedError)
704
+ {
705
+ if (SourceLocation const * sourceLocation
706
+ = boost::get_error_info<langutil::errinfo_sourceLocation>(_unimplementedError))
707
+ {
708
+ string const * comment = _unimplementedError.comment ();
709
+ m_errorReporter.error (
710
+ 1834_error,
711
+ Error::Type::CodeGenerationError,
712
+ *sourceLocation,
713
+ " Unimplemented feature error"
714
+ + ((comment && !comment->empty ()) ? " : " + *comment : string{}) + " in "
715
+ + _unimplementedError.lineInfo ());
716
+ return false ;
717
+ }
718
+ else
719
+ throw ;
720
+ }
707
721
}
708
- }
722
+ }
723
+
709
724
m_stackState = CompilationSuccessful;
710
725
this ->link ();
711
726
return true ;
0 commit comments