Class InvocationUtils

java.lang.Object
io.github.lukebemish.brainfrick.lang.runtime.InvocationUtils

public final class InvocationUtils extends Object
Contains methods used while invoking Caller instances from a compiled brainmap, or when attempting to box or unbox values in order to create integer indices during Cells.asInt(int).
  • Method Summary

    Modifier and Type
    Method
    Description
    static byte
    asB(Object obj)
    Attempts to unbox or convert a value to a byte.
    static char
    asC(Object obj)
    Attempts to unbox or convert a value to a char.
    static double
    asD(Object obj)
    Attempts to unbox or convert a value to a double.
    static float
    asF(Object obj)
    Attempts to unbox or convert a value to a float.
    static int
    asI(Object obj)
    Attempts to unbox or convert a value to an int.
    static long
    asJ(Object obj)
    Attempts to unbox or convert a value to a long.
    static short
    asS(Object obj)
    Attempts to unbox or convert a value to a short.
    static boolean
    asZ(Object obj)
    Attempts to unbox or convert a value to a boolean.
    static void
    checkEnough(int size, int needed)
    Checks whether the given buffer size is larger than the required buffer size.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • checkEnough

      public static void checkEnough(int size, int needed)
      Checks whether the given buffer size is larger than the required buffer size.
      Parameters:
      size - The number of values the buffer can provide.
      needed - The number of values needed to invoke the method.
      Throws:
      BufferTooSmallException - if the provided buffer size is less than the required size.
    • asI

      public static int asI(Object obj)
      Attempts to unbox or convert a value to an int.
      Parameters:
      obj - An object to unbox.
      Returns:
      An integer representation of the object.
      Throws:
      ImproperTypeException - if the value cannot be unboxed or converted.
      See Also:
    • asS

      public static short asS(Object obj)
      Attempts to unbox or convert a value to a short.
      Parameters:
      obj - An object to unbox.
      Returns:
      A short representation of the object.
      Throws:
      ImproperTypeException - if the value cannot be unboxed or converted.
      See Also:
    • asB

      public static byte asB(Object obj)
      Attempts to unbox or convert a value to a byte.
      Parameters:
      obj - An object to unbox.
      Returns:
      A byte representation of the object.
      Throws:
      ImproperTypeException - if the value cannot be unboxed or converted.
      See Also:
    • asC

      public static char asC(Object obj)
      Attempts to unbox or convert a value to a char.
      Parameters:
      obj - An object to unbox.
      Returns:
      A char representation of the object.
      Throws:
      ImproperTypeException - if the value cannot be unboxed or converted.
      See Also:
    • asJ

      public static long asJ(Object obj)
      Attempts to unbox or convert a value to a long.
      Parameters:
      obj - An object to unbox.
      Returns:
      A long representation of the object.
      Throws:
      ImproperTypeException - if the value cannot be unboxed or converted.
      See Also:
    • asF

      public static float asF(Object obj)
      Attempts to unbox or convert a value to a float.
      Parameters:
      obj - An object to unbox.
      Returns:
      A float representation of the object.
      Throws:
      ImproperTypeException - if the value cannot be unboxed or converted.
      See Also:
    • asD

      public static double asD(Object obj)
      Attempts to unbox or convert a value to a double.
      Parameters:
      obj - An object to unbox.
      Returns:
      A double representation of the object.
      Throws:
      ImproperTypeException - if the value cannot be unboxed or converted.
      See Also:
    • asZ

      public static boolean asZ(Object obj)
      Attempts to unbox or convert a value to a boolean.
      Parameters:
      obj - An object to unbox.
      Returns:
      A boolean representation of the object.
      See Also: