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 TypeMethodDescriptionClass<?>getClass(int cpi) Returns theClassinstance to the given constant pool index.doublegetDouble(int cpi) Returns the stored double value to the given constant pool index from the constant pool.floatgetFloat(int cpi) Returns the stored float value to the given constant pool index from the constant pool.intgetInt(int cpi) Returns the stored int value to the given constant pool index from the constant pool.longgetLong(int cpi) Returns the stored long value to the given constant pool index from the constant pool.Stores a value in the constant pool that is not a java native type, a java native-wrapper class or aClassinstance.intStores a Class instance in the constant pool and returns the constant pool index.intputDouble(double value) Stores a double value in the constant pool and returns the constant pool index.intputFloat(float value) Stores a float value in the constant pool and returns the constant pool index.intputInt(int value) Stores an int value in the constant pool and returns the constant pool index.intputLong(long value) Stores a long value in the constant pool and returns the constant pool index.intReturns the constant pool index of a value that is not a java native type, a java native-wrapper class or aClassinstance.
-
Method Details
-
putObject
Returns the constant pool index of a value that is not a java native type, a java native-wrapper class or aClassinstance. 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 aUnsupportedConstantPoolTypeExceptionshould be thrown.- Parameters:
clazz- theClassof 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
Stores a value in the constant pool that is not a java native type, a java native-wrapper class or aClassinstance. 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 aUnsupportedConstantPoolTypeExceptionshould be thrown.- Parameters:
clazz- theClassof 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
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
Returns theClassinstance 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.
-