Package org.ek9lang.compiler.symbols
Class FunctionSymbol
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.FunctionSymbol
- All Implemented Interfaces:
Serializable
,ICanBeGeneric
,ICanCaptureVariables
,IMayReturnSymbol
,IScope
,IScopedSymbol
,ISymbol
,ITokenReference
Scope for functions that are part of a module.
While in ek9 these are just functions, when mapped to java we can implement in any
way we like i.e. classes.
We need to ensure that any functions we extend have the same method signature.
- 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
ConstructorDescriptionFunctionSymbol
(String name, IScope enclosingScope) Create a new Function Symbol with a specific unique name (in the enclosing scope).FunctionSymbol
(String name, IScope enclosingScope, List<AggregateSymbol> typeParameterOrArguments) A function that can be parameterised, i.e. -
Method Summary
Modifier and TypeMethodDescriptionClone the symbol and re-parent if this symbol like a method should have a parent.protected FunctionSymbol
cloneIntoFunctionSymbol
(FunctionSymbol newCopy) protected String
doGetFriendlyName
(String withName, Optional<ISymbol> theType) boolean
double
Added convenience method to make the parameters a bit more obvious.Provide the name an end user would need to see on the screen.Useful for printing out errors and information.Provide a symbol that is returned from this function.getType()
double
int
hashCode()
boolean
isImplementingInSomeWay
(FunctionSymbol function) Does this function directly implement or through its hierarch implement the function passed in.boolean
Some functions have a named return symbol 'like rtn as String' for example.boolean
isSignatureMatchTo
(Optional<ISymbol> theirReturnType, List<ISymbol> theirParams) Check if the parameter types and return types match.protected void
justSetReturningSymbol
(VariableSymbol returningSymbol) resolveInThisScopeOnly
(SymbolSearch search) Just look in own scope.void
setReturningSymbol
(VariableSymbol returningSymbol) void
setSuperFunction
(Optional<FunctionSymbol> superFunctionSymbol) void
setSuperFunction
(FunctionSymbol superFunctionSymbol) Methods inherited from class org.ek9lang.compiler.symbols.PossibleGenericSymbol
addGenericSymbolReference, addTypeParameterOrArgument, cloneIntoPossibleGenericSymbol, getAnyConceptualTypeParameters, getAnyGenericParamsAsFriendlyNames, getGenericSymbolReferences, getGenericType, getTypeParameterOrArguments, isConceptualTypeParameter, isGenericInNature, isOpenForExtension, isParameterisedType, resolve, resolveFromParameterTypes, 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, define, findNearestDynamicBlockScopeInEnclosingScopes, findNearestNonBlockScopeInEnclosingScopes, getActualScope, getAllSymbolsMatchingName, getEnclosingScope, getEncounteredExceptionToken, getOuterMostTypeOrFunction, getScopeName, getScopeType, getSymbolsForThisScope, isMarkedPure, isMutable, isNotMarkedPure, isScopeAMatchForEnclosingScope, isTerminatedNormally, resolveMatchingMethods, resolveMatchingMethodsInThisScopeOnly, resolveMember, resolveWithParentScope, setEncounteredExceptionToken, setMarkedPure, setOuterMostTypeOrFunction, setScopeType
Methods inherited from class org.ek9lang.compiler.symbols.Symbol
clearInitialisedBy, cloneIntoSymbol, copySymbolProperties, 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, setName, 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.ISymbol
clearInitialisedBy, getAssignableWeightTo, getCategory, getFullyQualifiedName, getGenus, getInitialisedBy, getName, getParsedModule, getSourceToken, getSquirrelledData, isApplication, isAssignableTo, isAssignableTo, isConstant, isControl, isDeclaredAsConstant, isDevSource, isEk9Core, isExactSameType, isExtensionOfInjectable, isFromLiteral, isFunction, isIncomingParameter, isInitialised, isInjectable, isInjectionExpected, isLibSource, isLoopVariable, isMarkedAbstract, isMarkedPure, isMethod, isMutable, isNullAllowed, isPrimitiveType, isPrivate, isPromotionSupported, isPropertyField, isProtected, isPublic, isReferenced, isReturningParameter, isTemplateFunction, isTemplateType, isType, isVariable, putSquirrelledData, setGenus, setInitialisedBy, setInjectionExpected, setName, setNotMutable, setNullAllowed, setParsedModule, setReferenced
Methods inherited from interface org.ek9lang.compiler.symbols.ITokenReference
setSourceToken
-
Constructor Details
-
FunctionSymbol
Create a new Function Symbol with a specific unique name (in the enclosing scope). -
FunctionSymbol
public FunctionSymbol(String name, IScope enclosingScope, List<AggregateSymbol> typeParameterOrArguments) A function 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 interfaceIScope
- Specified by:
clone
in interfaceIScopedSymbol
- Specified by:
clone
in interfaceISymbol
- Overrides:
clone
in classPossibleGenericSymbol
-
cloneIntoFunctionSymbol
-
getCallParameters
Added convenience method to make the parameters a bit more obvious. -
isImplementingInSomeWay
Does this function directly implement or through its hierarch implement the function passed in. -
getAnySuperTypeOrFunction
- Overrides:
getAnySuperTypeOrFunction
in classScopedSymbol
-
isSignatureMatchTo
Check if the parameter types and return types match. -
getSuperFunction
-
setSuperFunction
-
setSuperFunction
-
isReturningSymbolPresent
public boolean isReturningSymbolPresent()Some functions have a named return symbol 'like rtn as String' for example. In other cases a function will not return anything (We use 'Void') in the case as the 'type'. So when a Returning Symbol is set we use the type of the returning variable as the type return on the function.- Specified by:
isReturningSymbolPresent
in interfaceIMayReturnSymbol
-
getReturningSymbol
Provide a symbol that is returned from this function. Note in EK9 this is not just a type but actually a variable symbol (that has a type).- Specified by:
getReturningSymbol
in interfaceIMayReturnSymbol
-
setReturningSymbol
- Specified by:
setReturningSymbol
in interfaceIMayReturnSymbol
-
justSetReturningSymbol
-
getAssignableWeightTo
- Specified by:
getAssignableWeightTo
in interfaceISymbol
- Overrides:
getAssignableWeightTo
in classSymbol
-
getUnCoercedAssignableWeightTo
- Specified by:
getUnCoercedAssignableWeightTo
in interfaceISymbol
- Overrides:
getUnCoercedAssignableWeightTo
in classSymbol
-
getFriendlyScopeName
Description copied from interface:IScope
Useful for printing out errors and information. The scope name might be a complex generated name used internally a bit like symbol names are. So some items are both scopes and symbols - so ideally we'd want to use a friendly name where possible.- Specified by:
getFriendlyScopeName
in interfaceIScope
- Overrides:
getFriendlyScopeName
in classScopedSymbol
- Returns:
- The friendly name to be used for the developer.
-
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
- Overrides:
getFriendlyName
in classPossibleGenericSymbol
- Returns:
- a user presentable of the symbol name.
-
doGetFriendlyName
-
getType
-
setType
-
setType
-
resolveInThisScopeOnly
Description copied from interface:IScope
Just look in own scope.- Specified by:
resolveInThisScopeOnly
in interfaceIScope
- Overrides:
resolveInThisScopeOnly
in classPossibleGenericSymbol
-
equals
- Overrides:
equals
in classPossibleGenericSymbol
-
hashCode
public int hashCode()- Overrides:
hashCode
in classPossibleGenericSymbol
-