| 49 | } |
| 50 | |
| 51 | bool 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 | |
| 72 | VariableDeclaration const* rootConstVariableDeclaration(VariableDeclaration const& _varDecl) |
| 73 | { |
no test coverage detected