solidity/libsolidity/codegen/Compiler.cpp

68 lines
2.0 KiB
C++
Raw Normal View History

2014-10-20 10:41:56 +00:00
/*
This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify
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.
cpp-ethereum is distributed in the hope that it will be useful,
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
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @author Christian <c@ethdev.com>
* @date 2014
* Solidity compiler.
2014-10-20 10:41:56 +00:00
*/
2015-10-20 22:21:52 +00:00
#include <libsolidity/codegen/Compiler.h>
#include <libevmasm/Assembly.h>
#include <libsolidity/codegen/ContractCompiler.h>
using namespace std;
using namespace dev;
using namespace dev::solidity;
2014-10-20 10:41:56 +00:00
void Compiler::compileContract(
ContractDefinition const& _contract,
2015-09-11 13:25:00 +00:00
std::map<const ContractDefinition*, eth::Assembly const*> const& _contracts
)
2014-10-20 10:41:56 +00:00
{
ContractCompiler runtimeCompiler(m_runtimeContext, m_optimize);
runtimeCompiler.compileContract(_contract, _contracts);
ContractCompiler creationCompiler(m_context, m_optimize);
m_runtimeSub = creationCompiler.compileConstructor(m_runtimeContext, _contract, _contracts);
2015-01-26 15:58:54 +00:00
2015-06-01 10:32:59 +00:00
if (m_optimize)
m_context.optimise(m_optimizeRuns);
2015-10-06 12:13:07 +00:00
if (_contract.isLibrary())
{
solAssert(m_runtimeSub != size_t(-1), "");
m_context.injectVersionStampIntoSub(m_runtimeSub);
}
2014-12-15 21:57:39 +00:00
}
2014-11-19 09:24:22 +00:00
2015-07-31 17:23:31 +00:00
void Compiler::compileClone(
ContractDefinition const& _contract,
map<ContractDefinition const*, eth::Assembly const*> const& _contracts
2015-07-31 17:23:31 +00:00
)
{
ContractCompiler cloneCompiler(m_context, m_optimize);
m_runtimeSub = cloneCompiler.compileClone(_contract, _contracts);
2015-07-31 17:23:31 +00:00
if (m_optimize)
m_context.optimise(m_optimizeRuns);
}
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
}