MCPcopy Create free account
hub / github.com/argotorg/solidity / compile

Method compile

libsolidity/interface/CompilerStack.cpp:780–843  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

778}
779
780bool CompilerStack::compile(State _stopAfter)
781{
782 m_stopAfter = _stopAfter;
783
784 solAssert(!m_viaSSACFG || m_experimental, "SSA CFG code generation is an experimental feature. It requires experimental mode to be enabled.");
785
786 if (m_stackState < AnalysisSuccessful)
787 if (!parseAndAnalyze(_stopAfter))
788 return false;
789
790 if (m_stackState >= m_stopAfter)
791 return true;
792
793 // Only compile contracts individually which have been requested.
794 std::map<ContractDefinition const*, std::shared_ptr<Compiler const>> otherCompilers;
795 bool requiresFullCompilation = false;
796
797 for (Source const* source: m_sourceOrder)
798 for (ASTPointer<ASTNode> const& node: source->ast->nodes())
799 if (auto contract = dynamic_cast<ContractDefinition const*>(node.get()))
800 if (isRequestedContract(*contract))
801 {
802 PipelineConfig pipelineConfig = requestedPipelineConfig(*contract);
803
804 try
805 {
806 // Skip if full compilation is not needed (i.e. no IR/bytecode requested)
807 if (!pipelineConfig.needsFullCompilation())
808 continue;
809 requiresFullCompilation = true;
810
811 if (pipelineConfig.needIR(m_viaIR))
812 generateIR(*contract, pipelineConfig.needIRCodegenOnly(m_viaIR));
813 if (pipelineConfig.needBytecode())
814 {
815 if (m_viaIR)
816 generateEVMFromIR(*contract);
817 else
818 {
819 if (m_experimentalAnalysis)
820 solThrow(CompilerError, "Legacy codegen after experimental analysis is unsupported.");
821 compileContract(*contract, otherCompilers);
822 }
823 }
824 }
825 catch (Error const& _error)
826 {
827 reportCodeGenerationError(_error, contract);
828 }
829 catch (UnimplementedFeatureError const& _error)
830 {
831 reportUnimplementedFeatureError(_error, contract);
832 }
833
834 if (m_errorReporter.hasErrors())
835 return false;
836 }
837

Callers

nothing calls this directly

Calls 9

linkMethod · 0.95
compileContractFunction · 0.85
nodesMethod · 0.80
needsFullCompilationMethod · 0.80
needIRMethod · 0.80
needIRCodegenOnlyMethod · 0.80
needBytecodeMethod · 0.80
getMethod · 0.45
hasErrorsMethod · 0.45

Tested by

no test coverage detected