public class FunctionDefinition extends ScopedDefinitionBase implements IFunctionDefinition
After a function definition is in the symbol table, it should always be
accessed through the read-only IFunctionDefinition
interface.
IFunctionDefinition.FunctionClassification
FLAG_CAST_FUNCTION, FLAG_CONSTRUCTOR, FLAG_CONTINGENT, FLAG_DECLARED_IN_CONTROL_FLOW, FLAG_DEFAULT, FLAG_DEPRECATED, FLAG_DYNAMIC, FLAG_FINAL, FLAG_GENERATED_EMBED_CLASS, FLAG_HAS_INIT, FLAG_IMPLICIT, FLAG_NATIVE, FLAG_OVERRIDE, FLAG_REST, FLAG_STATIC, flags, nodeRef, singletonEmptyMetaTags
Constructor and Description |
---|
FunctionDefinition(String name) |
Modifier and Type | Method and Description |
---|---|
protected void |
buildInnerString(StringBuilder sb)
For debugging only.
|
protected boolean |
canFunctionBeInlined() |
IFunctionDefinition.FunctionClassification |
getFunctionClassification()
Get the classification for this function (local, argument, class member,
etc)
|
IFunctionNode |
getFunctionNode()
Returns the
IFunctionNode from which this definition was created,
if the definition came from the AST for a source file. |
ParameterDefinition[] |
getParameters()
Get the parameters of this function as an array of
IParameterDefinition elements |
String |
getReturnTypeAsDisplayString()
Converts this definition's
IReference for its return type
to a human-readable String. |
IReference |
getReturnTypeReference()
Gets a reference to the return type for this function.
|
boolean |
hasCompatibleSignature(IFunctionDefinition other,
ICompilerProject project) |
boolean |
hasRequiredParameters()
Returns
true if the function has required parameters. |
boolean |
inlineFunction()
Can this function be inlined
|
boolean |
isCastFunction()
Is this a cast function?
|
boolean |
isConstructor()
Is this a constructor?
|
boolean |
isImplementation(ICompilerProject project)
Determines whether this function is an implementation of a function from
an implements Interface
|
boolean |
isInline()
Is this function marked as
inline ? |
boolean |
isTopLevelDefinition()
Is this definition a toplevel definition - constructors are special,
which is why this is overriden here
|
boolean |
matches(DefinitionBase definition) |
boolean |
overridesAncestor(ICompilerProject project)
Is this function actually overriding a function in a base class
|
IFunctionDefinition |
resolveImplementedFunction(ICompilerProject project)
Finds the definition of the IFunctionDefinition that defines this
function
|
FunctionDefinition |
resolveOverriddenFunction(ICompilerProject project)
Finds the definition of the IFunctionDefinition that we are overriding
|
List<IFunctionDefinition> |
resolveOverridenInterfaceFunctions(ICompilerProject project)
Return a list of FunctionDefinitions from the base interfaces that this FunctionDefinition overrides.
|
ITypeDefinition |
resolveReturnType(ICompilerProject project)
Resolve this function's return type in the given scope and find its
definition
|
void |
setAsConstructor(ClassDefinition classDef) |
void |
setCastFunction() |
void |
setNode(IDefinitionNode node)
Attaches a weak reference to the source node that produced this
definition, and copies over enough source-location information to
re-associate the node if it is garbage-collected.
|
void |
setParameters(ParameterDefinition[] value) |
void |
setReturnTypeReference(IReference returnTypeReference)
Sets a reference to the return type for this function.
|
getContainedScope, setContainedScope, verify
addMetaTag, buildString, getAbsoluteEnd, getAbsoluteStart, getAllMetaTags, getAncestorOfType, getArrayElementType, getBaseName, getBindableEventNames, getColumn, getContainingASScope, getContainingFilePath, getContainingScope, getContainingSourceFilePath, getDefinition, getDeprecationInfo, getEnd, getExplicitSourceComment, getFileScope, getFileSpecification, getInstanceType, getLine, getLocationString, getMaxSize, getMetaTagByName, getMetaTagsByName, getMName, getModifiers, getNameColumn, getNameEnd, getNameLine, getNamespaceReference, getNamespaceReferenceAsString, getNameStart, getNode, getPackageName, getParent, getPercentProxy, getQualifiedName, getSize, getSkinPart, getSourcePath, getStart, getStorageName, getTypeAsDisplayString, getTypeDependencyType, getTypeReference, hasCollapseWhiteSpace, hasExplicitComment, hasMetaTagByName, hasModifier, hasNamespace, hasRichTextContent, inPackageNamespace, isBindable, isBindableStyle, isColor, isContingent, isContingentNeeded, isDeprecated, isDynamic, isEmpty, isFinal, isGeneratedEmbedClass, isImplicit, isInProject, isInternal, isNative, isOverride, isPrivate, isProtected, isPublic, isRequiredSkinPart, isStatic, resolveNamespace, resolveType, resolveType, resolveType, resolveType, resolveType, setBindable, setContainingScope, setContingent, setDynamic, setFinal, setGeneratedEmbedClass, setImplicit, setLocation, setMetaTags, setModifier, setNameLocation, setNamespaceReference, setNative, setOverride, setPublic, setStatic, setTypeReference, toStorageName, toString, unsetOverride
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getContainedScope
getExplicitSourceComment, hasExplicitComment
getAbsoluteEnd, getAbsoluteStart, getAllMetaTags, getAncestorOfType, getBaseName, getBindableEventNames, getColumn, getContainingFilePath, getContainingScope, getContainingSourceFilePath, getDeprecationInfo, getEnd, getLine, getMetaTagByName, getMetaTagsByName, getModifiers, getNameColumn, getNameEnd, getNameLine, getNamespaceReference, getNameStart, getNode, getPackageName, getParent, getQualifiedName, getSourcePath, getStart, getTypeAsDisplayString, getTypeReference, hasMetaTagByName, hasModifier, hasNamespace, isBindable, isBindableStyle, isContingent, isContingentNeeded, isDeprecated, isDynamic, isFinal, isGeneratedEmbedClass, isImplicit, isInProject, isInternal, isNative, isOverride, isPrivate, isProtected, isPublic, isStatic, resolveNamespace, resolveType
public FunctionDefinition(String name)
public void setNode(IDefinitionNode node)
DefinitionBase
setNode
in class DefinitionBase
node
- The IDefinitionNode
that is producing
this definition.public IFunctionDefinition.FunctionClassification getFunctionClassification()
IFunctionDefinition
getFunctionClassification
in interface IFunctionDefinition
public ParameterDefinition[] getParameters()
IFunctionDefinition
IParameterDefinition
elementsgetParameters
in interface IFunctionDefinition
public boolean hasRequiredParameters()
IFunctionDefinition
true
if the function has required parameters.hasRequiredParameters
in interface IFunctionDefinition
public void setParameters(ParameterDefinition[] value)
public String getReturnTypeAsDisplayString()
IFunctionDefinition
IReference
for its return type
to a human-readable String.
If the definition does not have a return type reference, this method returns the empty string.
This method should only be used for displaying return types in problems, and not for making semantic decisions.
Note:
getReturnTypeAsDisplayString
in interface IFunctionDefinition
IReference.getDisplayString()
()
on the IReference
representing this definition's return type.public void setReturnTypeReference(IReference returnTypeReference)
returnTypeReference
- An IReference
to a class or interface.public IReference getReturnTypeReference()
IFunctionDefinition
For example, for the function private function f(i:int):String
,
this is a reference to the String
class.
getReturnTypeReference
in interface IFunctionDefinition
IReference
to a class or interface.public ITypeDefinition resolveReturnType(ICompilerProject project)
IFunctionDefinition
resolveReturnType
in interface IFunctionDefinition
project
- the ICompilerProject
in which to resolve
referencesITypeDefinition
representing this function's return
type, or nullpublic boolean isConstructor()
IFunctionDefinition
isConstructor
in interface IFunctionDefinition
public void setAsConstructor(ClassDefinition classDef)
public boolean isCastFunction()
IFunctionDefinition
isCastFunction
in interface IFunctionDefinition
public void setCastFunction()
public boolean inlineFunction()
IFunctionDefinition
inlineFunction
in interface IFunctionDefinition
public final boolean isInline()
IFunctionDefinition
inline
?isInline
in interface IFunctionDefinition
true
if the function is inline
.protected final boolean canFunctionBeInlined()
public boolean overridesAncestor(ICompilerProject project)
IFunctionDefinition
overridesAncestor
in interface IFunctionDefinition
public FunctionDefinition resolveOverriddenFunction(ICompilerProject project)
IFunctionDefinition
resolveOverriddenFunction
in interface IFunctionDefinition
IFunctionDefinition
or nullpublic boolean isImplementation(ICompilerProject project)
IFunctionDefinition
isImplementation
in interface IFunctionDefinition
public List<IFunctionDefinition> resolveOverridenInterfaceFunctions(ICompilerProject project)
project
- The project to use to resolve referencespublic IFunctionDefinition resolveImplementedFunction(ICompilerProject project)
IFunctionDefinition
resolveImplementedFunction
in interface IFunctionDefinition
IFunctionDefinition
or nullpublic boolean hasCompatibleSignature(IFunctionDefinition other, ICompilerProject project)
public IFunctionNode getFunctionNode()
IFunctionDefinition
IFunctionNode
from which this definition was created,
if the definition came from the AST for a source file.
This method may require the AST to be reloaded or regenerated and therefore may be slow.
getFunctionNode
in interface IFunctionDefinition
public boolean isTopLevelDefinition()
isTopLevelDefinition
in class DefinitionBase
public boolean matches(DefinitionBase definition)
matches
in class DefinitionBase
protected void buildInnerString(StringBuilder sb)
public function f(int, String):void
.buildInnerString
in class DefinitionBase
Copyright © 2016 The Apache Software Foundation. All rights reserved.