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, ISymbolNature, 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 IScope
IScope.ScopeType -
Constructor Summary
ConstructorsConstructorDescriptionPossibleGenericSymbol(String name, Optional<ISymbol> type, IScope enclosingScope) PossibleGenericSymbol(String name, IScope enclosingScope) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddGenericSymbolReference(PossibleGenericSymbol genericSymbolReference) Add a reference to a parameterised function.voidaddTypeParameterOrArgument(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 PossibleGenericSymbolbooleanIf 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 StringProvide 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'.inthashCode()booleanIs this itself a 'conceptual' type.booleanIs this symbol a type that is generic in nature i.e.booleanIs the symbol open for extension or not.booleanSo 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.voidsetConceptualTypeParameter(boolean conceptualTypeParameter) Set this type symbol to be conceptual in nature.voidsetGenericType(Optional<PossibleGenericSymbol> genericType) Used parameterizing a generic type with type arguments.voidsetGenericType(PossibleGenericSymbol genericType) voidsetOpenForExtension(boolean open) Methods inherited from class CaptureScopedSymbol
cloneIntoCaptureScopedSymbol, getCapturedVariables, getModuleScope, getPrivateVariablesForDisplay, isMarkedAbstract, resolveExcludingCapturedVariables, setCapturedVariables, setCapturedVariables, setCapturedVariablesVisibility, setMarkedAbstract, setModuleScopeMethods inherited from class 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, setScopeTypeMethods inherited from class Symbol
clearInitialisedBy, cloneIntoSymbol, copySymbolProperties, getAssignableCostTo, getAssignableCostTo, getCategory, 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, getFullyQualifiedName, getInitialisedBy, getName, getParsedModule, getSourceToken, getSquirrelledData, getType, getUnCoercedAssignableCostTo, isAssignableTo, isAssignableTo, isDeclaredAsConstant, isDevSource, isExactSameType, isExtensionOfInjectable, isFromLiteral, isIncomingParameter, isInitialised, isInjectable, isInjectionExpected, isLibSource, isLoopVariable, isMarkedAbstract, isMarkedPure, isMutable, 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, isConstant, isControl, isEk9Core, isFunction, isMethod, isPrimitiveType, isTemplateFunction, isTemplateType, isType, isVariable, setGenusMethods inherited from interface ITokenReference
setSourceToken
-
Constructor Details
-
PossibleGenericSymbol
-
PossibleGenericSymbol
-
-
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- Specified by:
clonein interfaceIScope- Specified by:
clonein interfaceIScopedSymbol- Specified by:
clonein interfaceISymbol- Overrides:
clonein classCaptureScopedSymbol
-
cloneIntoPossibleGenericSymbol
-
isParameterisedType
public boolean isParameterisedType()Description copied from interface:ISymbolNatureSo 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:
isParameterisedTypein interfaceISymbolNature- Returns:
- true if a parameterised type (note parameterised not just of a generic nature).
-
getGenericType
Description copied from interface:ICanBeGenericNot only can a class/function that implements this interface be generic in nature, they can also be a 'parameterised type'.- Specified by:
getGenericTypein interfaceICanBeGeneric
-
setGenericType
Used parameterizing a generic type with type arguments. -
setGenericType
-
isGenericInNature
public boolean isGenericInNature()Description copied from interface:ISymbolNatureIs 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:
isGenericInNaturein interfaceISymbolNature
-
isOpenForExtension
public boolean isOpenForExtension()Description copied from interface:ICanBeGenericIs 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:
isOpenForExtensionin interfaceICanBeGeneric
-
setOpenForExtension
public void setOpenForExtension(boolean open) -
isConceptualTypeParameter
public boolean isConceptualTypeParameter()Is this itself a 'conceptual' type.- Specified by:
isConceptualTypeParameterin interfaceISymbolNature
-
setConceptualTypeParameter
public void setConceptualTypeParameter(boolean conceptualTypeParameter) Set this type symbol to be conceptual in nature. -
getGenericSymbolReferences
Description copied from interface:ICanBeGenericUsed 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:
getGenericSymbolReferencesin 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:
addGenericSymbolReferencein interfaceICanBeGeneric
-
addTypeParameterOrArgument
Add a parameter type to this scope.- Specified by:
addTypeParameterOrArgumentin interfaceICanBeGeneric
-
getFriendlyName
Description copied from interface:ISymbolProvide 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:
getFriendlyNamein interfaceISymbol- Overrides:
getFriendlyNamein 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:
getAnyConceptualTypeParametersin interfaceICanBeGeneric
-
getTypeParameterOrArguments
- Specified by:
getTypeParameterOrArgumentsin 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:IScopeJust look in own scope.- Specified by:
resolveInThisScopeOnlyin interfaceIScope- Overrides:
resolveInThisScopeOnlyin classCaptureScopedSymbol
-
resolve
So this is where we alter the mechanism of normal symbol resolution.- Specified by:
resolvein interfaceIScope- Overrides:
resolvein classScopedSymbol
-
equals
- Overrides:
equalsin classCaptureScopedSymbol
-
hashCode
public int hashCode()- Overrides:
hashCodein classCaptureScopedSymbol
-