diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2017-04-19 22:52:54 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2017-04-21 02:38:00 +0800 |
commit | 6d132602326e9a981141d9e5213ba65c423dd099 (patch) | |
tree | 0a2112ffe34b03302e957be241eaaf70296e1beb /libsolidity | |
parent | 413c146eddb744f6b5d8dc248f63f4d46449306b (diff) | |
download | dexon-solidity-6d132602326e9a981141d9e5213ba65c423dd099.tar.gz dexon-solidity-6d132602326e9a981141d9e5213ba65c423dd099.tar.zst dexon-solidity-6d132602326e9a981141d9e5213ba65c423dd099.zip |
Pull out collectEVMObject
Diffstat (limited to 'libsolidity')
-rw-r--r-- | libsolidity/interface/StandardCompiler.cpp | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/libsolidity/interface/StandardCompiler.cpp b/libsolidity/interface/StandardCompiler.cpp index 6cfe6f3a..bd2e64c6 100644 --- a/libsolidity/interface/StandardCompiler.cpp +++ b/libsolidity/interface/StandardCompiler.cpp @@ -136,6 +136,16 @@ Json::Value formatLinkReferences(std::map<size_t, std::string> const& linkRefere return ret; } +Json::Value collectEVMObject(eth::LinkerObject const& _object, string const* _sourceMap) +{ + Json::Value output = Json::objectValue; + output["object"] = _object.toHex(); + output["opcodes"] = solidity::disassemble(_object.bytecode); + output["sourceMap"] = _sourceMap ? *_sourceMap : ""; + output["linkReferences"] = formatLinkReferences(_object.linkReferences); + return output; +} + } Json::Value StandardCompiler::compileInternal(Json::Value const& _input) @@ -314,23 +324,15 @@ Json::Value StandardCompiler::compileInternal(Json::Value const& _input) evmData["methodIdentifiers"] = methodIdentifiers(m_compilerStack.contractDefinition(contractName)); evmData["gasEstimates"] = m_compilerStack.gasEstimates(contractName); - // EVM bytecode - Json::Value bytecode(Json::objectValue); - bytecode["object"] = m_compilerStack.object(contractName).toHex(); - bytecode["opcodes"] = solidity::disassemble(m_compilerStack.object(contractName).bytecode); - auto sourceMap = m_compilerStack.sourceMapping(contractName); - bytecode["sourceMap"] = sourceMap ? *sourceMap : ""; - bytecode["linkReferences"] = formatLinkReferences(m_compilerStack.object(contractName).linkReferences); - evmData["bytecode"] = bytecode; - - // EVM deployed bytecode - Json::Value deployedBytecode(Json::objectValue); - deployedBytecode["object"] = m_compilerStack.runtimeObject(contractName).toHex(); - deployedBytecode["opcodes"] = solidity::disassemble(m_compilerStack.runtimeObject(contractName).bytecode); - auto runtimeSourceMap = m_compilerStack.runtimeSourceMapping(contractName); - deployedBytecode["sourceMap"] = runtimeSourceMap ? *runtimeSourceMap : ""; - deployedBytecode["linkReferences"] = formatLinkReferences(m_compilerStack.runtimeObject(contractName).linkReferences); - evmData["deployedBytecode"] = deployedBytecode; + evmData["bytecode"] = collectEVMObject( + m_compilerStack.object(contractName), + m_compilerStack.sourceMapping(contractName) + ); + + evmData["deployedBytecode"] = collectEVMObject( + m_compilerStack.runtimeObject(contractName), + m_compilerStack.runtimeSourceMapping(contractName) + ); contractData["evm"] = evmData; |