Package org.ek9lang.compiler.symbols
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
,ITokenReference
- Direct Known Subclasses:
AggregateWithTraitsSymbol
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 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
ConstructorDescriptionAggregateSymbol
(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 TypeMethodDescriptionvoid
We note down any subtypes this type is used with.protected void
addTraitsIfNotPresent
(List<AggregateWithTraitsSymbol> exiting, List<AggregateWithTraitsSymbol> additions) Clone the symbol and re-parent if this symbol like a method should have a parent.protected AggregateSymbol
cloneIntoAggregateSymbol
(AggregateSymbol newCopy) void
Define a Symbol in this scope.boolean
Typically 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.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()
double
int
hashCode()
boolean
hasImmediateSuper
(IAggregateSymbol theSuper) boolean
While this aggregate itself might not able been marked as injectable Does this extend an aggregate that is marked as injectable.boolean
isImplementingInSomeWay
(IAggregateSymbol aggregate) Only really used by aggregates that can have one or more traits.boolean
isInAggregateHierarchy
(IAggregateSymbol theAggregateToCheck) Does the aggregate passed in exist in this type hierarchy.boolean
Some classes generated can be injected and others not.boolean
Is this aggregate a dispatcher or just a normal class component whatever.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.void
setAggregateDescription
(String aggregateDescription) Typically used for synthetically generated aggregates.void
setInjectable
(boolean injectable) void
setMarkedAsDispatcher
(boolean markedAsDispatcher) void
void
setPipeSinkType
(Optional<String> pipeSinkType) void
setPipeSourceType
(Optional<String> pipeSourceType) void
setSuperAggregate
(Optional<IAggregateSymbol> superAggregate) Set the 'super' of this type.void
setSuperAggregate
(IAggregateSymbol baseSymbol) Methods inherited from class org.ek9lang.compiler.symbols.PossibleGenericSymbol
addGenericSymbolReference, addTypeParameterOrArgument, cloneIntoPossibleGenericSymbol, getAnyConceptualTypeParameters, getAnyGenericParamsAsFriendlyNames, getGenericSymbolReferences, getGenericType, getTypeParameterOrArguments, isConceptualTypeParameter, isGenericInNature, isOpenForExtension, isParameterisedType, resolve, resolveFromParameterTypes, resolveInThisScopeOnly, setConceptualTypeParameter, setGenericType, setGenericType, setOpenForExtension
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, findNearestDynamicBlockScopeInEnclosingScopes, findNearestNonBlockScopeInEnclosingScopes, getActualScope, getEnclosingScope, getEncounteredExceptionToken, getFriendlyScopeName, getOuterMostTypeOrFunction, getScopeName, getScopeType, getSymbolsForThisScope, isMarkedPure, isMutable, isNotMarkedPure, isScopeAMatchForEnclosingScope, isTerminatedNormally, resolveMatchingMethodsInThisScopeOnly, 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, isAssignableTo, isAssignableTo, isDevSource, isEk9Core, isExactSameType, isInjectionExpected, isLibSource, isNullAllowed, isPromotionSupported, isReferenced, putSquirrelledData, setCategory, setEk9Core, setGenus, setInitialisedBy, setInjectionExpected, setNotMutable, setNullAllowed, setParsedModule, setProduceFullyQualifiedName, setReferenced, setSourceToken, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.ek9lang.compiler.symbols.IAggregateSymbol
getAllExtensionConstrainedTraits, getName, getScopeType, getTraits, isExtensionConstrained
Methods inherited from interface org.ek9lang.compiler.symbols.ICanBeGeneric
addGenericSymbolReference, addTypeParameterOrArgument, getAnyConceptualTypeParameters, getGenericSymbolReferences, getGenericType, getTypeParameterOrArguments, isOpenForExtension
Methods inherited from interface org.ek9lang.compiler.symbols.IScope
findNearestDynamicBlockScopeInEnclosingScopes, findNearestNonBlockScopeInEnclosingScopes, getEnclosingScope, getEncounteredExceptionToken, getFriendlyScopeName, getScopeName, getSymbolsForThisScope, isMarkedPure, isScopeAMatchForEnclosingScope, isTerminatedNormally, resolve, resolveInThisScopeOnly, resolveMatchingMethodsInThisScopeOnly, setEncounteredExceptionToken
Methods inherited from interface org.ek9lang.compiler.symbols.ISymbol
clearInitialisedBy, getAssignableWeightTo, getAssignableWeightTo, getCategory, getFullyQualifiedName, getGenus, getInitialisedBy, getParsedModule, getSourceToken, getSquirrelledData, isApplication, isAssignableTo, isAssignableTo, isConceptualTypeParameter, isConstant, isControl, isDeclaredAsConstant, isDevSource, isEk9Core, isExactSameType, isFromLiteral, isFunction, isGenericInNature, isIncomingParameter, isInitialised, isInjectionExpected, isLibSource, isLoopVariable, isMarkedAbstract, isMarkedPure, isMethod, isMutable, isNullAllowed, isParameterisedType, isPrimitiveType, isPrivate, isPromotionSupported, isPropertyField, isProtected, isPublic, isReferenced, isReturningParameter, isTemplateFunction, isTemplateType, isType, isVariable, putSquirrelledData, setGenus, setInitialisedBy, setInjectionExpected, setNotMutable, setNullAllowed, setParsedModule, setReferenced, setType
Methods inherited from interface org.ek9lang.compiler.symbols.ITokenReference
setSourceToken
-
Constructor Details
-
AggregateSymbol
A simple straight forward aggregate type, like a class or record. -
AggregateSymbol
A simple straight forward aggregate type, like a class or record. -
AggregateSymbol
An aggregate that can be parameterised, i.e. like a 'List of T' So the name would be 'List' and the parameterTypes would be a single aggregate of a conceptual T.
-
-
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 interfaceIAggregateSymbol
- Specified by:
clone
in interfaceIScope
- Specified by:
clone
in interfaceIScopedSymbol
- Specified by:
clone
in interfaceISymbol
- Overrides:
clone
in classPossibleGenericSymbol
-
cloneIntoAggregateSymbol
-
setName
-
define
Description copied from interface:IScope
Define a Symbol in this scope.- Specified by:
define
in interfaceIScope
- Overrides:
define
in classScopedSymbol
-
getAnySuperTypeOrFunction
- Overrides:
getAnySuperTypeOrFunction
in classScopedSymbol
-
getFriendlyName
Provides a friendly name of this aggregate that could be presented to the developer.- Specified by:
getFriendlyName
in interfaceISymbol
- Overrides:
getFriendlyName
in classPossibleGenericSymbol
- Returns:
- The friendly name - especially useful for anonymous dynamic types.
-
getAggregateDescription
Typically used for synthetically generated aggregates.- Specified by:
getAggregateDescription
in interfaceIAggregateSymbol
- Returns:
- A description or the friendly name of no description has been set.
-
setAggregateDescription
Typically used for synthetically generated aggregates. -
getPipeSinkType
- Specified by:
getPipeSinkType
in interfaceIAggregateSymbol
-
setPipeSinkType
-
getPipeSourceType
-
setPipeSourceType
-
isMarkedAsDispatcher
public boolean isMarkedAsDispatcher()Description copied from interface:IAggregateSymbol
Is this aggregate a dispatcher or just a normal class component whatever.- Specified by:
isMarkedAsDispatcher
in interfaceIAggregateSymbol
- Returns:
- true if marked as a dispatcher.
-
setMarkedAsDispatcher
public void setMarkedAsDispatcher(boolean markedAsDispatcher) -
isInjectable
public boolean isInjectable()Description copied from interface:ISymbol
Some classes generated can be injected and others not.- Specified by:
isInjectable
in interfaceISymbol
- Returns:
- true if this can be injected, false if not.
-
setInjectable
public void setInjectable(boolean injectable) -
getSubAggregateSymbols
Description copied from interface:IAggregateSymbol
To get a full hierarchy you will need to get these subclasses and then get the subclasses of those.- Specified by:
getSubAggregateSymbols
in interfaceIAggregateSymbol
- Returns:
- a list of all the subclasses of this class
-
addSubAggregateSymbol
We note down any subtypes this type is used with.- Specified by:
addSubAggregateSymbol
in interfaceIAggregateSymbol
- Parameters:
sub
- The sub-class to point back to.
-
getAllAbstractMethods
Gets all abstract methods in this aggregate and any super classes.- Specified by:
getAllAbstractMethods
in 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:
getProperties
in interfaceIAggregateSymbol
- Returns:
- The list of properties.
-
getConstructors
Description copied from interface:IAggregateSymbol
A list of all the defined constructors.- Specified by:
getConstructors
in interfaceIAggregateSymbol
- Returns:
- The list of constructors
-
getAllMethods
Description copied from interface:IAggregateSymbol
Get all methods on this and any supers or traits.- Specified by:
getAllMethods
in interfaceIAggregateSymbol
- Returns:
- the list
-
getAllOperators
Description copied from interface:IAggregateSymbol
Get all operators on this and any supers or traits.- Specified by:
getAllOperators
in interfaceIAggregateSymbol
- Returns:
- the list
-
getAllNonAbstractMethods
Description copied from interface:IAggregateSymbol
Get all methods not marked as abstract in this or any supers.- Specified by:
getAllNonAbstractMethods
in interfaceIAggregateSymbol
- Returns:
- The list.
-
getAllNonAbstractMethodsInThisScopeOnly
Description copied from interface:IAggregateSymbol
Get all methods in this scope only that are not abstract.- Specified by:
getAllNonAbstractMethodsInThisScopeOnly
in interfaceIAggregateSymbol
- Returns:
- The list
-
getAllAbstractMethodsInThisScopeOnly
Description copied from interface:IAggregateSymbol
Get all methods in this scope only that are abstract.- Specified by:
getAllAbstractMethodsInThisScopeOnly
in interfaceIAggregateSymbol
- Returns:
- The list
-
getAllMethodInThisScopeOnly
Description copied from interface:IAggregateSymbol
All methods abstract and non-abstract in this scope.- Specified by:
getAllMethodInThisScopeOnly
in interfaceIAggregateSymbol
-
isImplementingInSomeWay
Description copied from interface:IAggregateSymbol
Only 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:
isImplementingInSomeWay
in interfaceIAggregateSymbol
-
getAllTraits
- Specified by:
getAllTraits
in interfaceIAggregateSymbol
-
addTraitsIfNotPresent
protected void addTraitsIfNotPresent(List<AggregateWithTraitsSymbol> exiting, List<AggregateWithTraitsSymbol> additions) -
isExtensionOfInjectable
public boolean isExtensionOfInjectable()Description copied from interface:ISymbol
While this aggregate itself might not able been marked as injectable Does this extend an aggregate that is marked as injectable.- Specified by:
isExtensionOfInjectable
in interfaceISymbol
- Returns:
- true if this is injectable or any of its supers area
-
getUnCoercedAssignableWeightTo
- Specified by:
getUnCoercedAssignableWeightTo
in interfaceISymbol
- Overrides:
getUnCoercedAssignableWeightTo
in classSymbol
-
getSuperAggregate
- Specified by:
getSuperAggregate
in interfaceIAggregateSymbol
-
setSuperAggregate
Set the 'super' of this type.- Specified by:
setSuperAggregate
in interfaceIAggregateSymbol
-
setSuperAggregate
- Specified by:
setSuperAggregate
in 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:
isInAggregateHierarchy
in interfaceIAggregateSymbol
-
setType
-
getType
-
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
- Overrides:
getAllSymbolsMatchingName
in classScopedSymbol
-
resolveMatchingMethods
public MethodSymbolSearchResult resolveMatchingMethods(MethodSymbolSearch search, MethodSymbolSearchResult result) Description copied from interface:IScope
Looks in scope and parent scopes.- Specified by:
resolveMatchingMethods
in interfaceIAggregateSymbol
- Specified by:
resolveMatchingMethods
in interfaceIScope
- Overrides:
resolveMatchingMethods
in classScopedSymbol
-
resolveMember
Just try and resolve a member in this or super scopes.- Specified by:
resolveMember
in interfaceIAggregateSymbol
- Specified by:
resolveMember
in interfaceIScope
- Overrides:
resolveMember
in classScopedSymbol
-
equals
- Overrides:
equals
in classPossibleGenericSymbol
-
hashCode
public int hashCode()- Overrides:
hashCode
in classPossibleGenericSymbol
-