diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2017-02-09 22:55:57 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2017-04-21 02:38:00 +0800 |
commit | 8c9e57fadf35711fd18ba2a129c0690d2a09cc03 (patch) | |
tree | 706a77f1141a35064fc544e28d69ba83e0f7f524 /solc/CommandLineInterface.cpp | |
parent | 965de29772963b640b00579fa8225bb662599ecd (diff) | |
download | dexon-solidity-8c9e57fadf35711fd18ba2a129c0690d2a09cc03.tar.gz dexon-solidity-8c9e57fadf35711fd18ba2a129c0690d2a09cc03.tar.zst dexon-solidity-8c9e57fadf35711fd18ba2a129c0690d2a09cc03.zip |
Add --standard-json to solc
Diffstat (limited to 'solc/CommandLineInterface.cpp')
-rw-r--r-- | solc/CommandLineInterface.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
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 <libsolidity/analysis/NameAndTypeResolver.h> #include <libsolidity/interface/Exceptions.h> #include <libsolidity/interface/CompilerStack.h> +#include <libsolidity/interface/StandardCompiler.h> #include <libsolidity/interface/SourceReferenceFormatter.h> #include <libsolidity/interface/GasEstimator.h> #include <libsolidity/formal/Why3Translator.h> @@ -103,6 +104,7 @@ static string const g_strVersion = "version"; static string const g_stdinFileNameStr = "<stdin>"; 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<string> const g_combinedJsonArgs{ @@ -527,6 +530,11 @@ Allowed options)", ) (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(); |