Interface SerializerConstantPool


public interface SerializerConstantPool
Experimental API. May change without notice. This interface is used as bridge between the PostOrderDeserializer, PostOrderSerializer and underlying constant pool implementation. A constant pool stores a value and returns an identifying index, with which the object can later be returned from the pool again. All methods of this class are optional and may throw a UnsupportedOperationException.
  • Method Summary

    Modifier and Type
    Method
    Description
    getClass(int cpi)
    Returns the Class instance to the given constant pool index.
    double
    getDouble(int cpi)
    Returns the stored double value to the given constant pool index from the constant pool.
    float
    getFloat(int cpi)
    Returns the stored float value to the given constant pool index from the constant pool.
    int
    getInt(int cpi)
    Returns the stored int value to the given constant pool index from the constant pool.
    long
    getLong(int cpi)
    Returns the stored long value to the given constant pool index from the constant pool.
    getObject(Class<?> clazz, int cpi)
    Stores a value in the constant pool that is not a java native type, a java native-wrapper class or a Class instance.
    int
    putClass(Class<?> value)
    Stores a Class instance in the constant pool and returns the constant pool index.
    int
    putDouble(double value)
    Stores a double value in the constant pool and returns the constant pool index.
    int
    putFloat(float value)
    Stores a float value in the constant pool and returns the constant pool index.
    int
    putInt(int value)
    Stores an int value in the constant pool and returns the constant pool index.
    int
    putLong(long value)
    Stores a long value in the constant pool and returns the constant pool index.
    int
    putObject(Class<?> clazz, Object value)
    Returns the constant pool index of a value that is not a java native type, a java native-wrapper class or a Class instance.
  • Method Details

    • putObject

      int putObject(Class<?> clazz, Object value) throws UnsupportedConstantPoolTypeException
      Returns the constant pool index of a value that is not a java native type, a java native-wrapper class or a Class instance. The implementor should support all additional types that are necessary to serialize a truffle AST for a specific truffle implementation. If a type is not supported by this constant pool implementation a UnsupportedConstantPoolTypeException should be thrown.
      Parameters:
      clazz - the Class of the value
      value - the value to be stored. Must be at least a subclass of the given clazz.
      Returns:
      the constant pool index
      Throws:
      UnsupportedConstantPoolTypeException - if a type is not supported for persistence in the constant pool.
    • getObject

      Object getObject(Class<?> clazz, int cpi) throws UnsupportedConstantPoolTypeException
      Stores a value in the constant pool that is not a java native type, a java native-wrapper class or a Class instance. The implementor should support all additional types that are necessary to serialize a truffle AST for a specific truffle implementation. If a type is not supported by this constant pool implementation a UnsupportedConstantPoolTypeException should be thrown.
      Parameters:
      clazz - the Class of the value in the constant pool.
      cpi - the previously returned index
      Returns:
      the value stored inside the constant pool
      Throws:
      UnsupportedConstantPoolTypeException - if a type is not supported for persistence in the constant pool.
      IllegalArgumentException - if the provided cpi is not a valid constant pool index.
    • putClass

      int putClass(Class<?> value)
      Stores a Class instance in the constant pool and returns the constant pool index.
      Parameters:
      value - the class to store
      Returns:
      the new or existing constant pool index of the Class
    • getClass

      Class<?> getClass(int cpi)
      Returns the Class instance to the given constant pool index.
      Parameters:
      cpi - the constant pool index
      Returns:
      stored value
      Throws:
      IllegalArgumentException - if the constant pool indes is invalid.
    • putInt

      int putInt(int value)
      Stores an int value in the constant pool and returns the constant pool index.
      Parameters:
      value - the value to store
      Returns:
      the new or existing constant pool index of the value
    • getInt

      int getInt(int cpi)
      Returns the stored int value to the given constant pool index from the constant pool.
      Parameters:
      cpi - the constant pool index
      Returns:
      stored value
      Throws:
      IllegalArgumentException - if the constant pool index is invalid.
    • putLong

      int putLong(long value)
      Stores a long value in the constant pool and returns the constant pool index.
      Parameters:
      value - the value to store
      Returns:
      the new or existing constant pool index of the value
    • getLong

      long getLong(int cpi)
      Returns the stored long value to the given constant pool index from the constant pool.
      Parameters:
      cpi - the constant pool index
      Returns:
      the stored value
      Throws:
      IllegalArgumentException - if the constant pool index is invalid.
    • putDouble

      int putDouble(double value)
      Stores a double value in the constant pool and returns the constant pool index.
      Parameters:
      value - the value to store
      Returns:
      the new or existing constant pool index of the value
    • getDouble

      double getDouble(int cpi)
      Returns the stored double value to the given constant pool index from the constant pool.
      Parameters:
      cpi - the constant pool index
      Returns:
      the stored value
      Throws:
      IllegalArgumentException - if the constant pool index is invalid.
    • putFloat

      int putFloat(float value)
      Stores a float value in the constant pool and returns the constant pool index.
      Parameters:
      value - the value to store
      Returns:
      the new or existing constant pool index of the value
    • getFloat

      float getFloat(int cpi)
      Returns the stored float value to the given constant pool index from the constant pool.
      Parameters:
      cpi - the constant pool index
      Returns:
      the stored value
      Throws:
      IllegalArgumentException - if the constant pool index is invalid.