From a535a8b06ed1b9c0c5fd41805a4fe39939755f05 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Thu, 15 Jun 2017 10:22:47 +0100 Subject: Split out the JSON functionality from assembly.stream() --- solc/CommandLineInterface.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'solc/CommandLineInterface.cpp') diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index 315f951e..560dc98b 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -865,10 +865,7 @@ void CommandLineInterface::handleCombinedJSON() if (requests.count(g_strOpcodes)) contractData[g_strOpcodes] = solidity::disassemble(m_compiler->object(contractName).bytecode); if (requests.count(g_strAsm)) - { - ostringstream unused; - contractData[g_strAsm] = m_compiler->streamAssembly(unused, contractName, m_sourceCodes, true); - } + contractData[g_strAsm] = m_compiler->assemblyJSON(contractName, m_sourceCodes); if (requests.count(g_strSrcMap)) { auto map = m_compiler->sourceMapping(contractName); @@ -1152,14 +1149,25 @@ void CommandLineInterface::outputCompilationResults() { if (m_args.count(g_argOutputDir)) { - stringstream data; - m_compiler->streamAssembly(data, contract, m_sourceCodes, m_args.count(g_argAsmJson)); - createFile(m_compiler->filesystemFriendlyName(contract) + (m_args.count(g_argAsmJson) ? "_evm.json" : ".evm"), data.str()); + if (m_args.count(g_argAsmJson) + { + Json::Value ret = m_compiler->assemblyJSON(contract, m_sourceCodes); + createFile(m_compiler->filesystemFriendlyName(contract) + "_evm.json", dev::jsonPrettyPrint(ret)); + } + else + { + stringstream data; + m_compiler->assemblyStream(data, contract, m_sourceCodes); + createFile(m_compiler->filesystemFriendlyName(contract) + ".evm", data.str()); + } } else { cout << "EVM assembly:" << endl; - m_compiler->streamAssembly(cout, contract, m_sourceCodes, m_args.count(g_argAsmJson)); + if (m_args.count(g_argAsmJson) + cout << m_compiler->assemblyJSON(contract, m_sourceCodes); + else + m_compiler->assemblyStream(cout, contract, m_sourceCodes); } } -- cgit v1.2.3