Package org.protelis.lang.datatype
Class FunctionDefinition
- java.lang.Object
-
- org.protelis.lang.datatype.FunctionDefinition
-
- All Implemented Interfaces:
java.io.Serializable
public final class FunctionDefinition extends java.lang.Object implements java.io.SerializableFirst-class Protelis function.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description FunctionDefinition(org.protelis.parser.protelis.FunctionDef functionDefinition, java.util.function.Supplier<ProtelisAST<?>> bodySupplier)FunctionDefinition(org.protelis.parser.protelis.Lambda lambda, java.util.List<Reference> args, ProtelisAST<?> body)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)ReferencegetArgumentByPosition(int i)ProtelisAST<?>getBody()java.lang.StringgetName()intgetParameterCount()byte[]getStackCode()inthashCode()booleaninvokerShouldInitializeIt()java.lang.StringtoString()
-
-
-
Constructor Detail
-
FunctionDefinition
public FunctionDefinition(org.protelis.parser.protelis.FunctionDef functionDefinition, java.util.function.Supplier<ProtelisAST<?>> bodySupplier)- Parameters:
functionDefinition- original parsed functionbodySupplier- body calculator
-
FunctionDefinition
public FunctionDefinition(org.protelis.parser.protelis.Lambda lambda, java.util.List<Reference> args, ProtelisAST<?> body)- Parameters:
lambda- lambda expressionargs- arguments for this lambdabody- the function body
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
getArgumentByPosition
public Reference getArgumentByPosition(int i)
- Parameters:
i- argument position- Returns:
- argument internal name
-
getBody
public ProtelisAST<?> getBody()
- Returns:
- the body of the function as defined. All annotations for the body are cleared. No side effects.
-
getName
public java.lang.String getName()
- Returns:
- function name
-
getParameterCount
public int getParameterCount()
- Returns:
- number of arguments
-
getStackCode
public byte[] getStackCode()
- Returns:
- a special hash code to identify this function in the call stack
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
invokerShouldInitializeIt
public boolean invokerShouldInitializeIt()
- Returns:
- true if this function definition was originated from a Kotlin-style lambda without explicit arguments, hence may be invoked with a single parameter 'it'
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-