Approximate size of the given value in bytes.
Approximate size of the given value in bytes. It is actual size only for primitive types.
Returns true if dataSize doesn't depend on data value.
Returns true if dataSize doesn't depend on data value. This is useful for optimizations of calculating sizes of collections. The method should have O(1) amortized complexity over n invocations to avoid over-cost attacks on ErgoTree interpretation.
Type code used in serialization of SType values.
Type code used in serialization of SType values.
TypeSerializer
Elvis operator for types.
Elvis operator for types. See https://en.wikipedia.org/wiki/Elvis_operator
Returns true if this type embeddable, i.e.
Returns true if this type embeddable, i.e. a type that can be combined with type
constructor for optimized encoding. For each embeddable type T
, and type
constructor C
, the type C[T]
can be represented by a single byte.
Returns parsable type term string of the type described by this type descriptor.
Returns parsable type term string of the type described by this type descriptor. For every type it should be inverse to SigmaTyper.parseType. This is default fallback implementation, should be overriden if it is not correct for a particular type.
Every type descriptor is a tree represented by nodes in SType hierarchy. In order to extend type family: - Implement concrete class derived from SType - Implement serializer (see SCollectionSerializer) and register it in STypeSerializer.table Each SType is serialized to array of bytes by: - emitting typeCode of each node (see special case for collections below) - then recursively serializing subtrees from left to right on each level - for each collection of primitive type there is special type code to emit single byte instead of two bytes Types code intervals - (1 .. MaxPrimTypeCode) // primitive types - (CollectionTypeCode .. CollectionTypeCode + MaxPrimTypeCode) // collections of primitive types - (MaxCollectionTypeCode ..) // Other types Collection of non-primitive type is serialized as (CollectionTypeCode, serialize(elementType))