Skip to content

Commit 552b4ee

Browse files
feat: add expected_scope_depth
1 parent fcf1b5a commit 552b4ee

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
@@ -734,6 +734,23 @@ function check_scope_depth(scope, depth)
734734
end
735735
end
736736

737+
"""
738+
$(TYPEDSIGNATURES)
739+
740+
Return the expected depth of the given `SymScope` from the root system.
741+
"""
742+
function expected_scope_depth(scope)
743+
if scope isa LocalScope
744+
return 0
745+
elseif scope isa ParentScope
746+
return expected_scope_depth(scope.parent) + 1
747+
elseif scope isa DelayParentScope
748+
return expected_scope_depth(scope.parent) + scope.N + 1
749+
elseif scope isa GlobalScope
750+
return -1
751+
end
752+
end
753+
737754
"""
738755
Find all the symbolic constants of some equations or terms and return them as a vector.
739756
"""

0 commit comments

Comments
 (0)