diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2017-06-15 17:22:47 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2017-09-11 22:48:52 +0800 |
commit | a535a8b06ed1b9c0c5fd41805a4fe39939755f05 (patch) | |
tree | 94484019deeef72cc1bab99de51b844647ec6881 /libsolidity/interface | |
parent | 55d2a459a9193024930101c79bbf48af2eb39e2d (diff) | |
download | dexon-solidity-a535a8b06ed1b9c0c5fd41805a4fe39939755f05.tar.gz dexon-solidity-a535a8b06ed1b9c0c5fd41805a4fe39939755f05.tar.zst dexon-solidity-a535a8b06ed1b9c0c5fd41805a4fe39939755f05.zip |
Split out the JSON functionality from assembly.stream()
Diffstat (limited to 'libsolidity/interface')
-rw-r--r-- | libsolidity/interface/AssemblyStack.cpp | 2 | ||||
-rw-r--r-- | libsolidity/interface/CompilerStack.cpp | 16 | ||||
-rw-r--r-- | libsolidity/interface/CompilerStack.h | 8 | ||||
-rw-r--r-- | libsolidity/interface/StandardCompiler.cpp | 4 |
4 files changed, 22 insertions, 8 deletions
diff --git a/libsolidity/interface/AssemblyStack.cpp b/libsolidity/interface/AssemblyStack.cpp index 23524bb3..025a01ac 100644 --- a/libsolidity/interface/AssemblyStack.cpp +++ b/libsolidity/interface/AssemblyStack.cpp @@ -92,7 +92,7 @@ MachineAssemblyObject AssemblyStack::assemble(Machine _machine) const assembly::CodeGenerator::assemble(*m_parserResult, *m_analysisInfo, assembly); object.bytecode = make_shared<eth::LinkerObject>(assembly.assemble()); ostringstream tmp; - assembly.stream(tmp); + assembly.assemblyStream(tmp); object.assembly = tmp.str(); return object; } diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index 259694da..4002bac3 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -347,18 +347,28 @@ eth::LinkerObject const& CompilerStack::cloneObject(string const& _contractName) return contract(_contractName).cloneObject; } -Json::Value CompilerStack::streamAssembly(ostream& _outStream, string const& _contractName, StringMap _sourceCodes, bool _inJsonFormat) const +ostream& CompilerStack::assemblyStream(ostream& _outStream, string const& _contractName, StringMap _sourceCodes) const { Contract const& currentContract = contract(_contractName); if (currentContract.compiler) - return currentContract.compiler->streamAssembly(_outStream, _sourceCodes, _inJsonFormat); + return currentContract.compiler->assemblyStream(_outStream, _sourceCodes); else { _outStream << "Contract not fully implemented" << endl; - return Json::Value(); + return _outStream; } } +/// FIXME: cache the JSON +Json::Value CompilerStack::assemblyJSON(string const& _contractName, StringMap _sourceCodes) const +{ + Contract const& currentContract = contract(_contractName); + if (currentContract.compiler) + return currentContract.compiler->assemblyJSON(_sourceCodes); + else + return Json::Value(); +} + vector<string> CompilerStack::sourceNames() const { vector<string> names; diff --git a/libsolidity/interface/CompilerStack.h b/libsolidity/interface/CompilerStack.h index 2756e57d..207778f0 100644 --- a/libsolidity/interface/CompilerStack.h +++ b/libsolidity/interface/CompilerStack.h @@ -192,9 +192,13 @@ 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 whether the out should be in Json format /// Prerequisite: Successful compilation. - Json::Value streamAssembly(std::ostream& _outStream, std::string const& _contractName = "", StringMap _sourceCodes = StringMap(), bool _inJsonFormat = false) const; + std::ostream& assemblyStream(std::ostream& _outStream, std::string const& _contractName = "", StringMap _sourceCodes = StringMap()) const; + + /// @returns a JSON representation of the assembly. + /// @arg _sourceCodes is the map of input files to source code strings + /// Prerequisite: Successful compilation. + Json::Value assemblyJSON(std::string const& _contractName = "", StringMap _sourceCodes = StringMap()) const; /// @returns a JSON representing the contract ABI. /// Prerequisite: Successful call to parse or compile. diff --git a/libsolidity/interface/StandardCompiler.cpp b/libsolidity/interface/StandardCompiler.cpp index be823743..c821a341 100644 --- a/libsolidity/interface/StandardCompiler.cpp +++ b/libsolidity/interface/StandardCompiler.cpp @@ -401,9 +401,9 @@ Json::Value StandardCompiler::compileInternal(Json::Value const& _input) Json::Value evmData(Json::objectValue); // @TODO: add ir ostringstream tmp; - m_compilerStack.streamAssembly(tmp, contractName, createSourceList(_input), false); + m_compilerStack.assemblyStream(tmp, contractName, createSourceList(_input)); evmData["assembly"] = tmp.str(); - evmData["legacyAssembly"] = m_compilerStack.streamAssembly(tmp, contractName, createSourceList(_input), true); + evmData["legacyAssembly"] = m_compilerStack.assemblyJSON(contractName, createSourceList(_input)); evmData["methodIdentifiers"] = m_compilerStack.methodIdentifiers(contractName); evmData["gasEstimates"] = m_compilerStack.gasEstimates(contractName); |