Package org.ek9lang.compiler.symbols
Class MethodSymbol
java.lang.Object
org.ek9lang.compiler.symbols.Symbol
org.ek9lang.compiler.symbols.ScopedSymbol
org.ek9lang.compiler.symbols.MethodSymbol
- All Implemented Interfaces:
Serializable
,IMayReturnSymbol
,IScope
,IScopedSymbol
,ISymbol
,ITokenReference
- Direct Known Subclasses:
CallSymbol
,ServiceOperationSymbol
,StreamCallSymbol
Represents some type of method that exists on an aggregate type scope.
Or it could just be a function type concept at the module level.
So it really is some type of callable 'thing' that has a scope of its own.
This scope is used to hold incoming parameters.
It can also have some form of visibility/access modifiers and holds the concept
of being overridable in terms of inheritance. In some cases it may also be
defined as one of the 'operators' such as '+' or '$' for example.
- 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
ConstructorDescriptionMethodSymbol
(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 MethodSymbol
cloneIntoMethodSymbol
(MethodSymbol newCopy) copyMethodProperties
(MethodSymbol newCopy) Just copies the properties over.protected String
doGetFriendlyName
(String withName, Optional<ISymbol> theType) boolean
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.int
hashCode()
boolean
boolean
boolean
boolean
isExactSignatureMatchTo
(MethodSymbol toMethod) This method just checks that the signature has exactly the same types as parameters.boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
isParameterSignatureMatchTo
(List<ISymbol> params) Very important method; that checks if the parameter list provided can match the parameters declared for this method.boolean
boolean
boolean
isPublic()
boolean
Some methods have a named return symbol 'like rtn as String' for example.boolean
isSignatureMatchTo
(MethodSymbol toMethod) Does the signature of this method match that of the method passed in.boolean
boolean
protected void
justSetReturningSymbol
(ISymbol returningSymbol) resolve
(SymbolSearch search) Find the nearest symbol of that name up the scope tree.resolveInThisScopeOnly
(SymbolSearch search) Just look in own scope.void
setAccessModifier
(String accessModifier) void
setCallParameters
(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) void
setEk9ReturnsThis
(boolean ek9ReturnsThis) void
setMarkedAbstract
(boolean markedAbstract) void
setMarkedAsDispatcher
(boolean markedAsDispatcher) void
setMarkedNoClone
(boolean markedNoClone) setOperator
(boolean operator) void
setOverride
(boolean override) void
setReturningSymbol
(VariableSymbol returningSymbol) Sets the returning symbol (variable not just type).void
setSynthetic
(boolean synthetic) void
setUsedAsProxyForDelegate
(String delegateName) Set this method to be marked so at it delegates any calls to a delegate.toString()
Methods inherited from class org.ek9lang.compiler.symbols.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, setScopeType
Methods inherited from class org.ek9lang.compiler.symbols.Symbol
clearInitialisedBy, cloneIntoSymbol, copySymbolProperties, getAssignableWeightTo, getAssignableWeightTo, getCategory, getFullyQualifiedName, getGenus, getInitialisedBy, getName, getParsedModule, getProduceFullyQualifiedName, getSourceToken, getSquirrelledData, getSymbolTypeAsString, getType, getUnCoercedAssignableWeightTo, isAssignableTo, isAssignableTo, isDevSource, isEk9Core, isExactSameType, isInjectionExpected, isLibSource, isNullAllowed, isPromotionSupported, isReferenced, putSquirrelledData, setCategory, setEk9Core, setGenus, setInitialisedBy, setInjectionExpected, setName, setNotMutable, setNullAllowed, setParsedModule, setProduceFullyQualifiedName, setReferenced, setSourceToken, setType
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, getAssignableWeightTo, getCategory, getFullyQualifiedName, getGenus, getInitialisedBy, getName, getParsedModule, getSourceToken, getSquirrelledData, getType, getUnCoercedAssignableWeightTo, isApplication, isAssignableTo, isAssignableTo, isConceptualTypeParameter, isControl, isDeclaredAsConstant, isDevSource, isEk9Core, isExactSameType, isExtensionOfInjectable, isFromLiteral, isFunction, isGenericInNature, isIncomingParameter, isInitialised, isInjectable, isInjectionExpected, isLibSource, isLoopVariable, isMethod, isNullAllowed, isParameterisedType, isPrimitiveType, isPromotionSupported, isPropertyField, isReferenced, isReturningParameter, isTemplateFunction, isTemplateType, isType, isVariable, putSquirrelledData, setGenus, setInitialisedBy, setInjectionExpected, setName, setNotMutable, setNullAllowed, setParsedModule, setReferenced, setType, setType
Methods inherited from interface org.ek9lang.compiler.symbols.ITokenReference
setSourceToken
-
Constructor Details
-
MethodSymbol
Create new method symbol of a specific name with an enclosing scope (i.e. a class). -
MethodSymbol
Typically used for cloning constructors. -
MethodSymbol
Create new method symbol of a specific name with an enclosing scope (i.e. a class).
-
-
Method Details
-
getParentScope
For actual methods this will be the aggregate they are part of. -
clone
-
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 classScopedSymbol
-
cloneIntoMethodSymbol
-
copyMethodProperties
Just copies the properties over. -
resolveInThisScopeOnly
Description copied from interface:IScope
Just look in own scope.- Specified by:
resolveInThisScopeOnly
in interfaceIScope
- Overrides:
resolveInThisScopeOnly
in classScopedSymbol
-
resolve
Description copied from interface:IScope
Find the nearest symbol of that name up the scope tree.- Specified by:
resolve
in interfaceIScope
- Overrides:
resolve
in classScopedSymbol
-
isSynthetic
public boolean isSynthetic() -
setSynthetic
public void setSynthetic(boolean synthetic) -
isOverride
public boolean isOverride() -
setOverride
public void setOverride(boolean override) -
getAccessModifier
-
setAccessModifier
-
isPrivate
public boolean isPrivate() -
isProtected
public boolean isProtected()- Specified by:
isProtected
in interfaceISymbol
-
isPublic
public boolean 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:
isMarkedAbstract
in interfaceISymbol
-
setMarkedAbstract
public void setMarkedAbstract(boolean markedAbstract) -
isNotMarkedAbstract
public boolean isNotMarkedAbstract() -
isConstant
public boolean isConstant()- Specified by:
isConstant
in interfaceISymbol
-
isConstructor
public boolean isConstructor() -
isNotConstructor
public boolean isNotConstructor() -
setConstructor
-
isOperator
public boolean isOperator() -
setOperator
-
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:
isReturningSymbolPresent
in 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:
getReturningSymbol
in interfaceIMayReturnSymbol
-
setReturningSymbol
Sets the returning symbol (variable not just type).- Specified by:
setReturningSymbol
in 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
Very important method; that checks if the parameter list provided can match the parameters declared for this method. But this takes into account polymorphism and promotions. -
getCallParameters
Added convenience method to make the parameters a bit more obvious. -
setCallParameters
Typically used when making synthetic methods you want to add in all the params from another method or something.- Parameters:
params
- The parameters to pass to the method.
-
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 classSymbol
- Returns:
- a user presentable of the symbol name.
-
doGetFriendlyName
-
equals
- Overrides:
equals
in classScopedSymbol
-
hashCode
public int hashCode()- Overrides:
hashCode
in classScopedSymbol
-
toString
-