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.Serializable
First-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 boolean
equals(java.lang.Object o)
Reference
getArgumentByPosition(int i)
ProtelisAST<?>
getBody()
java.lang.String
getName()
int
getParameterCount()
byte[]
getStackCode()
int
hashCode()
boolean
invokerShouldInitializeIt()
java.lang.String
toString()
-
-
-
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:
equals
in 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:
hashCode
in 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:
toString
in classjava.lang.Object
-
-