java.lang.Object
org.jfuncmachine.compiler.model.expr.boxing.Autobox

public class Autobox extends Object
A utility to add boxing or unboxing as necessary.
  • Method Details

    • autobox

      public static Expression autobox(Expression expr, Type desiredType)
      Autobox an expression if necessary
      Parameters:
      expr - The expression to autobox
      desiredType - The desired type of the expression
      Returns:
      The expression wrapped with a Box or Unbox expression, or if no autoboxing is needed, the expression as-is
    • autoboxNeeded

      public static boolean autoboxNeeded(Expression expr, Type desiredType)
      Returns true if the expression needs to be autoboxed to be of the desired type
      Parameters:
      expr - The expression to be examined
      desiredType - The desired type of the expression
      Returns:
      True if the expression needs autoboxing