Class ApplyOperatorPromotion

java.lang.Object
de.firemage.autograder.core.integrated.evaluator.fold.ApplyOperatorPromotion
All Implemented Interfaces:
Fold

public final class ApplyOperatorPromotion extends Object implements Fold
For some binary and unary operator expressions, the operands are cast to a different type before the operation is applied. This fold applies that cast to the operands (if they are literals).
  • Field Details

  • Method Details

    • create

      public static Fold create()
      Creates a new instance of this fold.

      It applies the operator promotion by default only on binary and unary operators with literal operands.

      Returns:
      the instance of this fold
    • create

      public static Fold create(ApplyOperatorPromotion.OperatorPredicate<? super spoon.reflect.code.CtBinaryOperator<?>> shouldApplyOnBinaryOperator, ApplyOperatorPromotion.OperatorPredicate<? super spoon.reflect.code.CtUnaryOperator<?>> shouldApplyOnUnaryOperator)
    • foldCtBinaryOperator

      public <T> spoon.reflect.code.CtExpression<T> foldCtBinaryOperator(spoon.reflect.code.CtBinaryOperator<T> ctBinaryOperator)
      Specified by:
      foldCtBinaryOperator in interface Fold
    • foldCtUnaryOperator

      public <T> spoon.reflect.code.CtExpression<T> foldCtUnaryOperator(spoon.reflect.code.CtUnaryOperator<T> ctUnaryOperator)
      Specified by:
      foldCtUnaryOperator in interface Fold