aboutsummaryrefslogtreecommitdiffstats
path: root/solc/CommandLineInterface.cpp
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2016-07-01 16:14:50 +0800
committerchriseth <c@ethdev.com>2016-07-21 01:45:43 +0800
commitc55584d3e2da49674993972a129ef478ba6b4914 (patch)
tree419a4abda107edef1ed3df15398b6030b43bd1a8 /solc/CommandLineInterface.cpp
parent980abfe52aac3161dc4f25574da83bfc6be977bf (diff)
downloaddexon-solidity-c55584d3e2da49674993972a129ef478ba6b4914.tar
dexon-solidity-c55584d3e2da49674993972a129ef478ba6b4914.tar.gz
dexon-solidity-c55584d3e2da49674993972a129ef478ba6b4914.tar.bz2
dexon-solidity-c55584d3e2da49674993972a129ef478ba6b4914.tar.lz
dexon-solidity-c55584d3e2da49674993972a129ef478ba6b4914.tar.xz
dexon-solidity-c55584d3e2da49674993972a129ef478ba6b4914.tar.zst
dexon-solidity-c55584d3e2da49674993972a129ef478ba6b4914.zip
Source location as part of AST.
Diffstat (limited to 'solc/CommandLineInterface.cpp')
-rw-r--r--solc/CommandLineInterface.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp
index 09c7c8e8..ac8db160 100644
--- a/solc/CommandLineInterface.cpp
+++ b/solc/CommandLineInterface.cpp
@@ -86,6 +86,8 @@ static set<string> const g_combinedJsonArgs{
"bin",
"bin-runtime",
"clone-bin",
+ "srcmap",
+ "srcmap-runtime",
"opcodes",
"abi",
"interface",
@@ -658,6 +660,16 @@ void CommandLineInterface::handleCombinedJSON()
ostringstream unused;
contractData["asm"] = m_compiler->streamAssembly(unused, contractName, m_sourceCodes, true);
}
+ if (requests.count("srcmap"))
+ {
+ auto map = m_compiler->sourceMapping(contractName);
+ contractData["srcmap"] = map ? *map : "";
+ }
+ if (requests.count("srcmap-runtime"))
+ {
+ auto map = m_compiler->runtimeSourceMapping(contractName);
+ contractData["srcmap"] = map ? *map : "";
+ }
if (requests.count("devdoc"))
contractData["devdoc"] = m_compiler->metadata(contractName, DocumentationType::NatspecDev);
if (requests.count("userdoc"))
@@ -665,12 +677,22 @@ void CommandLineInterface::handleCombinedJSON()
output["contracts"][contractName] = contractData;
}
+ bool needsSourceList = requests.count("ast") || requests.count("srcmap") || requests.count("srcmap-runtime");
+ if (needsSourceList)
+ {
+ // Indices into this array are used to abbreviate source names in source locations.
+ output["sourceList"] = Json::Value(Json::arrayValue);
+
+ for (auto const& source: m_compiler->sourceNames())
+ output["sourceList"].append(source);
+ }
+
if (requests.count("ast"))
{
output["sources"] = Json::Value(Json::objectValue);
for (auto const& sourceCode: m_sourceCodes)
{
- ASTJsonConverter converter(m_compiler->ast(sourceCode.first));
+ ASTJsonConverter converter(m_compiler->ast(sourceCode.first), m_compiler->sourceIndices());
output["sources"][sourceCode.first] = Json::Value(Json::objectValue);
output["sources"][sourceCode.first]["AST"] = converter.json();
}