From 2a5a5a99f91ff69abd4b510450c04806cca0bab2 Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Fri, 17 Apr 2015 17:41:41 +0200 Subject: [PATCH 01/14] added asm-json flag to cl compiler Conflicts: libsolidity/CompilerStack.cpp --- libevmcore/Assembly.cpp | 3 ++- libevmcore/Assembly.h | 2 +- libsolidity/Compiler.h | 5 +++-- libsolidity/CompilerContext.h | 3 ++- libsolidity/CompilerStack.cpp | 4 ++-- libsolidity/CompilerStack.h | 3 ++- solc/CommandLineInterface.cpp | 38 +++++++++++++++++++++-------------- 7 files changed, 35 insertions(+), 23 deletions(-) diff --git a/libevmcore/Assembly.cpp b/libevmcore/Assembly.cpp index bf4ea2145..589912857 100644 --- a/libevmcore/Assembly.cpp +++ b/libevmcore/Assembly.cpp @@ -101,8 +101,9 @@ string Assembly::getLocationFromSources(StringMap const& _sourceCodes, SourceLoc return move(cut); } -ostream& Assembly::stream(ostream& _out, string const& _prefix, StringMap const& _sourceCodes) const +ostream& Assembly::stream(ostream& _out, string const& _prefix, StringMap const& _sourceCodes, bool _inJsonFormat) const { + (void)_inJsonFormat; _out << _prefix << ".code:" << endl; for (AssemblyItem const& i: m_items) { diff --git a/libevmcore/Assembly.h b/libevmcore/Assembly.h index 2744af900..06cac8801 100644 --- a/libevmcore/Assembly.h +++ b/libevmcore/Assembly.h @@ -86,7 +86,7 @@ public: bytes assemble() const; Assembly& optimise(bool _enable); - std::ostream& stream(std::ostream& _out, std::string const& _prefix = "", const StringMap &_sourceCodes = StringMap()) const; + std::ostream& stream(std::ostream& _out, std::string const& _prefix = "", const StringMap &_sourceCodes = StringMap(), bool _inJsonFormat = false) const; protected: std::string getLocationFromSources(StringMap const& _sourceCodes, SourceLocation const& _location) const; diff --git a/libsolidity/Compiler.h b/libsolidity/Compiler.h index 4b1e1b4d6..260aebd33 100644 --- a/libsolidity/Compiler.h +++ b/libsolidity/Compiler.h @@ -42,9 +42,10 @@ public: bytes getAssembledBytecode() { return m_context.getAssembledBytecode(m_optimize); } bytes getRuntimeBytecode() { return m_runtimeContext.getAssembledBytecode(m_optimize);} /// @arg _sourceCodes is the map of input files to source code strings - void streamAssembly(std::ostream& _stream, StringMap const& _sourceCodes = StringMap()) const + /// @arg _inJsonFromat shows weather the out should be in Json format + void streamAssembly(std::ostream& _stream, StringMap const& _sourceCodes = StringMap(), bool _inJsonFormat = false) const { - m_context.streamAssembly(_stream, _sourceCodes); + m_context.streamAssembly(_stream, _sourceCodes, _inJsonFormat); } /// @returns Assembly items of the normal compiler context eth::AssemblyItems const& getAssemblyItems() const { return m_context.getAssembly().getItems(); } diff --git a/libsolidity/CompilerContext.h b/libsolidity/CompilerContext.h index e752d59b8..3fcf0706d 100644 --- a/libsolidity/CompilerContext.h +++ b/libsolidity/CompilerContext.h @@ -122,7 +122,8 @@ public: eth::Assembly const& getAssembly() const { return 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.stream(_stream, "", _sourceCodes); } + /// @arg _inJsonFromat shows weather the out should be in Json format + void streamAssembly(std::ostream& _stream, StringMap const& _sourceCodes = StringMap(), bool _inJsonFormat = false) const { m_asm.stream(_stream, "", _sourceCodes, _inJsonFormat); } bytes getAssembledBytecode(bool _optimize = false) { return m_asm.optimise(_optimize).assemble(); } diff --git a/libsolidity/CompilerStack.cpp b/libsolidity/CompilerStack.cpp index c35d9324c..592f61276 100644 --- a/libsolidity/CompilerStack.cpp +++ b/libsolidity/CompilerStack.cpp @@ -184,11 +184,11 @@ dev::h256 CompilerStack::getContractCodeHash(string const& _contractName) const return dev::sha3(getRuntimeBytecode(_contractName)); } -void CompilerStack::streamAssembly(ostream& _outStream, string const& _contractName, StringMap _sourceCodes) const +void CompilerStack::streamAssembly(ostream& _outStream, string const& _contractName, StringMap _sourceCodes, bool _inJsonFormat) const { Contract const& contract = getContract(_contractName); if (contract.compiler) - getContract(_contractName).compiler->streamAssembly(_outStream, _sourceCodes); + contract(_contractName).compiler->streamAssembly(_outStream, _sourceCodes, _inJsonFormat); else _outStream << "Contract not fully implemented" << endl; } diff --git a/libsolidity/CompilerStack.h b/libsolidity/CompilerStack.h index 19c1ba4e1..ef3d09663 100644 --- a/libsolidity/CompilerStack.h +++ b/libsolidity/CompilerStack.h @@ -102,8 +102,9 @@ public: /// Streams a verbose version of the assembly to @a _outStream. /// @arg _sourceCodes is the map of input files to source code strings + /// @arg _inJsonFromat shows weather the out should be in Json format /// Prerequisite: Successful compilation. - void streamAssembly(std::ostream& _outStream, std::string const& _contractName = "", StringMap _sourceCodes = StringMap()) const; + void streamAssembly(std::ostream& _outStream, std::string const& _contractName = "", StringMap _sourceCodes = StringMap(), bool _inJsonFormat = false) const; /// Returns a string representing the contract interface in JSON. /// Prerequisite: Successful call to parse or compile. diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index 6ed90cdea..d21839f14 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -55,6 +55,7 @@ namespace solidity static string const g_argAbiStr = "json-abi"; static string const g_argSolAbiStr = "sol-abi"; static string const g_argAsmStr = "asm"; +static string const g_argAsmJsonStr = "asm-json"; static string const g_argAstStr = "ast"; static string const g_argAstJson = "ast-json"; static string const g_argBinaryStr = "binary"; @@ -80,10 +81,15 @@ static bool needStdout(po::variables_map const& _args) { return - argToStdout(_args, g_argAbiStr) || argToStdout(_args, g_argSolAbiStr) || - argToStdout(_args, g_argNatspecUserStr) || argToStdout(_args, g_argAstJson) || - argToStdout(_args, g_argNatspecDevStr) || argToStdout(_args, g_argAsmStr) || - argToStdout(_args, g_argOpcodesStr) || argToStdout(_args, g_argBinaryStr); + argToStdout(_args, g_argAbiStr) || + argToStdout(_args, g_argSolAbiStr) || + argToStdout(_args, g_argNatspecUserStr) || + argToStdout(_args, g_argAstJson) || + argToStdout(_args, g_argNatspecDevStr) || + argToStdout(_args, g_argAsmStr) || + argToStdout(_args, g_argAsmJsonStr) || + argToStdout(_args, g_argOpcodesStr) || + argToStdout(_args, g_argBinaryStr); } static inline bool outputToFile(OutputType type) @@ -215,23 +221,25 @@ bool CommandLineInterface::parseArguments(int argc, char** argv) ("add-std", po::value()->default_value(false), "Add standard contracts") ("input-file", po::value>(), "input file") (g_argAstStr.c_str(), po::value()->value_name("stdout|file|both"), - "Request to output the AST of the contract.") + "Request to output the AST of the contract.") (g_argAstJson.c_str(), po::value()->value_name("stdout|file|both"), - "Request to output the AST of the contract in JSON format.") + "Request to output the AST of the contract in JSON format.") (g_argAsmStr.c_str(), po::value()->value_name("stdout|file|both"), - "Request to output the EVM assembly of the contract.") + "Request to output the EVM assembly of the contract.") + (g_argAsmJsonStr.c_str(), po::value()->value_name("stdout|file|both"), + "Request to output the EVM assembly of the contract in JSON format.") (g_argOpcodesStr.c_str(), po::value()->value_name("stdout|file|both"), - "Request to output the Opcodes of the contract.") + "Request to output the Opcodes of the contract.") (g_argBinaryStr.c_str(), po::value()->value_name("stdout|file|both"), - "Request to output the contract in binary (hexadecimal).") + "Request to output the contract in binary (hexadecimal).") (g_argAbiStr.c_str(), po::value()->value_name("stdout|file|both"), - "Request to output the contract's JSON ABI interface.") + "Request to output the contract's JSON ABI interface.") (g_argSolAbiStr.c_str(), po::value()->value_name("stdout|file|both"), - "Request to output the contract's Solidity ABI interface.") + "Request to output the contract's Solidity ABI interface.") (g_argNatspecUserStr.c_str(), po::value()->value_name("stdout|file|both"), - "Request to output the contract's Natspec user documentation.") + "Request to output the contract's Natspec user documentation.") (g_argNatspecDevStr.c_str(), po::value()->value_name("stdout|file|both"), - "Request to output the contract's Natspec developer documentation."); + "Request to output the contract's Natspec developer documentation."); // All positional options should be interpreted as input files po::positional_options_description p; @@ -417,13 +425,13 @@ void CommandLineInterface::actOnInput() if (outputToStdout(choice)) { cout << "EVM assembly:" << endl; - m_compiler->streamAssembly(cout, contract, m_sourceCodes); + m_compiler->streamAssembly(cout, contract, m_sourceCodes, m_args.count(g_argAsmJsonStr)); } if (outputToFile(choice)) { ofstream outFile(contract + ".evm"); - m_compiler->streamAssembly(outFile, contract, m_sourceCodes); + m_compiler->streamAssembly(outFile, contract, m_sourceCodes, m_args.count(g_argAsmJsonStr)); outFile.close(); } } From 1305502fc95c361833a7e02c26d0ee5a94ce42da Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Fri, 17 Apr 2015 16:13:34 +0200 Subject: [PATCH 02/14] initial output for asm-json flag. Conflicts: libevmcore/Assembly.cpp --- libevmcore/Assembly.cpp | 162 +++++++++++++++++++++++++++++++++- libevmcore/Assembly.h | 6 ++ libevmcore/CMakeLists.txt | 1 + solc/CommandLineInterface.cpp | 4 +- 4 files changed, 169 insertions(+), 4 deletions(-) diff --git a/libevmcore/Assembly.cpp b/libevmcore/Assembly.cpp index 589912857..0d24618ee 100644 --- a/libevmcore/Assembly.cpp +++ b/libevmcore/Assembly.cpp @@ -24,6 +24,7 @@ #include #include #include +#include using namespace std; using namespace dev; @@ -101,9 +102,8 @@ string Assembly::getLocationFromSources(StringMap const& _sourceCodes, SourceLoc return move(cut); } -ostream& Assembly::stream(ostream& _out, string const& _prefix, StringMap const& _sourceCodes, bool _inJsonFormat) const +ostream& Assembly::streamAsm(ostream& _out, string const& _prefix, StringMap const& _sourceCodes) const { - (void)_inJsonFormat; _out << _prefix << ".code:" << endl; for (AssemblyItem const& i: m_items) { @@ -158,6 +158,164 @@ ostream& Assembly::stream(ostream& _out, string const& _prefix, StringMap const& return _out; } +ostream& Assembly::streamAsmJson(ostream& _out, string const& _prefix, StringMap const& _sourceCodes, bool _inJsonFormat) const +{ + Json::Value root; + + string currentArrayName = ".code"; + std::vector currentCollection; + for (AssemblyItem const& i: m_items) + { + //todo check and remove where location.isEmpty() + switch (i.type()) + { + case Operation: + { + Json::Value op; + op["name"] = instructionInfo(i.instruction()).name; + op["jumpType"] = i.getJumpTypeAsString(); + op["locationX"] = i.getLocation().start; + op["locationY"] = i.getLocation().end; + currentCollection.push_back(op); + //_out << " " << instructionInfo(i.instruction()).name << "\t" << i.getJumpTypeAsString(); + } + break; + case Push: + { + Json::Value pushitem; + pushitem["name"] = "PUSH"; + pushitem["value"] = string(i.data()); + pushitem["locationX"] = boost::lexical_cast(i.getLocation().start); + pushitem["locationY"] = boost::lexical_cast(i.getLocation().end); + currentCollection.push_back(pushitem); + //_out << " PUSH " << i.data(); + } + break; + case PushString: + { + Json::Value pushString; + pushString["name"] = "PUSH tag"; + pushString["value"] = m_strings.at((h256)i.data()); + pushString["locationX"] = i.getLocation().start; + pushString["locationY"] = i.getLocation().end; + currentCollection.push_back(pushString); + //_out << " PUSH \"" << m_strings.at((h256)i.data()) << "\""; + } + break; + case PushTag: + { + Json::Value pushTag; + pushTag["name"] = "PUSH [tag]"; + pushTag["value"] = string(i.data()); + pushTag["locationX"] = boost::lexical_cast(i.getLocation().start); + pushTag["locationY"] = boost::lexical_cast(i.getLocation().end); + currentCollection.push_back(pushTag); + } + //_out << " PUSH [tag" << i.data() << "]"; + break; + case PushSub: + { + Json::Value pushSub; + pushSub["name"] = "PUSH [$]"; + pushSub["value"] = h256(i.data()).abridged() ; + pushSub["locationX"] = boost::lexical_cast(i.getLocation().start); + pushSub["locationY"] = boost::lexical_cast(i.getLocation().end); + currentCollection.push_back(pushSub); + } + //_out << " PUSH [$" << h256(i.data()).abridged() << "]"; + break; + case PushSubSize: + { + Json::Value pushSubSize; + pushSubSize["name"] = "PUSH #[$]"; + pushSubSize["value"] = h256(i.data()).abridged(); + pushSubSize["locationX"] = boost::lexical_cast(i.getLocation().start); + pushSubSize["locationY"] = boost::lexical_cast(i.getLocation().end); + currentCollection.push_back(pushSubSize); + } + //_out << " PUSH #[$" << h256(i.data()).abridged() << "]"; + break; + case PushProgramSize: + { + Json::Value pushSize; + pushSize["name"] = "PUSHSIZE"; + pushSize["locationX"] = boost::lexical_cast(i.getLocation().start); + pushSize["locationY"] = boost::lexical_cast(i.getLocation().end); + currentCollection.push_back(pushSize); + } + //_out << " PUSHSIZE"; + break; + case Tag: + { + Json::Value collection(Json::arrayValue); + for(auto it: currentCollection) + collection.append(it); + currentCollection.clear(); + root[currentArrayName] = collection; + currentArrayName = "tag" + string(i.data()); + } + //_out << "tag" << i.data() << ": " << endl << _prefix << " JUMPDEST"; + break; + case PushData: + { + Json::Value pushData; + pushData["name"] = "PUSH hex"; + std::stringstream hexStr; + hexStr << hex << (unsigned)i.data(); + pushData["value"] = hexStr.str(); + pushData["locationX"] = boost::lexical_cast(i.getLocation().start); + pushData["locationY"] = boost::lexical_cast(i.getLocation().end); + currentCollection.push_back(pushData); + } + //_out << " PUSH [" << hex << (unsigned)i.data() << "]"; + break; + default: + BOOST_THROW_EXCEPTION(InvalidOpcode()); + } + } + + //todo check if the last was tag + Json::Value collection(Json::arrayValue); + for(auto it: currentCollection) + collection.append(it); + root[currentArrayName] = collection; + + if (!m_data.empty() || !m_subs.empty()) + { + Json::Value dataCollection(Json::arrayValue); + for (auto const& i: m_data) + if (u256(i.first) >= m_subs.size()) + { + std::stringstream hexStr; + hexStr << _prefix << hex << (unsigned)(u256)i.first << ": " << toHex(i.second); + Json::Value data; + data["value"] = hexStr.str(); + dataCollection.append(data); + } + root[_prefix + ".data"] = collection; + + for (size_t i = 0; i < m_subs.size(); ++i) + { + std::stringstream hexStr; + hexStr << _prefix << hex << i << ": "; + //_out << _prefix << " " << hex << i << ": " << endl; + //todo check recursion + m_subs[i].stream(_out, _prefix + " ", _sourceCodes, _inJsonFormat); + } + } + + _out << root; + return _out; +} + +ostream& Assembly::stream(ostream& _out, string const& _prefix, StringMap const& _sourceCodes, bool _inJsonFormat) const +{ + if (!_inJsonFormat) + return streamAsm(_out, _prefix, _sourceCodes); + else + return streamAsmJson(_out, _prefix, _sourceCodes, _inJsonFormat); +} + AssemblyItem const& Assembly::append(AssemblyItem const& _i) { m_deposit += _i.deposit(); diff --git a/libevmcore/Assembly.h b/libevmcore/Assembly.h index 06cac8801..d2927abac 100644 --- a/libevmcore/Assembly.h +++ b/libevmcore/Assembly.h @@ -93,6 +93,10 @@ protected: void donePath() { if (m_totalDeposit != INT_MAX && m_totalDeposit != m_deposit) BOOST_THROW_EXCEPTION(InvalidDeposit()); } unsigned bytesRequired() const; +private: + std::ostream& streamAsmJson(std::ostream& _out, const std::string &_prefix, const StringMap &_sourceCodes, bool _inJsonFormat) const; + std::ostream& streamAsm(std::ostream& _out, std::string const& _prefix, StringMap const& _sourceCodes) const; +protected: unsigned m_usedTags = 0; AssemblyItems m_items; mutable std::map m_data; @@ -104,8 +108,10 @@ protected: int m_totalDeposit = 0; SourceLocation m_currentSourceLocation; + }; + inline std::ostream& operator<<(std::ostream& _out, Assembly const& _a) { _a.stream(_out); diff --git a/libevmcore/CMakeLists.txt b/libevmcore/CMakeLists.txt index 6a834936b..83a4e115c 100644 --- a/libevmcore/CMakeLists.txt +++ b/libevmcore/CMakeLists.txt @@ -11,6 +11,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSTATICLIB") aux_source_directory(. SRC_LIST) +include_directories(BEFORE ${JSONCPP_INCLUDE_DIRS}) include_directories(BEFORE ..) include_directories(${Boost_INCLUDE_DIRS}) diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index d21839f14..cb924d9b5 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -419,9 +419,9 @@ void CommandLineInterface::actOnInput() cout << endl << "======= " << contract << " =======" << endl; // do we need EVM assembly? - if (m_args.count(g_argAsmStr)) + if (m_args.count(g_argAsmStr) || m_args.count(g_argAsmJsonStr)) { - auto choice = m_args[g_argAsmStr].as(); + auto choice = m_args.count(g_argAsmStr) ? m_args[g_argAsmStr].as() : m_args[g_argAsmJsonStr].as(); if (outputToStdout(choice)) { cout << "EVM assembly:" << endl; From 2189306c9d355b38d7981b2811475a138e98bec6 Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Mon, 13 Apr 2015 18:09:35 +0200 Subject: [PATCH 03/14] reordered output. modified push tags --- libevmcore/Assembly.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/libevmcore/Assembly.cpp b/libevmcore/Assembly.cpp index 0d24618ee..bd9b5e832 100644 --- a/libevmcore/Assembly.cpp +++ b/libevmcore/Assembly.cpp @@ -216,8 +216,8 @@ ostream& Assembly::streamAsmJson(ostream& _out, string const& _prefix, StringMap case PushSub: { Json::Value pushSub; - pushSub["name"] = "PUSH [$]"; - pushSub["value"] = h256(i.data()).abridged() ; + pushSub["name"] = "PUSH"; + pushSub["value"] = "[$]" + string(h256(i.data()).abridged()); pushSub["locationX"] = boost::lexical_cast(i.getLocation().start); pushSub["locationY"] = boost::lexical_cast(i.getLocation().end); currentCollection.push_back(pushSub); @@ -227,8 +227,8 @@ ostream& Assembly::streamAsmJson(ostream& _out, string const& _prefix, StringMap case PushSubSize: { Json::Value pushSubSize; - pushSubSize["name"] = "PUSH #[$]"; - pushSubSize["value"] = h256(i.data()).abridged(); + pushSubSize["name"] = "PUSH"; + pushSubSize["value"] = "#[$]" + string(h256(i.data()).abridged()); pushSubSize["locationX"] = boost::lexical_cast(i.getLocation().start); pushSubSize["locationY"] = boost::lexical_cast(i.getLocation().end); currentCollection.push_back(pushSubSize); @@ -253,6 +253,9 @@ ostream& Assembly::streamAsmJson(ostream& _out, string const& _prefix, StringMap currentCollection.clear(); root[currentArrayName] = collection; currentArrayName = "tag" + string(i.data()); + Json::Value jumpdest; + jumpdest["name"] = "JUMDEST"; + currentCollection.push_back(jumpdest); } //_out << "tag" << i.data() << ": " << endl << _prefix << " JUMPDEST"; break; @@ -292,19 +295,21 @@ ostream& Assembly::streamAsmJson(ostream& _out, string const& _prefix, StringMap data["value"] = hexStr.str(); dataCollection.append(data); } - root[_prefix + ".data"] = collection; for (size_t i = 0; i < m_subs.size(); ++i) { std::stringstream hexStr; hexStr << _prefix << hex << i << ": "; //_out << _prefix << " " << hex << i << ": " << endl; - //todo check recursion + //todo check recursion check order. m_subs[i].stream(_out, _prefix + " ", _sourceCodes, _inJsonFormat); } - } + root[_prefix + ".data"] = collection; + _out << root; + + } else + _out << root; - _out << root; return _out; } From 4ef9b70dd3cd71773953d2225295fc6e68ccaf8e Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Tue, 14 Apr 2015 11:38:36 +0200 Subject: [PATCH 04/14] style fixes --- libevmcore/Assembly.cpp | 9 ++++----- libevmcore/Assembly.h | 12 ++++++++++-- libsolidity/Compiler.h | 2 +- libsolidity/CompilerContext.h | 7 +++++-- libsolidity/CompilerStack.h | 2 +- 5 files changed, 21 insertions(+), 11 deletions(-) diff --git a/libevmcore/Assembly.cpp b/libevmcore/Assembly.cpp index bd9b5e832..99ff168df 100644 --- a/libevmcore/Assembly.cpp +++ b/libevmcore/Assembly.cpp @@ -248,7 +248,7 @@ ostream& Assembly::streamAsmJson(ostream& _out, string const& _prefix, StringMap case Tag: { Json::Value collection(Json::arrayValue); - for(auto it: currentCollection) + for (auto it: currentCollection) collection.append(it); currentCollection.clear(); root[currentArrayName] = collection; @@ -279,7 +279,7 @@ ostream& Assembly::streamAsmJson(ostream& _out, string const& _prefix, StringMap //todo check if the last was tag Json::Value collection(Json::arrayValue); - for(auto it: currentCollection) + for (auto it: currentCollection) collection.append(it); root[currentArrayName] = collection; @@ -295,6 +295,8 @@ ostream& Assembly::streamAsmJson(ostream& _out, string const& _prefix, StringMap data["value"] = hexStr.str(); dataCollection.append(data); } + root[_prefix + ".data"] = collection; + _out << root; for (size_t i = 0; i < m_subs.size(); ++i) { @@ -304,9 +306,6 @@ ostream& Assembly::streamAsmJson(ostream& _out, string const& _prefix, StringMap //todo check recursion check order. m_subs[i].stream(_out, _prefix + " ", _sourceCodes, _inJsonFormat); } - root[_prefix + ".data"] = collection; - _out << root; - } else _out << root; diff --git a/libevmcore/Assembly.h b/libevmcore/Assembly.h index d2927abac..6eef34194 100644 --- a/libevmcore/Assembly.h +++ b/libevmcore/Assembly.h @@ -86,7 +86,11 @@ public: bytes assemble() const; Assembly& optimise(bool _enable); - std::ostream& stream(std::ostream& _out, std::string const& _prefix = "", const StringMap &_sourceCodes = StringMap(), bool _inJsonFormat = false) const; + std::ostream& stream( + std::ostream& _out, + std::string const& _prefix = "", + const StringMap &_sourceCodes = StringMap(), + bool _inJsonFormat = false) const; protected: std::string getLocationFromSources(StringMap const& _sourceCodes, SourceLocation const& _location) const; @@ -94,7 +98,11 @@ protected: unsigned bytesRequired() const; private: - std::ostream& streamAsmJson(std::ostream& _out, const std::string &_prefix, const StringMap &_sourceCodes, bool _inJsonFormat) const; + std::ostream& streamAsmJson( + std::ostream& _out, + const std::string &_prefix, + const StringMap &_sourceCodes, + bool _inJsonFormat) const; std::ostream& streamAsm(std::ostream& _out, std::string const& _prefix, StringMap const& _sourceCodes) const; protected: unsigned m_usedTags = 0; diff --git a/libsolidity/Compiler.h b/libsolidity/Compiler.h index 260aebd33..d476ec684 100644 --- a/libsolidity/Compiler.h +++ b/libsolidity/Compiler.h @@ -42,7 +42,7 @@ public: bytes getAssembledBytecode() { return m_context.getAssembledBytecode(m_optimize); } bytes getRuntimeBytecode() { return m_runtimeContext.getAssembledBytecode(m_optimize);} /// @arg _sourceCodes is the map of input files to source code strings - /// @arg _inJsonFromat shows weather the out should be in Json format + /// @arg _inJsonFromat shows whether the out should be in Json format void streamAssembly(std::ostream& _stream, StringMap const& _sourceCodes = StringMap(), bool _inJsonFormat = false) const { m_context.streamAssembly(_stream, _sourceCodes, _inJsonFormat); diff --git a/libsolidity/CompilerContext.h b/libsolidity/CompilerContext.h index 3fcf0706d..9c2156bfa 100644 --- a/libsolidity/CompilerContext.h +++ b/libsolidity/CompilerContext.h @@ -122,8 +122,11 @@ public: eth::Assembly const& getAssembly() const { return m_asm; } /// @arg _sourceCodes is the map of input files to source code strings - /// @arg _inJsonFromat shows weather the out should be in Json format - void streamAssembly(std::ostream& _stream, StringMap const& _sourceCodes = StringMap(), bool _inJsonFormat = false) const { m_asm.stream(_stream, "", _sourceCodes, _inJsonFormat); } + /// @arg _inJsonFormat shows whether the out should be in Json format + void streamAssembly(std::ostream& _stream, StringMap const& _sourceCodes = StringMap(), bool _inJsonFormat = false) const + { + m_asm.stream(_stream, "", _sourceCodes, _inJsonFormat); + } bytes getAssembledBytecode(bool _optimize = false) { return m_asm.optimise(_optimize).assemble(); } diff --git a/libsolidity/CompilerStack.h b/libsolidity/CompilerStack.h index ef3d09663..2e7c217d5 100644 --- a/libsolidity/CompilerStack.h +++ b/libsolidity/CompilerStack.h @@ -102,7 +102,7 @@ public: /// Streams a verbose version of the assembly to @a _outStream. /// @arg _sourceCodes is the map of input files to source code strings - /// @arg _inJsonFromat shows weather the out should be in Json format + /// @arg _inJsonFromat shows whether the out should be in Json format /// Prerequisite: Successful compilation. void streamAssembly(std::ostream& _outStream, std::string const& _contractName = "", StringMap _sourceCodes = StringMap(), bool _inJsonFormat = false) const; From 9fa9190f1d4a7e49bee9a8ff523a51bdbe9f2080 Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Tue, 14 Apr 2015 15:42:27 +0200 Subject: [PATCH 05/14] code refactoring --- libevmcore/Assembly.cpp | 136 +++++++++++++--------------------------- libevmcore/Assembly.h | 6 ++ 2 files changed, 51 insertions(+), 91 deletions(-) diff --git a/libevmcore/Assembly.cpp b/libevmcore/Assembly.cpp index 99ff168df..3bdf3e0a0 100644 --- a/libevmcore/Assembly.cpp +++ b/libevmcore/Assembly.cpp @@ -158,6 +158,20 @@ ostream& Assembly::streamAsm(ostream& _out, string const& _prefix, StringMap con return _out; } +Json::Value Assembly::createJsonValue(string _name, int _locationX, int _locationY, string _value, string _jumpType) const +{ + Json::Value value; + assert(!_name.empty()); + value["name"] = _name; + value["locationX"] = _locationX; + value["locationY"] = _locationY; + if (!_value.empty()) + value["value"] = _value; + if (!_jumpType.empty()) + value["jumpType"] = _jumpType; + return move(value); +} + ostream& Assembly::streamAsmJson(ostream& _out, string const& _prefix, StringMap const& _sourceCodes, bool _inJsonFormat) const { Json::Value root; @@ -166,111 +180,50 @@ ostream& Assembly::streamAsmJson(ostream& _out, string const& _prefix, StringMap std::vector currentCollection; for (AssemblyItem const& i: m_items) { - //todo check and remove where location.isEmpty() switch (i.type()) { case Operation: - { - Json::Value op; - op["name"] = instructionInfo(i.instruction()).name; - op["jumpType"] = i.getJumpTypeAsString(); - op["locationX"] = i.getLocation().start; - op["locationY"] = i.getLocation().end; - currentCollection.push_back(op); - //_out << " " << instructionInfo(i.instruction()).name << "\t" << i.getJumpTypeAsString(); - } + currentCollection.push_back(createJsonValue(instructionInfo(i.instruction()).name, i.getLocation().start, i.getLocation().end, i.getJumpTypeAsString())); break; case Push: - { - Json::Value pushitem; - pushitem["name"] = "PUSH"; - pushitem["value"] = string(i.data()); - pushitem["locationX"] = boost::lexical_cast(i.getLocation().start); - pushitem["locationY"] = boost::lexical_cast(i.getLocation().end); - currentCollection.push_back(pushitem); - //_out << " PUSH " << i.data(); - } + currentCollection.push_back(createJsonValue(string("PUSH"), i.getLocation().start, i.getLocation().end, string(i.data()), i.getJumpTypeAsString())); break; case PushString: - { - Json::Value pushString; - pushString["name"] = "PUSH tag"; - pushString["value"] = m_strings.at((h256)i.data()); - pushString["locationX"] = i.getLocation().start; - pushString["locationY"] = i.getLocation().end; - currentCollection.push_back(pushString); - //_out << " PUSH \"" << m_strings.at((h256)i.data()) << "\""; - } + currentCollection.push_back(createJsonValue(string("PUSH tag"), i.getLocation().start, i.getLocation().end, m_strings.at((h256)i.data()))); break; case PushTag: - { - Json::Value pushTag; - pushTag["name"] = "PUSH [tag]"; - pushTag["value"] = string(i.data()); - pushTag["locationX"] = boost::lexical_cast(i.getLocation().start); - pushTag["locationY"] = boost::lexical_cast(i.getLocation().end); - currentCollection.push_back(pushTag); - } - //_out << " PUSH [tag" << i.data() << "]"; + currentCollection.push_back(createJsonValue(string("PUSH [tag]"), i.getLocation().start, i.getLocation().end, string(i.data()))); break; case PushSub: - { - Json::Value pushSub; - pushSub["name"] = "PUSH"; - pushSub["value"] = "[$]" + string(h256(i.data()).abridged()); - pushSub["locationX"] = boost::lexical_cast(i.getLocation().start); - pushSub["locationY"] = boost::lexical_cast(i.getLocation().end); - currentCollection.push_back(pushSub); - } - //_out << " PUSH [$" << h256(i.data()).abridged() << "]"; + currentCollection.push_back(createJsonValue(string("PUSH"), i.getLocation().start, i.getLocation().end, string("[$]" + string(h256(i.data()).abridged())))); break; case PushSubSize: - { - Json::Value pushSubSize; - pushSubSize["name"] = "PUSH"; - pushSubSize["value"] = "#[$]" + string(h256(i.data()).abridged()); - pushSubSize["locationX"] = boost::lexical_cast(i.getLocation().start); - pushSubSize["locationY"] = boost::lexical_cast(i.getLocation().end); - currentCollection.push_back(pushSubSize); - } - //_out << " PUSH #[$" << h256(i.data()).abridged() << "]"; + currentCollection.push_back(createJsonValue(string("PUSH"), i.getLocation().start, i.getLocation().end, string("#[$]" + string(h256(i.data()).abridged())))); break; case PushProgramSize: - { - Json::Value pushSize; - pushSize["name"] = "PUSHSIZE"; - pushSize["locationX"] = boost::lexical_cast(i.getLocation().start); - pushSize["locationY"] = boost::lexical_cast(i.getLocation().end); - currentCollection.push_back(pushSize); - } - //_out << " PUSHSIZE"; + currentCollection.push_back(createJsonValue(string("PUSHSIZE"), i.getLocation().start, i.getLocation().end)); break; case Tag: - { - Json::Value collection(Json::arrayValue); - for (auto it: currentCollection) - collection.append(it); - currentCollection.clear(); - root[currentArrayName] = collection; - currentArrayName = "tag" + string(i.data()); - Json::Value jumpdest; - jumpdest["name"] = "JUMDEST"; - currentCollection.push_back(jumpdest); - } - //_out << "tag" << i.data() << ": " << endl << _prefix << " JUMPDEST"; + { + Json::Value collection(Json::arrayValue); + for (auto it: currentCollection) + collection.append(it); + currentCollection.clear(); + root[currentArrayName] = collection; + currentArrayName = "tag" + string(i.data()); + Json::Value jumpdest; + jumpdest["name"] = "JUMDEST"; + currentCollection.push_back(jumpdest); + } break; case PushData: - { - Json::Value pushData; - pushData["name"] = "PUSH hex"; - std::stringstream hexStr; - hexStr << hex << (unsigned)i.data(); - pushData["value"] = hexStr.str(); - pushData["locationX"] = boost::lexical_cast(i.getLocation().start); - pushData["locationY"] = boost::lexical_cast(i.getLocation().end); - currentCollection.push_back(pushData); - } - //_out << " PUSH [" << hex << (unsigned)i.data() << "]"; + { + Json::Value pushData; + pushData["name"] = "PUSH hex"; + std::stringstream hexStr; + hexStr << hex << (unsigned)i.data(); + currentCollection.push_back(createJsonValue(string("PUSH hex"), i.getLocation().start, i.getLocation().end, hexStr.str())); + } break; default: BOOST_THROW_EXCEPTION(InvalidOpcode()); @@ -283,6 +236,7 @@ ostream& Assembly::streamAsmJson(ostream& _out, string const& _prefix, StringMap collection.append(it); root[currentArrayName] = collection; + Json::Value rootData; if (!m_data.empty() || !m_subs.empty()) { Json::Value dataCollection(Json::arrayValue); @@ -295,8 +249,8 @@ ostream& Assembly::streamAsmJson(ostream& _out, string const& _prefix, StringMap data["value"] = hexStr.str(); dataCollection.append(data); } - root[_prefix + ".data"] = collection; - _out << root; + rootData[_prefix + ".data"] = collection; + _out << root << rootData; for (size_t i = 0; i < m_subs.size(); ++i) { @@ -314,10 +268,10 @@ ostream& Assembly::streamAsmJson(ostream& _out, string const& _prefix, StringMap ostream& Assembly::stream(ostream& _out, string const& _prefix, StringMap const& _sourceCodes, bool _inJsonFormat) const { - if (!_inJsonFormat) - return streamAsm(_out, _prefix, _sourceCodes); - else + if (_inJsonFormat) return streamAsmJson(_out, _prefix, _sourceCodes, _inJsonFormat); + else + return streamAsm(_out, _prefix, _sourceCodes); } AssemblyItem const& Assembly::append(AssemblyItem const& _i) diff --git a/libevmcore/Assembly.h b/libevmcore/Assembly.h index 6eef34194..49c45d37b 100644 --- a/libevmcore/Assembly.h +++ b/libevmcore/Assembly.h @@ -30,6 +30,10 @@ #include #include "Exceptions.h" +namespace Json +{ +class Value; +} namespace dev { namespace eth @@ -104,6 +108,8 @@ private: const StringMap &_sourceCodes, bool _inJsonFormat) const; std::ostream& streamAsm(std::ostream& _out, std::string const& _prefix, StringMap const& _sourceCodes) const; + Json::Value createJsonValue(std::string _name, int _locationX, int _locationY, std::string _value = std::string(), std::string _jumpType = std::string()) const; + protected: unsigned m_usedTags = 0; AssemblyItems m_items; From c6652616ae67583e16a7e0e237b386c541eb9466 Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Fri, 17 Apr 2015 16:15:25 +0200 Subject: [PATCH 06/14] reordered output Conflicts: libevmcore/Assembly.cpp --- libevmcore/Assembly.cpp | 57 ++++++++++++++++++++++++++--------------- libevmcore/Assembly.h | 8 +++--- liblll/CMakeLists.txt | 1 + 3 files changed, 43 insertions(+), 23 deletions(-) diff --git a/libevmcore/Assembly.cpp b/libevmcore/Assembly.cpp index 3bdf3e0a0..f794ffa3b 100644 --- a/libevmcore/Assembly.cpp +++ b/libevmcore/Assembly.cpp @@ -30,6 +30,8 @@ using namespace std; using namespace dev; using namespace dev::eth; + + void Assembly::append(Assembly const& _a) { auto newDeposit = m_deposit + _a.deposit(); @@ -66,6 +68,13 @@ void Assembly::append(Assembly const& _a, int _deposit) } } +string Assembly::out() const +{ + stringstream ret; + stream(ret); + return ret.str(); +} + unsigned Assembly::bytesRequired() const { for (unsigned br = 1;; ++br) @@ -172,7 +181,7 @@ Json::Value Assembly::createJsonValue(string _name, int _locationX, int _locatio return move(value); } -ostream& Assembly::streamAsmJson(ostream& _out, string const& _prefix, StringMap const& _sourceCodes, bool _inJsonFormat) const +Json::Value Assembly::streamAsmJson(ostream& _out, string const& _prefix, StringMap const& _sourceCodes, bool _inJsonFormat) const { Json::Value root; @@ -183,25 +192,32 @@ ostream& Assembly::streamAsmJson(ostream& _out, string const& _prefix, StringMap switch (i.type()) { case Operation: - currentCollection.push_back(createJsonValue(instructionInfo(i.instruction()).name, i.getLocation().start, i.getLocation().end, i.getJumpTypeAsString())); + currentCollection.push_back( + createJsonValue(instructionInfo(i.instruction()).name, i.getLocation().start, i.getLocation().end, i.getJumpTypeAsString())); break; case Push: - currentCollection.push_back(createJsonValue(string("PUSH"), i.getLocation().start, i.getLocation().end, string(i.data()), i.getJumpTypeAsString())); + currentCollection.push_back( + createJsonValue(string("PUSH"), i.getLocation().start, i.getLocation().end, string(i.data()), i.getJumpTypeAsString())); break; case PushString: - currentCollection.push_back(createJsonValue(string("PUSH tag"), i.getLocation().start, i.getLocation().end, m_strings.at((h256)i.data()))); + currentCollection.push_back( + createJsonValue(string("PUSH tag"), i.getLocation().start, i.getLocation().end, m_strings.at((h256)i.data()))); break; case PushTag: - currentCollection.push_back(createJsonValue(string("PUSH [tag]"), i.getLocation().start, i.getLocation().end, string(i.data()))); + currentCollection.push_back( + createJsonValue(string("PUSH [tag]"), i.getLocation().start, i.getLocation().end, string(i.data()))); break; case PushSub: - currentCollection.push_back(createJsonValue(string("PUSH"), i.getLocation().start, i.getLocation().end, string("[$]" + string(h256(i.data()).abridged())))); + currentCollection.push_back( + createJsonValue(string("PUSH"), i.getLocation().start, i.getLocation().end, string("[$]" + string(h256(i.data()).abridged())))); break; case PushSubSize: - currentCollection.push_back(createJsonValue(string("PUSH"), i.getLocation().start, i.getLocation().end, string("#[$]" + string(h256(i.data()).abridged())))); + currentCollection.push_back( + createJsonValue(string("PUSH"), i.getLocation().start, i.getLocation().end, string("#[$]" + string(h256(i.data()).abridged())))); break; case PushProgramSize: - currentCollection.push_back(createJsonValue(string("PUSHSIZE"), i.getLocation().start, i.getLocation().end)); + currentCollection.push_back( + createJsonValue(string("PUSHSIZE"), i.getLocation().start, i.getLocation().end)); break; case Tag: { @@ -230,13 +246,11 @@ ostream& Assembly::streamAsmJson(ostream& _out, string const& _prefix, StringMap } } - //todo check if the last was tag Json::Value collection(Json::arrayValue); for (auto it: currentCollection) collection.append(it); root[currentArrayName] = collection; - Json::Value rootData; if (!m_data.empty() || !m_subs.empty()) { Json::Value dataCollection(Json::arrayValue); @@ -249,29 +263,32 @@ ostream& Assembly::streamAsmJson(ostream& _out, string const& _prefix, StringMap data["value"] = hexStr.str(); dataCollection.append(data); } - rootData[_prefix + ".data"] = collection; - _out << root << rootData; for (size_t i = 0; i < m_subs.size(); ++i) { std::stringstream hexStr; - hexStr << _prefix << hex << i << ": "; - //_out << _prefix << " " << hex << i << ": " << endl; - //todo check recursion check order. - m_subs[i].stream(_out, _prefix + " ", _sourceCodes, _inJsonFormat); + hexStr << _prefix << hex << i; + Json::Value num; + num["sub assembly"] = hexStr.str(); + dataCollection.append(num); + dataCollection.append(m_subs[i].stream(_out, _prefix + " ", _sourceCodes, _inJsonFormat)); } - } else + root[_prefix + ".data"] = dataCollection; _out << root; + } - return _out; + return move(root); } -ostream& Assembly::stream(ostream& _out, string const& _prefix, StringMap const& _sourceCodes, bool _inJsonFormat) const +Json::Value Assembly::stream(ostream& _out, string const& _prefix, StringMap const& _sourceCodes, bool _inJsonFormat) const { if (_inJsonFormat) return streamAsmJson(_out, _prefix, _sourceCodes, _inJsonFormat); else - return streamAsm(_out, _prefix, _sourceCodes); + { + streamAsm(_out, _prefix, _sourceCodes); + return Json::Value(); + } } AssemblyItem const& Assembly::append(AssemblyItem const& _i) diff --git a/libevmcore/Assembly.h b/libevmcore/Assembly.h index 49c45d37b..2de399b0a 100644 --- a/libevmcore/Assembly.h +++ b/libevmcore/Assembly.h @@ -29,6 +29,7 @@ #include #include #include "Exceptions.h" +#include namespace Json { @@ -80,7 +81,7 @@ public: void popTo(int _deposit) { while (m_deposit > _deposit) append(Instruction::POP); } void injectStart(AssemblyItem const& _i); - std::string out() const { std::stringstream ret; stream(ret); return ret.str(); } + std::string out() const; int deposit() const { return m_deposit; } void adjustDeposit(int _adjustment) { m_deposit += _adjustment; if (asserts(m_deposit >= 0)) BOOST_THROW_EXCEPTION(InvalidDeposit()); } void setDeposit(int _deposit) { m_deposit = _deposit; if (asserts(m_deposit >= 0)) BOOST_THROW_EXCEPTION(InvalidDeposit()); } @@ -90,7 +91,7 @@ public: bytes assemble() const; Assembly& optimise(bool _enable); - std::ostream& stream( + Json::Value stream( std::ostream& _out, std::string const& _prefix = "", const StringMap &_sourceCodes = StringMap(), @@ -102,7 +103,7 @@ protected: unsigned bytesRequired() const; private: - std::ostream& streamAsmJson( + Json::Value streamAsmJson( std::ostream& _out, const std::string &_prefix, const StringMap &_sourceCodes, @@ -132,5 +133,6 @@ inline std::ostream& operator<<(std::ostream& _out, Assembly const& _a) return _out; } + } } diff --git a/liblll/CMakeLists.txt b/liblll/CMakeLists.txt index e60522a7c..b865d4afe 100644 --- a/liblll/CMakeLists.txt +++ b/liblll/CMakeLists.txt @@ -11,6 +11,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSTATICLIB") aux_source_directory(. SRC_LIST) +include_directories(BEFORE ${JSONCPP_INCLUDE_DIRS}) include_directories(BEFORE ..) include_directories(${Boost_INCLUDE_DIRS}) From 3482c4dfc2cf67ce0d9c7a5595b17c526f0ffb7f Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Wed, 15 Apr 2015 13:28:49 +0200 Subject: [PATCH 07/14] fixed extension of file json format changed value for PUSH to hex --- libevmcore/Assembly.cpp | 46 +++++++++++++++++------------------ libevmcore/Assembly.h | 3 --- solc/CommandLineInterface.cpp | 2 +- 3 files changed, 24 insertions(+), 27 deletions(-) diff --git a/libevmcore/Assembly.cpp b/libevmcore/Assembly.cpp index f794ffa3b..cb4af28c9 100644 --- a/libevmcore/Assembly.cpp +++ b/libevmcore/Assembly.cpp @@ -25,13 +25,10 @@ #include #include #include - using namespace std; using namespace dev; using namespace dev::eth; - - void Assembly::append(Assembly const& _a) { auto newDeposit = m_deposit + _a.deposit(); @@ -170,7 +167,6 @@ ostream& Assembly::streamAsm(ostream& _out, string const& _prefix, StringMap con Json::Value Assembly::createJsonValue(string _name, int _locationX, int _locationY, string _value, string _jumpType) const { Json::Value value; - assert(!_name.empty()); value["name"] = _name; value["locationX"] = _locationX; value["locationY"] = _locationY; @@ -196,8 +192,12 @@ Json::Value Assembly::streamAsmJson(ostream& _out, string const& _prefix, String createJsonValue(instructionInfo(i.instruction()).name, i.getLocation().start, i.getLocation().end, i.getJumpTypeAsString())); break; case Push: + { + std::stringstream hexStr; + hexStr << hex << (unsigned)i.data(); currentCollection.push_back( - createJsonValue(string("PUSH"), i.getLocation().start, i.getLocation().end, string(i.data()), i.getJumpTypeAsString())); + createJsonValue(string("PUSH"), i.getLocation().start, i.getLocation().end, hexStr.str(), i.getJumpTypeAsString())); + } break; case PushString: currentCollection.push_back( @@ -220,26 +220,26 @@ Json::Value Assembly::streamAsmJson(ostream& _out, string const& _prefix, String createJsonValue(string("PUSHSIZE"), i.getLocation().start, i.getLocation().end)); break; case Tag: - { - Json::Value collection(Json::arrayValue); - for (auto it: currentCollection) - collection.append(it); - currentCollection.clear(); - root[currentArrayName] = collection; - currentArrayName = "tag" + string(i.data()); - Json::Value jumpdest; - jumpdest["name"] = "JUMDEST"; - currentCollection.push_back(jumpdest); - } + { + Json::Value collection(Json::arrayValue); + for (auto it: currentCollection) + collection.append(it); + currentCollection.clear(); + root[currentArrayName] = collection; + currentArrayName = "tag" + string(i.data()); + Json::Value jumpdest; + jumpdest["name"] = "JUMDEST"; + currentCollection.push_back(jumpdest); + } break; case PushData: - { - Json::Value pushData; - pushData["name"] = "PUSH hex"; - std::stringstream hexStr; - hexStr << hex << (unsigned)i.data(); - currentCollection.push_back(createJsonValue(string("PUSH hex"), i.getLocation().start, i.getLocation().end, hexStr.str())); - } + { + Json::Value pushData; + pushData["name"] = "PUSH hex"; + std::stringstream hexStr; + hexStr << hex << (unsigned)i.data(); + currentCollection.push_back(createJsonValue(string("PUSH hex"), i.getLocation().start, i.getLocation().end, hexStr.str())); + } break; default: BOOST_THROW_EXCEPTION(InvalidOpcode()); diff --git a/libevmcore/Assembly.h b/libevmcore/Assembly.h index 2de399b0a..86169a93d 100644 --- a/libevmcore/Assembly.h +++ b/libevmcore/Assembly.h @@ -123,16 +123,13 @@ protected: int m_totalDeposit = 0; SourceLocation m_currentSourceLocation; - }; - inline std::ostream& operator<<(std::ostream& _out, Assembly const& _a) { _a.stream(_out); return _out; } - } } diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index cb924d9b5..182015709 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -430,7 +430,7 @@ void CommandLineInterface::actOnInput() if (outputToFile(choice)) { - ofstream outFile(contract + ".evm"); + ofstream outFile(contract + (m_args.count(g_argAsmJsonStr) ? "_evm.json" : ".evm")); m_compiler->streamAssembly(outFile, contract, m_sourceCodes, m_args.count(g_argAsmJsonStr)); outFile.close(); } From 95e161bfc99c2f83a8b9f522679c101de7fa8b98 Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Wed, 15 Apr 2015 14:09:39 +0200 Subject: [PATCH 08/14] style fixes --- libevmcore/Assembly.cpp | 16 ++++++++-------- libevmcore/Assembly.h | 18 ++++++++++-------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/libevmcore/Assembly.cpp b/libevmcore/Assembly.cpp index cb4af28c9..a5ea0211e 100644 --- a/libevmcore/Assembly.cpp +++ b/libevmcore/Assembly.cpp @@ -189,35 +189,35 @@ Json::Value Assembly::streamAsmJson(ostream& _out, string const& _prefix, String { case Operation: currentCollection.push_back( - createJsonValue(instructionInfo(i.instruction()).name, i.getLocation().start, i.getLocation().end, i.getJumpTypeAsString())); + createJsonValue(instructionInfo(i.instruction()).name, i.getLocation().start, i.getLocation().end, i.getJumpTypeAsString())); break; case Push: { std::stringstream hexStr; - hexStr << hex << (unsigned)i.data(); + hexStr << hex << i.data(); currentCollection.push_back( - createJsonValue(string("PUSH"), i.getLocation().start, i.getLocation().end, hexStr.str(), i.getJumpTypeAsString())); + createJsonValue(string("PUSH"), i.getLocation().start, i.getLocation().end, hexStr.str(), i.getJumpTypeAsString())); } break; case PushString: currentCollection.push_back( - createJsonValue(string("PUSH tag"), i.getLocation().start, i.getLocation().end, m_strings.at((h256)i.data()))); + createJsonValue(string("PUSH tag"), i.getLocation().start, i.getLocation().end, m_strings.at((h256)i.data()))); break; case PushTag: currentCollection.push_back( - createJsonValue(string("PUSH [tag]"), i.getLocation().start, i.getLocation().end, string(i.data()))); + createJsonValue(string("PUSH [tag]"), i.getLocation().start, i.getLocation().end, string(i.data()))); break; case PushSub: currentCollection.push_back( - createJsonValue(string("PUSH"), i.getLocation().start, i.getLocation().end, string("[$]" + string(h256(i.data()).abridged())))); + createJsonValue(string("PUSH"), i.getLocation().start, i.getLocation().end, string("[$]" + dev::toString(h256(i.data()))))); break; case PushSubSize: currentCollection.push_back( - createJsonValue(string("PUSH"), i.getLocation().start, i.getLocation().end, string("#[$]" + string(h256(i.data()).abridged())))); + createJsonValue(string("PUSH"), i.getLocation().start, i.getLocation().end, string("#[$]" + dev::toString(h256(i.data()))))); break; case PushProgramSize: currentCollection.push_back( - createJsonValue(string("PUSHSIZE"), i.getLocation().start, i.getLocation().end)); + createJsonValue(string("PUSHSIZE"), i.getLocation().start, i.getLocation().end)); break; case Tag: { diff --git a/libevmcore/Assembly.h b/libevmcore/Assembly.h index 86169a93d..86fd222b3 100644 --- a/libevmcore/Assembly.h +++ b/libevmcore/Assembly.h @@ -92,10 +92,11 @@ public: bytes assemble() const; Assembly& optimise(bool _enable); Json::Value stream( - std::ostream& _out, - std::string const& _prefix = "", - const StringMap &_sourceCodes = StringMap(), - bool _inJsonFormat = false) const; + std::ostream& _out, + std::string const& _prefix = "", + const StringMap &_sourceCodes = StringMap(), + bool _inJsonFormat = false + ) const; protected: std::string getLocationFromSources(StringMap const& _sourceCodes, SourceLocation const& _location) const; @@ -104,10 +105,11 @@ protected: private: Json::Value streamAsmJson( - std::ostream& _out, - const std::string &_prefix, - const StringMap &_sourceCodes, - bool _inJsonFormat) const; + std::ostream& _out, + const std::string &_prefix, + const StringMap &_sourceCodes, + bool _inJsonFormat + ) const; std::ostream& streamAsm(std::ostream& _out, std::string const& _prefix, StringMap const& _sourceCodes) const; Json::Value createJsonValue(std::string _name, int _locationX, int _locationY, std::string _value = std::string(), std::string _jumpType = std::string()) const; From 20132bd44547ac5447dad42f149bede1ff0b4a9d Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Wed, 15 Apr 2015 14:29:18 +0200 Subject: [PATCH 09/14] renamed locationx/y to begin/end --- libevmcore/Assembly.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libevmcore/Assembly.cpp b/libevmcore/Assembly.cpp index a5ea0211e..fbb1b94f4 100644 --- a/libevmcore/Assembly.cpp +++ b/libevmcore/Assembly.cpp @@ -168,8 +168,8 @@ Json::Value Assembly::createJsonValue(string _name, int _locationX, int _locatio { Json::Value value; value["name"] = _name; - value["locationX"] = _locationX; - value["locationY"] = _locationY; + value["begin"] = _locationX; + value["end"] = _locationY; if (!_value.empty()) value["value"] = _value; if (!_jumpType.empty()) From 6d56c979ab2e8e5d7c4b449feb0fd6bc9cb50979 Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Wed, 15 Apr 2015 15:00:20 +0200 Subject: [PATCH 10/14] removed explicit move --- libevmcore/Assembly.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libevmcore/Assembly.cpp b/libevmcore/Assembly.cpp index fbb1b94f4..7a82bcee5 100644 --- a/libevmcore/Assembly.cpp +++ b/libevmcore/Assembly.cpp @@ -174,7 +174,7 @@ Json::Value Assembly::createJsonValue(string _name, int _locationX, int _locatio value["value"] = _value; if (!_jumpType.empty()) value["jumpType"] = _jumpType; - return move(value); + return value; } Json::Value Assembly::streamAsmJson(ostream& _out, string const& _prefix, StringMap const& _sourceCodes, bool _inJsonFormat) const @@ -277,7 +277,7 @@ Json::Value Assembly::streamAsmJson(ostream& _out, string const& _prefix, String _out << root; } - return move(root); + return root; } Json::Value Assembly::stream(ostream& _out, string const& _prefix, StringMap const& _sourceCodes, bool _inJsonFormat) const From a89b7ee9119e252baf1e9e129b5d22870f9af80b Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Wed, 15 Apr 2015 15:54:11 +0200 Subject: [PATCH 11/14] fixed push #[$] and push [$] --- libevmcore/Assembly.cpp | 20 ++++++++++++-------- libevmcore/Assembly.h | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/libevmcore/Assembly.cpp b/libevmcore/Assembly.cpp index 7a82bcee5..b4081776d 100644 --- a/libevmcore/Assembly.cpp +++ b/libevmcore/Assembly.cpp @@ -164,12 +164,12 @@ ostream& Assembly::streamAsm(ostream& _out, string const& _prefix, StringMap con return _out; } -Json::Value Assembly::createJsonValue(string _name, int _locationX, int _locationY, string _value, string _jumpType) const +Json::Value Assembly::createJsonValue(string _name, int _begin, int _end, string _value, string _jumpType) const { Json::Value value; value["name"] = _name; - value["begin"] = _locationX; - value["end"] = _locationY; + value["begin"] = _begin; + value["end"] = _end; if (!_value.empty()) value["value"] = _value; if (!_jumpType.empty()) @@ -204,16 +204,20 @@ Json::Value Assembly::streamAsmJson(ostream& _out, string const& _prefix, String createJsonValue(string("PUSH tag"), i.getLocation().start, i.getLocation().end, m_strings.at((h256)i.data()))); break; case PushTag: + { + std::stringstream hexStr; + hexStr << hex << i.data(); currentCollection.push_back( - createJsonValue(string("PUSH [tag]"), i.getLocation().start, i.getLocation().end, string(i.data()))); + createJsonValue(string("PUSH [tag]"), i.getLocation().start, i.getLocation().end, hexStr.str())); + } break; case PushSub: currentCollection.push_back( - createJsonValue(string("PUSH"), i.getLocation().start, i.getLocation().end, string("[$]" + dev::toString(h256(i.data()))))); + createJsonValue(string("PUSH [$]"), i.getLocation().start, i.getLocation().end, dev::toString(h256(i.data())))); break; case PushSubSize: currentCollection.push_back( - createJsonValue(string("PUSH"), i.getLocation().start, i.getLocation().end, string("#[$]" + dev::toString(h256(i.data()))))); + createJsonValue(string("PUSH #[$]"), i.getLocation().start, i.getLocation().end, dev::toString(h256(i.data())))); break; case PushProgramSize: currentCollection.push_back( @@ -237,7 +241,7 @@ Json::Value Assembly::streamAsmJson(ostream& _out, string const& _prefix, String Json::Value pushData; pushData["name"] = "PUSH hex"; std::stringstream hexStr; - hexStr << hex << (unsigned)i.data(); + hexStr << hex << i.data(); currentCollection.push_back(createJsonValue(string("PUSH hex"), i.getLocation().start, i.getLocation().end, hexStr.str())); } break; @@ -258,7 +262,7 @@ Json::Value Assembly::streamAsmJson(ostream& _out, string const& _prefix, String if (u256(i.first) >= m_subs.size()) { std::stringstream hexStr; - hexStr << _prefix << hex << (unsigned)(u256)i.first << ": " << toHex(i.second); + hexStr << _prefix << hex << (u256)i.first << ": " << toHex(i.second); Json::Value data; data["value"] = hexStr.str(); dataCollection.append(data); diff --git a/libevmcore/Assembly.h b/libevmcore/Assembly.h index 86fd222b3..d0eb43a20 100644 --- a/libevmcore/Assembly.h +++ b/libevmcore/Assembly.h @@ -111,7 +111,7 @@ private: bool _inJsonFormat ) const; std::ostream& streamAsm(std::ostream& _out, std::string const& _prefix, StringMap const& _sourceCodes) const; - Json::Value createJsonValue(std::string _name, int _locationX, int _locationY, std::string _value = std::string(), std::string _jumpType = std::string()) const; + Json::Value createJsonValue(std::string _name, int _begin, int _end, std::string _value = std::string(), std::string _jumpType = std::string()) const; protected: unsigned m_usedTags = 0; From ebd4be49f6d38ad8544f47edf5aa5ac029dc718a Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Thu, 16 Apr 2015 12:54:58 +0200 Subject: [PATCH 12/14] changed the format of json output --- libevmcore/Assembly.cpp | 56 ++++++++++++++--------------------------- 1 file changed, 19 insertions(+), 37 deletions(-) diff --git a/libevmcore/Assembly.cpp b/libevmcore/Assembly.cpp index b4081776d..1f8307f81 100644 --- a/libevmcore/Assembly.cpp +++ b/libevmcore/Assembly.cpp @@ -177,6 +177,13 @@ Json::Value Assembly::createJsonValue(string _name, int _begin, int _end, string return value; } +string toStringInHex(u256 _value) +{ + std::stringstream hexStr; + hexStr << hex << _value; + return hexStr.str(); +} + Json::Value Assembly::streamAsmJson(ostream& _out, string const& _prefix, StringMap const& _sourceCodes, bool _inJsonFormat) const { Json::Value root; @@ -192,24 +199,16 @@ Json::Value Assembly::streamAsmJson(ostream& _out, string const& _prefix, String createJsonValue(instructionInfo(i.instruction()).name, i.getLocation().start, i.getLocation().end, i.getJumpTypeAsString())); break; case Push: - { - std::stringstream hexStr; - hexStr << hex << i.data(); currentCollection.push_back( - createJsonValue(string("PUSH"), i.getLocation().start, i.getLocation().end, hexStr.str(), i.getJumpTypeAsString())); - } + createJsonValue(string("PUSH"), i.getLocation().start, i.getLocation().end, toStringInHex(i.data()), i.getJumpTypeAsString())); break; case PushString: currentCollection.push_back( createJsonValue(string("PUSH tag"), i.getLocation().start, i.getLocation().end, m_strings.at((h256)i.data()))); break; case PushTag: - { - std::stringstream hexStr; - hexStr << hex << i.data(); currentCollection.push_back( - createJsonValue(string("PUSH [tag]"), i.getLocation().start, i.getLocation().end, hexStr.str())); - } + createJsonValue(string("PUSH [tag]"), i.getLocation().start, i.getLocation().end, toStringInHex(i.data()))); break; case PushSub: currentCollection.push_back( @@ -225,24 +224,17 @@ Json::Value Assembly::streamAsmJson(ostream& _out, string const& _prefix, String break; case Tag: { - Json::Value collection(Json::arrayValue); - for (auto it: currentCollection) - collection.append(it); - currentCollection.clear(); - root[currentArrayName] = collection; - currentArrayName = "tag" + string(i.data()); - Json::Value jumpdest; - jumpdest["name"] = "JUMDEST"; - currentCollection.push_back(jumpdest); + currentCollection.push_back( + createJsonValue(string("tag"), i.getLocation().start, i.getLocation().end, string(i.data()))); + currentCollection.push_back( + createJsonValue(string("JUMDEST"), -1, -1)); } break; case PushData: { Json::Value pushData; pushData["name"] = "PUSH hex"; - std::stringstream hexStr; - hexStr << hex << i.data(); - currentCollection.push_back(createJsonValue(string("PUSH hex"), i.getLocation().start, i.getLocation().end, hexStr.str())); + currentCollection.push_back(createJsonValue(string("PUSH hex"), i.getLocation().start, i.getLocation().end, toStringInHex(i.data()))); } break; default: @@ -257,30 +249,20 @@ Json::Value Assembly::streamAsmJson(ostream& _out, string const& _prefix, String if (!m_data.empty() || !m_subs.empty()) { - Json::Value dataCollection(Json::arrayValue); + Json::Value data; for (auto const& i: m_data) if (u256(i.first) >= m_subs.size()) - { - std::stringstream hexStr; - hexStr << _prefix << hex << (u256)i.first << ": " << toHex(i.second); - Json::Value data; - data["value"] = hexStr.str(); - dataCollection.append(data); - } + data[toStringInHex((u256)i.first)] = toHex(i.second); for (size_t i = 0; i < m_subs.size(); ++i) { std::stringstream hexStr; - hexStr << _prefix << hex << i; - Json::Value num; - num["sub assembly"] = hexStr.str(); - dataCollection.append(num); - dataCollection.append(m_subs[i].stream(_out, _prefix + " ", _sourceCodes, _inJsonFormat)); + hexStr << hex << i; + data[hexStr.str()] = m_subs[i].stream(_out, _prefix + " ", _sourceCodes, _inJsonFormat); } - root[_prefix + ".data"] = dataCollection; + root[".data"] = data; _out << root; } - return root; } From 78bb6deadbf04557158ec4275f7b568deab43207 Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Fri, 17 Apr 2015 15:45:30 +0200 Subject: [PATCH 13/14] style fixes --- libevmcore/Assembly.cpp | 50 +++++++++++++++++++---------------------- libevmcore/Assembly.h | 4 +--- 2 files changed, 24 insertions(+), 30 deletions(-) diff --git a/libevmcore/Assembly.cpp b/libevmcore/Assembly.cpp index 1f8307f81..d21167e6b 100644 --- a/libevmcore/Assembly.cpp +++ b/libevmcore/Assembly.cpp @@ -184,57 +184,56 @@ string toStringInHex(u256 _value) return hexStr.str(); } -Json::Value Assembly::streamAsmJson(ostream& _out, string const& _prefix, StringMap const& _sourceCodes, bool _inJsonFormat) const +Json::Value Assembly::streamAsmJson(ostream& _out, StringMap const& _sourceCodes, bool _inJsonFormat) const { Json::Value root; - string currentArrayName = ".code"; - std::vector currentCollection; + Json::Value collection(Json::arrayValue); for (AssemblyItem const& i: m_items) { switch (i.type()) { case Operation: - currentCollection.push_back( + collection.append( createJsonValue(instructionInfo(i.instruction()).name, i.getLocation().start, i.getLocation().end, i.getJumpTypeAsString())); break; case Push: - currentCollection.push_back( - createJsonValue(string("PUSH"), i.getLocation().start, i.getLocation().end, toStringInHex(i.data()), i.getJumpTypeAsString())); + collection.append( + createJsonValue("PUSH", i.getLocation().start, i.getLocation().end, toStringInHex(i.data()), i.getJumpTypeAsString())); break; case PushString: - currentCollection.push_back( - createJsonValue(string("PUSH tag"), i.getLocation().start, i.getLocation().end, m_strings.at((h256)i.data()))); + collection.append( + createJsonValue("PUSH tag", i.getLocation().start, i.getLocation().end, m_strings.at((h256)i.data()))); break; case PushTag: - currentCollection.push_back( - createJsonValue(string("PUSH [tag]"), i.getLocation().start, i.getLocation().end, toStringInHex(i.data()))); + collection.append( + createJsonValue("PUSH [tag]", i.getLocation().start, i.getLocation().end, toStringInHex(i.data()))); break; case PushSub: - currentCollection.push_back( - createJsonValue(string("PUSH [$]"), i.getLocation().start, i.getLocation().end, dev::toString(h256(i.data())))); + collection.append( + createJsonValue("PUSH [$]", i.getLocation().start, i.getLocation().end, dev::toString(h256(i.data())))); break; case PushSubSize: - currentCollection.push_back( - createJsonValue(string("PUSH #[$]"), i.getLocation().start, i.getLocation().end, dev::toString(h256(i.data())))); + collection.append( + createJsonValue("PUSH #[$]", i.getLocation().start, i.getLocation().end, dev::toString(h256(i.data())))); break; case PushProgramSize: - currentCollection.push_back( - createJsonValue(string("PUSHSIZE"), i.getLocation().start, i.getLocation().end)); + collection.append( + createJsonValue("PUSHSIZE", i.getLocation().start, i.getLocation().end)); break; case Tag: { - currentCollection.push_back( - createJsonValue(string("tag"), i.getLocation().start, i.getLocation().end, string(i.data()))); - currentCollection.push_back( - createJsonValue(string("JUMDEST"), -1, -1)); + collection.append( + createJsonValue("tag", i.getLocation().start, i.getLocation().end, string(i.data()))); + collection.append( + createJsonValue("JUMDEST", i.getLocation().start, i.getLocation().end)); } break; case PushData: { Json::Value pushData; pushData["name"] = "PUSH hex"; - currentCollection.push_back(createJsonValue(string("PUSH hex"), i.getLocation().start, i.getLocation().end, toStringInHex(i.data()))); + collection.append(createJsonValue("PUSH hex", i.getLocation().start, i.getLocation().end, toStringInHex(i.data()))); } break; default: @@ -242,10 +241,7 @@ Json::Value Assembly::streamAsmJson(ostream& _out, string const& _prefix, String } } - Json::Value collection(Json::arrayValue); - for (auto it: currentCollection) - collection.append(it); - root[currentArrayName] = collection; + root[".code"] = collection; if (!m_data.empty() || !m_subs.empty()) { @@ -258,7 +254,7 @@ Json::Value Assembly::streamAsmJson(ostream& _out, string const& _prefix, String { std::stringstream hexStr; hexStr << hex << i; - data[hexStr.str()] = m_subs[i].stream(_out, _prefix + " ", _sourceCodes, _inJsonFormat); + data[hexStr.str()] = m_subs[i].stream(_out, "", _sourceCodes, _inJsonFormat); } root[".data"] = data; _out << root; @@ -269,7 +265,7 @@ Json::Value Assembly::streamAsmJson(ostream& _out, string const& _prefix, String Json::Value Assembly::stream(ostream& _out, string const& _prefix, StringMap const& _sourceCodes, bool _inJsonFormat) const { if (_inJsonFormat) - return streamAsmJson(_out, _prefix, _sourceCodes, _inJsonFormat); + return streamAsmJson(_out, _sourceCodes, _inJsonFormat); else { streamAsm(_out, _prefix, _sourceCodes); diff --git a/libevmcore/Assembly.h b/libevmcore/Assembly.h index d0eb43a20..60df34215 100644 --- a/libevmcore/Assembly.h +++ b/libevmcore/Assembly.h @@ -104,9 +104,7 @@ protected: unsigned bytesRequired() const; private: - Json::Value streamAsmJson( - std::ostream& _out, - const std::string &_prefix, + Json::Value streamAsmJson(std::ostream& _out, const StringMap &_sourceCodes, bool _inJsonFormat ) const; From 254c845490ecbfbf5799bb408d32cf2ea2e09643 Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Fri, 17 Apr 2015 16:40:40 +0200 Subject: [PATCH 14/14] removed unused parameter from streamAsmJson --- libevmcore/Assembly.cpp | 6 +++--- libevmcore/Assembly.h | 5 +---- libsolidity/CompilerStack.cpp | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/libevmcore/Assembly.cpp b/libevmcore/Assembly.cpp index d21167e6b..ae8567e2a 100644 --- a/libevmcore/Assembly.cpp +++ b/libevmcore/Assembly.cpp @@ -184,7 +184,7 @@ string toStringInHex(u256 _value) return hexStr.str(); } -Json::Value Assembly::streamAsmJson(ostream& _out, StringMap const& _sourceCodes, bool _inJsonFormat) const +Json::Value Assembly::streamAsmJson(ostream& _out, StringMap const& _sourceCodes) const { Json::Value root; @@ -254,7 +254,7 @@ Json::Value Assembly::streamAsmJson(ostream& _out, StringMap const& _sourceCodes { std::stringstream hexStr; hexStr << hex << i; - data[hexStr.str()] = m_subs[i].stream(_out, "", _sourceCodes, _inJsonFormat); + data[hexStr.str()] = m_subs[i].stream(_out, "", _sourceCodes, true); } root[".data"] = data; _out << root; @@ -265,7 +265,7 @@ Json::Value Assembly::streamAsmJson(ostream& _out, StringMap const& _sourceCodes Json::Value Assembly::stream(ostream& _out, string const& _prefix, StringMap const& _sourceCodes, bool _inJsonFormat) const { if (_inJsonFormat) - return streamAsmJson(_out, _sourceCodes, _inJsonFormat); + return streamAsmJson(_out, _sourceCodes); else { streamAsm(_out, _prefix, _sourceCodes); diff --git a/libevmcore/Assembly.h b/libevmcore/Assembly.h index 60df34215..4ac873682 100644 --- a/libevmcore/Assembly.h +++ b/libevmcore/Assembly.h @@ -104,10 +104,7 @@ protected: unsigned bytesRequired() const; private: - Json::Value streamAsmJson(std::ostream& _out, - const StringMap &_sourceCodes, - bool _inJsonFormat - ) const; + Json::Value streamAsmJson(std::ostream& _out, const StringMap &_sourceCodes) const; std::ostream& streamAsm(std::ostream& _out, std::string const& _prefix, StringMap const& _sourceCodes) const; Json::Value createJsonValue(std::string _name, int _begin, int _end, std::string _value = std::string(), std::string _jumpType = std::string()) const; diff --git a/libsolidity/CompilerStack.cpp b/libsolidity/CompilerStack.cpp index 592f61276..d6274e2c7 100644 --- a/libsolidity/CompilerStack.cpp +++ b/libsolidity/CompilerStack.cpp @@ -188,7 +188,7 @@ void CompilerStack::streamAssembly(ostream& _outStream, string const& _contractN { Contract const& contract = getContract(_contractName); if (contract.compiler) - contract(_contractName).compiler->streamAssembly(_outStream, _sourceCodes, _inJsonFormat); + contract.compiler->streamAssembly(_outStream, _sourceCodes, _inJsonFormat); else _outStream << "Contract not fully implemented" << endl; }