Class EvaluatedExpressionCompilationUtils

java.lang.Object
io.micronaut.expressions.parser.ast.util.EvaluatedExpressionCompilationUtils

@Internal public final class EvaluatedExpressionCompilationUtils extends Object
Unility methods for used when compiling evaluated expressions.
Since:
4.0.0
Author:
Sergey Gavrilov
  • Constructor Details

    • EvaluatedExpressionCompilationUtils

      public EvaluatedExpressionCompilationUtils()
  • Method Details

    • isAssignable

      public static boolean isAssignable(@NonNull @NonNull ClassElement parameter, @NonNull @NonNull ClassElement argument)
      Checks whether the argument class element is assignable to the parameter class element. This method also accepts primitive and wrapper elements and determines whether argument can be assigned to parameter after boxing or unboxing. In case when parameter or argument is an array, array dimensions are also checked.
      Parameters:
      parameter - checked parameter
      argument - checked argument
      Returns:
      whether argument is assignable to parameter
    • getRequiredClassElement

      @NonNull public static @NonNull ClassElement getRequiredClassElement(org.objectweb.asm.Type type, VisitorContext visitorContext)
      Provides ClassElement for passed type or throws exception if class element can not be provided.
      Parameters:
      type - Type element for which ClassElement needs to be obtained. This type can also represent a primitive type. In this case it will be boxed
      visitorContext - visitor context
      Returns:
      resolved class element
      Throws:
      ExpressionCompilationException - if class element can not be obtained
    • pushUnboxPrimitiveIfNecessary

      public static void pushUnboxPrimitiveIfNecessary(@NonNull @NonNull org.objectweb.asm.Type type, @NonNull @NonNull org.objectweb.asm.commons.GeneratorAdapter mv)
      Pushed unboxing instruction if passed type is a primitive wrapper.
      Parameters:
      type - type to unbox
      mv - method visitor
    • pushBoxPrimitiveIfNecessary

      public static void pushBoxPrimitiveIfNecessary(@NonNull @NonNull org.objectweb.asm.Type type, @NonNull @NonNull org.objectweb.asm.commons.GeneratorAdapter mv)
      Pushed primitive boxing instruction if passed type is a wrapper.
      Parameters:
      type - type to box
      mv - method visitor
    • toPrimitiveElement

      public static Optional<PrimitiveElement> toPrimitiveElement(org.objectweb.asm.Type type)
      Parameters:
      type - type to be converted to PrimitiveElement
      Returns:
      optional corresponding primitive element
    • pushPrimitiveCastIfNecessary

      public static void pushPrimitiveCastIfNecessary(@NonNull @NonNull org.objectweb.asm.Type type, @NonNull @NonNull org.objectweb.asm.Type targetType, @NonNull @NonNull org.objectweb.asm.commons.GeneratorAdapter mv)
      This method checks whether passed primitive type needs to be explicitly cast to target type. If it is, respective cast instruction is pushed.
      Parameters:
      type - type to cast
      targetType - target type to which the cast is required
      mv - method visitor