Skip to content

Commit 441ab02

Browse files
feat: add expected_scope_depth
1 parent 439e862 commit 441ab02

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/utils.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,23 @@ function check_scope_depth(scope, depth)
639639
end
640640
end
641641

642+
"""
643+
$(TYPEDSIGNATURES)
644+
645+
Return the expected depth of the given `SymScope` from the root system.
646+
"""
647+
function expected_scope_depth(scope)
648+
if scope isa LocalScope
649+
return 0
650+
elseif scope isa ParentScope
651+
return expected_scope_depth(scope.parent) + 1
652+
elseif scope isa DelayParentScope
653+
return expected_scope_depth(scope.parent) + scope.N + 1
654+
elseif scope isa GlobalScope
655+
return -1
656+
end
657+
end
658+
642659
"""
643660
Find all the symbolic constants of some equations or terms and return them as a vector.
644661
"""

0 commit comments

Comments
 (0)