Browse Source

Tighter coupling for Assembly items retrieval

- Exposing only assembly items, not the entire compiler context
cl-refactor
Lefteris Karapetsas 10 years ago
parent
commit
0a8acbc7db
  1. 9
      libsolidity/Compiler.h
  2. 2
      test/Assembly.cpp

9
libsolidity/Compiler.h

@ -26,6 +26,7 @@
#include <functional> #include <functional>
#include <libsolidity/ASTVisitor.h> #include <libsolidity/ASTVisitor.h>
#include <libsolidity/CompilerContext.h> #include <libsolidity/CompilerContext.h>
#include <libevmcore/Assembly.h>
namespace dev { namespace dev {
namespace solidity { namespace solidity {
@ -41,9 +42,11 @@ public:
bytes getAssembledBytecode() { return m_context.getAssembledBytecode(m_optimize); } bytes getAssembledBytecode() { return m_context.getAssembledBytecode(m_optimize); }
bytes getRuntimeBytecode() { return m_runtimeContext.getAssembledBytecode(m_optimize);} bytes getRuntimeBytecode() { return m_runtimeContext.getAssembledBytecode(m_optimize);}
void streamAssembly(std::ostream& _stream) const { m_context.streamAssembly(_stream); } void streamAssembly(std::ostream& _stream) const { m_context.streamAssembly(_stream); }
/// Getters for compiler contexts. Only for testing purposes.
CompilerContext const& getContext() const { return m_context; } /// @returns Assembly items of the normal compiler context
CompilerContext const& getRuntimeContext() const { return m_runtimeContext; } eth::AssemblyItems const& getAssemblyItems() const { return m_context.getAssembly().getItems(); }
/// @returns Assembly items of the runtime compiler context
eth::AssemblyItems const& getRuntimeAssemblyItems() const { return m_runtimeContext.getAssembly().getItems(); }
private: private:
/// Registers the non-function objects inside the contract with the context. /// Registers the non-function objects inside the contract with the context.

2
test/Assembly.cpp

@ -64,7 +64,7 @@ eth::AssemblyItems compileContract(const string& _sourceCode)
Compiler compiler; Compiler compiler;
compiler.compileContract(*contract, map<ContractDefinition const*, bytes const*>{}); compiler.compileContract(*contract, map<ContractDefinition const*, bytes const*>{});
return compiler.getRuntimeContext().getAssembly().getItems(); return compiler.getRuntimeAssemblyItems();
} }
BOOST_FAIL("No contract found in source."); BOOST_FAIL("No contract found in source.");
return AssemblyItems(); return AssemblyItems();

Loading…
Cancel
Save