diff options
author | chriseth <c@ethdev.com> | 2016-07-01 16:14:50 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2016-07-21 01:45:43 +0800 |
commit | c55584d3e2da49674993972a129ef478ba6b4914 (patch) | |
tree | 419a4abda107edef1ed3df15398b6030b43bd1a8 /solc/jsonCompiler.cpp | |
parent | 980abfe52aac3161dc4f25574da83bfc6be977bf (diff) | |
download | dexon-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.cpp | 15 |
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); |