Coverage Report

Created: 2022-08-24 06:31

/src/solidity/libsolidity/codegen/Compiler.cpp
Line
Count
Source (jump to first uncovered line)
1
/*
2
  This file is part of solidity.
3
4
  solidity is free software: you can redistribute it and/or modify
5
  it under the terms of the GNU General Public License as published by
6
  the Free Software Foundation, either version 3 of the License, or
7
  (at your option) any later version.
8
9
  solidity is distributed in the hope that it will be useful,
10
  but WITHOUT ANY WARRANTY; without even the implied warranty of
11
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
  GNU General Public License for more details.
13
14
  You should have received a copy of the GNU General Public License
15
  along with solidity.  If not, see <http://www.gnu.org/licenses/>.
16
*/
17
// SPDX-License-Identifier: GPL-3.0
18
/**
19
 * @author Christian <c@ethdev.com>
20
 * @date 2014
21
 * Solidity compiler.
22
 */
23
24
#include <libsolidity/codegen/Compiler.h>
25
26
#include <libsolidity/codegen/ContractCompiler.h>
27
#include <libevmasm/Assembly.h>
28
29
using namespace std;
30
using namespace solidity;
31
using namespace solidity::frontend;
32
33
void Compiler::compileContract(
34
  ContractDefinition const& _contract,
35
  std::map<ContractDefinition const*, shared_ptr<Compiler const>> const& _otherCompilers,
36
  bytes const& _metadata
37
)
38
0
{
39
0
  ContractCompiler runtimeCompiler(nullptr, m_runtimeContext, m_optimiserSettings);
40
0
  runtimeCompiler.compileContract(_contract, _otherCompilers);
41
0
  m_runtimeContext.appendToAuxiliaryData(_metadata);
42
43
  // This might modify m_runtimeContext because it can access runtime functions at
44
  // creation time.
45
0
  OptimiserSettings creationSettings{m_optimiserSettings};
46
  // The creation code will be executed at most once, so we modify the optimizer
47
  // settings accordingly.
48
0
  creationSettings.expectedExecutionsPerDeployment = 1;
49
0
  ContractCompiler creationCompiler(&runtimeCompiler, m_context, creationSettings);
50
0
  m_runtimeSub = creationCompiler.compileConstructor(_contract, _otherCompilers);
51
52
0
  m_context.optimise(m_optimiserSettings);
53
54
0
  solAssert(m_context.appendYulUtilityFunctionsRan(), "appendYulUtilityFunctions() was not called.");
55
0
  solAssert(m_runtimeContext.appendYulUtilityFunctionsRan(), "appendYulUtilityFunctions() was not called.");
56
0
}
57
58
std::shared_ptr<evmasm::Assembly> Compiler::runtimeAssemblyPtr() const
59
0
{
60
0
  solAssert(m_context.runtimeContext(), "");
61
0
  return m_context.runtimeContext()->assemblyPtr();
62
0
}