Package ru.ispras.fortress.transformer
Class Reducer
- java.lang.Object
-
- ru.ispras.fortress.transformer.Reducer
-
public final class Reducer extends java.lang.Object
Reducer
provides methods to reduce expressions to a value. Reduction is performed with the help of the calculator that evaluates specific subexpressions.
-
-
Constructor Summary
Constructors Constructor Description Reducer()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Node
reduce(CalculatorEngine engine, ReduceOptions options, Node expression)
Attempts to reduce the specified expression including to a value.static Node
reduce(CalculatorEngine engine, ValueProvider valueProvider, ReduceOptions options, Node expression)
Attempts to reduce the specified expression including to a value.static Node
reduce(Node expression)
Attempts to reduce the specified expression including to a value.static Node
reduce(ReduceOptions options, Node expression)
Attempts to reduce the specified expression including to a value.static Node
reduce(ValueProvider valueProvider, Node expression)
-
-
-
Method Detail
-
reduce
public static Node reduce(CalculatorEngine engine, ValueProvider valueProvider, ReduceOptions options, Node expression)
Attempts to reduce the specified expression including to a value. Reduction is performed with the help of the calculator object that performs specific operations with specific data types.The operation may be totally reduced (or, so to speak, reduced to a value), partially reduced or left unchanged. In the last case, the method returns a reference to the current operation (this).
- Parameters:
engine
- Calculator engine (ifnull
, the default engine to be used).valueProvider
- Provider of variable values to be used for expression reduction.options
- Option flags to tune the reduction strategy.expression
- Expression to be reduced.- Returns:
- Reduced expression (value or another operation expression with minimal subexpressions) or the initial expression if it is impossible to reduce it.
- Throws:
java.lang.IllegalArgumentException
- if any of the parameters isnull
.
-
reduce
public static Node reduce(ValueProvider valueProvider, Node expression)
-
reduce
public static Node reduce(Node expression)
Attempts to reduce the specified expression including to a value. Uses defaultengine
withReduceOptions.NEW_INSTANCE
policy.- Parameters:
expression
- Expression to be reduced.- Returns:
- Reduced expression.
- Throws:
java.lang.IllegalArgumentException
- if the parameter isnull
.- See Also:
reduce(CalculatorEngine, ReduceOptions, Node)
-
reduce
public static Node reduce(ReduceOptions options, Node expression)
Attempts to reduce the specified expression including to a value. Uses defaultengine
.- Parameters:
options
- Option flags to tune the reduction strategy.expression
- Expression to be reduced.- Returns:
- Reduced expression.
- Throws:
java.lang.IllegalArgumentException
- if any of the parameters isnull
.- See Also:
reduce(CalculatorEngine, ReduceOptions, Node)
-
reduce
public static Node reduce(CalculatorEngine engine, ReduceOptions options, Node expression)
Attempts to reduce the specified expression including to a value. Reduction is performed with the help of the calculator object that performs specific operations with specific data types.The operation may be totally reduced (or, so to speak, reduced to a value), partially reduced or left unchanged. In the last case, the method returns a reference to the current operation (this).
- Parameters:
engine
- Calculator engine (ifnull
, the default engine to be used).options
- Option flags to tune the reduction strategy.expression
- Expression to be reduced.- Returns:
- Reduced expression (value or another operation expression with minimal subexpressions) or the initial expression if it is impossible to reduce it.
- Throws:
java.lang.IllegalArgumentException
- if any of the parameters isnull
.
-
-