Class LocalScope
java.lang.Object
org.ek9lang.compiler.symbols.SymbolTable
org.ek9lang.compiler.symbols.LocalScope
- All Implemented Interfaces:
Serializable, IScope
- Direct Known Subclasses:
CaptureScope
Used in many ways via composition.
The local scope can be either just a block (if, where, etc.)
or aggregate (class, component, etc.).
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface IScope
IScope.ScopeType -
Constructor Summary
ConstructorsConstructorDescriptionLocalScope(String scopeName, IScope enclosingScope) Create a new named local scope with an outer enclosing scope.LocalScope(IScope enclosingScope) LocalScope(IScope.ScopeType scopeType, String scopeName, IScope enclosingScope) Create a new named local scope with an outer enclosing scope. -
Method Summary
Modifier and TypeMethodDescriptioncloneIntoLocalScope(LocalScope newCopy) Clones the content of this into the new copy.booleanTraverses up the scope tree of enclosing scopes to find the first scope type that is an aggregate.inthashCode()booleanisScopeAMatchForEnclosingScope(IScope toCheck) Useful to be able to check if the scope you have in hand is the same the enclosing scope for this.protected MethodSymbolSearchResultThere are no supers so this will not add any methods.This class is the root and so there is no enclosing scope.voidsetScopeType(IScope.ScopeType scopeType) Methods inherited from class SymbolTable
cloneIntoSymbolTable, define, getAllSymbolsMatchingName, getEncounteredExceptionToken, getFriendlyScopeName, getScopeName, getSymbolsForThisScope, getSymbolsForThisScopeOfCategory, isMarkedPure, isTerminatedNormally, resolve, resolveInThisScopeOnly, resolveMatchingMethods, resolveMatchingMethodsInThisScopeOnly, resolveMember, searchIsNotInThisScope, setEncounteredExceptionToken, setMarkedPure, toString
-
Constructor Details
-
LocalScope
-
LocalScope
Create a new named local scope with an outer enclosing scope. But will set the scope type to the type passed in. -
LocalScope
-
-
Method Details
-
equals
- Overrides:
equalsin classSymbolTable
-
hashCode
public int hashCode()- Overrides:
hashCodein classSymbolTable
-
clone
- Specified by:
clonein interfaceIScope- Overrides:
clonein classSymbolTable
-
cloneIntoLocalScope
Clones the content of this into the new copy. -
getScopeType
- Specified by:
getScopeTypein interfaceIScope- Overrides:
getScopeTypein classSymbolTable
-
setScopeType
-
getEnclosingScope
- Specified by:
getEnclosingScopein interfaceIScope- Overrides:
getEnclosingScopein classSymbolTable
-
isScopeAMatchForEnclosingScope
Useful to be able to check if the scope you have in hand is the same the enclosing scope for this. Typically, used when looking at access modifiers. Find the scope of the aggregate (assuming not a function) where the call is being made from then call this to see if that scope is the same enclosing scope. Then you can determine if access should be allowed.- Specified by:
isScopeAMatchForEnclosingScopein interfaceIScope- Overrides:
isScopeAMatchForEnclosingScopein classSymbolTable- Parameters:
toCheck- The scope to check- Returns:
- true if a match false otherwise
-
findNearestNonBlockScopeInEnclosingScopes
Traverses up the scope tree of enclosing scopes to find the first scope type that is an aggregate. It might not find anything - if you call this in a local scope in a function or program there is no aggregate up the enclosing scopes only in class/component type stuff is there an aggregate scope for things.- Specified by:
findNearestNonBlockScopeInEnclosingScopesin interfaceIScope- Overrides:
findNearestNonBlockScopeInEnclosingScopesin classSymbolTable- Returns:
- An Optional scope of the first encounter with and scope that is an aggregate or empty.
-
findNearestDynamicBlockScopeInEnclosingScopes
- Specified by:
findNearestDynamicBlockScopeInEnclosingScopesin interfaceIScope- Overrides:
findNearestDynamicBlockScopeInEnclosingScopesin classSymbolTable
-
resolveWithEnclosingScope
Description copied from class:SymbolTableThis class is the root and so there is no enclosing scope. subclasses will override to provide the scope that encloses them- Overrides:
resolveWithEnclosingScopein classSymbolTable
-
resolveMatchingMethodsInEnclosingScope
protected MethodSymbolSearchResult resolveMatchingMethodsInEnclosingScope(MethodSymbolSearch search, MethodSymbolSearchResult result) Description copied from class:SymbolTableThere are no supers so this will not add any methods.- Overrides:
resolveMatchingMethodsInEnclosingScopein classSymbolTable
-