Browse Source

Merge pull request #2147 from chriseth/sol_fix_sourceLocations

Added missing source locations for new memory management code.
cl-refactor
Gav Wood 10 years ago
parent
commit
838ee26689
  1. 4
      libsolidity/Compiler.cpp
  2. 4
      test/libsolidity/Assembly.cpp

4
libsolidity/Compiler.cpp

@ -52,6 +52,8 @@ void Compiler::compileContract(ContractDefinition const& _contract,
map<ContractDefinition const*, bytes const*> const& _contracts) map<ContractDefinition const*, bytes const*> const& _contracts)
{ {
m_context = CompilerContext(); // clear it just in case m_context = CompilerContext(); // clear it just in case
{
CompilerContext::LocationSetter locationSetterRunTime(m_context, _contract);
CompilerUtils(m_context).initialiseFreeMemoryPointer(); CompilerUtils(m_context).initialiseFreeMemoryPointer();
initializeContext(_contract, _contracts); initializeContext(_contract, _contracts);
appendFunctionSelector(_contract); appendFunctionSelector(_contract);
@ -65,9 +67,11 @@ void Compiler::compileContract(ContractDefinition const& _contract,
} }
functions = m_context.getFunctionsWithoutCode(); functions = m_context.getFunctionsWithoutCode();
} }
}
// Swap the runtime context with the creation-time context // Swap the runtime context with the creation-time context
swap(m_context, m_runtimeContext); swap(m_context, m_runtimeContext);
CompilerContext::LocationSetter locationSetterCreationTime(m_context, _contract);
CompilerUtils(m_context).initialiseFreeMemoryPointer(); CompilerUtils(m_context).initialiseFreeMemoryPointer();
initializeContext(_contract, _contracts); initializeContext(_contract, _contracts);
packIntoContractCreator(_contract, m_runtimeContext); packIntoContractCreator(_contract, m_runtimeContext);

4
test/libsolidity/Assembly.cpp

@ -105,8 +105,8 @@ BOOST_AUTO_TEST_CASE(location_test)
shared_ptr<string const> n = make_shared<string>("source"); shared_ptr<string const> n = make_shared<string>("source");
AssemblyItems items = compileContract(sourceCode); AssemblyItems items = compileContract(sourceCode);
vector<SourceLocation> locations = vector<SourceLocation> locations =
vector<SourceLocation>(11, SourceLocation(2, 75, n)) + vector<SourceLocation>(17, SourceLocation(2, 75, n)) +
vector<SourceLocation>(12, SourceLocation(20, 72, n)) + vector<SourceLocation>(14, SourceLocation(20, 72, n)) +
vector<SourceLocation>{SourceLocation(42, 51, n), SourceLocation(65, 67, n)} + vector<SourceLocation>{SourceLocation(42, 51, n), SourceLocation(65, 67, n)} +
vector<SourceLocation>(4, SourceLocation(58, 67, n)) + vector<SourceLocation>(4, SourceLocation(58, 67, n)) +
vector<SourceLocation>(3, SourceLocation(20, 72, n)); vector<SourceLocation>(3, SourceLocation(20, 72, n));

Loading…
Cancel
Save