aboutsummaryrefslogtreecommitdiffstats
path: root/solc
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2016-11-16 02:16:07 +0800
committerGitHub <noreply@github.com>2016-11-16 02:16:07 +0800
commit192a81892dca3762c050f159da202c8c8f90f72c (patch)
tree049fdd9eaf1bbe8ec18ff643739378a076d54e9e /solc
parent0072160d7772b2f30c2c6af4428728cb31641696 (diff)
parent227f6aab4f96003e0f7c99194a9ea1095041970f (diff)
downloaddexon-solidity-192a81892dca3762c050f159da202c8c8f90f72c.tar
dexon-solidity-192a81892dca3762c050f159da202c8c8f90f72c.tar.gz
dexon-solidity-192a81892dca3762c050f159da202c8c8f90f72c.tar.bz2
dexon-solidity-192a81892dca3762c050f159da202c8c8f90f72c.tar.lz
dexon-solidity-192a81892dca3762c050f159da202c8c8f90f72c.tar.xz
dexon-solidity-192a81892dca3762c050f159da202c8c8f90f72c.tar.zst
dexon-solidity-192a81892dca3762c050f159da202c8c8f90f72c.zip
Merge pull request #1377 from ethereum/keep-json-values
Keep internal results in JSON
Diffstat (limited to 'solc')
-rw-r--r--solc/CommandLineInterface.cpp19
-rw-r--r--solc/jsonCompiler.cpp7
2 files changed, 17 insertions, 9 deletions
diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp
index 83168f86..7b23f886 100644
--- a/solc/CommandLineInterface.cpp
+++ b/solc/CommandLineInterface.cpp
@@ -41,6 +41,7 @@
#include <libdevcore/Common.h>
#include <libdevcore/CommonData.h>
#include <libdevcore/CommonIO.h>
+#include <libdevcore/JSON.h>
#include <libevmasm/Instruction.h>
#include <libevmasm/GasMeter.h>
#include <libsolidity/interface/Version.h>
@@ -230,12 +231,18 @@ void CommandLineInterface::handleMeta(DocumentationType _type, string const& _co
if (m_args.count(argName))
{
+ std::string output;
+ if (_type == DocumentationType::ABIInterface)
+ output = dev::jsonCompactPrint(m_compiler->metadata(_contract, _type));
+ else
+ output = dev::jsonPrettyPrint(m_compiler->metadata(_contract, _type));
+
if (m_args.count("output-dir"))
- createFile(_contract + suffix, m_compiler->metadata(_contract, _type));
+ createFile(_contract + suffix, output);
else
{
cout << title << endl;
- cout << m_compiler->metadata(_contract, _type) << endl;
+ cout << output << endl;
}
}
@@ -651,7 +658,7 @@ void CommandLineInterface::handleCombinedJSON()
{
Json::Value contractData(Json::objectValue);
if (requests.count("abi"))
- contractData["abi"] = m_compiler->interface(contractName);
+ contractData["abi"] = dev::jsonCompactPrint(m_compiler->interface(contractName));
if (requests.count("bin"))
contractData["bin"] = m_compiler->object(contractName).toHex();
if (requests.count("bin-runtime"))
@@ -676,9 +683,9 @@ void CommandLineInterface::handleCombinedJSON()
contractData["srcmap-runtime"] = map ? *map : "";
}
if (requests.count("devdoc"))
- contractData["devdoc"] = m_compiler->metadata(contractName, DocumentationType::NatspecDev);
+ contractData["devdoc"] = dev::jsonCompactPrint(m_compiler->metadata(contractName, DocumentationType::NatspecDev));
if (requests.count("userdoc"))
- contractData["userdoc"] = m_compiler->metadata(contractName, DocumentationType::NatspecUser);
+ contractData["userdoc"] = dev::jsonCompactPrint(m_compiler->metadata(contractName, DocumentationType::NatspecUser));
output["contracts"][contractName] = contractData;
}
@@ -702,7 +709,7 @@ void CommandLineInterface::handleCombinedJSON()
output["sources"][sourceCode.first]["AST"] = converter.json();
}
}
- cout << Json::FastWriter().write(output) << endl;
+ cout << dev::jsonCompactPrint(output) << endl;
}
void CommandLineInterface::handleAst(string const& _argStr)
diff --git a/solc/jsonCompiler.cpp b/solc/jsonCompiler.cpp
index e5be8404..771f0df8 100644
--- a/solc/jsonCompiler.cpp
+++ b/solc/jsonCompiler.cpp
@@ -27,6 +27,7 @@
#include <libdevcore/Common.h>
#include <libdevcore/CommonData.h>
#include <libdevcore/CommonIO.h>
+#include <libdevcore/JSON.h>
#include <libevmasm/Instruction.h>
#include <libevmasm/GasMeter.h>
#include <libsolidity/parsing/Scanner.h>
@@ -213,7 +214,7 @@ string compile(StringMap const& _sources, bool _optimize, CStyleReadFileCallback
for (string const& contractName: compiler.contractNames())
{
Json::Value contractData(Json::objectValue);
- contractData["interface"] = compiler.interface(contractName);
+ contractData["interface"] = dev::jsonCompactPrint(compiler.interface(contractName));
contractData["bytecode"] = compiler.object(contractName).toHex();
contractData["runtimeBytecode"] = compiler.runtimeObject(contractName).toHex();
contractData["opcodes"] = solidity::disassemble(compiler.object(contractName).bytecode);
@@ -274,7 +275,7 @@ string compile(StringMap const& _sources, bool _optimize, CStyleReadFileCallback
try
{
- return Json::FastWriter().write(output);
+ return dev::jsonCompactPrint(output);
}
catch (...)
{
@@ -292,7 +293,7 @@ string compileMulti(string const& _input, bool _optimize, CStyleReadFileCallback
errors.append("Error parsing input JSON: " + reader.getFormattedErrorMessages());
Json::Value output(Json::objectValue);
output["errors"] = errors;
- return Json::FastWriter().write(output);
+ return dev::jsonCompactPrint(output);
}
else
{