Class 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 Detail

      • FunctionDefinition

        public FunctionDefinition​(org.protelis.parser.protelis.FunctionDef functionDefinition,
                                  java.util.function.Supplier<ProtelisAST<?>> bodySupplier)
        Parameters:
        functionDefinition - original parsed function
        bodySupplier - body calculator
      • FunctionDefinition

        public FunctionDefinition​(org.protelis.parser.protelis.Lambda lambda,
                                  java.util.List<Reference> args,
                                  ProtelisAST<?> body)
        Parameters:
        lambda - lambda expression
        args - arguments for this lambda
        body - the function body
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.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 class java.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 class java.lang.Object