MCPcopy Create free account
hub / github.com/argotorg/solidity / isConstantVariableRecursive

Function isConstantVariableRecursive

libsolidity/ast/ASTUtils.cpp:51–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49}
50
51bool isConstantVariableRecursive(VariableDeclaration const& _varDecl)
52{
53 solAssert(_varDecl.isConstant(), "Constant variable expected");
54
55 auto visitor = [](VariableDeclaration const& _variable, util::CycleDetector<VariableDeclaration>& _cycleDetector, size_t _depth)
56 {
57 solAssert(_depth < 256, "Recursion depth limit reached");
58 if (!_variable.value())
59 // This should result in an error later on.
60 return;
61
62 if (auto referencedVarDecl = dynamic_cast<VariableDeclaration const*>(
63 ASTNode::referencedDeclaration(*_variable.value()))
64 )
65 if (referencedVarDecl->isConstant())
66 _cycleDetector.run(*referencedVarDecl);
67 };
68
69 return util::CycleDetector<VariableDeclaration>(visitor).run(_varDecl) != nullptr;
70}
71
72VariableDeclaration const* rootConstVariableDeclaration(VariableDeclaration const& _varDecl)
73{

Callers 2

visitMethod · 0.85

Calls 4

referencedDeclarationFunction · 0.85
isConstantMethod · 0.45
valueMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected