From 652bc583c0abde30cd54b960502ac50ffd8192d4 Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 3 May 2016 01:13:41 +0200 Subject: Remove non-determinism in missing code queue. --- libsolidity/codegen/Compiler.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'libsolidity/codegen/Compiler.cpp') diff --git a/libsolidity/codegen/Compiler.cpp b/libsolidity/codegen/Compiler.cpp index d4c94297..1675f659 100644 --- a/libsolidity/codegen/Compiler.cpp +++ b/libsolidity/codegen/Compiler.cpp @@ -58,7 +58,7 @@ void Compiler::compileContract( CompilerContext::LocationSetter locationSetterRunTime(m_context, _contract); initializeContext(_contract, _contracts); appendFunctionSelector(_contract); - appendFunctionsWithoutCode(); + appendMissingFunctions(); } // Swap the runtime context with the creation-time context @@ -95,7 +95,7 @@ void Compiler::compileClone( m_context << Instruction::DUP1 << runtimeSub << u256(0) << Instruction::CODECOPY; m_context << u256(0) << Instruction::RETURN; - appendFunctionsWithoutCode(); + appendMissingFunctions(); if (m_optimize) m_context.optimise(m_optimizeRuns); @@ -168,7 +168,7 @@ void Compiler::packIntoContractCreator(ContractDefinition const& _contract, Comp m_context << u256(0) << Instruction::RETURN; // note that we have to include the functions again because of absolute jump labels - appendFunctionsWithoutCode(); + appendMissingFunctions(); } void Compiler::appendBaseConstructor(FunctionDefinition const& _constructor) @@ -778,17 +778,13 @@ bool Compiler::visit(PlaceholderStatement const& _placeholderStatement) return true; } -void Compiler::appendFunctionsWithoutCode() +void Compiler::appendMissingFunctions() { - set functions = m_context.functionsWithoutCode(); - while (!functions.empty()) + while (Declaration const* function = m_context.nextFunctionToCompile()) { - for (Declaration const* function: functions) - { - m_context.setStackOffset(0); - function->accept(*this); - } - functions = m_context.functionsWithoutCode(); + m_context.setStackOffset(0); + function->accept(*this); + solAssert(m_context.nextFunctionToCompile() != function, "Compiled the wrong function?"); } } -- cgit