Class EvaluatedExpressionCompilationUtils
java.lang.Object
io.micronaut.expressions.parser.ast.util.EvaluatedExpressionCompilationUtils
Unility methods for used when compiling evaluated expressions.
- Since:
- 4.0.0
- Author:
- Sergey Gavrilov
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic @NonNull ClassElement
getRequiredClassElement
(org.objectweb.asm.Type type, VisitorContext visitorContext) ProvidesClassElement
for passed type or throws exception if class element can not be provided.static boolean
isAssignable
(@NonNull ClassElement parameter, @NonNull ClassElement argument) Checks whether the argument class element is assignable to the parameter class element.static void
pushBoxPrimitiveIfNecessary
(@NonNull org.objectweb.asm.Type type, @NonNull org.objectweb.asm.commons.GeneratorAdapter mv) Pushed primitive boxing instruction if passed type is a wrapper.static void
pushPrimitiveCastIfNecessary
(@NonNull org.objectweb.asm.Type type, @NonNull org.objectweb.asm.Type targetType, @NonNull org.objectweb.asm.commons.GeneratorAdapter mv) This method checks whether passed primitive type needs to be explicitly cast to target type.static void
pushUnboxPrimitiveIfNecessary
(@NonNull org.objectweb.asm.Type type, @NonNull org.objectweb.asm.commons.GeneratorAdapter mv) Pushed unboxing instruction if passed type is a primitive wrapper.static Optional<PrimitiveElement>
toPrimitiveElement
(org.objectweb.asm.Type type)
-
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 parameterargument
- checked argument- Returns:
- whether argument is assignable to parameter
-
getRequiredClassElement
@NonNull public static @NonNull ClassElement getRequiredClassElement(org.objectweb.asm.Type type, VisitorContext visitorContext) ProvidesClassElement
for passed type or throws exception if class element can not be provided.- Parameters:
type
- Type element for whichClassElement
needs to be obtained. This type can also represent a primitive type. In this case it will be boxedvisitorContext
- 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 unboxmv
- 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 boxmv
- method visitor
-
toPrimitiveElement
- Parameters:
type
- type to be converted toPrimitiveElement
- 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 casttargetType
- target type to which the cast is requiredmv
- method visitor
-