From 8c9e57fadf35711fd18ba2a129c0690d2a09cc03 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Thu, 9 Feb 2017 14:55:57 +0000 Subject: Add --standard-json to solc --- solc/CommandLineInterface.cpp | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'solc') diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index 76102b53..a622fcfe 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -103,6 +104,7 @@ static string const g_strVersion = "version"; static string const g_stdinFileNameStr = ""; static string const g_strMetadataLiteral = "metadata-literal"; static string const g_strAllowPaths = "allow-paths"; +static string const g_strStandardJSON = "standard-json"; static string const g_argAbi = g_strAbi; static string const g_argAddStandard = g_strAddStandard; @@ -133,6 +135,7 @@ static string const g_argVersion = g_strVersion; static string const g_stdinFileName = g_stdinFileNameStr; static string const g_argMetadataLiteral = g_strMetadataLiteral; static string const g_argAllowPaths = g_strAllowPaths; +static string const g_argStandardJSON = g_strStandardJSON; /// Possible arguments to for --combined-json static set const g_combinedJsonArgs{ @@ -526,6 +529,11 @@ Allowed options)", "Output a single json document containing the specified information." ) (g_argGas.c_str(), "Print an estimate of the maximal gas usage for each function.") + ( + g_argStandardJSON.c_str(), + "Switch to Standard JSON input / output mode, ignoring all options." + "It reads from standard input and provides the result on the standard output." + ) ( g_argAssemble.c_str(), "Switch to assembly mode, ignoring all options and assumes input is assembly." @@ -615,6 +623,20 @@ bool CommandLineInterface::processInput() m_allowedDirectories.push_back(boost::filesystem::path(path)); } + if (m_args.count(g_argStandardJSON)) + { + string input; + while (!cin.eof()) + { + string tmp; + getline(cin, tmp); + input.append(tmp + "\n"); + } + StandardCompiler compiler; + cout << compiler.compile(input) << endl; + return true; + } + readInputFilesAndConfigureRemappings(); if (m_args.count(g_argLibraries)) @@ -882,7 +904,9 @@ void CommandLineInterface::handleAst(string const& _argStr) bool CommandLineInterface::actOnInput() { - if (m_onlyAssemble) + if (m_args.count(g_argStandardJSON)) + return true; + else if (m_onlyAssemble) outputAssembly(); else if (m_onlyLink) writeLinkedFiles(); -- cgit