diff options
author | Christian <c@ethdev.com> | 2015-01-20 06:08:48 +0800 |
---|---|---|
committer | Christian <c@ethdev.com> | 2015-01-20 06:35:04 +0800 |
commit | ddf5e20d100535c10315d0ae73ba4ed753ef3397 (patch) | |
tree | 2d2e5bc26cacc78c98677f4fa3e3b3f9df7835db /CallGraph.cpp | |
parent | af92f98d86ba1e15e3f41ac49bb9639be1ab4e41 (diff) | |
download | dexon-solidity-ddf5e20d100535c10315d0ae73ba4ed753ef3397.tar.gz dexon-solidity-ddf5e20d100535c10315d0ae73ba4ed753ef3397.tar.zst dexon-solidity-ddf5e20d100535c10315d0ae73ba4ed753ef3397.zip |
Call constructors of base classes.
Diffstat (limited to 'CallGraph.cpp')
-rw-r--r-- | CallGraph.cpp | 44 |
1 files changed, 38 insertions, 6 deletions
diff --git a/CallGraph.cpp b/CallGraph.cpp index b30afb61..88d874f3 100644 --- a/CallGraph.cpp +++ b/CallGraph.cpp @@ -31,13 +31,9 @@ namespace dev namespace solidity { -void CallGraph::addFunction(FunctionDefinition const& _function) +void CallGraph::addNode(ASTNode const& _node) { - if (!m_functionsSeen.count(&_function)) - { - m_functionsSeen.insert(&_function); - m_workQueue.push(&_function); - } + _node.accept(*this); } set<FunctionDefinition const*> const& CallGraph::getCalls() @@ -63,5 +59,41 @@ bool CallGraph::visit(Identifier const& _identifier) return true; } +bool CallGraph::visit(FunctionDefinition const& _function) +{ + addFunction(_function); + return true; +} + +bool CallGraph::visit(MemberAccess const& _memberAccess) +{ + // used for "BaseContract.baseContractFunction" + if (_memberAccess.getExpression().getType()->getCategory() == Type::Category::TYPE) + { + TypeType const& type = dynamic_cast<TypeType const&>(*_memberAccess.getExpression().getType()); + if (type.getMembers().getMemberType(_memberAccess.getMemberName())) + { + ContractDefinition const& contract = dynamic_cast<ContractType const&>(*type.getActualType()) + .getContractDefinition(); + for (ASTPointer<FunctionDefinition> const& function: contract.getDefinedFunctions()) + if (function->getName() == _memberAccess.getMemberName()) + { + addFunction(*function); + return true; + } + } + } + return true; +} + +void CallGraph::addFunction(FunctionDefinition const& _function) +{ + if (!m_functionsSeen.count(&_function)) + { + m_functionsSeen.insert(&_function); + m_workQueue.push(&_function); + } +} + } } |