Interface IScope

All Superinterfaces:
Serializable
All Known Subinterfaces:
IAggregateSymbol, IScopedSymbol
All Known Implementing Classes:
AggregateSymbol, AggregateWithTraitsSymbol, CallSymbol, CaptureScope, CaptureScopedSymbol, ControlSymbol, ForSymbol, FunctionSymbol, LocalScope, MethodSymbol, ModuleScope, PossibleGenericSymbol, ScopedSymbol, ServiceOperationSymbol, StackConsistencyScope, StreamCallSymbol, SwitchSymbol, SymbolTable, TrySymbol, WhileSymbol

public interface IScope extends Serializable
Concept of a scope where functions, methods and variables can be declared.
  • Method Details

    • clone

      IScope clone(IScope withParentAsAppropriate)
    • getScopeType

      IScope.ScopeType getScopeType()
    • getScopeName

      String getScopeName()
    • getEnclosingScope

      IScope getEnclosingScope()
    • getFriendlyScopeName

      String getFriendlyScopeName()
      Useful for printing out errors and information. The scope name might be a complex generated name used internally a bit like symbol names are. So some items are both scopes and symbols - so ideally we'd want to use a friendly name where possible.
      Returns:
      The friendly name to be used for the developer.
    • isMarkedPure

      boolean isMarkedPure()
      Typically used with functions. Something that is pure cannot have 'side effects'. To enforce this a bit of logic can have no references to other variables, methods and functions else how can no side effects be guaranteed. Hence, a function that just tests a value or calculates a result is deemed pure. Anything else is questionable.
      Returns:
      true if marked as pure, false otherwise.
    • define

      void define(ISymbol symbol)
      Define a Symbol in this scope.
    • getSymbolsForThisScope

      List<ISymbol> getSymbolsForThisScope()
      Provide a list of all the parameters held in this scope and only this scope.
    • getAllSymbolsMatchingName

      List<ISymbol> getAllSymbolsMatchingName(String symbolName)
      Return a list of all the symbols that match the name. So for class and traits this must include supers and traits.
    • resolve

      Optional<ISymbol> resolve(SymbolSearch search)
      Find the nearest symbol of that name up the scope tree.
    • resolveMatchingMethods

      MethodSymbolSearchResult resolveMatchingMethods(MethodSymbolSearch search, MethodSymbolSearchResult result)
      Looks in scope and parent scopes.
    • resolveMatchingMethodsInThisScopeOnly

      MethodSymbolSearchResult resolveMatchingMethodsInThisScopeOnly(MethodSymbolSearch search, MethodSymbolSearchResult result)
      Look in own scope just for methods and return all those that could match. ideally there would be one in the case of ambiguities there will be more.
    • resolveMember

      Optional<ISymbol> resolveMember(SymbolSearch search)
      Just resolve on this or supers/traits - but not anything outside of the class hierarchy.
    • resolveInThisScopeOnly

      Optional<ISymbol> resolveInThisScopeOnly(SymbolSearch search)
      Just look in own scope.
    • isScopeAMatchForEnclosingScope

      boolean isScopeAMatchForEnclosingScope(IScope toCheck)
    • findNearestNonBlockScopeInEnclosingScopes

      Optional<ScopedSymbol> findNearestNonBlockScopeInEnclosingScopes()
    • findNearestDynamicBlockScopeInEnclosingScopes

      Optional<ScopedSymbol> findNearestDynamicBlockScopeInEnclosingScopes()
    • isTerminatedNormally

      boolean isTerminatedNormally()
      Typically in a scoped block we can encounter situations (like exceptions) that cause the block to end (terminate) early.
    • getEncounteredExceptionToken

      IToken getEncounteredExceptionToken()
    • setEncounteredExceptionToken

      void setEncounteredExceptionToken(IToken encounteredExceptionToken)