Class ScopedLambdaExpression
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 Summary
ConstructorDescriptionScopedLambdaExpression
(nz.org.riskscape.rl.ast.Lambda expression, nz.org.riskscape.engine.Tuple scope) -
Method Summary
Modifier and TypeMethodDescriptionnz.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.protected boolean
boolean
nz.org.riskscape.rl.ast.Lambda
The expression that has been returned.nz.org.riskscape.engine.Tuple
getScope()
The scope that this expression closes over.int
hashCode()
toString()
-
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 viaScopedLambdaType.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 theLambdaType
that the function is realized against. That means that any struct member from the scope type can be used to access this tuple. -
equals
-
canEqual
-
hashCode
public int hashCode() -
toString
-