Class AggregateSymbol
java.lang.Object
org.ek9lang.compiler.symbols.Symbol
org.ek9lang.compiler.symbols.ScopedSymbol
org.ek9lang.compiler.symbols.CaptureScopedSymbol
org.ek9lang.compiler.symbols.PossibleGenericSymbol
org.ek9lang.compiler.symbols.AggregateSymbol
- All Implemented Interfaces:
Serializable, IAggregateSymbol, ICanBeGeneric, ICanCaptureVariables, IScope, IScopedSymbol, ISymbol, ISymbolNature, ITokenReference
- Direct Known Subclasses:
AggregateWithTraitsSymbol, AnyTypeSymbol
public class AggregateSymbol
extends PossibleGenericSymbol
implements IAggregateSymbol, Serializable
This is typically a 'class' or an interface type where it can include the definitions of new
properties. These can then be made accessible via the symbol table to its
methods.
But note there is also a single super 'AggregateSymbol' that maps to a
super class so here the resolve can access variables in the super class.
i.e. we only support single inheritance - but see AggregateWithTraitsSymbol for 'traits' support.
I've also added in a mechanism to parameterize the aggregate like Java generics.
In general the resolution would be able to resolve variables in the enclosing
scope because that will be module level in EK9, there are new global types
and global constants that can appear to exist in the package (module) level
scope.
So for example it is possible to reference a 'constant' or a 'type' that is
defined in the same module or if another module is drawn in through
'references'.
In reality (when creating the Java code) the constants and types can just be
public statics on a class. For example module "the.mod" that defines Constants
could have a class called the.mod._Constants with public final statics
defined.
So there are two ways to resolve references first is module scope and second
is super class type scope.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface IScope
IScope.ScopeType -
Constructor Summary
ConstructorsConstructorDescriptionAggregateSymbol(String name, Optional<ISymbol> type, IScope enclosingScope) A simple straight forward aggregate type, like a class or record.AggregateSymbol(String name, IScope enclosingScope) A simple straight forward aggregate type, like a class or record.AggregateSymbol(String name, IScope enclosingScope, List<ISymbol> typeParameterOrArguments) An aggregate that can be parameterised, i.e. -
Method Summary
Modifier and TypeMethodDescriptionvoidWe note down any subtypes this type is used with.protected voidaddTraitsIfNotPresent(List<AggregateWithTraitsSymbol> exiting, List<AggregateWithTraitsSymbol> additions) Clone the symbol and re-parent if this symbol like a method should have a parent.protected AggregateSymbolcloneIntoAggregateSymbol(AggregateSymbol newCopy) voidDefine a Symbol in this scope.booleanTypically used for synthetically generated aggregates.Gets all abstract methods in this aggregate and any super classes.Get all methods in this scope only that are abstract.Gets all methods that are effective, by this I mean if supers (classes or traits) have the same method name but, it has been overridden then we would only retain the 'overridden' one as that has taken effect.All methods abstract and non-abstract in this scope.Get all methods on this and any supers or traits.Get all methods not marked as abstract in this or any supers.Get all methods in this scope only that are not abstract.Get all operators on this and any supers or traits.getAllSymbolsMatchingName(String symbolName) Return a list of all the symbols that match the name.A list of all the defined constructors.Provides a friendly name of this aggregate that could be presented to the developer.Provides access to the properties on this aggregate - but only this aggregate.To get a full hierarchy you will need to get these subclasses and then get the subclasses of those.getType()doubleinthashCode()booleanhasImmediateSuper(IAggregateSymbol theSuper) booleanWhile this aggregate itself might not able been marked as injectable Does this extend an aggregate that is marked as injectable.booleanisImplementingInSomeWay(IAggregateSymbol aggregate) Only really used by aggregates that can have one or more traits.booleanisInAggregateHierarchy(IAggregateSymbol theAggregateToCheck) Does the aggregate passed in exist in this type hierarchy.booleanSome classes generated can be injected and others not.booleanIs this aggregate a dispatcher or just a normal class component whatever.protected booleanmethodNotPresent(List<MethodSymbol> defined, MethodSymbol checkMethod) protected booleanmethodsMatch(MethodSymbol m1, MethodSymbol m2) resolveMatchingMethods(MethodSymbolSearch search, MethodSymbolSearchResult result) Looks in scope and parent scopes.resolveMember(SymbolSearch search) Just try and resolve a member in this or super scopes.voidsetAggregateDescription(String aggregateDescription) Typically used for synthetically generated aggregates.voidsetApplication(AggregateSymbol application) voidsetInjectable(boolean injectable) voidsetMarkedAsDispatcher(boolean markedAsDispatcher) voidvoidsetPipeSinkType(Optional<String> pipeSinkType) voidsetPipeSourceType(Optional<String> pipeSourceType) voidsetSuperAggregate(Optional<IAggregateSymbol> superAggregate) Set the 'super' of this type.voidsetSuperAggregate(IAggregateSymbol baseSymbol) Methods inherited from class PossibleGenericSymbol
addGenericSymbolReference, addTypeParameterOrArgument, cloneIntoPossibleGenericSymbol, getAnyConceptualTypeParameters, getAnyGenericParamsAsFriendlyNames, getGenericSymbolReferences, getGenericType, getTypeParameterOrArguments, isConceptualTypeParameter, isGenericInNature, isOpenForExtension, isParameterisedType, resolve, resolveFromParameterTypes, resolveInThisScopeOnly, setConceptualTypeParameter, setGenericType, setGenericType, setOpenForExtensionMethods inherited from class CaptureScopedSymbol
cloneIntoCaptureScopedSymbol, getCapturedVariables, getModuleScope, getPrivateVariablesForDisplay, isMarkedAbstract, resolveExcludingCapturedVariables, setCapturedVariables, setCapturedVariables, setCapturedVariablesVisibility, setMarkedAbstract, setModuleScopeMethods inherited from class ScopedSymbol
cloneIntoScopeSymbol, copyScopedSymbolProperties, findNearestDynamicBlockScopeInEnclosingScopes, findNearestNonBlockScopeInEnclosingScopes, getActualScope, getEnclosingScope, getEncounteredExceptionToken, getFriendlyScopeName, getOuterMostTypeOrFunction, getScopeName, getScopeType, getSymbolsForThisScope, isMarkedPure, isMutable, isNotMarkedPure, isScopeAMatchForEnclosingScope, isTerminatedNormally, resolveMatchingMethodsInThisScopeOnly, resolveWithParentScope, setEncounteredExceptionToken, setMarkedPure, setOuterMostTypeOrFunction, setScopeTypeMethods inherited from class Symbol
clearInitialisedBy, cloneIntoSymbol, copySymbolProperties, getAssignableCostTo, getAssignableCostTo, getCategory, getFullyQualifiedName, getGenus, getInitialisedBy, getName, getParsedModule, getProduceFullyQualifiedName, getSourceToken, getSquirrelledData, getSymbolTypeAsString, isAssignableTo, isAssignableTo, isDevSource, isEk9Core, isExactSameType, isInjectionExpected, isLibSource, isNullAllowed, isPromotionSupported, isReferenced, putSquirrelledData, setCategory, setEk9Core, setGenus, setInitialisedBy, setInjectionExpected, setNotMutable, setNullAllowed, setParsedModule, setProduceFullyQualifiedName, setReferenced, setSourceToken, toStringMethods inherited from interface IAggregateSymbol
getAllExtensionConstrainedTraits, getName, getScopeType, getTraits, isExtensionConstrainedMethods inherited from interface ICanBeGeneric
addGenericSymbolReference, addTypeParameterOrArgument, getAnyConceptualTypeParameters, getGenericSymbolReferences, getGenericType, getTypeParameterOrArguments, isOpenForExtensionMethods inherited from interface IScope
findNearestDynamicBlockScopeInEnclosingScopes, findNearestNonBlockScopeInEnclosingScopes, getEnclosingScope, getEncounteredExceptionToken, getFriendlyScopeName, getScopeName, getSymbolsForThisScope, isMarkedPure, isScopeAMatchForEnclosingScope, isTerminatedNormally, resolve, resolveInThisScopeOnly, resolveMatchingMethodsInThisScopeOnly, setEncounteredExceptionTokenMethods inherited from interface ISymbol
clearInitialisedBy, getAssignableCostTo, getAssignableCostTo, getFullyQualifiedName, getInitialisedBy, getParsedModule, getSourceToken, getSquirrelledData, isAssignableTo, isAssignableTo, isDeclaredAsConstant, isDevSource, isExactSameType, isFromLiteral, isIncomingParameter, isInitialised, isInjectionExpected, isLibSource, isLoopVariable, isMarkedAbstract, isMarkedPure, isMutable, isNullAllowed, isPrivate, isPromotionSupported, isPropertyField, isProtected, isPublic, isReferenced, isReturningParameter, putSquirrelledData, setInitialisedBy, setInjectionExpected, setNotMutable, setNullAllowed, setParsedModule, setReferenced, 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
-
AggregateSymbol
-
AggregateSymbol
-
AggregateSymbol
-
-
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 interfaceIAggregateSymbol- Specified by:
clonein interfaceIScope- Specified by:
clonein interfaceIScopedSymbol- Specified by:
clonein interfaceISymbol- Overrides:
clonein classPossibleGenericSymbol
-
cloneIntoAggregateSymbol
-
getApplication
-
setApplication
-
setName
-
define
-
getAnySuperTypeOrFunction
- Overrides:
getAnySuperTypeOrFunctionin classScopedSymbol
-
getFriendlyName
Provides a friendly name of this aggregate that could be presented to the developer.- Specified by:
getFriendlyNamein interfaceISymbol- Overrides:
getFriendlyNamein classPossibleGenericSymbol- Returns:
- The friendly name - especially useful for anonymous dynamic types.
-
getAggregateDescription
Typically used for synthetically generated aggregates.- Specified by:
getAggregateDescriptionin interfaceIAggregateSymbol- Returns:
- A description or the friendly name of no description has been set.
-
setAggregateDescription
Typically used for synthetically generated aggregates. -
getPipeSinkType
- Specified by:
getPipeSinkTypein interfaceIAggregateSymbol
-
setPipeSinkType
-
getPipeSourceType
-
setPipeSourceType
-
isMarkedAsDispatcher
public boolean isMarkedAsDispatcher()Description copied from interface:IAggregateSymbolIs this aggregate a dispatcher or just a normal class component whatever.- Specified by:
isMarkedAsDispatcherin interfaceIAggregateSymbol- Returns:
- true if marked as a dispatcher.
-
setMarkedAsDispatcher
public void setMarkedAsDispatcher(boolean markedAsDispatcher) - Specified by:
setMarkedAsDispatcherin interfaceIAggregateSymbol
-
isInjectable
public boolean isInjectable()Description copied from interface:ISymbolSome classes generated can be injected and others not.- Specified by:
isInjectablein interfaceISymbol- Returns:
- true if this can be injected, false if not.
-
setInjectable
public void setInjectable(boolean injectable) -
getSubAggregateSymbols
Description copied from interface:IAggregateSymbolTo get a full hierarchy you will need to get these subclasses and then get the subclasses of those.- Specified by:
getSubAggregateSymbolsin interfaceIAggregateSymbol- Returns:
- a list of all the subclasses of this class
-
addSubAggregateSymbol
We note down any subtypes this type is used with.- Specified by:
addSubAggregateSymbolin interfaceIAggregateSymbol- Parameters:
sub- The subclass to point back to.
-
getAllAbstractMethods
Gets all abstract methods in this aggregate and any super classes.- Specified by:
getAllAbstractMethodsin interfaceIAggregateSymbol- Returns:
- A list of all the methods marked as abstract.
-
getProperties
Provides access to the properties on this aggregate - but only this aggregate.- Specified by:
getPropertiesin interfaceIAggregateSymbol- Returns:
- The list of properties.
-
getConstructors
Description copied from interface:IAggregateSymbolA list of all the defined constructors.- Specified by:
getConstructorsin interfaceIAggregateSymbol- Returns:
- The list of constructors
-
getAllEffectiveMethods
Description copied from interface:IAggregateSymbolGets all methods that are effective, by this I mean if supers (classes or traits) have the same method name but, it has been overridden then we would only retain the 'overridden' one as that has taken effect. In the case of a trait that has multiple traits where the same method has been overridden in the trait only one method is now in effect. However, if there are multiple traits (or a super has the same method name) we would end up with 'duplicate' methods of the same name in this list 'CheckConflictingMethods' will need to detect this.- Specified by:
getAllEffectiveMethodsin interfaceIAggregateSymbol- Returns:
- A List of methods that are in effect.
-
getAllMethods
Description copied from interface:IAggregateSymbolGet all methods on this and any supers or traits.- Specified by:
getAllMethodsin interfaceIAggregateSymbol- Returns:
- the list
-
getAllOperators
Description copied from interface:IAggregateSymbolGet all operators on this and any supers or traits.- Specified by:
getAllOperatorsin interfaceIAggregateSymbol- Returns:
- the list
-
getAllNonAbstractMethods
Description copied from interface:IAggregateSymbolGet all methods not marked as abstract in this or any supers.- Specified by:
getAllNonAbstractMethodsin interfaceIAggregateSymbol- Returns:
- The list.
-
getAllNonAbstractMethodsInThisScopeOnly
Description copied from interface:IAggregateSymbolGet all methods in this scope only that are not abstract.- Specified by:
getAllNonAbstractMethodsInThisScopeOnlyin interfaceIAggregateSymbol- Returns:
- The list
-
getAllAbstractMethodsInThisScopeOnly
Description copied from interface:IAggregateSymbolGet all methods in this scope only that are abstract.- Specified by:
getAllAbstractMethodsInThisScopeOnlyin interfaceIAggregateSymbol- Returns:
- The list
-
getAllMethodInThisScopeOnly
Description copied from interface:IAggregateSymbolAll methods abstract and non-abstract in this scope.- Specified by:
getAllMethodInThisScopeOnlyin interfaceIAggregateSymbol
-
isImplementingInSomeWay
Description copied from interface:IAggregateSymbolOnly really used by aggregates that can have one or more traits. But also super classes or super traits. So can either be implementing directly, super, super - super or traits and supe traits.- Specified by:
isImplementingInSomeWayin interfaceIAggregateSymbol
-
getAllTraits
- Specified by:
getAllTraitsin interfaceIAggregateSymbol
-
addTraitsIfNotPresent
protected void addTraitsIfNotPresent(List<AggregateWithTraitsSymbol> exiting, List<AggregateWithTraitsSymbol> additions) -
isExtensionOfInjectable
public boolean isExtensionOfInjectable()Description copied from interface:ISymbolWhile this aggregate itself might not able been marked as injectable Does this extend an aggregate that is marked as injectable.- Specified by:
isExtensionOfInjectablein interfaceISymbol- Returns:
- true if this is injectable or any of its supers area
-
getUnCoercedAssignableCostTo
- Specified by:
getUnCoercedAssignableCostToin interfaceISymbol- Overrides:
getUnCoercedAssignableCostToin classSymbol
-
getSuperAggregate
- Specified by:
getSuperAggregatein interfaceIAggregateSymbol
-
setSuperAggregate
Set the 'super' of this type.- Specified by:
setSuperAggregatein interfaceIAggregateSymbol
-
setSuperAggregate
- Specified by:
setSuperAggregatein interfaceIAggregateSymbol
-
hasImmediateSuper
-
isInAggregateHierarchy
Does the aggregate passed in exist in this type hierarchy. This does include a check that this is the same aggregate.- Specified by:
isInAggregateHierarchyin interfaceIAggregateSymbol
-
setType
-
getType
-
getAllSymbolsMatchingName
Description copied from interface:IScopeReturn a list of all the symbols that match the name. So for class and traits this must include supers and traits.- Specified by:
getAllSymbolsMatchingNamein interfaceIScope- Overrides:
getAllSymbolsMatchingNamein classScopedSymbol
-
resolveMatchingMethods
public MethodSymbolSearchResult resolveMatchingMethods(MethodSymbolSearch search, MethodSymbolSearchResult result) Description copied from interface:IScopeLooks in scope and parent scopes.- Specified by:
resolveMatchingMethodsin interfaceIAggregateSymbol- Specified by:
resolveMatchingMethodsin interfaceIScope- Overrides:
resolveMatchingMethodsin classScopedSymbol
-
resolveMember
Just try and resolve a member in this or super scopes.- Specified by:
resolveMemberin interfaceIAggregateSymbol- Specified by:
resolveMemberin interfaceIScope- Overrides:
resolveMemberin classScopedSymbol
-
methodNotPresent
-
methodsMatch
-
equals
- Overrides:
equalsin classPossibleGenericSymbol
-
hashCode
public int hashCode()- Overrides:
hashCodein classPossibleGenericSymbol
-