aboutsummaryrefslogtreecommitdiffstats
path: root/CallGraph.cpp
diff options
context:
space:
mode:
authorChristian <c@ethdev.com>2015-01-20 06:08:48 +0800
committerChristian <c@ethdev.com>2015-01-20 06:35:04 +0800
commitddf5e20d100535c10315d0ae73ba4ed753ef3397 (patch)
tree2d2e5bc26cacc78c98677f4fa3e3b3f9df7835db /CallGraph.cpp
parentaf92f98d86ba1e15e3f41ac49bb9639be1ab4e41 (diff)
downloaddexon-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.cpp44
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);
+ }
+}
+
}
}