Class MethodSymbol
- All Implemented Interfaces:
Serializable, IMayReturnSymbol, IScope, IScopedSymbol, ISymbol, ISymbolNature, ITokenReference
- Direct Known Subclasses:
CallSymbol, ServiceOperationSymbol, StreamCallSymbol
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface IScope
IScope.ScopeType -
Constructor Summary
ConstructorsConstructorDescriptionMethodSymbol(String name, Optional<ISymbol> type, IScope enclosingScope) Create new method symbol of a specific name with an enclosing scope (i.e.MethodSymbol(String name, IScope enclosingScope) Create new method symbol of a specific name with an enclosing scope (i.e.MethodSymbol(String name, ISymbol type, IScope enclosingScope) Typically used for cloning constructors. -
Method Summary
Modifier and TypeMethodDescriptionClone the symbol and re-parent if this symbol like a method should have a parent.protected MethodSymbolcloneIntoMethodSymbol(MethodSymbol newCopy) copyMethodProperties(MethodSymbol newCopy) Just copies the properties over.protected StringdoGetFriendlyName(String withName, Optional<ISymbol> theType) booleanTwo symbols are the same symbol when they agree on name, category, genus, mutability AND the declaration site they came from.Added convenience method to make the parameters a bit more obvious.Provide the name an end user would need to see on the screen.For actual methods this will be the aggregate they are part of.Provide a symbol that is returned from this method.inthashCode()Mixes in exactly the fieldsSymbol.equals(Object)compares, and nothing else.booleanbooleanbooleanbooleanisExactSignatureMatchTo(MethodSymbol toMethod) This method just checks that the signature has exactly the same types as parameters.booleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanisParameterSignatureMatchTo(List<ISymbol> params) Very important method; that checks if the parameter list provided can match the parameters declared for this method.booleanbooleanbooleanisPublic()booleanSome methods have a named return symbol 'like rtn as String' for example.booleanisSignatureMatchTo(MethodSymbol toMethod) Does the signature of this method match that of the method passed in.booleanbooleanprotected voidjustSetReturningSymbol(VariableSymbol returningSymbol) resolve(SymbolSearch search) Find the nearest symbol of that name up the scope tree.resolveInThisScopeOnly(SymbolSearch search) Just look in own scope.voidsetAccessModifier(String accessModifier) voidsetCallParameters(List<ISymbol> params) Typically used when making synthetic methods you want to add in all the params from another method or something.setConstructor(boolean constructor) voidsetEk9ReturnsThis(boolean ek9ReturnsThis) voidsetMarkedAbstract(boolean markedAbstract) voidsetMarkedAsDispatcher(boolean markedAsDispatcher) voidsetMarkedNoClone(boolean markedNoClone) setOperator(boolean operator) voidsetOverride(boolean override) voidsetReturningSymbol(VariableSymbol returningSymbol) Sets the returning symbol (variable not just type).voidsetSynthetic(boolean synthetic) voidsetUsedAsProxyForDelegate(String delegateName) Set this method to be marked so at it delegates any calls to a delegate.toString()Methods inherited from class ScopedSymbol
cloneIntoScopeSymbol, copyScopedSymbolProperties, define, findNearestDynamicBlockScopeInEnclosingScopes, findNearestNonBlockScopeInEnclosingScopes, getActualScope, getAllSymbolsMatchingName, getAnySuperTypeOrFunction, getEnclosingScope, getEncounteredExceptionToken, getFriendlyScopeName, 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, getAssignableCostTo, getCategory, getFullyQualifiedName, getGenus, getInitialisedBy, getName, getParsedModule, getProduceFullyQualifiedName, getSourceToken, getSquirrelledData, getSymbolTypeAsString, getType, getUnCoercedAssignableCostTo, isAssignableTo, isAssignableTo, isDevSource, isEk9Core, isExactSameType, isInjectionExpected, isLibSource, isNullAllowed, isPromotionSupported, isReferenced, putSquirrelledData, setCategory, setEk9Core, setGenus, setInitialisedBy, setInjectionExpected, setName, setNotMutable, setNullAllowed, setParsedModule, setProduceFullyQualifiedName, setReferenced, setSourceToken, setTypeMethods inherited from interface ISymbol
clearInitialisedBy, getAssignableCostTo, getAssignableCostTo, getFullyQualifiedName, getInitialisedBy, getName, getParsedModule, getSourceToken, getSquirrelledData, getType, getUnCoercedAssignableCostTo, isAssignableTo, isAssignableTo, isDeclaredAsConstant, isDevSource, isExactSameType, isExtensionOfInjectable, isFromLiteral, isIncomingParameter, isInitialised, isInjectable, isInjectionExpected, isLibSource, isLoopVariable, isNullAllowed, isPromotionSupported, isPropertyField, isReferenced, isReturningParameter, putSquirrelledData, setInitialisedBy, setInjectionExpected, setName, setNotMutable, setNullAllowed, setParsedModule, setReferenced, setType, setTypeMethods inherited from interface ISymbolNature
getCategory, getGenus, isApplication, isConceptualTypeParameter, isControl, isEk9Core, isFunction, isGenericInNature, isMethod, isParameterisedType, isPrimitiveType, isTemplateFunction, isTemplateType, isType, isVariable, setGenusMethods inherited from interface ITokenReference
setSourceToken
-
Constructor Details
-
MethodSymbol
-
MethodSymbol
-
MethodSymbol
-
-
Method Details
-
getParentScope
For actual methods this will be the aggregate they are part of. -
clone
-
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 classScopedSymbol
-
cloneIntoMethodSymbol
-
copyMethodProperties
Just copies the properties over. -
resolveInThisScopeOnly
Description copied from interface:IScopeJust look in own scope.- Specified by:
resolveInThisScopeOnlyin interfaceIScope- Overrides:
resolveInThisScopeOnlyin classScopedSymbol
-
resolve
Description copied from interface:IScopeFind the nearest symbol of that name up the scope tree.- Specified by:
resolvein interfaceIScope- Overrides:
resolvein classScopedSymbol
-
isSynthetic
public boolean isSynthetic() -
setSynthetic
public void setSynthetic(boolean synthetic) -
isOverride
public boolean isOverride() -
setOverride
public void setOverride(boolean override) -
getAccessModifier
-
setAccessModifier
-
isPrivate
-
isProtected
public boolean isProtected()- Specified by:
isProtectedin interfaceISymbol
-
isPublic
-
isUsedAsProxyForDelegate
public boolean isUsedAsProxyForDelegate() -
getUsedAsProxyForDelegate
-
setUsedAsProxyForDelegate
Set this method to be marked so at it delegates any calls to a delegate. -
isEk9ReturnsThis
public boolean isEk9ReturnsThis() -
setEk9ReturnsThis
public void setEk9ReturnsThis(boolean ek9ReturnsThis) -
isMarkedNoClone
public boolean isMarkedNoClone() -
setMarkedNoClone
public void setMarkedNoClone(boolean markedNoClone) -
isMarkedAsDispatcher
public boolean isMarkedAsDispatcher() -
setMarkedAsDispatcher
public void setMarkedAsDispatcher(boolean markedAsDispatcher) -
isMarkedAbstract
public boolean isMarkedAbstract()- Specified by:
isMarkedAbstractin interfaceISymbol
-
setMarkedAbstract
public void setMarkedAbstract(boolean markedAbstract) -
isNotMarkedAbstract
public boolean isNotMarkedAbstract() -
isConstant
public boolean isConstant()- Specified by:
isConstantin interfaceISymbolNature
-
isConstructor
public boolean isConstructor() -
setConstructor
-
isNotConstructor
public boolean isNotConstructor() -
isOperator
public boolean isOperator() -
setOperator
-
isNotOperator
public boolean isNotOperator() -
isReturningSymbolPresent
public boolean isReturningSymbolPresent()Some methods have a named return symbol 'like rtn as String' for example. In other cases a method 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 method.- Specified by:
isReturningSymbolPresentin interfaceIMayReturnSymbol
-
getReturningSymbol
Provide a symbol that is returned from this method. Note in EK9 this is not just a type but actually a variable symbol (that has a type).- Specified by:
getReturningSymbolin interfaceIMayReturnSymbol
-
setReturningSymbol
Sets the returning symbol (variable not just type).- Specified by:
setReturningSymbolin interfaceIMayReturnSymbol
-
justSetReturningSymbol
-
isSignatureMatchTo
Does the signature of this method match that of the method passed in. Not the name of the method just the signature of the parameter types and special treatment for the return type - this can be coerced back or be a super type. This also takes into account polymorphism and promotions. -
isExactSignatureMatchTo
This method just checks that the signature has exactly the same types as parameters. So this is 'exact' in addition it does not check the return type at all, nor the method name. It just focuses on the number order and type of the parameters matching. -
isParameterSignatureMatchTo
-
getCallParameters
-
setCallParameters
-
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 classSymbol- Returns:
- a user presentable of the symbol name.
-
doGetFriendlyName
-
equals
Description copied from class:SymbolTwo symbols are the same symbol when they agree on name, category, genus, mutability AND the declaration site they came from.The source token is part of identity deliberately. Name alone is not enough: symbol names are unqualified here, so two unrelated variables both called
count, or two types calledFooin different modules, would otherwise compare equal. The compiler relies on telling those apart -CodeFlowMapkeys initialisation state onMap<IScope, Map<ISymbol, SymbolAccess>>, and conflating two same-named declarations there makes flow analysis attribute one variable's initialisation to another.That distinction used to be present ONLY in
Symbol.hashCode(), which is why this looked like it worked: two same-named symbols compared equal yet hashed apart, so hash collections usually - but not reliably - kept them separate, while any directequalscall saw them as one. Encoding it here makes the two agree. SeeSymbolEqualsHashCodeContractTest.- Overrides:
equalsin classScopedSymbol
-
hashCode
public int hashCode()Description copied from class:SymbolMixes in exactly the fieldsSymbol.equals(Object)compares, and nothing else.A hashCode may legitimately use FEWER fields than equals (that only causes collisions, which are correct), but never MORE: any extra field makes two symbols that compare equal land in different buckets, so a HashSet silently holds visible duplicates and a HashMap lookup misses an entry that is present. This method used to mix in purity, which no equals at THIS level consults - purity belongs in
FunctionSymbol, the level whose equals compares it. The source token stays, and is now matched bySymbol.equals(Object). SeeSymbolEqualsHashCodeContractTest.- Overrides:
hashCodein classScopedSymbol
-
toString
-