aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/CompilerStack.cpp
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-10-07 21:57:17 +0800
committerchriseth <c@ethdev.com>2015-10-07 23:35:07 +0800
commit24d04087d2ee4e5b2769c4bb69e5629bc1aaeb97 (patch)
treebdce0b1394334555ce5764edd451f3003cca8f4a /libsolidity/CompilerStack.cpp
parent68bf6e60c5869ab1cb862674de44e5ab4c79b5bc (diff)
downloaddexon-solidity-24d04087d2ee4e5b2769c4bb69e5629bc1aaeb97.tar.gz
dexon-solidity-24d04087d2ee4e5b2769c4bb69e5629bc1aaeb97.tar.zst
dexon-solidity-24d04087d2ee4e5b2769c4bb69e5629bc1aaeb97.zip
Resolve binary dependencies properly.
Diffstat (limited to 'libsolidity/CompilerStack.cpp')
-rw-r--r--libsolidity/CompilerStack.cpp43
1 files changed, 27 insertions, 16 deletions
diff --git a/libsolidity/CompilerStack.cpp b/libsolidity/CompilerStack.cpp
index 7d9ca32c..8c1cd8cf 100644
--- a/libsolidity/CompilerStack.cpp
+++ b/libsolidity/CompilerStack.cpp
@@ -170,22 +170,8 @@ bool CompilerStack::compile(bool _optimize, unsigned _runs)
map<ContractDefinition const*, eth::Assembly const*> compiledContracts;
for (Source const* source: m_sourceOrder)
for (ASTPointer<ASTNode> const& node: source->ast->nodes())
- if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
- {
- if (!contract->annotation().isFullyImplemented)
- continue;
- shared_ptr<Compiler> compiler = make_shared<Compiler>(_optimize, _runs);
- compiler->compileContract(*contract, compiledContracts);
- Contract& compiledContract = m_contracts.at(contract->name());
- compiledContract.compiler = compiler;
- compiledContract.object = compiler->assembledObject();
- compiledContract.runtimeObject = compiler->runtimeObject();
- compiledContracts[compiledContract.contract] = &compiler->assembly();
-
- Compiler cloneCompiler(_optimize, _runs);
- cloneCompiler.compileClone(*contract, compiledContracts);
- compiledContract.cloneObject = cloneCompiler.assembledObject();
- }
+ if (auto contract = dynamic_cast<ContractDefinition const*>(node.get()))
+ compileContract(_optimize, _runs, *contract, compiledContracts);
return true;
}
@@ -375,6 +361,31 @@ void CompilerStack::resolveImports()
swap(m_sourceOrder, sourceOrder);
}
+void CompilerStack::compileContract(
+ bool _optimize,
+ unsigned _runs,
+ ContractDefinition const& _contract,
+ map<ContractDefinition const*, eth::Assembly const*>& _compiledContracts
+)
+{
+ if (_compiledContracts.count(&_contract) || !_contract.annotation().isFullyImplemented)
+ return;
+ for (auto const* dependency: _contract.annotation().contractDependencies)
+ compileContract(_optimize, _runs, *dependency, _compiledContracts);
+
+ shared_ptr<Compiler> compiler = make_shared<Compiler>(_optimize, _runs);
+ compiler->compileContract(_contract, _compiledContracts);
+ Contract& compiledContract = m_contracts.at(_contract.name());
+ compiledContract.compiler = compiler;
+ compiledContract.object = compiler->assembledObject();
+ compiledContract.runtimeObject = compiler->runtimeObject();
+ _compiledContracts[compiledContract.contract] = &compiler->assembly();
+
+ Compiler cloneCompiler(_optimize, _runs);
+ cloneCompiler.compileClone(_contract, _compiledContracts);
+ compiledContract.cloneObject = cloneCompiler.assembledObject();
+}
+
std::string CompilerStack::defaultContractName() const
{
return contract("").contract->name();