Class ScopeManager


  • public class ScopeManager
    extends java.lang.Object
    The scope manager builds a multitree-structure of scopes associated to a scope. These Scopes capture the are of validity of certain (Variable-, Field-, Record-)declarations but are also used to identify outer scopes that should be target of a jump (continue, break, throw).

    enterScope(Node) and leaveScope(Node) can be used to enter the Tree of scopes and then sitting at a path, access the currently valid "stack" of scopes.

    • Constructor Detail

      • ScopeManager

        public ScopeManager()
    • Method Detail

      • isInBlock

        public boolean isInBlock()
      • isInFunction

        public boolean isInFunction()
      • isInRecord

        public boolean isInRecord()
      • getCurrentScope

        public Scope getCurrentScope()
      • enterScopeIfExists

        public void enterScopeIfExists​(Node nodeToScope)
      • leaveScopeIfExists

        public @Nullable Scope leaveScopeIfExists​(Node nodeToLeave)
      • enterScope

        public void enterScope​(Node nodeToScope)
      • isBreakable

        public boolean isBreakable​(Scope scope)
      • isContinuable

        public boolean isContinuable​(Scope scope)
      • leaveScope

        public @Nullable Scope leaveScope​(Node nodeToLeave)
        Remove all scopes above the specified one including the specified one.
        Parameters:
        nodeToLeave - - The scope is defined by its astNode
        Returns:
        the scope is returned for processing
      • getFirstScopeThat

        public @Nullable Scope getFirstScopeThat​(java.util.function.Predicate<Scope> predicate)
      • getFirstScopeThat

        public @Nullable Scope getFirstScopeThat​(Scope searchScope,
                                                 java.util.function.Predicate<Scope> predicate)
      • getScopesThat

        public java.util.List<Scope> getScopesThat​(java.util.function.Predicate<Scope> predicate)
      • getUniqueScopesThat

        public <T> java.util.List<Scope> getUniqueScopesThat​(java.util.function.Predicate<Scope> predicate,
                                                             java.util.function.Function<Scope,​T> uniqueProperty)
      • addBreakStatement

        public void addBreakStatement​(BreakStatement breakStatement)
      • addContinueStatement

        public void addContinueStatement​(ContinueStatement continueStatement)
      • addLabelStatement

        public void addLabelStatement​(LabelStatement labelStatement)
      • getLabelStatement

        public @Nullable LabelStatement getLabelStatement​(java.lang.String labelString)
      • addValueDeclaration

        public void addValueDeclaration​(VariableDeclaration variableDeclaration)
      • addValueDeclaration

        public void addValueDeclaration​(FieldDeclaration fieldDeclaration)
      • addValueDeclaration

        public void addValueDeclaration​(FunctionDeclaration functionDeclaration)
      • getCurrentNamePrefix

        public java.lang.String getCurrentNamePrefix()
      • getFullNamePrefix

        public java.lang.String getFullNamePrefix()
      • getScopeOfStatment

        public Scope getScopeOfStatment​(Node node)
      • getDeclarationForName

        public @Nullable Declaration getDeclarationForName​(java.lang.String name)