diff options
author | chriseth <chris@ethereum.org> | 2017-05-02 20:25:37 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2017-05-03 17:26:21 +0800 |
commit | e0266b79f3709eb6314e883938bb969ba106beaa (patch) | |
tree | 162e72232dd647a4485b8f14c0303960b88e0f9f /libsolidity/analysis/StaticAnalyzer.cpp | |
parent | a6faa5acf324a127aad11b354e48d7bb2bcf0fbc (diff) | |
download | dexon-solidity-e0266b79f3709eb6314e883938bb969ba106beaa.tar dexon-solidity-e0266b79f3709eb6314e883938bb969ba106beaa.tar.gz dexon-solidity-e0266b79f3709eb6314e883938bb969ba106beaa.tar.bz2 dexon-solidity-e0266b79f3709eb6314e883938bb969ba106beaa.tar.lz dexon-solidity-e0266b79f3709eb6314e883938bb969ba106beaa.tar.xz dexon-solidity-e0266b79f3709eb6314e883938bb969ba106beaa.tar.zst dexon-solidity-e0266b79f3709eb6314e883938bb969ba106beaa.zip |
Refactor: Combine bool and function pointer.
Diffstat (limited to 'libsolidity/analysis/StaticAnalyzer.cpp')
-rw-r--r-- | libsolidity/analysis/StaticAnalyzer.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/libsolidity/analysis/StaticAnalyzer.cpp b/libsolidity/analysis/StaticAnalyzer.cpp index 21c97c3b..26e77283 100644 --- a/libsolidity/analysis/StaticAnalyzer.cpp +++ b/libsolidity/analysis/StaticAnalyzer.cpp @@ -49,8 +49,7 @@ void StaticAnalyzer::endVisit(ContractDefinition const&) bool StaticAnalyzer::visit(FunctionDefinition const& _function) { if (_function.isImplemented()) - m_inFunction = true; - m_currentFunction = &_function; + m_currentFunction = &_function; m_localVarUseCount.clear(); m_nonPayablePublic = _function.isPublic() && !_function.isPayable(); return true; @@ -58,7 +57,7 @@ bool StaticAnalyzer::visit(FunctionDefinition const& _function) void StaticAnalyzer::endVisit(FunctionDefinition const&) { - m_inFunction = false; + m_currentFunction = nullptr; m_nonPayablePublic = false; for (auto const& var: m_localVarUseCount) if (var.second == 0) @@ -67,7 +66,7 @@ void StaticAnalyzer::endVisit(FunctionDefinition const&) bool StaticAnalyzer::visit(Identifier const& _identifier) { - if (m_inFunction) + if (m_currentFunction) { if (auto var = dynamic_cast<VariableDeclaration const*>(_identifier.annotation().referencedDeclaration)) { @@ -81,7 +80,7 @@ bool StaticAnalyzer::visit(Identifier const& _identifier) bool StaticAnalyzer::visit(VariableDeclaration const& _variable) { - if (m_inFunction) + if (m_currentFunction) { solAssert(_variable.isLocalVariable(), ""); if (_variable.name() != "") @@ -101,9 +100,9 @@ bool StaticAnalyzer::visit(Return const& _return) { // If the return has an expression, it counts as // a "use" of the return parameters. - if (m_inFunction && _return.expression() != NULL) - for (auto const& var: m_currentFunction->returnParameterList()->parameters()) - if (var->name() != "") + if (m_currentFunction && _return.expression()) + for (auto const& var: m_currentFunction->returnParameters()) + if (!var->name().empty()) m_localVarUseCount[var.get()] += 1; return true; } |