diff options
author | chriseth <chris@ethereum.org> | 2018-09-27 04:31:27 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-27 04:31:27 +0800 |
commit | f81c6e6d164d282f49d0c7d44729946b7da12181 (patch) | |
tree | 7600c1d2445b7125c0bfdc1ae67d7a37e0ac202b /libsolidity/interface | |
parent | 2a392aa8f9cdc8e01951360d9265b7ef4c5ccf4f (diff) | |
parent | 384a65f660b5eb030e9f4fd2c5edf144b1de4964 (diff) | |
download | dexon-solidity-f81c6e6d164d282f49d0c7d44729946b7da12181.tar dexon-solidity-f81c6e6d164d282f49d0c7d44729946b7da12181.tar.gz dexon-solidity-f81c6e6d164d282f49d0c7d44729946b7da12181.tar.bz2 dexon-solidity-f81c6e6d164d282f49d0c7d44729946b7da12181.tar.lz dexon-solidity-f81c6e6d164d282f49d0c7d44729946b7da12181.tar.xz dexon-solidity-f81c6e6d164d282f49d0c7d44729946b7da12181.tar.zst dexon-solidity-f81c6e6d164d282f49d0c7d44729946b7da12181.zip |
Merge pull request #5099 from ethereum/standard-json-optimiser
Be more strict about values in the optimizer block in StandardJSON
Diffstat (limited to 'libsolidity/interface')
-rw-r--r-- | libsolidity/interface/StandardCompiler.cpp | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/libsolidity/interface/StandardCompiler.cpp b/libsolidity/interface/StandardCompiler.cpp index e7b1553f..2305da13 100644 --- a/libsolidity/interface/StandardCompiler.cpp +++ b/libsolidity/interface/StandardCompiler.cpp @@ -342,10 +342,25 @@ Json::Value StandardCompiler::compileInternal(Json::Value const& _input) } m_compilerStack.setRemappings(remappings); - Json::Value optimizerSettings = settings.get("optimizer", Json::Value()); - bool const optimize = optimizerSettings.get("enabled", Json::Value(false)).asBool(); - unsigned const optimizeRuns = optimizerSettings.get("runs", Json::Value(200u)).asUInt(); - m_compilerStack.setOptimiserSettings(optimize, optimizeRuns); + if (settings.isMember("optimizer")) + { + Json::Value optimizerSettings = settings["optimizer"]; + if (optimizerSettings.isMember("enabled")) + { + if (!optimizerSettings["enabled"].isBool()) + return formatFatalError("JSONError", "The \"enabled\" setting must be a boolean."); + + bool const optimize = optimizerSettings["enabled"].asBool(); + unsigned optimizeRuns = 200; + if (optimizerSettings.isMember("runs")) + { + if (!optimizerSettings["runs"].isUInt()) + return formatFatalError("JSONError", "The \"runs\" setting must be an unsigned number."); + optimizeRuns = optimizerSettings["runs"].asUInt(); + } + m_compilerStack.setOptimiserSettings(optimize, optimizeRuns); + } + } map<string, h160> libraries; Json::Value jsonLibraries = settings.get("libraries", Json::Value(Json::objectValue)); |