Package org.ek9lang.compiler.symbols
Class PossibleGenericSymbol
java.lang.Object
org.ek9lang.compiler.symbols.Symbol
org.ek9lang.compiler.symbols.ScopedSymbol
org.ek9lang.compiler.symbols.CaptureScopedSymbol
org.ek9lang.compiler.symbols.PossibleGenericSymbol
- All Implemented Interfaces:
Serializable
,ICanBeGeneric
,ICanCaptureVariables
,IScope
,IScopedSymbol
,ISymbol
,ITokenReference
- Direct Known Subclasses:
AggregateSymbol
,FunctionSymbol
Added as a common symbol type for both Functions and Aggregates that could possibly be
generic in nature and also be a parameterised type.
This is quite (very) complex, as in ek9 both classes and functions can be:
A 'GenericType'
Have 'Type Parameters'
Can be 'Parameterised Types' through the use of 'Type Arguments'
This can result in 'Parameterised Types' actually still being a 'GenericType'.
It's hard to get your (mine) head around all this.
- 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
ConstructorDescriptionPossibleGenericSymbol
(String name, Optional<ISymbol> type, IScope enclosingScope) PossibleGenericSymbol
(String name, IScope enclosingScope) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addGenericSymbolReference
(PossibleGenericSymbol genericSymbolReference) Add a reference to a parameterised function.void
addTypeParameterOrArgument
(ISymbol typeParameterOrArgument) Add a parameter type to this scope.Clone the symbol and re-parent if this symbol like a method should have a parent.protected PossibleGenericSymbol
boolean
If this scope has been parameterised, then go through those parameters and return a list of all those that are generic 'T' in nature and not actually concrete types.protected String
Provide the name an end user would need to see on the screen.Used to keep track of any generic types/functions used in a generic type that use some or all of the generic type parameters or arguments.Not only can a class/function that implements this interface be generic in nature, they can also be a 'parameterised type'.int
hashCode()
boolean
Is this itself a 'conceptual' type.boolean
Is this symbol a type that is generic in nature i.e.boolean
Is the symbol open for extension or not.boolean
So just to add to the confusion.resolve
(SymbolSearch search) So this is where we alter the mechanism of normal symbol resolution.Used when the type/function is one that is generic/template.resolveInThisScopeOnly
(SymbolSearch search) Just look in own scope.void
setConceptualTypeParameter
(boolean conceptualTypeParameter) Set this type symbol to be conceptual in nature.void
setGenericType
(Optional<PossibleGenericSymbol> genericType) Used parameterizing a generic type with type arguments.void
setGenericType
(PossibleGenericSymbol genericType) void
setOpenForExtension
(boolean open) Methods inherited from class org.ek9lang.compiler.symbols.CaptureScopedSymbol
cloneIntoCaptureScopedSymbol, getCapturedVariables, getModuleScope, getPrivateVariablesForDisplay, isMarkedAbstract, resolveExcludingCapturedVariables, setCapturedVariables, setCapturedVariables, setCapturedVariablesVisibility, setMarkedAbstract, setModuleScope
Methods inherited from class org.ek9lang.compiler.symbols.ScopedSymbol
cloneIntoScopeSymbol, copyScopedSymbolProperties, define, findNearestDynamicBlockScopeInEnclosingScopes, findNearestNonBlockScopeInEnclosingScopes, getActualScope, getAllSymbolsMatchingName, getAnySuperTypeOrFunction, getEnclosingScope, getEncounteredExceptionToken, getFriendlyScopeName, getOuterMostTypeOrFunction, getScopeName, getScopeType, getSymbolsForThisScope, isMarkedPure, isMutable, isNotMarkedPure, isScopeAMatchForEnclosingScope, isTerminatedNormally, resolveMatchingMethods, resolveMatchingMethodsInThisScopeOnly, resolveMember, resolveWithParentScope, setEncounteredExceptionToken, setMarkedPure, setOuterMostTypeOrFunction, setScopeType
Methods inherited from class org.ek9lang.compiler.symbols.Symbol
clearInitialisedBy, cloneIntoSymbol, copySymbolProperties, getAssignableWeightTo, getAssignableWeightTo, getCategory, 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, getFullyQualifiedName, getGenus, getInitialisedBy, getName, getParsedModule, getSourceToken, getSquirrelledData, getType, getUnCoercedAssignableWeightTo, isApplication, isAssignableTo, isAssignableTo, isConstant, isControl, isDeclaredAsConstant, isDevSource, isEk9Core, isExactSameType, isExtensionOfInjectable, isFromLiteral, isFunction, isIncomingParameter, isInitialised, isInjectable, isInjectionExpected, isLibSource, isLoopVariable, isMarkedAbstract, isMarkedPure, isMethod, isMutable, isNullAllowed, 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
-
PossibleGenericSymbol
-
PossibleGenericSymbol
-
-
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- Specified by:
clone
in interfaceIScope
- Specified by:
clone
in interfaceIScopedSymbol
- Specified by:
clone
in interfaceISymbol
- Overrides:
clone
in classCaptureScopedSymbol
-
cloneIntoPossibleGenericSymbol
-
isParameterisedType
public boolean isParameterisedType()Description copied from interface:ISymbol
So just to add to the confusion. A type that has been used with a type that is generic in nature with some parameters. So this would normally result in a type that is now concrete. i.e. List (generic in nature) and String (concrete) so this resulting type 'List of String' isAParameterisedType=true and isGenericInNature=false. But if List were parameterised with another generic parameter it would still be of a generic nature. For example, consider List T and Iterator I when we defined List T and use the Iterator with it; we parameterise Iterator with 'T'. But they are still both 'isGenericTypeParameter' it only when we use List (and by implication Iterator) with String do they both stop being generic in nature.- Specified by:
isParameterisedType
in interfaceISymbol
- Returns:
- true if a parameterised type (note parameterised not just of a generic nature).
-
getGenericType
Description copied from interface:ICanBeGeneric
Not only can a class/function that implements this interface be generic in nature, they can also be a 'parameterised type'.- Specified by:
getGenericType
in interfaceICanBeGeneric
-
setGenericType
Used parameterizing a generic type with type arguments. -
setGenericType
-
isGenericInNature
public boolean isGenericInNature()Description copied from interface:ISymbol
Is this symbol a type that is generic in nature i.e. can it be parameterised with types. Aggregate Symbols can be defined to accept one or more parameters ie S and T.- Specified by:
isGenericInNature
in interfaceISymbol
-
isOpenForExtension
public boolean isOpenForExtension()Description copied from interface:ICanBeGeneric
Is the symbol open for extension or not. Typically this means a function is open/abstract and therefore can/must be extended. The same with classes and components.- Specified by:
isOpenForExtension
in interfaceICanBeGeneric
-
setOpenForExtension
public void setOpenForExtension(boolean open) -
isConceptualTypeParameter
public boolean isConceptualTypeParameter()Is this itself a 'conceptual' type.- Specified by:
isConceptualTypeParameter
in interfaceISymbol
-
setConceptualTypeParameter
public void setConceptualTypeParameter(boolean conceptualTypeParameter) Set this type symbol to be conceptual in nature. -
getGenericSymbolReferences
Description copied from interface:ICanBeGeneric
Used to keep track of any generic types/functions used in a generic type that use some or all of the generic type parameters or arguments. For example a 'List of type T' might use or return an 'Iterator of type T'. It is the 'Iterator' that would be a generic symbol reference.- Specified by:
getGenericSymbolReferences
in interfaceICanBeGeneric
-
addGenericSymbolReference
Add a reference to a parameterised function. I'm still in two minds about adding these references. Leave as is at the moment, and then see what I think later on.- Specified by:
addGenericSymbolReference
in interfaceICanBeGeneric
-
addTypeParameterOrArgument
Add a parameter type to this scope.- Specified by:
addTypeParameterOrArgument
in interfaceICanBeGeneric
-
getFriendlyName
Description copied from interface:ISymbol
Provide the name an end user would need to see on the screen. Normally this is just 'getName' but in the case of Templates We use a very nasty internal naming for List of SomeClass - which will probably be something like _List_hashed_version_of_ComeClass and the end user needs to see 'List of SomeClass' for it to be meaningful.- Specified by:
getFriendlyName
in interfaceISymbol
- Overrides:
getFriendlyName
in classSymbol
- Returns:
- a user presentable of the symbol name.
-
getAnyGenericParamsAsFriendlyNames
-
getAnyConceptualTypeParameters
If this scope has been parameterised, then go through those parameters and return a list of all those that are generic 'T' in nature and not actually concrete types.- Specified by:
getAnyConceptualTypeParameters
in interfaceICanBeGeneric
-
getTypeParameterOrArguments
- Specified by:
getTypeParameterOrArguments
in interfaceICanBeGeneric
-
resolveFromParameterTypes
Used when the type/function is one that is generic/template. It will have a number of parameterTypes, these are 'T' and the like. The conceptual or concrete types. -
resolveInThisScopeOnly
Description copied from interface:IScope
Just look in own scope.- Specified by:
resolveInThisScopeOnly
in interfaceIScope
- Overrides:
resolveInThisScopeOnly
in classCaptureScopedSymbol
-
resolve
So this is where we alter the mechanism of normal symbol resolution.- Specified by:
resolve
in interfaceIScope
- Overrides:
resolve
in classScopedSymbol
-
equals
- Overrides:
equals
in classCaptureScopedSymbol
-
hashCode
public int hashCode()- Overrides:
hashCode
in classCaptureScopedSymbol
-