Class ScopedSymbol
java.lang.Object
org.ek9lang.compiler.symbols.Symbol
org.ek9lang.compiler.symbols.ScopedSymbol
- All Implemented Interfaces:
Serializable, IScope, IScopedSymbol, ISymbol, ISymbolNature, 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 IScope
IScope.ScopeType -
Constructor Summary
ConstructorsConstructorDescriptionScopedSymbol(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 ScopedSymbolcloneIntoScopeSymbol(ScopedSymbol newCopy) copyScopedSymbolProperties(ScopedSymbol newCopy) Just copies the properties over.voidDefine a Symbol in this scope.booleangetAllSymbolsMatchingName(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.inthashCode()booleanThis symbol itself can be marked as pure - i.e.booleanEven constants can be mutable until set.booleanbooleanisScopeAMatchForEnclosingScope(IScope toCheck) booleanTypically 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.voidsetEncounteredExceptionToken(IToken encounteredExceptionToken) voidsetMarkedPure(boolean markedPure) voidsetOuterMostTypeOrFunction(IScopedSymbol outerMostTypeOrFunction) voidsetScopeType(IScope.ScopeType scopeType) Methods inherited from class Symbol
clearInitialisedBy, cloneIntoSymbol, copySymbolProperties, getAssignableCostTo, getAssignableCostTo, getCategory, getFriendlyName, getFullyQualifiedName, getGenus, getInitialisedBy, getName, getParsedModule, getProduceFullyQualifiedName, getSourceToken, getSquirrelledData, getSymbolTypeAsString, getType, getUnCoercedAssignableCostTo, isAssignableTo, isAssignableTo, isDevSource, isEk9Core, isExactSameType, isInjectionExpected, isLibSource, isNullAllowed, isPromotionSupported, isReferenced, putSquirrelledData, setCategory, setEk9Core, setGenus, setInitialisedBy, setInjectionExpected, setName, setNotMutable, setNullAllowed, setParsedModule, setProduceFullyQualifiedName, setReferenced, setSourceToken, setType, toStringMethods inherited from interface ISymbol
clearInitialisedBy, getAssignableCostTo, getAssignableCostTo, getFriendlyName, getFullyQualifiedName, getInitialisedBy, getName, getParsedModule, getSourceToken, getSquirrelledData, getType, getUnCoercedAssignableCostTo, isAssignableTo, isAssignableTo, isDeclaredAsConstant, isDevSource, isExactSameType, isExtensionOfInjectable, isFromLiteral, isIncomingParameter, isInitialised, isInjectable, isInjectionExpected, isLibSource, isLoopVariable, isMarkedAbstract, isNullAllowed, isPrivate, isPromotionSupported, isPropertyField, isProtected, isPublic, isReferenced, isReturningParameter, putSquirrelledData, setInitialisedBy, setInjectionExpected, setName, setNotMutable, setNullAllowed, setParsedModule, setReferenced, setType, setTypeMethods inherited from interface ISymbolNature
getCategory, getGenus, isApplication, isConceptualTypeParameter, isConstant, isControl, isEk9Core, isFunction, isGenericInNature, isMethod, isParameterisedType, isPrimitiveType, isTemplateFunction, isTemplateType, isType, isVariable, setGenusMethods inherited from interface ITokenReference
setSourceToken
-
Constructor Details
-
ScopedSymbol
-
ScopedSymbol
-
ScopedSymbol
-
-
Method Details
-
clone
Description copied from interface:ISymbolClone 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:
getScopeTypein interfaceIScope
-
setScopeType
-
resolveWithParentScope
Resolve with super type/function or via enclosing scope. -
isMarkedPure
public boolean isMarkedPure()Description copied from interface:ISymbolThis symbol itself can be marked as pure - i.e. an operator with no side effects.- Specified by:
isMarkedPurein interfaceIScope- Specified by:
isMarkedPurein interfaceISymbol- Overrides:
isMarkedPurein classSymbol- Returns:
- true if pure, false otherwise. By default, false - lets assume the worst.
-
setMarkedPure
public void setMarkedPure(boolean markedPure) - Overrides:
setMarkedPurein classSymbol
-
isNotMarkedPure
public boolean isNotMarkedPure() -
isMutable
public boolean isMutable()Description copied from interface:ISymbolEven 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:IScopeTypically in a scoped block we can encounter situations (like exceptions) that cause the block to end (terminate) early.- Specified by:
isTerminatedNormallyin interfaceIScope
-
getEncounteredExceptionToken
- Specified by:
getEncounteredExceptionTokenin interfaceIScope
-
setEncounteredExceptionToken
- Specified by:
setEncounteredExceptionTokenin interfaceIScope
-
getScopeName
- Specified by:
getScopeNamein interfaceIScope
-
getFriendlyScopeName
Description copied from interface:IScopeUseful 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:
getFriendlyScopeNamein interfaceIScope- Returns:
- The friendly name to be used for the developer.
-
define
-
getEnclosingScope
- Specified by:
getEnclosingScopein interfaceIScope
-
getAnySuperTypeOrFunction
-
getSymbolsForThisScope
Description copied from interface:IScopeProvide a list of all the parameters held in this scope and only this scope.- Specified by:
getSymbolsForThisScopein interfaceIScope
-
getAllSymbolsMatchingName
-
resolveMatchingMethods
public MethodSymbolSearchResult resolveMatchingMethods(MethodSymbolSearch search, MethodSymbolSearchResult result) Description copied from interface:IScopeLooks in scope and parent scopes.- Specified by:
resolveMatchingMethodsin interfaceIScope
-
resolveMatchingMethodsInThisScopeOnly
public MethodSymbolSearchResult resolveMatchingMethodsInThisScopeOnly(MethodSymbolSearch search, MethodSymbolSearchResult result) Description copied from interface:IScopeLook 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:
resolveMatchingMethodsInThisScopeOnlyin interfaceIScope
-
resolveInThisScopeOnly
Description copied from interface:IScopeJust look in own scope.- Specified by:
resolveInThisScopeOnlyin interfaceIScope
-
resolve
-
resolveMember
Description copied from interface:IScopeJust resolve on this or supers/traits - but not anything outside of the class hierarchy.- Specified by:
resolveMemberin interfaceIScope
-
findNearestNonBlockScopeInEnclosingScopes
- Specified by:
findNearestNonBlockScopeInEnclosingScopesin interfaceIScope
-
findNearestDynamicBlockScopeInEnclosingScopes
- Specified by:
findNearestDynamicBlockScopeInEnclosingScopesin interfaceIScope
-
isScopeAMatchForEnclosingScope
- Specified by:
isScopeAMatchForEnclosingScopein interfaceIScope
-
equals
-
hashCode
-