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

public class ReturnUtils extends Object
Contains utility methods used by brainfrick to handle casting to return types.
  • Method Details

    • fromChars

      public static String fromChars(List list)
      Creates a string from a buffer. If the buffer contains a string at the top, that string should be returned. Otherwise, each element of the buffer should be converted to a character and the output string assembled from those. Called at the end of brainfrick methods returning a String
      Parameters:
      list - The buffer to assemble a string from.
      Returns:
      A string to be returned by the brainfrick method.
      Throws:
      BufferTooSmallException - if the buffer does not contain at least one item.
      ImproperTypeException - if a member of the buffer cannot be converted to a character.
    • fromBuffer

      public static Object fromBuffer(List list)
      Gets a value to return from the top of a buffer. Called at the end of brainfrick methods whose return tyoes do not have special cases.
      Parameters:
      list - The buffer to assemble a string from.
      Returns:
      An object to be returned, after type conversion, by the brainfrick method.
      Throws:
      BufferTooSmallException - if the buffer does not contain at least one item.
      See Also: