diff --git a/libevmasm/Assembly.cpp b/libevmasm/Assembly.cpp index 990c00a75..852f0e446 100644 --- a/libevmasm/Assembly.cpp +++ b/libevmasm/Assembly.cpp @@ -109,16 +109,14 @@ AssemblyItem Assembly::createAssemblyItemFromJSON(Json::Value const& _json) std::string name = getOrDefault(_json, "name", ""); solAssert(!name.empty()); - int begin = get(_json, "begin"); - int end = get(_json, "end"); + SourceLocation location; + location.start = get(_json, "begin"); + location.end = get(_json, "end"); int srcIndex = get(_json, "source"); size_t modifierDepth = static_cast(getOrDefault(_json, "modifierDepth", 0)); std::string value = getOrDefault(_json, "value", ""); std::string jumpType = getOrDefault(_json, "jumpType", ""); - SourceLocation location; - location.start = begin; - location.end = end; auto updateUsedTags = [&](u256 const& data) { m_usedTags = max(m_usedTags, static_cast(data) + 1); @@ -142,10 +140,9 @@ AssemblyItem Assembly::createAssemblyItemFromJSON(Json::Value const& _json) AssemblyItem result(0); - if (c_instructions.find(name) != c_instructions.end()) + if (c_instructions.count(name)) { AssemblyItem item{c_instructions.at(name), location}; - item.m_modifierDepth = modifierDepth; if (!jumpType.empty()) item.setJumpType(jumpType); result = item; @@ -154,42 +151,42 @@ AssemblyItem Assembly::createAssemblyItemFromJSON(Json::Value const& _json) { if (name == "PUSH") { - AssemblyItem item{AssemblyItemType::Push, u256("0x" + value), location}; + AssemblyItem item{AssemblyItemType::Push, u256("0x" + value)}; if (!jumpType.empty()) item.setJumpType(jumpType); result = item; } else if (name == "PUSH [ErrorTag]") - result = {AssemblyItemType::PushTag, 0, location}; + result = {AssemblyItemType::PushTag, 0}; else if (name == "PUSH [tag]") - result = {AssemblyItemType::PushTag, updateUsedTags(u256(value)), location}; + result = {AssemblyItemType::PushTag, updateUsedTags(u256(value))}; else if (name == "PUSH [$]") - result = {AssemblyItemType::PushSub, u256("0x" + value), location}; + result = {AssemblyItemType::PushSub, u256("0x" + value)}; else if (name == "PUSH #[$]") - result = {AssemblyItemType::PushSubSize, u256("0x" + value), location}; + result = {AssemblyItemType::PushSubSize, u256("0x" + value)}; else if (name == "PUSHSIZE") - result = {AssemblyItemType::PushProgramSize, 0, location}; + result = {AssemblyItemType::PushProgramSize, 0}; else if (name == "PUSHLIB") - result = {AssemblyItemType::PushLibraryAddress, libraryHash(value), location}; + result = {AssemblyItemType::PushLibraryAddress, libraryHash(value)}; else if (name == "PUSHDEPLOYADDRESS") - result = {AssemblyItemType::PushDeployTimeAddress, 0, location}; + result = {AssemblyItemType::PushDeployTimeAddress, 0}; else if (name == "PUSHIMMUTABLE") - result = {AssemblyItemType::PushImmutable, immutableHash(value), location}; + result = {AssemblyItemType::PushImmutable, immutableHash(value)}; else if (name == "ASSIGNIMMUTABLE") - result = {AssemblyItemType::AssignImmutable, immutableHash(value), location}; + result = {AssemblyItemType::AssignImmutable, immutableHash(value)}; else if (name == "tag") - result = {AssemblyItemType::Tag, updateUsedTags(u256(value)), location}; + result = {AssemblyItemType::Tag, updateUsedTags(u256(value))}; else if (name == "PUSH data") - result = {AssemblyItemType::PushData, u256("0x" + value), location}; + result = {AssemblyItemType::PushData, u256("0x" + value)}; else if (name == "VERBATIM") { AssemblyItem item(fromHex(value), 0, 0); - item.setLocation(location); result = item; } else assertThrow(false, InvalidOpcode, ""); } + result.setLocation(location); result.m_modifierDepth = modifierDepth; return result; } diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index 493607027..7539436a3 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -242,6 +242,7 @@ void CompilerStack::setLibraries(std::map const& _libra void CompilerStack::setOptimiserSettings(bool _optimize, size_t _runs) { OptimiserSettings settings = _optimize ? OptimiserSettings::standard() : OptimiserSettings::minimal(); + settings.enabled = _optimize; settings.expectedExecutionsPerDeployment = _runs; setOptimiserSettings(std::move(settings)); } diff --git a/solc/CommandLineParser.cpp b/solc/CommandLineParser.cpp index bab8b0161..db3be10e7 100644 --- a/solc/CommandLineParser.cpp +++ b/solc/CommandLineParser.cpp @@ -279,8 +279,6 @@ OptimiserSettings CommandLineOptions::optimiserSettings() const solAssert(settings.yulOptimiserCleanupSteps == OptimiserSettings::DefaultYulOptimiserCleanupSteps); } - settings.enabled = optimizer.enabled; - return settings; }