Package org.ek9lang.compiler.symbols
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 org.ek9lang.compiler.symbols.IScope
IScope.ScopeType
-
Constructor Summary
ConstructorDescriptionLocalScope
(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.boolean
Traverses up the scope tree of enclosing scopes to find the first scope type that is an aggregate.int
hashCode()
boolean
isScopeAMatchForEnclosingScope
(IScope toCheck) Useful to be able to check if the scope you have in hand is the same the enclosing scope for this.protected MethodSymbolSearchResult
There are no supers so this will not add any methods.This class is the root and so there is no enclosing scope.void
setScopeType
(IScope.ScopeType scopeType) Methods inherited from class org.ek9lang.compiler.symbols.SymbolTable
cloneIntoSymbolTable, define, getAllSymbolsMatchingName, getEncounteredExceptionToken, getFriendlyScopeName, getScopeName, getSymbolsForThisScope, getSymbolsForThisScopeOfCategory, isMarkedPure, isTerminatedNormally, resolve, resolveInThisScopeOnly, resolveMatchingMethods, resolveMatchingMethodsInThisScopeOnly, resolveMember, searchIsNotInThisScope, setEncounteredExceptionToken, setMarkedPure, toString
-
Constructor Details
-
LocalScope
Create a new named local scope with an outer enclosing scope. Scope type default to BLOCK. -
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:
equals
in classSymbolTable
-
hashCode
public int hashCode()- Overrides:
hashCode
in classSymbolTable
-
clone
- Specified by:
clone
in interfaceIScope
- Overrides:
clone
in classSymbolTable
-
cloneIntoLocalScope
Clones the content of this into the new copy. -
getScopeType
- Specified by:
getScopeType
in interfaceIScope
- Overrides:
getScopeType
in classSymbolTable
-
setScopeType
-
getEnclosingScope
- Specified by:
getEnclosingScope
in interfaceIScope
- Overrides:
getEnclosingScope
in 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:
isScopeAMatchForEnclosingScope
in interfaceIScope
- Overrides:
isScopeAMatchForEnclosingScope
in 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:
findNearestNonBlockScopeInEnclosingScopes
in interfaceIScope
- Overrides:
findNearestNonBlockScopeInEnclosingScopes
in classSymbolTable
- Returns:
- An Optional scope of the first encounter with and scope that is an aggregate or empty.
-
findNearestDynamicBlockScopeInEnclosingScopes
- Specified by:
findNearestDynamicBlockScopeInEnclosingScopes
in interfaceIScope
- Overrides:
findNearestDynamicBlockScopeInEnclosingScopes
in classSymbolTable
-
resolveWithEnclosingScope
Description copied from class:SymbolTable
This class is the root and so there is no enclosing scope. subclasses will override to provide the scope that encloses them- Overrides:
resolveWithEnclosingScope
in classSymbolTable
-
resolveMatchingMethodsInEnclosingScope
protected MethodSymbolSearchResult resolveMatchingMethodsInEnclosingScope(MethodSymbolSearch search, MethodSymbolSearchResult result) Description copied from class:SymbolTable
There are no supers so this will not add any methods.- Overrides:
resolveMatchingMethodsInEnclosingScope
in classSymbolTable
-