aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-09-30 02:05:39 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-10-05 03:30:14 +0800
commita0394a1bfadb93b1f697b43bf52750bbff02af37 (patch)
tree0b9b5af1f6099d6041f70fff28fed0bd751be01f /libsolidity
parentf96e932243273050fcf2bd4ba89d80412252a9d9 (diff)
downloaddexon-solidity-a0394a1bfadb93b1f697b43bf52750bbff02af37.tar.gz
dexon-solidity-a0394a1bfadb93b1f697b43bf52750bbff02af37.tar.zst
dexon-solidity-a0394a1bfadb93b1f697b43bf52750bbff02af37.zip
Restrict contracts compiled via outputSelection (but not the individual output details)
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/interface/StandardCompiler.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/libsolidity/interface/StandardCompiler.cpp b/libsolidity/interface/StandardCompiler.cpp
index b4fbbef9..430739ac 100644
--- a/libsolidity/interface/StandardCompiler.cpp
+++ b/libsolidity/interface/StandardCompiler.cpp
@@ -92,6 +92,22 @@ Json::Value formatErrorWithException(
return formatError(_warning, _type, _component, message, formattedMessage, location);
}
+set<string> requestedContractNames(Json::Value const& _outputSelection)
+{
+ set<string> names;
+ for (auto const& sourceName: _outputSelection.getMemberNames())
+ {
+ for (auto const& contractName: _outputSelection[sourceName].getMemberNames())
+ {
+ /// Consider the "all sources" shortcuts as requesting everything.
+ if (contractName == "*" || contractName == "")
+ return set<string>();
+ names.insert((sourceName == "*" ? "" : sourceName) + ":" + contractName);
+ }
+ }
+ return names;
+}
+
/// Returns true iff @a _hash (hex with 0x prefix) is the Keccak256 hash of the binary data in @a _content.
bool hashMatchesContent(string const& _hash, string const& _content)
{
@@ -265,6 +281,9 @@ Json::Value StandardCompiler::compileInternal(Json::Value const& _input)
Json::Value metadataSettings = settings.get("metadata", Json::Value());
m_compilerStack.useMetadataLiteralSources(metadataSettings.get("useLiteralContent", Json::Value(false)).asBool());
+ Json::Value outputSelection = settings.get("outputSelection", Json::Value());
+ m_compilerStack.setRequestedContractNames(requestedContractNames(outputSelection));
+
auto scannerFromSourceName = [&](string const& _sourceName) -> solidity::Scanner const& { return m_compilerStack.scanner(_sourceName); };
try