aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiana Husikyan <liana@ethdev.com>2015-03-04 01:11:10 +0800
committerLiana Husikyan <liana@ethdev.com>2015-03-05 19:08:43 +0800
commite32bf97e87621bbb1de9623482c84d448e9884ac (patch)
tree6f78d33c7d4041f95562b35505089d4d5f2608b4
parenta4d772315d814408c057a9473c2c1fefa351a5b4 (diff)
downloaddexon-solidity-e32bf97e87621bbb1de9623482c84d448e9884ac.tar
dexon-solidity-e32bf97e87621bbb1de9623482c84d448e9884ac.tar.gz
dexon-solidity-e32bf97e87621bbb1de9623482c84d448e9884ac.tar.bz2
dexon-solidity-e32bf97e87621bbb1de9623482c84d448e9884ac.tar.lz
dexon-solidity-e32bf97e87621bbb1de9623482c84d448e9884ac.tar.xz
dexon-solidity-e32bf97e87621bbb1de9623482c84d448e9884ac.tar.zst
dexon-solidity-e32bf97e87621bbb1de9623482c84d448e9884ac.zip
to include source lines in output stream AssemblyItem's appropriate function is now receiving the map of fileNames to sourceCodes as argument.
-rw-r--r--Compiler.h7
-rw-r--r--CompilerContext.h5
-rw-r--r--CompilerStack.cpp4
-rw-r--r--CompilerStack.h7
4 files changed, 14 insertions, 9 deletions
diff --git a/Compiler.h b/Compiler.h
index 2804e8ec..76f16f3a 100644
--- a/Compiler.h
+++ b/Compiler.h
@@ -41,8 +41,11 @@ public:
std::map<ContractDefinition const*, bytes const*> const& _contracts);
bytes getAssembledBytecode() { return m_context.getAssembledBytecode(m_optimize); }
bytes getRuntimeBytecode() { return m_runtimeContext.getAssembledBytecode(m_optimize);}
- void streamAssembly(std::ostream& _stream) const { m_context.streamAssembly(_stream); }
-
+ /// @arg _sourceCodes is the map of input files to source code strings
+ void streamAssembly(std::ostream& _stream, StringMap const& _sourceCodes = StringMap()) const
+ {
+ m_context.streamAssembly(_stream, _sourceCodes);
+ }
/// @returns Assembly items of the normal compiler context
eth::AssemblyItems const& getAssemblyItems() const { return m_context.getAssembly().getItems(); }
/// @returns Assembly items of the runtime compiler context
diff --git a/CompilerContext.h b/CompilerContext.h
index 301ef146..e42e7c76 100644
--- a/CompilerContext.h
+++ b/CompilerContext.h
@@ -28,6 +28,7 @@
#include <libevmcore/Assembly.h>
#include <libsolidity/ASTForward.h>
#include <libsolidity/Types.h>
+#include <libdevcore/Common.h>
namespace dev {
namespace solidity {
@@ -118,7 +119,9 @@ public:
CompilerContext& operator<<(bytes const& _data);
eth::Assembly const& getAssembly() const { return m_asm; }
- void streamAssembly(std::ostream& _stream) const { _stream << m_asm; }
+ /// @arg _sourceCodes is the map of input files to source code strings
+ void streamAssembly(std::ostream& _stream, StringMap const& _sourceCodes = StringMap()) const { m_asm.streamRLP(_stream, "", _sourceCodes); }
+
bytes getAssembledBytecode(bool _optimize = false) { return m_asm.optimise(_optimize).assemble(); }
/**
diff --git a/CompilerStack.cpp b/CompilerStack.cpp
index 10504a24..a878bb61 100644
--- a/CompilerStack.cpp
+++ b/CompilerStack.cpp
@@ -180,9 +180,9 @@ dev::h256 CompilerStack::getContractCodeHash(string const& _contractName) const
return dev::sha3(getRuntimeBytecode(_contractName));
}
-void CompilerStack::streamAssembly(ostream& _outStream, string const& _contractName) const
+void CompilerStack::streamAssembly(ostream& _outStream, string const& _contractName, StringMap _sourceCodes) const
{
- getContract(_contractName).compiler->streamAssembly(_outStream);
+ getContract(_contractName).compiler->streamAssembly(_outStream, _sourceCodes);
}
string const& CompilerStack::getInterface(string const& _contractName) const
diff --git a/CompilerStack.h b/CompilerStack.h
index 2f34ab72..1cf576ab 100644
--- a/CompilerStack.h
+++ b/CompilerStack.h
@@ -59,8 +59,6 @@ enum class DocumentationType: uint8_t
ABISolidityInterface
};
-extern const std::map<std::string, std::string> StandardSources;
-
/**
* Easy to use and self-contained Solidity compiler with as few header dependencies as possible.
* It holds state and can be used to either step through the compilation stages (and abort e.g.
@@ -74,7 +72,7 @@ public:
/// Adds a source object (e.g. file) to the parser. After this, parse has to be called again.
/// @returns true if a source object by the name already existed and was replaced.
- void addSources(std::map<std::string, std::string> const& _nameContents, bool _isLibrary = false) { for (auto const& i: _nameContents) addSource(i.first, i.second, _isLibrary); }
+ void addSources(StringMap const& _nameContents, bool _isLibrary = false) { for (auto const& i: _nameContents) addSource(i.first, i.second, _isLibrary); }
bool addSource(std::string const& _name, std::string const& _content, bool _isLibrary = false);
void setSource(std::string const& _sourceCode);
/// Parses all source units that were added
@@ -103,8 +101,9 @@ public:
dev::h256 getContractCodeHash(std::string const& _contractName = "") const;
/// Streams a verbose version of the assembly to @a _outStream.
+ /// @arg _sourceCodes is the map of input files to source code strings
/// Prerequisite: Successful compilation.
- void streamAssembly(std::ostream& _outStream, std::string const& _contractName = "") const;
+ void streamAssembly(std::ostream& _outStream, std::string const& _contractName = "", StringMap _sourceCodes = StringMap()) const;
/// Returns a string representing the contract interface in JSON.
/// Prerequisite: Successful call to parse or compile.