Package org.ek9lang.compiler.symbols
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
Concept of a scope where functions, methods and variables can be declared.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic enum
The main type of scope in use a block is just like a set of instruction inside an if block or a while block whereas a non-block is as the whole class/function/component level. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Define a Symbol in this scope.getAllSymbolsMatchingName
(String symbolName) Return a list of all the symbols that match the name.Useful for printing out errors and information.Provide a list of all the parameters held in this scope and only this scope.boolean
Typically used with functions.boolean
isScopeAMatchForEnclosingScope
(IScope toCheck) boolean
Typically in a scoped block we can encounter situations (like exceptions) that cause the block to end (terminate) early.resolve
(SymbolSearch search) Find the nearest symbol of that name up the scope tree.resolveInThisScopeOnly
(SymbolSearch search) Just look in own scope.resolveMatchingMethods
(MethodSymbolSearch search, MethodSymbolSearchResult result) Looks in scope and parent scopes.Look in own scope just for methods and return all those that could match.resolveMember
(SymbolSearch search) Just resolve on this or supers/traits - but not anything outside of the class hierarchy.void
setEncounteredExceptionToken
(IToken encounteredExceptionToken)
-
Method Details
-
clone
-
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
Define a Symbol in this scope. -
getSymbolsForThisScope
Provide a list of all the parameters held in this scope and only this scope. -
getAllSymbolsMatchingName
Return a list of all the symbols that match the name. So for class and traits this must include supers and traits. -
resolve
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
Just resolve on this or supers/traits - but not anything outside of the class hierarchy. -
resolveInThisScopeOnly
Just look in own scope. -
isScopeAMatchForEnclosingScope
-
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
-