Package org.ek9lang.compiler.symbols
Class Symbol
java.lang.Object
org.ek9lang.compiler.symbols.Symbol
- All Implemented Interfaces:
Serializable
,ISymbol
,ITokenReference
- Direct Known Subclasses:
ConstantSymbol
,ExpressionSymbol
,ParamExpressionSymbol
,ScopedSymbol
,StreamPipeLineSymbol
,VariableSymbol
A bit of a beast.
The 'Symbol' can be a type, a function, a variable, a control statement,
i.e. it can be used in a very wide range of contexts.
Is extended widely for particular types of symbol.
- See Also:
-
Nested Class Summary
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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Clone the symbol and re-parent if this symbol like a method should have a parent.protected Symbol
cloneIntoSymbol
(Symbol newCopy) copySymbolProperties
(Symbol newCopy) Just copies the properties over.boolean
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()
getName()
Provide the internal name of this symbol - not fully qualified in terms of the module it is in.boolean
getSquirrelledData
(String key) protected String
getSymbolTypeAsString
(Optional<ISymbol> type) getType()
double
int
hashCode()
boolean
boolean
boolean
boolean
Is this a core thing from EK9.boolean
isExactSameType
(ISymbol symbolType) Checks if the type match exactly.boolean
boolean
boolean
This symbol itself can be marked as pure - i.e.boolean
Even constants can be mutable until set.boolean
boolean
For some symbols we might support the _promote method via coercion.boolean
void
putSquirrelledData
(String key, String value) Sometimes it's important to 'squirrel' away information during different phases of the compilation.void
setCategory
(ISymbol.SymbolCategory category) void
setEk9Core
(boolean ek9Core) set this symbol as an EK9 core symbol.void
setGenus
(ISymbol.SymbolGenus genus) void
setInitialisedBy
(IToken initialisedBy) void
setInjectionExpected
(boolean injectionExpected) void
setMarkedPure
(boolean markedPure) void
void
void
setNullAllowed
(boolean nullAllowed) void
setParsedModule
(Optional<Module> module) For some symbols you may wish to specify the parsed module they were defined in.void
setProduceFullyQualifiedName
(boolean produceFullyQualifiedName) void
setReferenced
(boolean referenced) void
setSourceToken
(IToken sourceToken) 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
isApplication, isConceptualTypeParameter, isConstant, isControl, isDeclaredAsConstant, isExtensionOfInjectable, isFromLiteral, isFunction, isGenericInNature, isIncomingParameter, isInitialised, isInjectable, isLoopVariable, isMarkedAbstract, isMethod, isParameterisedType, isPrimitiveType, isPrivate, isPropertyField, isProtected, isPublic, isReturningParameter, isTemplateFunction, isTemplateType, isType, isVariable, setType
-
Constructor Details
-
Symbol
-
Symbol
-
-
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 -
cloneIntoSymbol
-
copySymbolProperties
Just copies the properties over. -
isMarkedPure
public boolean isMarkedPure()Description copied from interface:ISymbol
This symbol itself can be marked as pure - i.e. an operator with no side effects.- Specified by:
isMarkedPure
in interfaceISymbol
- Returns:
- true if pure, false otherwise. By default, false - lets assume the worst.
-
setMarkedPure
public void setMarkedPure(boolean markedPure) -
isReferenced
public boolean isReferenced()- Specified by:
isReferenced
in interfaceISymbol
-
setReferenced
public void setReferenced(boolean referenced) - Specified by:
setReferenced
in interfaceISymbol
-
putSquirrelledData
Sometimes it's important to 'squirrel' away information during different phases of the compilation. This mechanism on a symbol enables arbitrary data to be recorded against a symbol. This can then be retrieved in later stages of compilation.- Specified by:
putSquirrelledData
in interfaceISymbol
-
getSquirrelledData
- Specified by:
getSquirrelledData
in interfaceISymbol
-
isMutable
public boolean isMutable()Description copied from interface:ISymbol
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. -
setNotMutable
public void setNotMutable()- Specified by:
setNotMutable
in interfaceISymbol
-
isNullAllowed
public boolean isNullAllowed()- Specified by:
isNullAllowed
in interfaceISymbol
-
setNullAllowed
public void setNullAllowed(boolean nullAllowed) - Specified by:
setNullAllowed
in interfaceISymbol
-
isInjectionExpected
public boolean isInjectionExpected()- Specified by:
isInjectionExpected
in interfaceISymbol
-
setInjectionExpected
public void setInjectionExpected(boolean injectionExpected) - Specified by:
setInjectionExpected
in interfaceISymbol
-
isEk9Core
public boolean isEk9Core()Description copied from interface:ISymbol
Is this a core thing from EK9. -
setEk9Core
public void setEk9Core(boolean ek9Core) set this symbol as an EK9 core symbol. This means it is designed and built right into the language or is part of the standard EK9 library. -
isDevSource
public boolean isDevSource()- Specified by:
isDevSource
in interfaceISymbol
-
isLibSource
public boolean isLibSource()- Specified by:
isLibSource
in interfaceISymbol
-
getProduceFullyQualifiedName
public boolean getProduceFullyQualifiedName() -
setProduceFullyQualifiedName
public void setProduceFullyQualifiedName(boolean produceFullyQualifiedName) -
getSourceToken
- Specified by:
getSourceToken
in interfaceISymbol
- Specified by:
getSourceToken
in interfaceITokenReference
-
setSourceToken
- Specified by:
setSourceToken
in interfaceITokenReference
-
getInitialisedBy
- Specified by:
getInitialisedBy
in interfaceISymbol
-
setInitialisedBy
- Specified by:
setInitialisedBy
in interfaceISymbol
-
clearInitialisedBy
public void clearInitialisedBy()- Specified by:
clearInitialisedBy
in interfaceISymbol
-
getParsedModule
- Specified by:
getParsedModule
in interfaceISymbol
-
setParsedModule
Description copied from interface:ISymbol
For some symbols you may wish to specify the parsed module they were defined in.- Specified by:
setParsedModule
in interfaceISymbol
- Parameters:
module
- The parsedModule the symbol was defined in.
-
getFullyQualifiedName
Description copied from interface:ISymbol
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.- Specified by:
getFullyQualifiedName
in interfaceISymbol
-
isExactSameType
Checks if the type match exactly.- Specified by:
isExactSameType
in interfaceISymbol
-
isAssignableTo
- Specified by:
isAssignableTo
in interfaceISymbol
-
isAssignableTo
- Specified by:
isAssignableTo
in interfaceISymbol
-
getAssignableWeightTo
- Specified by:
getAssignableWeightTo
in interfaceISymbol
-
getAssignableWeightTo
- Specified by:
getAssignableWeightTo
in interfaceISymbol
-
isPromotionSupported
Description copied from interface:ISymbol
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.- Specified by:
isPromotionSupported
in interfaceISymbol
-
getUnCoercedAssignableWeightTo
- Specified by:
getUnCoercedAssignableWeightTo
in interfaceISymbol
-
getCategory
- Specified by:
getCategory
in interfaceISymbol
-
setCategory
-
getGenus
-
setGenus
-
equals
-
hashCode
public int hashCode() -
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
- Returns:
- a user presentable of the symbol name.
-
getSymbolTypeAsString
-
toString
-
getName
Description copied from interface:ISymbol
Provide the internal name of this symbol - not fully qualified in terms of the module it is in. -
setName
-
getType
-
setType
-