Class Lambda


public class Lambda extends Expression
A lambda (anonymous function) expression
  • Field Details

    • parameters

      public final Field[] parameters
      The lambda parameters
    • body

      public final Expression body
      The body of the lambda
    • returnType

      public final Type returnType
      The return type of the lambda
    • interfaceType

      public final Type interfaceType
      The type of the interface representing the lambda
    • interfaceMethodName

      public final String interfaceMethodName
      The name of the method in the lambda's interface
    • parameterTypes

      public Type[] parameterTypes
      The types of the lambda parameters
    • useObjectInterface

      public final boolean useObjectInterface
      If true, the interface describing this lambda should use objects instead of native types. This allows it to be compatible with the java.util.function package
  • Constructor Details

    • Lambda

      public Lambda(Field[] parameters, Type returnType, Expression body)
      Create a lambda expression
      Parameters:
      parameters - The lambda parameters and their types
      returnType - The lambda return type
      body - The body of the lambda
    • Lambda

      public Lambda(Field[] parameters, Type returnType, Expression body, String filename, int lineNumber)
      Create a lambda expression
      Parameters:
      parameters - The lambda parameters and their types
      returnType - The lambda return type
      body - The body of the lambda
      filename - The source filename this expression is associated with
      lineNumber - The source line number this expression is associated with
    • Lambda

      public Lambda(Type interfaceType, String interfaceMethodName, Field[] parameters, Type returnType, Expression body)
      Create a lambda expression
      Parameters:
      interfaceType - The type of the lambda interface
      interfaceMethodName - The name of the interface method to generate
      parameters - The lambda parameters and their types
      returnType - The lambda return type
      body - The body of the lambda
    • Lambda

      public Lambda(Type interfaceType, String interfaceMethodName, Field[] parameters, Type returnType, Expression body, String filename, int lineNumber)
      Create a lambda expression
      Parameters:
      interfaceType - The type of the lambda interface
      interfaceMethodName - The name of the interface method to generate
      parameters - The lambda parameters and their types
      returnType - The lambda return type
      body - The body of the lambda
      filename - The source filename this expression is associated with
      lineNumber - The source line number this expression is associated with
    • Lambda

      public Lambda(Field[] parameters, Type returnType, boolean useObjectInterface, Expression body)
      Create a lambda expression
      Parameters:
      parameters - The lambda parameters and their types
      returnType - The lambda return type
      useObjectInterface - If true, the lambda interface should not use native types
      body - The body of the lambda
    • Lambda

      public Lambda(Field[] parameters, Type returnType, boolean useObjectInterface, Expression body, String filename, int lineNumber)
      Create a lambda expression
      Parameters:
      parameters - The lambda parameters and their types
      returnType - The lambda return type
      useObjectInterface - If true, the lambda interface should not use native types
      body - The body of the lambda
      filename - The source filename this expression is associated with
      lineNumber - The source line number this expression is associated with
    • Lambda

      public Lambda(Type interfaceType, String interfaceMethodName, Field[] parameters, Type returnType, boolean useObjectInterface, Expression body)
      Create a lambda expression
      Parameters:
      interfaceType - The type of the lambda interface
      interfaceMethodName - The name of the interface method to generate
      parameters - The lambda parameters and their types
      returnType - The lambda return type
      useObjectInterface - If true, the lambda interface should not use native types
      body - The body of the lambda
    • Lambda

      public Lambda(Type interfaceType, String interfaceMethodName, Field[] parameters, Type returnType, boolean useObjectInterface, Expression body, String filename, int lineNumber)
      Create a lambda expression
      Parameters:
      interfaceType - The type of the lambda interface
      interfaceMethodName - The name of the interface method to generate
      parameters - The lambda parameters and their types
      returnType - The lambda return type
      useObjectInterface - If true, the lambda interface should not use native types
      body - The body of the lambda
      filename - The source filename this expression is associated with
      lineNumber - The source line number this expression is associated with
  • Method Details

    • getType

      public Type getType()
      Description copied from class: Expression
      Get the type returned by this expression
      Specified by:
      getType in class Expression
      Returns:
      The type of this expression
    • reset

      public void reset()
      Description copied from class: Expression
      Resets any labels in expressions so that the method can be regenerated
      Overrides:
      reset in class Expression
    • findCaptured

      public void findCaptured(Environment env)
      Description copied from class: Expression
      Search for local variables that would be captured by a lambda. Each expression has its own implementation of this, because each subexpression must be searched.
      Specified by:
      findCaptured in class Expression
      Parameters:
      env - The environment chain to search
    • convertToFullTailCalls

      public Expression convertToFullTailCalls(boolean inTailPosition)
      Description copied from class: Expression
      Converts this expression to one that is compatible with full tail call optimization
      Specified by:
      convertToFullTailCalls in class Expression
      Parameters:
      inTailPosition - True if this expression is called from the tail position
      Returns:
      A version of this expression whose types are compatible with full tail call optimization
    • generate

      public void generate(ClassGenerator generator, Environment env, boolean inTailPosition)
      Description copied from class: Expression
      Generate the bytecode for this expression
      Specified by:
      generate in class Expression
      Parameters:
      generator - The generator for generating instructions and additional declarations
      env - The environment containing the local variables currently visible to this expression
      inTailPosition - True if this expression is being generated from the tail position of the method