Class ScopedLambdaExpression

java.lang.Object
nz.org.riskscape.engine.rl.ScopedLambdaExpression

public class ScopedLambdaExpression extends Object

The result of calling RealizedExpression.evaluate(Object) on a Lambda that has been realized. This value can be passed to the user of the expression to execute it (or whatever)

  • Constructor Details

    • ScopedLambdaExpression

      public ScopedLambdaExpression(nz.org.riskscape.rl.ast.Lambda expression, nz.org.riskscape.engine.Tuple scope)
  • Method Details

    • buildCallingScope

      public nz.org.riskscape.engine.Tuple buildCallingScope(nz.org.riskscape.engine.types.Struct newScopeType, Object... lambdaValues)

      Build a tuple to use as the calling scope, i.e. what you pass to RealizedExpression.evaluate(Object) for this lambda expression. The calling scope combines this expression's closed over scope combined with the actual argument values passed to the lambda.

      Parameters:
      newScopeType - The type of the resulting tuple, typically built via ScopedLambdaType.buildCallingScopeType(nz.org.riskscape.engine.types.Type...)
      lambdaValues - The arguments supplied to the expression to call it with, e.g. the values of x and y from (x, y) -> x + y
      Returns:
      the combination of getScope() and the lambda arguments
    • getExpression

      public nz.org.riskscape.rl.ast.Lambda getExpression()

      The expression that has been returned. At the moment, RiskScape does not support 'dynamic expressions', so this will always be the same expression across evaluations of an expression

    • getScope

      public nz.org.riskscape.engine.Tuple getScope()

      The scope that this expression closes over. This should be the same object as the type of ScopedLambdaType.getScopeType() for the LambdaType that the function is realized against. That means that any struct member from the scope type can be used to access this tuple.

    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object