aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/formal
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-11-24 06:57:17 +0800
committerchriseth <c@ethdev.com>2015-11-26 22:37:55 +0800
commitb47d5932528357939ee29758a8b8027c90bdb1e5 (patch)
treea32526db014b5a654e193660e883e97ab437aa95 /libsolidity/formal
parent86495dfc57dde9b825ffd8c219ea809446e978f9 (diff)
downloaddexon-solidity-b47d5932528357939ee29758a8b8027c90bdb1e5.tar.gz
dexon-solidity-b47d5932528357939ee29758a8b8027c90bdb1e5.tar.zst
dexon-solidity-b47d5932528357939ee29758a8b8027c90bdb1e5.zip
Do not store elements of a contract by AST node type.
Diffstat (limited to 'libsolidity/formal')
-rw-r--r--libsolidity/formal/Why3Translator.cpp15
-rw-r--r--libsolidity/formal/Why3Translator.h2
2 files changed, 6 insertions, 11 deletions
diff --git a/libsolidity/formal/Why3Translator.cpp b/libsolidity/formal/Why3Translator.cpp
index fe3729d4..5028e2c3 100644
--- a/libsolidity/formal/Why3Translator.cpp
+++ b/libsolidity/formal/Why3Translator.cpp
@@ -145,8 +145,8 @@ bool Why3Translator::visit(ContractDefinition const& _contract)
addLine("type state = {");
indent();
- m_stateVariables = &_contract.stateVariables();
- for (auto const& variable: _contract.stateVariables())
+ m_stateVariables = _contract.stateVariables();
+ for (VariableDeclaration const* variable: m_stateVariables)
{
string varType = toFormalType(*variable->annotation().type);
if (varType.empty())
@@ -174,7 +174,7 @@ bool Why3Translator::visit(ContractDefinition const& _contract)
void Why3Translator::endVisit(ContractDefinition const& _contract)
{
- m_stateVariables = nullptr;
+ m_stateVariables.clear();
addSourceFromDocStrings(_contract.annotation());
unindent();
addLine("end");
@@ -600,17 +600,12 @@ bool Why3Translator::visit(Literal const& _literal)
bool Why3Translator::isStateVariable(VariableDeclaration const* _var) const
{
- solAssert(!!m_stateVariables, "");
- for (auto const& var: *m_stateVariables)
- if (var.get() == _var)
- return true;
- return false;
+ return contains(m_stateVariables, _var);
}
bool Why3Translator::isStateVariable(string const& _name) const
{
- solAssert(!!m_stateVariables, "");
- for (auto const& var: *m_stateVariables)
+ for (auto const& var: m_stateVariables)
if (var->name() == _name)
return true;
return false;
diff --git a/libsolidity/formal/Why3Translator.h b/libsolidity/formal/Why3Translator.h
index e5c298b4..f4315a7a 100644
--- a/libsolidity/formal/Why3Translator.h
+++ b/libsolidity/formal/Why3Translator.h
@@ -117,7 +117,7 @@ private:
bool m_seenContract = false;
bool m_errorOccured = false;
- std::vector<ASTPointer<VariableDeclaration>> const* m_stateVariables = nullptr;
+ std::vector<VariableDeclaration const*> m_stateVariables;
std::map<std::string, VariableDeclaration const*> m_localVariables;
struct Line