diff options
Diffstat (limited to 'solc')
-rw-r--r-- | solc/CommandLineInterface.cpp | 25 | ||||
-rw-r--r-- | solc/jsonCompiler.cpp | 14 |
2 files changed, 11 insertions, 28 deletions
diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index 5509a414..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> @@ -107,18 +108,6 @@ static void version() exit(0); } -string jsonPrettyPrint(Json::Value const& input) -{ - return Json::StyledWriter().write(input); -} - -string jsonCompactPrint(Json::Value const& input) -{ - Json::FastWriter writer; - writer.omitEndingLineFeed(); - return writer.write(input); -} - static bool needsHumanTargetedStdout(po::variables_map const& _args) { if (_args.count(g_argGas)) @@ -244,9 +233,9 @@ void CommandLineInterface::handleMeta(DocumentationType _type, string const& _co { std::string output; if (_type == DocumentationType::ABIInterface) - output = jsonCompactPrint(m_compiler->metadata(_contract, _type)); + output = dev::jsonCompactPrint(m_compiler->metadata(_contract, _type)); else - output = jsonPrettyPrint(m_compiler->metadata(_contract, _type)); + output = dev::jsonPrettyPrint(m_compiler->metadata(_contract, _type)); if (m_args.count("output-dir")) createFile(_contract + suffix, output); @@ -669,7 +658,7 @@ void CommandLineInterface::handleCombinedJSON() { Json::Value contractData(Json::objectValue); if (requests.count("abi")) - contractData["abi"] = jsonCompactPrint(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")) @@ -694,9 +683,9 @@ void CommandLineInterface::handleCombinedJSON() contractData["srcmap-runtime"] = map ? *map : ""; } if (requests.count("devdoc")) - contractData["devdoc"] = jsonCompactPrint(m_compiler->metadata(contractName, DocumentationType::NatspecDev)); + contractData["devdoc"] = dev::jsonCompactPrint(m_compiler->metadata(contractName, DocumentationType::NatspecDev)); if (requests.count("userdoc")) - contractData["userdoc"] = jsonCompactPrint(m_compiler->metadata(contractName, DocumentationType::NatspecUser)); + contractData["userdoc"] = dev::jsonCompactPrint(m_compiler->metadata(contractName, DocumentationType::NatspecUser)); output["contracts"][contractName] = contractData; } @@ -720,7 +709,7 @@ void CommandLineInterface::handleCombinedJSON() output["sources"][sourceCode.first]["AST"] = converter.json(); } } - cout << jsonCompactPrint(output) << endl; + cout << dev::jsonCompactPrint(output) << endl; } void CommandLineInterface::handleAst(string const& _argStr) diff --git a/solc/jsonCompiler.cpp b/solc/jsonCompiler.cpp index 52f796a5..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> @@ -125,13 +126,6 @@ Json::Value estimateGas(CompilerStack const& _compiler, string const& _contract) return gasEstimates; } -string jsonCompactPrint(Json::Value const& input) -{ - Json::FastWriter writer; - writer.omitEndingLineFeed(); - return writer.write(input); -} - string compile(StringMap const& _sources, bool _optimize, CStyleReadFileCallback _readCallback) { Json::Value output(Json::objectValue); @@ -220,7 +214,7 @@ string compile(StringMap const& _sources, bool _optimize, CStyleReadFileCallback for (string const& contractName: compiler.contractNames()) { Json::Value contractData(Json::objectValue); - contractData["interface"] = jsonCompactPrint(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); @@ -281,7 +275,7 @@ string compile(StringMap const& _sources, bool _optimize, CStyleReadFileCallback try { - return jsonCompactPrint(output); + return dev::jsonCompactPrint(output); } catch (...) { @@ -299,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 jsonCompactPrint(output); + return dev::jsonCompactPrint(output); } else { |