Package org.ek9lang.compiler.symbols
Class ScopedSymbol
java.lang.Object
org.ek9lang.compiler.symbols.Symbol
org.ek9lang.compiler.symbols.ScopedSymbol
- All Implemented Interfaces:
Serializable
,IScope
,IScopedSymbol
,ISymbol
,ITokenReference
- Direct Known Subclasses:
CaptureScopedSymbol
,ControlSymbol
,ForSymbol
,MethodSymbol
,StackConsistencyScope
,WhileSymbol
Represents a symbol that also has a scope. Typically, this means it can have variables,
methods and function declared within it. But also includes block scoped constructs like
for loops for example.
It's turning into a bit of a 'bitbucket' because I don't really want duplication at the FunctionSymbol
and AggregateSymbol level. So some things like CaptureVariables are not really applicable (yet).
But I may use them later for other constructs and controls.
I may refactor the generic bits out to a new Symbol type between ScopedSymbol and Symbol
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.ek9lang.compiler.symbols.IScope
IScope.ScopeType
Nested classes/interfaces inherited from interface org.ek9lang.compiler.symbols.ISymbol
ISymbol.SymbolCategory, ISymbol.SymbolGenus
-
Field Summary
Fields inherited from interface org.ek9lang.compiler.symbols.ISymbol
NOT_ASSIGNABLE
-
Constructor Summary
ConstructorDescriptionScopedSymbol
(String name, Optional<ISymbol> type, IScope enclosingScope) ScopedSymbol
(String name, IScope enclosingScope) ScopedSymbol
(IScope.ScopeType scopeType, String scopeName, IScope enclosingScope) -
Method Summary
Modifier and TypeMethodDescriptionClone the symbol and re-parent if this symbol like a method should have a parent.protected ScopedSymbol
cloneIntoScopeSymbol
(ScopedSymbol newCopy) copyScopedSymbolProperties
(ScopedSymbol newCopy) Just copies the properties over.void
Define a Symbol in this scope.boolean
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.int
hashCode()
boolean
This symbol itself can be marked as pure - i.e.boolean
Even constants can be mutable until set.boolean
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.resolveWithParentScope
(SymbolSearch search) Resolve with super type/function or via enclosing scope.void
setEncounteredExceptionToken
(IToken encounteredExceptionToken) void
setMarkedPure
(boolean markedPure) void
setOuterMostTypeOrFunction
(IScopedSymbol outerMostTypeOrFunction) void
setScopeType
(IScope.ScopeType scopeType) Methods inherited from class org.ek9lang.compiler.symbols.Symbol
clearInitialisedBy, cloneIntoSymbol, copySymbolProperties, getAssignableWeightTo, getAssignableWeightTo, getCategory, getFriendlyName, getFullyQualifiedName, getGenus, getInitialisedBy, getName, getParsedModule, getProduceFullyQualifiedName, getSourceToken, getSquirrelledData, getSymbolTypeAsString, getType, getUnCoercedAssignableWeightTo, isAssignableTo, isAssignableTo, isDevSource, isEk9Core, isExactSameType, isInjectionExpected, isLibSource, isNullAllowed, isPromotionSupported, isReferenced, putSquirrelledData, setCategory, setEk9Core, setGenus, setInitialisedBy, setInjectionExpected, setName, setNotMutable, setNullAllowed, setParsedModule, setProduceFullyQualifiedName, setReferenced, setSourceToken, setType, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.ek9lang.compiler.symbols.ISymbol
clearInitialisedBy, getAssignableWeightTo, getAssignableWeightTo, getCategory, getFriendlyName, getFullyQualifiedName, getGenus, getInitialisedBy, getName, getParsedModule, getSourceToken, getSquirrelledData, getType, getUnCoercedAssignableWeightTo, isApplication, isAssignableTo, isAssignableTo, isConceptualTypeParameter, isConstant, isControl, isDeclaredAsConstant, isDevSource, isEk9Core, isExactSameType, isExtensionOfInjectable, isFromLiteral, isFunction, isGenericInNature, isIncomingParameter, isInitialised, isInjectable, isInjectionExpected, isLibSource, isLoopVariable, isMarkedAbstract, isMethod, isNullAllowed, isParameterisedType, isPrimitiveType, isPrivate, isPromotionSupported, isPropertyField, isProtected, isPublic, isReferenced, isReturningParameter, isTemplateFunction, isTemplateType, isType, isVariable, putSquirrelledData, setGenus, setInitialisedBy, setInjectionExpected, setName, setNotMutable, setNullAllowed, setParsedModule, setReferenced, setType, setType
Methods inherited from interface org.ek9lang.compiler.symbols.ITokenReference
setSourceToken
-
Constructor Details
-
ScopedSymbol
-
ScopedSymbol
-
ScopedSymbol
-
-
Method Details
-
clone
Description copied from interface:ISymbol
Clone the symbol and re-parent if this symbol like a method should have a parent. Other symbols like VariableSymbols are un-parented -
cloneIntoScopeSymbol
-
copyScopedSymbolProperties
Just copies the properties over. -
getOuterMostTypeOrFunction
-
setOuterMostTypeOrFunction
-
getActualScope
-
getScopeType
- Specified by:
getScopeType
in interfaceIScope
-
setScopeType
-
resolveWithParentScope
Resolve with super type/function or via enclosing scope. -
isMarkedPure
public boolean isMarkedPure()Description copied from interface:ISymbol
This symbol itself can be marked as pure - i.e. an operator with no side effects.- Specified by:
isMarkedPure
in interfaceIScope
- Specified by:
isMarkedPure
in interfaceISymbol
- Overrides:
isMarkedPure
in classSymbol
- Returns:
- true if pure, false otherwise. By default, false - lets assume the worst.
-
isNotMarkedPure
public boolean isNotMarkedPure() -
setMarkedPure
public void setMarkedPure(boolean markedPure) - Overrides:
setMarkedPure
in classSymbol
-
isMutable
public boolean isMutable()Description copied from interface:ISymbol
Even constants can be mutable until set. then they change to being none mutable. Likewise in 'pure' scopes a variable can be mutable until it is first set then none mutable. -
isTerminatedNormally
public boolean isTerminatedNormally()Description copied from interface:IScope
Typically in a scoped block we can encounter situations (like exceptions) that cause the block to end (terminate) early.- Specified by:
isTerminatedNormally
in interfaceIScope
-
getEncounteredExceptionToken
- Specified by:
getEncounteredExceptionToken
in interfaceIScope
-
setEncounteredExceptionToken
- Specified by:
setEncounteredExceptionToken
in interfaceIScope
-
getScopeName
- Specified by:
getScopeName
in interfaceIScope
-
getFriendlyScopeName
Description copied from interface:IScope
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.- Specified by:
getFriendlyScopeName
in interfaceIScope
- Returns:
- The friendly name to be used for the developer.
-
define
Description copied from interface:IScope
Define a Symbol in this scope. -
getEnclosingScope
- Specified by:
getEnclosingScope
in interfaceIScope
-
getAnySuperTypeOrFunction
-
getSymbolsForThisScope
Description copied from interface:IScope
Provide a list of all the parameters held in this scope and only this scope.- Specified by:
getSymbolsForThisScope
in interfaceIScope
-
getAllSymbolsMatchingName
Description copied from interface:IScope
Return a list of all the symbols that match the name. So for class and traits this must include supers and traits.- Specified by:
getAllSymbolsMatchingName
in interfaceIScope
-
resolveMatchingMethods
public MethodSymbolSearchResult resolveMatchingMethods(MethodSymbolSearch search, MethodSymbolSearchResult result) Description copied from interface:IScope
Looks in scope and parent scopes.- Specified by:
resolveMatchingMethods
in interfaceIScope
-
resolveMatchingMethodsInThisScopeOnly
public MethodSymbolSearchResult resolveMatchingMethodsInThisScopeOnly(MethodSymbolSearch search, MethodSymbolSearchResult result) Description copied from interface:IScope
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.- Specified by:
resolveMatchingMethodsInThisScopeOnly
in interfaceIScope
-
resolveInThisScopeOnly
Description copied from interface:IScope
Just look in own scope.- Specified by:
resolveInThisScopeOnly
in interfaceIScope
-
resolve
Description copied from interface:IScope
Find the nearest symbol of that name up the scope tree. -
resolveMember
Description copied from interface:IScope
Just resolve on this or supers/traits - but not anything outside of the class hierarchy.- Specified by:
resolveMember
in interfaceIScope
-
findNearestNonBlockScopeInEnclosingScopes
- Specified by:
findNearestNonBlockScopeInEnclosingScopes
in interfaceIScope
-
findNearestDynamicBlockScopeInEnclosingScopes
- Specified by:
findNearestDynamicBlockScopeInEnclosingScopes
in interfaceIScope
-
isScopeAMatchForEnclosingScope
- Specified by:
isScopeAMatchForEnclosingScope
in interfaceIScope
-
equals
-
hashCode
public int hashCode()
-