aboutsummaryrefslogtreecommitdiffstats
path: root/Compiler.cpp
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-06-06 01:22:30 +0800
committerchriseth <c@ethdev.com>2015-06-06 01:22:30 +0800
commit779e793d60f2076fbd35b34f0c2073e92c058eef (patch)
tree5bde2e4f0270ed40529f9ef5e79d5ecdc14666bf /Compiler.cpp
parent92eb04c6eccba8b6d7c5c02e5ca2084d9e4fecf6 (diff)
parent9efd5374ed5d3e2c5abf6d85907e1e3ac5ce5b32 (diff)
downloaddexon-solidity-779e793d60f2076fbd35b34f0c2073e92c058eef.tar
dexon-solidity-779e793d60f2076fbd35b34f0c2073e92c058eef.tar.gz
dexon-solidity-779e793d60f2076fbd35b34f0c2073e92c058eef.tar.bz2
dexon-solidity-779e793d60f2076fbd35b34f0c2073e92c058eef.tar.lz
dexon-solidity-779e793d60f2076fbd35b34f0c2073e92c058eef.tar.xz
dexon-solidity-779e793d60f2076fbd35b34f0c2073e92c058eef.tar.zst
dexon-solidity-779e793d60f2076fbd35b34f0c2073e92c058eef.zip
Merge pull request #2084 from chriseth/sol_computeConstants
Compute constants
Diffstat (limited to 'Compiler.cpp')
-rw-r--r--Compiler.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/Compiler.cpp b/Compiler.cpp
index 6425367d..6dc72840 100644
--- a/Compiler.cpp
+++ b/Compiler.cpp
@@ -69,6 +69,8 @@ void Compiler::compileContract(ContractDefinition const& _contract,
swap(m_context, m_runtimeContext);
initializeContext(_contract, _contracts);
packIntoContractCreator(_contract, m_runtimeContext);
+ if (m_optimize)
+ m_context.optimise(m_optimizeRuns);
}
eth::AssemblyItem Compiler::getFunctionEntryLabel(FunctionDefinition const& _function) const
@@ -120,9 +122,11 @@ void Compiler::packIntoContractCreator(ContractDefinition const& _contract, Comp
else if (auto c = m_context.getNextConstructor(_contract))
appendBaseConstructor(*c);
- eth::AssemblyItem sub = m_context.addSubroutine(_runtimeContext.getAssembly());
+ eth::AssemblyItem runtimeSub = m_context.addSubroutine(_runtimeContext.getAssembly());
+ solAssert(runtimeSub.data() < numeric_limits<size_t>::max(), "");
+ m_runtimeSub = size_t(runtimeSub.data());
// stack contains sub size
- m_context << eth::Instruction::DUP1 << sub << u256(0) << eth::Instruction::CODECOPY;
+ m_context << eth::Instruction::DUP1 << runtimeSub << u256(0) << eth::Instruction::CODECOPY;
m_context << u256(0) << eth::Instruction::RETURN;
// note that we have to include the functions again because of absolute jump labels