aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-05-29 20:24:55 +0800
committerGitHub <noreply@github.com>2017-05-29 20:24:55 +0800
commit002df12d13fb423be641878a20b73bd10f90a6df (patch)
treeab296de4cf368e64d4772aa36a616ab3b303747f
parent2c4a107f431735a41444c5965f191f93fefb263e (diff)
parent1131c5035f37e3b4821dedb207e8d6acb5967a0d (diff)
downloaddexon-solidity-002df12d13fb423be641878a20b73bd10f90a6df.tar.gz
dexon-solidity-002df12d13fb423be641878a20b73bd10f90a6df.tar.zst
dexon-solidity-002df12d13fb423be641878a20b73bd10f90a6df.zip
Merge pull request #2287 from ethereum/legacyAstCLI
add legacy/compact AST-format options to CLI
-rw-r--r--docs/using-the-compiler.rst2
-rw-r--r--solc/CommandLineInterface.cpp36
2 files changed, 24 insertions, 14 deletions
diff --git a/docs/using-the-compiler.rst b/docs/using-the-compiler.rst
index 7aa997f8..7f82df70 100644
--- a/docs/using-the-compiler.rst
+++ b/docs/using-the-compiler.rst
@@ -119,7 +119,7 @@ Input Description
//
// The available output types are as follows:
// abi - ABI
- // ast - AST of all source files (not supported atm)
+ // ast - AST of all source files
// legacyAST - legacy AST of all source files
// devdoc - Developer documentation (natspec)
// userdoc - User documentation (natspec)
diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp
index c14a46e8..b2e257ee 100644
--- a/solc/CommandLineInterface.cpp
+++ b/solc/CommandLineInterface.cpp
@@ -69,17 +69,21 @@ namespace dev
namespace solidity
{
+static string const g_stdinFileNameStr = "<stdin>";
static string const g_strAbi = "abi";
static string const g_strAddStandard = "add-std";
+static string const g_strAllowPaths = "allow-paths";
static string const g_strAsm = "asm";
static string const g_strAsmJson = "asm-json";
static string const g_strAssemble = "assemble";
static string const g_strAst = "ast";
static string const g_strAstJson = "ast-json";
+static string const g_strAstCompactJson = "ast-compact-json";
static string const g_strBinary = "bin";
static string const g_strBinaryRuntime = "bin-runtime";
static string const g_strCloneBinary = "clone-bin";
static string const g_strCombinedJson = "combined-json";
+static string const g_strCompactJSON = "compact-format";
static string const g_strContracts = "contracts";
static string const g_strEVM = "evm";
static string const g_strEVM15 = "evm15";
@@ -93,6 +97,7 @@ static string const g_strJulia = "julia";
static string const g_strLibraries = "libraries";
static string const g_strLink = "link";
static string const g_strMetadata = "metadata";
+static string const g_strMetadataLiteral = "metadata-literal";
static string const g_strNatspecDev = "devdoc";
static string const g_strNatspecUser = "userdoc";
static string const g_strOpcodes = "opcodes";
@@ -105,23 +110,23 @@ static string const g_strSources = "sources";
static string const g_strSourceList = "sourceList";
static string const g_strSrcMap = "srcmap";
static string const g_strSrcMapRuntime = "srcmap-runtime";
-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_strVersion = "version";
static string const g_argAbi = g_strAbi;
static string const g_argAddStandard = g_strAddStandard;
+static string const g_argAllowPaths = g_strAllowPaths;
static string const g_argAsm = g_strAsm;
static string const g_argAsmJson = g_strAsmJson;
static string const g_argAssemble = g_strAssemble;
static string const g_argAst = g_strAst;
+static string const g_argAstCompactJson = g_strAstCompactJson;
static string const g_argAstJson = g_strAstJson;
static string const g_argBinary = g_strBinary;
static string const g_argBinaryRuntime = g_strBinaryRuntime;
static string const g_argCloneBinary = g_strCloneBinary;
static string const g_argCombinedJson = g_strCombinedJson;
+static string const g_argCompactJSON = g_strCompactJSON;
static string const g_argFormal = g_strFormal;
static string const g_argGas = g_strGas;
static string const g_argHelp = g_strHelp;
@@ -131,6 +136,7 @@ static string const g_argLibraries = g_strLibraries;
static string const g_argLink = g_strLink;
static string const g_argMachine = "machine";
static string const g_argMetadata = g_strMetadata;
+static string const g_argMetadataLiteral = g_strMetadataLiteral;
static string const g_argNatspecDev = g_strNatspecDev;
static string const g_argNatspecUser = g_strNatspecUser;
static string const g_argOpcodes = g_strOpcodes;
@@ -138,20 +144,20 @@ static string const g_argOptimize = g_strOptimize;
static string const g_argOptimizeRuns = g_strOptimizeRuns;
static string const g_argOutputDir = g_strOutputDir;
static string const g_argSignatureHashes = g_strSignatureHashes;
+static string const g_argStandardJSON = g_strStandardJSON;
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{
+static set<string> const g_combinedJsonArgs
+{
g_strAbi,
g_strAsm,
g_strAst,
g_strBinary,
g_strBinaryRuntime,
g_strCloneBinary,
+ g_strCompactJSON,
g_strInterface,
g_strMetadata,
g_strNatspecUser,
@@ -580,6 +586,7 @@ Allowed options)",
outputComponents.add_options()
(g_argAst.c_str(), "AST of all source files.")
(g_argAstJson.c_str(), "AST of all source files in JSON format.")
+ (g_argAstCompactJson.c_str(), "AST of all source files in a compact JSON format.")
(g_argAsm.c_str(), "EVM assembly of the contracts.")
(g_argAsmJson.c_str(), "EVM assembly of the contracts in JSON format.")
(g_argOpcodes.c_str(), "Opcodes of the contracts.")
@@ -878,10 +885,11 @@ void CommandLineInterface::handleCombinedJSON()
if (requests.count(g_strAst))
{
+ bool legacyFormat = !requests.count(g_strCompactJSON);
output[g_strSources] = Json::Value(Json::objectValue);
for (auto const& sourceCode: m_sourceCodes)
{
- ASTJsonConverter converter(true, m_compiler->sourceIndices());
+ ASTJsonConverter converter(legacyFormat, m_compiler->sourceIndices());
output[g_strSources][sourceCode.first] = Json::Value(Json::objectValue);
output[g_strSources][sourceCode.first]["AST"] = converter.toJson(m_compiler->ast(sourceCode.first));
}
@@ -897,6 +905,8 @@ void CommandLineInterface::handleAst(string const& _argStr)
title = "Syntax trees:";
else if (_argStr == g_argAstJson)
title = "JSON AST:";
+ else if (_argStr == g_argAstCompactJson)
+ title = "JSON AST (compact format):";
else
BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Illegal argStr for AST"));
@@ -913,6 +923,7 @@ void CommandLineInterface::handleAst(string const& _argStr)
asts
);
+ bool legacyFormat = !m_args.count(g_argAstCompactJson);
if (m_args.count(g_argOutputDir))
{
for (auto const& sourceCode: m_sourceCodes)
@@ -926,7 +937,7 @@ void CommandLineInterface::handleAst(string const& _argStr)
}
else
{
- ASTJsonConverter(true).print(data, m_compiler->ast(sourceCode.first));
+ ASTJsonConverter(legacyFormat, m_compiler->sourceIndices()).print(data, m_compiler->ast(sourceCode.first));
postfix += "_json";
}
boost::filesystem::path path(sourceCode.first);
@@ -949,9 +960,7 @@ void CommandLineInterface::handleAst(string const& _argStr)
printer.print(cout);
}
else
- {
- ASTJsonConverter(true).print(cout, m_compiler->ast(sourceCode.first));
- }
+ ASTJsonConverter(legacyFormat, m_compiler->sourceIndices()).print(cout, m_compiler->ast(sourceCode.first));
}
}
}
@@ -1100,6 +1109,7 @@ void CommandLineInterface::outputCompilationResults()
// do we need AST output?
handleAst(g_argAst);
handleAst(g_argAstJson);
+ handleAst(g_argAstCompactJson);
vector<string> contracts = m_compiler->contractNames();
for (string const& contract: contracts)