mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Adjustments after rebase
This commit is contained in:
parent
d6ab70c27d
commit
1bfc766139
@ -98,7 +98,7 @@ bool FunctionCallGraphBuilder::visit(Identifier const& _identifier)
|
|||||||
// For events kind() == Event, so we have an extra check here
|
// For events kind() == Event, so we have an extra check here
|
||||||
if (funType && funType->kind() == FunctionType::Kind::Internal)
|
if (funType && funType->kind() == FunctionType::Kind::Internal)
|
||||||
{
|
{
|
||||||
processFunction(callable->resolveVirtual(*m_contract), _identifier.annotation());
|
processFunction(callable->resolveVirtual(*m_contract), _identifier.annotation().calledDirectly);
|
||||||
|
|
||||||
solAssert(m_currentNode.has_value(), "");
|
solAssert(m_currentNode.has_value(), "");
|
||||||
}
|
}
|
||||||
@ -125,19 +125,37 @@ void FunctionCallGraphBuilder::endVisit(MemberAccess const& _memberAccess)
|
|||||||
// Super functions
|
// Super functions
|
||||||
if (*_memberAccess.annotation().requiredLookup == VirtualLookup::Super)
|
if (*_memberAccess.annotation().requiredLookup == VirtualLookup::Super)
|
||||||
{
|
{
|
||||||
if (ContractType const* type = dynamic_cast<ContractType const*>(_memberAccess.expression().annotation().type))
|
if (auto const* typeType = dynamic_cast<TypeType const*>(_memberAccess.expression().annotation().type))
|
||||||
{
|
if (auto const contractType = dynamic_cast<ContractType const*>(typeType->actualType()))
|
||||||
solAssert(type->isSuper(), "");
|
{
|
||||||
functionDef = &functionDef->resolveVirtual(*m_contract, type->contractDefinition().superContract(*m_contract));
|
solAssert(contractType->isSuper(), "");
|
||||||
}
|
functionDef =
|
||||||
|
&functionDef->resolveVirtual(
|
||||||
|
*m_contract,
|
||||||
|
contractType->contractDefinition().superContract(*m_contract)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
solAssert(*_memberAccess.annotation().requiredLookup == VirtualLookup::Static, "");
|
solAssert(*_memberAccess.annotation().requiredLookup == VirtualLookup::Static, "");
|
||||||
|
|
||||||
processFunction(*functionDef, _memberAccess.annotation());
|
processFunction(*functionDef, _memberAccess.annotation().calledDirectly);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FunctionCallGraphBuilder::endVisit(ModifierInvocation const& _modifierInvocation)
|
||||||
|
{
|
||||||
|
if (auto const* modifier = dynamic_cast<ModifierDefinition const*>(_modifierInvocation.name().annotation().referencedDeclaration))
|
||||||
|
{
|
||||||
|
if (*_modifierInvocation.name().annotation().requiredLookup == VirtualLookup::Virtual)
|
||||||
|
modifier = &modifier->resolveVirtual(*m_contract);
|
||||||
|
else
|
||||||
|
solAssert(*_modifierInvocation.name().annotation().requiredLookup == VirtualLookup::Static, "");
|
||||||
|
|
||||||
|
processFunction(*modifier);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void FunctionCallGraphBuilder::visitCallable(CallableDeclaration const* _callable, bool _directCall)
|
void FunctionCallGraphBuilder::visitCallable(CallableDeclaration const* _callable, bool _directCall)
|
||||||
{
|
{
|
||||||
solAssert(!m_graph->edges.count(_callable), "");
|
solAssert(!m_graph->edges.count(_callable), "");
|
||||||
@ -175,13 +193,13 @@ bool FunctionCallGraphBuilder::add(Node _caller, Node _callee)
|
|||||||
return m_graph->edges[_caller].insert(_callee).second;
|
return m_graph->edges[_caller].insert(_callee).second;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FunctionCallGraphBuilder::processFunction(CallableDeclaration const& _callable, ExpressionAnnotation const& _annotation)
|
void FunctionCallGraphBuilder::processFunction(CallableDeclaration const& _callable, bool _calledDirectly)
|
||||||
{
|
{
|
||||||
if (m_graph->edges.count(&_callable))
|
if (m_graph->edges.count(&_callable))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Create edge to creation dispatch
|
// Create edge to creation dispatch
|
||||||
if (!_annotation.calledDirectly)
|
if (!_calledDirectly)
|
||||||
add(m_currentDispatch, &_callable);
|
add(m_currentDispatch, &_callable);
|
||||||
visitCallable(&_callable, _annotation.calledDirectly);
|
visitCallable(&_callable, _calledDirectly);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -81,12 +81,13 @@ private:
|
|||||||
bool visit(Identifier const& _identifier) override;
|
bool visit(Identifier const& _identifier) override;
|
||||||
bool visit(NewExpression const& _newExpression) override;
|
bool visit(NewExpression const& _newExpression) override;
|
||||||
void endVisit(MemberAccess const& _memberAccess) override;
|
void endVisit(MemberAccess const& _memberAccess) override;
|
||||||
|
void endVisit(ModifierInvocation const& _modifierInvocation) override;
|
||||||
|
|
||||||
void visitCallable(CallableDeclaration const* _callable, bool _directCall = true);
|
void visitCallable(CallableDeclaration const* _callable, bool _directCall = true);
|
||||||
void visitConstructor(ContractDefinition const& _contract);
|
void visitConstructor(ContractDefinition const& _contract);
|
||||||
|
|
||||||
bool add(Node _caller, Node _callee);
|
bool add(Node _caller, Node _callee);
|
||||||
void processFunction(CallableDeclaration const& _callable, ExpressionAnnotation const& _annotation);
|
void processFunction(CallableDeclaration const& _callable, bool _calledDirectly = true);
|
||||||
|
|
||||||
ContractDefinition const* m_contract = nullptr;
|
ContractDefinition const* m_contract = nullptr;
|
||||||
std::optional<Node> m_currentNode;
|
std::optional<Node> m_currentNode;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user