aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/interface
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2018-09-24 18:48:25 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2018-09-26 23:51:08 +0800
commit384a65f660b5eb030e9f4fd2c5edf144b1de4964 (patch)
tree331ef88f22077d87d067e158cc520fc270817e4c /libsolidity/interface
parent2c860b7d7403fdec27442b617e9d01e610d06502 (diff)
downloaddexon-solidity-384a65f660b5eb030e9f4fd2c5edf144b1de4964.tar.gz
dexon-solidity-384a65f660b5eb030e9f4fd2c5edf144b1de4964.tar.zst
dexon-solidity-384a65f660b5eb030e9f4fd2c5edf144b1de4964.zip
Be more strict about values in the optimizer block in StandardJSON
Diffstat (limited to 'libsolidity/interface')
-rw-r--r--libsolidity/interface/StandardCompiler.cpp23
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));