Package org.ek9lang.compiler.symbols
Interface ISymbol
- All Superinterfaces:
ITokenReference
,Serializable
- All Known Subinterfaces:
IAggregateSymbol
,ICanBeGeneric
,IScopedSymbol
- All Known Implementing Classes:
AggregateSymbol
,AggregateWithTraitsSymbol
,CallSymbol
,CaptureScopedSymbol
,ConstantSymbol
,ControlSymbol
,ExpressionSymbol
,ForSymbol
,FunctionSymbol
,MethodSymbol
,ParamExpressionSymbol
,PossibleGenericSymbol
,ScopedSymbol
,ServiceOperationSymbol
,StackConsistencyScope
,StreamCallSymbol
,StreamPipeLineSymbol
,SwitchSymbol
,Symbol
,TrySymbol
,VariableSymbol
,WhileSymbol
Represents the concept of what functionality a Symbol should have.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic enum
Typically used on symbols; so we know their broad use and type.static enum
Typically, used on aggregates because we might use a AggregateSymbol But when coming to process it we need to ensure other aggregate symbols that extend it are of compatible genus i.e a class can only extend a base class not a style but one style could extend another style. -
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Clone the symbol and re-parent if this symbol like a method should have a parent.double
double
Provide the name an end user would need to see on the screen.Provide the internal fully qualified name of this symbol.getGenus()
static String
getModuleNameIfPresent
(String symbolName) Symbol names can be fully qualified (i.e.getName()
Provide the internal name of this symbol - not fully qualified in terms of the module it is in.getSquirrelledData
(String key) getType()
double
static String
getUnqualifiedName
(String symbolName) Just returns the actual symbol name in unqualified form (i.e.default boolean
Is the symbol an application of some sort.boolean
boolean
default boolean
Some symbols are simulated as generic type parameters like T and S and U for example When they are constructed as AggregateTypes this will be set to true in those classes.default boolean
default boolean
default boolean
Only use on symbols, to see if they are directly defined as a constant.boolean
boolean
Is this a core thing from EK9.boolean
isExactSameType
(ISymbol symbolType) If is the symbol is an exact match.default boolean
While this aggregate itself might not able been marked as injectable Does this extend an aggregate that is marked as injectable.default boolean
default boolean
default boolean
Is this symbol a type that is generic in nature i.e.default boolean
default boolean
default boolean
Some classes generated can be injected and others not.boolean
boolean
default boolean
default boolean
boolean
This symbol itself can be marked as pure - i.e.default boolean
isMethod()
boolean
Even constants can be mutable until set.boolean
default boolean
So just to add to the confusion.default boolean
Is the symbol a core primitive type.default boolean
boolean
For some symbols we might support the _promote method via coercion.default boolean
default boolean
default boolean
isPublic()
static boolean
isQualifiedName
(String symbolName) boolean
default boolean
default boolean
default boolean
default boolean
isType()
default boolean
static String
makeFullyQualifiedName
(String scopeName, String symbolName) Convert a scope name (module name) and a symbol name into a fully qualified symbol name.void
putSquirrelledData
(String key, String value) void
setGenus
(ISymbol.SymbolGenus genus) void
setInitialisedBy
(IToken initialisedBy) void
setInjectionExpected
(boolean injectionExpected) void
void
void
setNullAllowed
(boolean nullAllowed) void
setParsedModule
(Optional<Module> parsedModule) For some symbols you may wish to specify the parsed module they were defined in.void
setReferenced
(boolean referenced) default ISymbol
Methods inherited from interface org.ek9lang.compiler.symbols.ITokenReference
setSourceToken
-
Field Details
-
NOT_ASSIGNABLE
static final double NOT_ASSIGNABLE- See Also:
-
-
Method Details
-
getModuleNameIfPresent
Symbol names can be fully qualified (i.e. with the module name) or just a name. This method returns the module name if present or "" if not. -
getUnqualifiedName
Just returns the actual symbol name in unqualified form (i.e. no module name). -
isQualifiedName
-
makeFullyQualifiedName
Convert a scope name (module name) and a symbol name into a fully qualified symbol name. -
isNullAllowed
boolean isNullAllowed() -
setNullAllowed
void setNullAllowed(boolean nullAllowed) -
isInjectionExpected
boolean isInjectionExpected() -
setInjectionExpected
void setInjectionExpected(boolean injectionExpected) -
isReferenced
boolean isReferenced() -
setReferenced
void setReferenced(boolean referenced) -
putSquirrelledData
-
getSquirrelledData
-
getParsedModule
-
setParsedModule
For some symbols you may wish to specify the parsed module they were defined in.- Parameters:
parsedModule
- The parsedModule the symbol was defined in.
-
isDevSource
boolean isDevSource() -
isLibSource
boolean isLibSource() -
clone
Clone the symbol and re-parent if this symbol like a method should have a parent. Other symbols like VariableSymbols are un-parented -
isParameterisedType
default boolean isParameterisedType()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.- Returns:
- true if a parameterised type (note parameterised not just of a generic nature).
-
isGenericInNature
default boolean isGenericInNature()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. -
isConceptualTypeParameter
default boolean isConceptualTypeParameter()Some symbols are simulated as generic type parameters like T and S and U for example When they are constructed as AggregateTypes this will be set to true in those classes. In general this is useful when working with Generic classes and needing types like S and T But they can never really be generated. -
isMarkedPure
boolean isMarkedPure()This symbol itself can be marked as pure - i.e. an operator with no side effects.- Returns:
- true if pure, false otherwise. By default, false - lets assume the worst.
-
isMutable
boolean isMutable()Even 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.- Returns:
- If this symbol is mutable or not.
-
setNotMutable
void setNotMutable() -
getSourceToken
IToken getSourceToken()- Specified by:
getSourceToken
in interfaceITokenReference
-
getInitialisedBy
IToken getInitialisedBy() -
setInitialisedBy
-
clearInitialisedBy
void clearInitialisedBy() -
isInitialised
default boolean isInitialised() -
isPrivate
default boolean isPrivate() -
isProtected
default boolean isProtected() -
isPublic
default boolean isPublic() -
isLoopVariable
default boolean isLoopVariable() -
isIncomingParameter
default boolean isIncomingParameter() -
isReturningParameter
default boolean isReturningParameter() -
isPropertyField
default boolean isPropertyField() -
isTemplateType
default boolean isTemplateType() -
isTemplateFunction
default boolean isTemplateFunction() -
isType
default boolean isType() -
isVariable
default boolean isVariable() -
isPrimitiveType
default boolean isPrimitiveType()Is the symbol a core primitive type. -
isApplication
default boolean isApplication()Is the symbol an application of some sort. -
isDeclaredAsConstant
default boolean isDeclaredAsConstant()Only use on symbols, to see if they are directly defined as a constant. -
isMethod
default boolean isMethod() -
isFunction
default boolean isFunction() -
isControl
default boolean isControl() -
isConstant
default boolean isConstant() -
isFromLiteral
default boolean isFromLiteral() -
isMarkedAbstract
default boolean isMarkedAbstract() -
isInjectable
default boolean isInjectable()Some classes generated can be injected and others not.- Returns:
- true if this can be injected, false if not.
-
isExtensionOfInjectable
default boolean isExtensionOfInjectable()While this aggregate itself might not able been marked as injectable Does this extend an aggregate that is marked as injectable.- Returns:
- true if this is injectable or any of its supers area
-
isExactSameType
If is the symbol is an exact match. -
isEk9Core
boolean isEk9Core()Is this a core thing from EK9. -
isPromotionSupported
For some symbols we might support the _promote method via coercion. i.e. Long -> Float for example But with class structures and traits/interfaces there is a time when objects are assignable because of base and super classes/types but don't need coercion. The isAssignable deals with mingling both coercion and super/trait type compatibility. But we need to know when it comes to IR generation whether to include a PromoteNode or whether the code generated will just work because of class inheritance/interface implementation. -
isAssignableTo
-
isAssignableTo
-
getAssignableWeightTo
-
getAssignableWeightTo
-
getUnCoercedAssignableWeightTo
-
getGenus
ISymbol.SymbolGenus getGenus() -
setGenus
-
getCategory
ISymbol.SymbolCategory getCategory() -
getFullyQualifiedName
String getFullyQualifiedName()Provide the internal fully qualified name of this symbol. Defaults to just the name unless overridden. -Useful for generating output where you want to ensure fully qualified names are used. -
getFriendlyName
String getFriendlyName()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.- Returns:
- a user presentable of the symbol name.
-
getName
String getName()Provide the internal name of this symbol - not fully qualified in terms of the module it is in.- Returns:
- The basic internal name we'd use to resolve the symbol
-
setName
-
getType
-
setType
-
setType
-