aboutsummaryrefslogtreecommitdiffstats
path: root/solc/jsonCompiler.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/jsonCompiler.cpp
parent980abfe52aac3161dc4f25574da83bfc6be977bf (diff)
downloaddexon-solidity-c55584d3e2da49674993972a129ef478ba6b4914.tar.gz
dexon-solidity-c55584d3e2da49674993972a129ef478ba6b4914.tar.zst
dexon-solidity-c55584d3e2da49674993972a129ef478ba6b4914.zip
Source location as part of AST.
Diffstat (limited to 'solc/jsonCompiler.cpp')
-rw-r--r--solc/jsonCompiler.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/solc/jsonCompiler.cpp b/solc/jsonCompiler.cpp
index bc1305c5..8fc42d73 100644
--- a/solc/jsonCompiler.cpp
+++ b/solc/jsonCompiler.cpp
@@ -214,6 +214,10 @@ string compile(StringMap const& _sources, bool _optimize, CStyleReadFileCallback
contractData["opcodes"] = solidity::disassemble(compiler.object(contractName).bytecode);
contractData["functionHashes"] = functionHashes(compiler.contractDefinition(contractName));
contractData["gasEstimates"] = estimateGas(compiler, contractName);
+ auto sourceMap = compiler.sourceMapping(contractName);
+ contractData["srcmap"] = sourceMap ? *sourceMap : "";
+ auto runtimeSourceMap = compiler.sourceMapping(contractName);
+ contractData["srcmap-runtime"] = runtimeSourceMap ? *runtimeSourceMap : "";
ostringstream unused;
contractData["assembly"] = compiler.streamAssembly(unused, contractName, _sources, true);
output["contracts"][contractName] = contractData;
@@ -235,12 +239,13 @@ string compile(StringMap const& _sources, bool _optimize, CStyleReadFileCallback
output["formal"]["errors"] = errors;
}
+ // Indices into this array are used to abbreviate source names in source locations.
+ output["sourceList"] = Json::Value(Json::arrayValue);
+ for (auto const& source: compiler.sourceNames())
+ output["sourceList"].append(source);
output["sources"] = Json::Value(Json::objectValue);
- for (auto const& source: _sources)
- {
- output["sources"][source.first] = Json::Value(Json::objectValue);
- output["sources"][source.first]["AST"] = ASTJsonConverter(compiler.ast(source.first)).json();
- }
+ for (auto const& source: compiler.sourceNames())
+ output["sources"][source]["AST"] = ASTJsonConverter(compiler.ast(source), compiler.sourceIndices()).json();
}
return Json::FastWriter().write(output);