Interface SerializerConstantPool
-
public interface SerializerConstantPool
Experimental API. May change without notice. This interface is used as bridge between thePostOrderDeserializer
,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 aUnsupportedOperationException
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.Class<?>
getClass(int cpi)
Returns theClass
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.java.lang.Object
getObject(java.lang.Class<?> clazz, int cpi)
Stores a value in the constant pool that is not a java native type, a java native-wrapper class or aClass
instance.int
putClass(java.lang.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(java.lang.Class<?> clazz, java.lang.Object value)
Returns the constant pool index of a value that is not a java native type, a java native-wrapper class or aClass
instance.
-
-
-
Method Detail
-
putObject
int putObject(java.lang.Class<?> clazz, java.lang.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 aClass
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 aUnsupportedConstantPoolTypeException
should be thrown.- Parameters:
clazz
- theClass
of the valuevalue
- 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
java.lang.Object getObject(java.lang.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 aClass
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 aUnsupportedConstantPoolTypeException
should be thrown.- Parameters:
clazz
- theClass
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.java.lang.IllegalArgumentException
- if the provided cpi is not a valid constant pool index.
-
putClass
int putClass(java.lang.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
java.lang.Class<?> getClass(int cpi)
Returns theClass
instance to the given constant pool index.- Parameters:
cpi
- the constant pool index- Returns:
- stored value
- Throws:
java.lang.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:
java.lang.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:
java.lang.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:
java.lang.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:
java.lang.IllegalArgumentException
- if the constant pool index is invalid.
-
-