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, IFunctionSymbol, IMayReturnSymbol, IScope, IScopedSymbol, ISymbol, ISymbolNature, 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 IScope
IScope.ScopeType -
Constructor Summary
ConstructorsConstructorDescriptionFunctionSymbol(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 FunctionSymbolcloneIntoFunctionSymbol(FunctionSymbol newCopy) protected StringdoGetFriendlyName(String withName, Optional<ISymbol> theType) booleandoubleAdded 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()doubleinthashCode()booleanisImplementingInSomeWay(IFunctionSymbol function) Does this function directly implement or through its hierarchy implement the function passed in.booleanSome functions have a named return symbol 'like rtn as String' for example.booleanisSignatureMatchTo(Optional<ISymbol> theirReturnType, List<ISymbol> theirParams) Check if the parameter types and return types match.protected voidjustSetReturningSymbol(VariableSymbol returningSymbol) resolveInThisScopeOnly(SymbolSearch search) Just look in own scope.voidsetReturningSymbol(VariableSymbol returningSymbol) voidsetSuperFunction(Optional<IFunctionSymbol> superFunctionSymbol) voidsetSuperFunction(IFunctionSymbol superFunctionSymbol) Methods inherited from class PossibleGenericSymbol
addGenericSymbolReference, addTypeParameterOrArgument, cloneIntoPossibleGenericSymbol, getAnyConceptualTypeParameters, getAnyGenericParamsAsFriendlyNames, getGenericSymbolReferences, getGenericType, getTypeParameterOrArguments, isConceptualTypeParameter, isGenericInNature, isOpenForExtension, isParameterisedType, resolve, resolveFromParameterTypes, 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, define, findNearestDynamicBlockScopeInEnclosingScopes, findNearestNonBlockScopeInEnclosingScopes, getActualScope, getAllSymbolsMatchingName, getEnclosingScope, getEncounteredExceptionToken, getOuterMostTypeOrFunction, getScopeName, getScopeType, getSymbolsForThisScope, isMarkedPure, isMutable, isNotMarkedPure, isScopeAMatchForEnclosingScope, isTerminatedNormally, resolveMatchingMethods, resolveMatchingMethodsInThisScopeOnly, resolveMember, resolveWithParentScope, setEncounteredExceptionToken, setMarkedPure, setOuterMostTypeOrFunction, setScopeTypeMethods inherited from class Symbol
clearInitialisedBy, cloneIntoSymbol, copySymbolProperties, 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, setName, setNotMutable, setNullAllowed, setParsedModule, setProduceFullyQualifiedName, setReferenced, setSourceToken, toStringMethods inherited from interface ICanBeGeneric
addGenericSymbolReference, addTypeParameterOrArgument, getAnyConceptualTypeParameters, getGenericSymbolReferences, getGenericType, getTypeParameterOrArguments, isOpenForExtensionMethods inherited from interface IScope
define, findNearestDynamicBlockScopeInEnclosingScopes, findNearestNonBlockScopeInEnclosingScopes, getAllSymbolsMatchingName, getEnclosingScope, getEncounteredExceptionToken, getScopeName, getScopeType, getSymbolsForThisScope, isMarkedPure, isScopeAMatchForEnclosingScope, isTerminatedNormally, resolve, resolveMatchingMethods, resolveMatchingMethodsInThisScopeOnly, resolveMember, setEncounteredExceptionTokenMethods inherited from interface ISymbol
clearInitialisedBy, getAssignableCostTo, getFullyQualifiedName, getInitialisedBy, getName, getParsedModule, getSourceToken, getSquirrelledData, isAssignableTo, isAssignableTo, isDeclaredAsConstant, isDevSource, isExactSameType, isExtensionOfInjectable, isFromLiteral, isIncomingParameter, isInitialised, isInjectable, isInjectionExpected, isLibSource, isLoopVariable, isMarkedAbstract, isMarkedPure, isMutable, isNullAllowed, isPrivate, isPromotionSupported, isPropertyField, isProtected, isPublic, isReferenced, isReturningParameter, putSquirrelledData, setInitialisedBy, setInjectionExpected, setName, setNotMutable, setNullAllowed, setParsedModule, setReferencedMethods 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
-
FunctionSymbol
-
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: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 interfaceIScope- Specified by:
clonein interfaceIScopedSymbol- Specified by:
clonein interfaceISymbol- Overrides:
clonein classPossibleGenericSymbol
-
cloneIntoFunctionSymbol
-
getCallParameters
Added convenience method to make the parameters a bit more obvious.- Specified by:
getCallParametersin interfaceIFunctionSymbol
-
isImplementingInSomeWay
Does this function directly implement or through its hierarchy implement the function passed in.- Specified by:
isImplementingInSomeWayin interfaceIFunctionSymbol
-
getAnySuperTypeOrFunction
- Overrides:
getAnySuperTypeOrFunctionin classScopedSymbol
-
isSignatureMatchTo
-
getSuperFunction
- Specified by:
getSuperFunctionin interfaceIFunctionSymbol
-
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:
isReturningSymbolPresentin 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:
getReturningSymbolin interfaceIMayReturnSymbol
-
setReturningSymbol
- Specified by:
setReturningSymbolin interfaceIMayReturnSymbol
-
justSetReturningSymbol
-
getAssignableCostTo
- Specified by:
getAssignableCostToin interfaceISymbol- Overrides:
getAssignableCostToin classSymbol
-
getUnCoercedAssignableCostTo
- Specified by:
getUnCoercedAssignableCostToin interfaceISymbol- Overrides:
getUnCoercedAssignableCostToin classSymbol
-
getFriendlyScopeName
Description copied from interface:IScopeUseful 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:
getFriendlyScopeNamein interfaceIScope- Overrides:
getFriendlyScopeNamein classScopedSymbol- Returns:
- The friendly name to be used for the developer.
-
getFriendlyName
Description copied from interface:ISymbolProvide 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:
getFriendlyNamein interfaceISymbol- Overrides:
getFriendlyNamein classPossibleGenericSymbol- Returns:
- a user presentable of the symbol name.
-
doGetFriendlyName
-
getType
-
setType
-
setType
-
resolveInThisScopeOnly
Description copied from interface:IScopeJust look in own scope.- Specified by:
resolveInThisScopeOnlyin interfaceIScope- Overrides:
resolveInThisScopeOnlyin classPossibleGenericSymbol
-
equals
- Overrides:
equalsin classPossibleGenericSymbol
-
hashCode
public int hashCode()- Overrides:
hashCodein classPossibleGenericSymbol
-