2014-10-20 10:41:56 +00:00
|
|
|
/*
|
2016-11-18 23:13:20 +00:00
|
|
|
This file is part of solidity.
|
2014-10-20 10:41:56 +00:00
|
|
|
|
2016-11-18 23:13:20 +00:00
|
|
|
solidity is free software: you can redistribute it and/or modify
|
2014-10-20 10:41:56 +00:00
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
2016-11-18 23:13:20 +00:00
|
|
|
solidity is distributed in the hope that it will be useful,
|
2014-10-20 10:41:56 +00:00
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2016-11-18 23:13:20 +00:00
|
|
|
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
2014-10-20 10:41:56 +00:00
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* @author Christian <c@ethdev.com>
|
|
|
|
* @date 2014
|
2014-10-30 00:20:32 +00:00
|
|
|
* Solidity compiler.
|
2014-10-20 10:41:56 +00:00
|
|
|
*/
|
|
|
|
|
2015-10-20 22:21:52 +00:00
|
|
|
#include <libsolidity/codegen/Compiler.h>
|
2018-12-17 16:06:11 +00:00
|
|
|
|
2016-05-19 17:32:14 +00:00
|
|
|
#include <libsolidity/codegen/ContractCompiler.h>
|
2018-12-17 16:06:11 +00:00
|
|
|
#include <libevmasm/Assembly.h>
|
2016-05-19 17:32:14 +00:00
|
|
|
|
2014-10-30 00:20:32 +00:00
|
|
|
using namespace std;
|
2015-06-15 10:10:41 +00:00
|
|
|
using namespace dev;
|
|
|
|
using namespace dev::solidity;
|
2014-10-20 10:41:56 +00:00
|
|
|
|
2015-09-10 10:01:05 +00:00
|
|
|
void Compiler::compileContract(
|
|
|
|
ContractDefinition const& _contract,
|
2019-01-10 15:44:31 +00:00
|
|
|
std::map<ContractDefinition const*, shared_ptr<Compiler const>> const& _otherCompilers,
|
2016-11-29 16:47:47 +00:00
|
|
|
bytes const& _metadata
|
2015-09-11 13:25:00 +00:00
|
|
|
)
|
2014-10-20 10:41:56 +00:00
|
|
|
{
|
2018-09-10 10:09:42 +00:00
|
|
|
ContractCompiler runtimeCompiler(nullptr, m_runtimeContext, m_optimize, m_optimizeRuns);
|
2019-01-10 15:44:31 +00:00
|
|
|
runtimeCompiler.compileContract(_contract, _otherCompilers);
|
2016-11-29 16:47:47 +00:00
|
|
|
m_runtimeContext.appendAuxiliaryData(_metadata);
|
2016-05-19 17:32:14 +00:00
|
|
|
|
2016-11-10 17:16:21 +00:00
|
|
|
// This might modify m_runtimeContext because it can access runtime functions at
|
|
|
|
// creation time.
|
2018-09-10 10:09:42 +00:00
|
|
|
ContractCompiler creationCompiler(&runtimeCompiler, m_context, m_optimize, 1);
|
2019-01-10 15:44:31 +00:00
|
|
|
m_runtimeSub = creationCompiler.compileConstructor(_contract, _otherCompilers);
|
2015-01-26 15:58:54 +00:00
|
|
|
|
2016-11-11 13:11:07 +00:00
|
|
|
m_context.optimise(m_optimize, m_optimizeRuns);
|
2014-12-15 21:57:39 +00:00
|
|
|
}
|
2014-11-19 09:24:22 +00:00
|
|
|
|
2019-01-16 10:44:11 +00:00
|
|
|
std::shared_ptr<eth::Assembly> Compiler::runtimeAssemblyPtr() const
|
|
|
|
{
|
|
|
|
solAssert(m_context.runtimeContext(), "");
|
|
|
|
return m_context.runtimeContext()->assemblyPtr();
|
|
|
|
}
|
|
|
|
|
2015-08-31 16:44:29 +00:00
|
|
|
eth::AssemblyItem Compiler::functionEntryLabel(FunctionDefinition const& _function) const
|
2015-05-26 09:27:59 +00:00
|
|
|
{
|
2015-08-31 16:44:29 +00:00
|
|
|
return m_runtimeContext.functionEntryLabelIfExists(_function);
|
2015-05-26 09:27:59 +00:00
|
|
|
}
|