SerializerOperation

enum SerializerOperation : Enum<SerializerOperation>

A SerializerOpcode describes how to disassemble and assemble the various kinds of objects encountered in Avail.

The ordinal is passed in the constructor as a cross-check, to increase the difficulty of (accidentally) changing the serialized representation without due care for migration of existing serialized data.

Author

Mark van Gulik

Parameters

shouldCaptureObject

Whether, during serialization, this operation should record the provided object as a value to capture for use in pumping other serializers and deserializers.

ordinal

The ordinal of this enum value, supplied as a cross-check to reduce the chance of accidental incompatibility due to the addition of new categories of Avail objects.

operands

The list of operands that describe the interpretation of a stream of bytes written with this SerializerOperation.

Entries

Link copied to clipboard
READ_WRITE_VARIABLE_TYPE(101, OBJECT_REFERENCE.named("read type"), OBJECT_REFERENCE.named("write type"))

A variable type for which the read type and write type are (actually) unequal.

Link copied to clipboard
SIMPLE_VARIABLE_TYPE(100, OBJECT_REFERENCE.named("content type"))

A variable type for which the read type and write type are equal.

Link copied to clipboard
LIST_NODE_TYPE(99, BYTE.named("list phrase kind"), OBJECT_REFERENCE.named("expression type"), OBJECT_REFERENCE.named("subexpressions tuple type"))
Link copied to clipboard
PHRASE_TYPE(98, BYTE.named("kind"), OBJECT_REFERENCE.named("expression type"))
Link copied to clipboard
LITERAL_TOKEN_TYPE(97, OBJECT_REFERENCE.named("literal type"))
Link copied to clipboard
TOKEN_TYPE(96, OBJECT_REFERENCE.named("literal type"))
Link copied to clipboard
MAP_TYPE(95, OBJECT_REFERENCE.named("size range"), OBJECT_REFERENCE.named("key type"), OBJECT_REFERENCE.named("value type"))
Link copied to clipboard
SET_TYPE(94, OBJECT_REFERENCE.named("size range"), OBJECT_REFERENCE.named("element type"))
Link copied to clipboard
INSTANCE_META(93, OBJECT_REFERENCE.named("meta's instance"))

An Avail instance meta, a type that has an instance i, which is itself a type. Subtypes of type i are also considered instances of this instance meta.

Link copied to clipboard
INSTANCE_TYPE(92, OBJECT_REFERENCE.named("type's instance"))

An Avail singular enumeration, a type that has a single (non-type) instance.

Link copied to clipboard
ENUMERATION_TYPE(91, TUPLE_OF_OBJECTS.named("set of instances"))

An Avail enumeration, a type that has an explicit finite list of its instances.

Link copied to clipboard
CONTINUATION_TYPE(90, OBJECT_REFERENCE.named("function type for continuation type"))

The bottom pojo type, representing the most specific type of pojo.

Link copied to clipboard
COMPILED_CODE_TYPE(89, OBJECT_REFERENCE.named("function type for code type"))

The bottom pojo type, representing the most specific type of pojo.

Link copied to clipboard

The bottom pojo type, representing the most specific type of pojo.

Link copied to clipboard
SELF_POJO_TYPE_REPRESENTATIVE(87, TUPLE_OF_OBJECTS.named("class names"))

A set of class standing in for a pojo type representing a "self type". A self type is used for for parameterizing a Java class by itself. For example, in the parametric type Enum<E extends Enum<E>>, we parameterize the class Enum with such a self type. To reconstruct a self type all we need is a way to get to the raw Java classes involved, so we serialize their names.

Link copied to clipboard
ARRAY_POJO_TYPE(86, OBJECT_REFERENCE.named("content type"), OBJECT_REFERENCE.named("size range"))

A pojo type representing a Java array type. We can reconstruct this array type from the content type and the range of allowable sizes (a much stronger model than Java itself supports).

Link copied to clipboard
FUSED_POJO_TYPE(85, GENERAL_MAP.named("ancestor parameterizations map"))

A pojo type for which AvailObject.isPojoFusedType is true. This indicates a representation without the juicy class filling, so we have to say how each ancestor is parameterized.

Link copied to clipboard
UNFUSED_POJO_TYPE(84, OBJECT_REFERENCE.named("class name"), TUPLE_OF_OBJECTS.named("class parameterization"))

A pojo type for which AvailObject.isPojoFusedType is false. This indicates a representation with a juicy class filling, which allows a particularly compact representation involving the class name and its parameter types.

Link copied to clipboard
INTEGER_RANGE_TYPE(83, BYTE.named("Inclusive flags"), OBJECT_REFERENCE.named("Lower bound"), OBJECT_REFERENCE.named("Upper bound"))
Link copied to clipboard
TUPLE_TYPE(82, OBJECT_REFERENCE.named("Tuple sizes"), TUPLE_OF_OBJECTS.named("Leading types"), OBJECT_REFERENCE.named("Default type"))
Link copied to clipboard
FUNCTION_TYPE(81, OBJECT_REFERENCE.named("Arguments tuple type"), OBJECT_REFERENCE.named("Return type"), TUPLE_OF_OBJECTS.named("Checked exceptions"))
Link copied to clipboard
FIBER_TYPE(80, OBJECT_REFERENCE.named("Result type"))
Link copied to clipboard

Reserved for future use.

Link copied to clipboard

Reserved for future use.

Link copied to clipboard
SEQUENCE_AS_EXPRESSION_PHRASE(77, OBJECT_REFERENCE.named("sequence"))
Link copied to clipboard
STATIC_POJO_FIELD(76, OBJECT_REFERENCE.named("class name"), OBJECT_REFERENCE.named("field name"))

A variable bound to a static Java field.

Link copied to clipboard
ARBITRARY_PRIMITIVE_TYPE(false, 75, BYTE.named("primitive type ordinal"))

An arbitrary primitive type that is not already a special object. Exists primarily to support hidden types that are not exposed directly to an Avail programmer but which must still be visible to the serialization mechanism.

Link copied to clipboard
MARKER_PHRASE(74, OBJECT_REFERENCE.named("value"), OBJECT_REFERENCE.named("yield type"))

A marker phrase. These should not be created during normal parsing, and must be transformed into other phrases by some means before code generation.

Link copied to clipboard
VARIABLE_USE_PHRASE(73, OBJECT_REFERENCE.named("use token"), OBJECT_REFERENCE.named("declaration"))
Link copied to clipboard
SUPER_CAST_PHRASE(72, OBJECT_REFERENCE.named("expression"), OBJECT_REFERENCE.named("type for lookup"))
Link copied to clipboard
SEQUENCE_PHRASE(71, TUPLE_OF_OBJECTS.named("statements"))
Link copied to clipboard
SEND_PHRASE(70, OBJECT_REFERENCE.named("bundle"), OBJECT_REFERENCE.named("arguments list phrase"), OBJECT_REFERENCE.named("return type"), TUPLE_OF_OBJECTS.named("tokens"))
Link copied to clipboard
REFERENCE_PHRASE(69, OBJECT_REFERENCE.named("variable use"))
Link copied to clipboard
PERMUTED_LIST_PHRASE(68, OBJECT_REFERENCE.named("list phrase"), TUPLE_OF_OBJECTS.named("permutation"))
Link copied to clipboard
MACRO_SUBSTITUTION_PHRASE(67, OBJECT_REFERENCE.named("original phrase"), OBJECT_REFERENCE.named("output phrase"))
Link copied to clipboard
LITERAL_PHRASE(66, OBJECT_REFERENCE.named("literal token"))
Link copied to clipboard
LIST_PHRASE(65, TUPLE_OF_OBJECTS.named("expressions"))
Link copied to clipboard
FIRST_OF_SEQUENCE_PHRASE(64, TUPLE_OF_OBJECTS.named("statements"))
Link copied to clipboard
EXPRESSION_AS_STATEMENT_PHRASE(63, OBJECT_REFERENCE.named("expression"))
Link copied to clipboard
DECLARATION_PHRASE(62, BYTE.named("declaration kind ordinal"), OBJECT_REFERENCE.named("token"), OBJECT_REFERENCE.named("declared type"), OBJECT_REFERENCE.named("type expression"), OBJECT_REFERENCE.named("initialization expression"), OBJECT_REFERENCE.named("literal object"))
Link copied to clipboard
BLOCK_PHRASE(61, TUPLE_OF_OBJECTS.named("arguments tuple"), COMPRESSED_ARBITRARY_CHARACTER_TUPLE.named("primitive name"), TUPLE_OF_OBJECTS.named("statements tuple"), OBJECT_REFERENCE.named("result type"), TUPLE_OF_OBJECTS.named("declared exceptions"), UNSIGNED_INT.named("starting line number"), TUPLE_OF_OBJECTS.named("tokens"))
Link copied to clipboard
ASSIGNMENT_PHRASE(60, BYTE.named("flags"), OBJECT_REFERENCE.named("variable"), OBJECT_REFERENCE.named("expression"), OBJECT_REFERENCE.named("tokens"))
Link copied to clipboard
RAW_PRIMITIVE_JAVA_CLASS(59, OBJECT_REFERENCE.named("primitive class name"))

The serialization of a raw (unparameterized) Java primitiveClass.

Link copied to clipboard
RAW_POJO_CONSTRUCTOR(58, OBJECT_REFERENCE.named("declaring class pojo"), OBJECT_REFERENCE.named("marshaled argument pojo types"))

An instance of Constructor, likely created as part of P_CreatePojoConstructorFunction.

Link copied to clipboard
RAW_POJO_METHOD(57, OBJECT_REFERENCE.named("declaring class pojo"), OBJECT_REFERENCE.named("method name string"), OBJECT_REFERENCE.named("marshaled argument pojo types"))

An instance of Method, likely created as part of P_CreatePojoInstanceMethodFunction. The method may be an instance method or a static method.

Link copied to clipboard
RAW_NONPRIMITIVE_JAVA_CLASS(56, OBJECT_REFERENCE.named("class name"))

The serialization of a raw (unparameterized) Java primitiveClass.

Link copied to clipboard
RAW_POJO_NULL(false, 55)

The raw pojo for the Java null value.

Link copied to clipboard
EXPLICIT_SUBCLASS_ATOM(54, OBJECT_REFERENCE.named("atom name"), OBJECT_REFERENCE.named("module name"))

An atom which is used for creating explicit subclasses. Output the atom name and the name of the module that issued it. Look up the corresponding atom during reconstruction, recreating it if it's not present and supposed to have been issued by the current module.

Link copied to clipboard
MODULE(53, OBJECT_REFERENCE.named("module name"))

A reference to a module, possibly the one being constructed.

Link copied to clipboard
MESSAGE_BUNDLE(52, OBJECT_REFERENCE.named("message atom"))

A reference to a message bundle, which should be reconstructed by looking it up.

Link copied to clipboard
FORWARD_DEFINITION(51, OBJECT_REFERENCE.named("method"), OBJECT_REFERENCE.named("signature"))

A reference to a forward, which should be reconstructed by looking it up.

Link copied to clipboard
ABSTRACT_DEFINITION(50, OBJECT_REFERENCE.named("method"), OBJECT_REFERENCE.named("signature"))

A reference to an abstract, which should be reconstructed by looking it up.

Link copied to clipboard
MACRO_DEFINITION(49, OBJECT_REFERENCE.named("bundle"), OBJECT_REFERENCE.named("signature"))

A reference to a macro, which should be reconstructed by looking it up.

Link copied to clipboard
METHOD_DEFINITION(48, OBJECT_REFERENCE.named("method"), OBJECT_REFERENCE.named("signature"))

A reference to a method, which should be reconstructed by looking it up.

Link copied to clipboard
METHOD(47, TUPLE_OF_OBJECTS.named("module name / atom name pairs"))

A reference to a method that should be looked up during deserialization. A method can have multiple message bundles, and each pair is recorded during serialization. For system atoms we output nil for the module name. During deserialization, the list is searched for a module that has been loaded, and if the corresponding name is an atom, and if that atom has a bundle associated with it, that bundle's method is used.

Link copied to clipboard
CONTINUATION(46, OBJECT_REFERENCE.named("calling continuation"), OBJECT_REFERENCE.named("continuation's function"), TUPLE_OF_OBJECTS.named("continuation frame slots"), COMPRESSED_SHORT.named("program counter"), COMPRESSED_SHORT.named("stack pointer"))

The representation of a continuation, which is just its level one state.

Link copied to clipboard
ASSIGN_TO_VARIABLE(false, 45, OBJECT_REFERENCE.named("variable to assign"), OBJECT_REFERENCE.named("value to assign"))

This special opcode causes a previously built variable to have a previously built value to be assigned to it at this point during deserialization.

Link copied to clipboard
COMMENT_TOKEN(44, COMPRESSED_ARBITRARY_CHARACTER_TUPLE.named("token string"), SIGNED_INT.named("start position"), SIGNED_INT.named("line number"))
Link copied to clipboard
LITERAL_TOKEN(43, OBJECT_REFERENCE.named("token string"), OBJECT_REFERENCE.named("literal value"), SIGNED_INT.named("start position"), SIGNED_INT.named("line number"))
Link copied to clipboard
TOKEN(42, COMPRESSED_ARBITRARY_CHARACTER_TUPLE.named("token string"), SIGNED_INT.named("start position"), SIGNED_INT.named("line number"), BYTE.named("token type code"))
Link copied to clipboard
SET(41, TUPLE_OF_OBJECTS.named("tuple of objects"))

A set. Convert it to a tuple and work with that, converting it back to a set when deserializing.

Link copied to clipboard
GLOBAL_VARIABLE(40, OBJECT_REFERENCE.named("variable type"), OBJECT_REFERENCE.named("module name"), COMPRESSED_ARBITRARY_CHARACTER_TUPLE.named("variable name"), BYTE.named("flags"))

A global variable. It's serialized as the type, the module that defined it, the variable's name within that module, and a flag byte.

Link copied to clipboard
LOCAL_VARIABLE(39, OBJECT_REFERENCE.named("variable type"))

A non-global variable. Deserialization reconstructs a new one, since there's no way to know where the original one came from.

Link copied to clipboard
GENERAL_FUNCTION(38, OBJECT_REFERENCE.named("Compiled code"), TUPLE_OF_OBJECTS.named("Outer values"))

A function with one or more outer (lexically captured) variables.

Link copied to clipboard
CLEAN_FUNCTION(37, OBJECT_REFERENCE.named("Compiled code"))

A function with no outer (lexically captured) variables.

Link copied to clipboard
COMPILED_CODE(36, COMPRESSED_SHORT.named("Total number of frame slots"), COMPRESSED_ARBITRARY_CHARACTER_TUPLE.named("Primitive name"), OBJECT_REFERENCE.named("Type if primitive fails"), OBJECT_REFERENCE.named("Function type"), UNCOMPRESSED_NYBBLE_TUPLE.named("Level one nybblecodes"), TUPLE_OF_OBJECTS.named("Regular literals"), TUPLE_OF_OBJECTS.named("Local types"), TUPLE_OF_OBJECTS.named("Constant types"), TUPLE_OF_OBJECTS.named("Outer types"), OBJECT_REFERENCE.named("Module name"), UNSIGNED_INT.named("Line number"), COMPRESSED_INT_TUPLE.named("Encoded line number deltas"), OBJECT_REFERENCE.named("Originating phrase or index"), OBJECT_REFERENCE.named("Packed declaration names"))

A compiled code object. Output any information needed to reconstruct the compiled code object.

Link copied to clipboard
HERITABLE_ATOM(35, OBJECT_REFERENCE.named("atom name"), OBJECT_REFERENCE.named("module name"))

An atom. Output the atom name and the name of the module that issued it. Look up the corresponding atom during reconstruction, recreating it if it's not present and supposed to have been issued by the current module.

Link copied to clipboard
ATOM(34, OBJECT_REFERENCE.named("atom name"), OBJECT_REFERENCE.named("module name"))

An atom. Output the atom name and the name of the module that issued it. Look up the corresponding atom during reconstruction, recreating it if it's not present and supposed to have been issued by the current module.

Link copied to clipboard
OBJECT_TYPE(33, GENERAL_MAP.named("field type map"))

A map. Convert it to a tuple (key1, value1, ... key``[N]``, value``[N]``) and work with that, converting it back to a map when deserializing.

Link copied to clipboard
OBJECT(32, GENERAL_MAP.named("field map"))

A map. Convert it to a tuple (key1, value1, ... key``[N]``, value``[N]``) and work with that, converting it back to a map when deserializing.

Link copied to clipboard
MAP(31, GENERAL_MAP.named("map contents"))

A map. Convert it to a tuple (key1, value1, … key``[N]``, value``[N]``) and work with that, converting it back to a map when deserializing.

Link copied to clipboard
NYBBLE_TUPLE(30, UNCOMPRESSED_NYBBLE_TUPLE.named("tuple of nybbles"))

A tuple whose values fall in the range 0..15.

Link copied to clipboard
BYTE_TUPLE(29, UNCOMPRESSED_BYTE_TUPLE.named("tuple of bytes"))

A tuple of integers whose values all fall in the range 0..255.

Link copied to clipboard
INT_TUPLE(28, COMPRESSED_INT_TUPLE.named("tuple of ints"))

A tuple of integers whose values all fall in the range 0..2^31-1.

Link copied to clipboard
ARBITRARY_STRING(27, COMPRESSED_ARBITRARY_CHARACTER_TUPLE.named("arbitrary string"))

A tuple of characters with arbitrary code points. Write the compressed number of characters then each compressed character.

Link copied to clipboard
SHORT_STRING(26, COMPRESSED_SHORT_CHARACTER_TUPLE.named( "Basic Multilingual Plane string"))

A tuple of characters whose code points all fall in the range 0..65535. Write the compressed number of characters then each compressed character.

Link copied to clipboard
BYTE_STRING(25, BYTE_CHARACTER_TUPLE.named("Latin-1 string"))

A tuple of characters with code points in Latin-1. Write the size of the tuple then the sequence of character bytes.

Link copied to clipboard
GENERAL_TUPLE(24, TUPLE_OF_OBJECTS.named("tuple elements"))

A tuple of arbitrary objects. Write the size of the tuple then the elements as object identifiers.

Link copied to clipboard
DOUBLE(false, 23, SIGNED_INT.named("upper raw bits"), SIGNED_INT.named("lower raw bits"))

A double. Convert the raw bits to a long and write it in big endian.

Link copied to clipboard
FLOAT(false, 22, SIGNED_INT.named("raw bits"))

A float. Convert the raw bits to an int for writing.

Link copied to clipboard
LARGE_CHARACTER(false, 21, BYTE.named("SMP codepoint high byte"), BYTE.named("SMP codepoint middle byte"), BYTE.named("SMP codepoint low byte"))

A character whose code point requires three bytes to represent (0..16777215, but technically only 0..1114111).

Link copied to clipboard
SHORT_CHARACTER(false, 20, UNCOMPRESSED_SHORT.named("BMP code point"))

A character whose code point requires an unsigned short (256..65535).

Link copied to clipboard
BYTE_CHARACTER(false, 19, BYTE.named("Latin-1 code point"))

A character whose code point fits in an unsigned byte (0..255).

Link copied to clipboard
SPECIAL_ATOM(false, 18, COMPRESSED_SHORT.named("special atom number"))

One of the special atoms that the AvailRuntime maintains.

Link copied to clipboard
SPECIAL_OBJECT(false, 17, COMPRESSED_SHORT.named("special object number"))

One of the special objects that the AvailRuntime maintains.

Link copied to clipboard
CHECKPOINT(false, 16, OBJECT_REFERENCE.named("object to checkpoint"))

This special opcode causes a previously built object to be produced as an actual checkpoint output from the Deserializer.

Link copied to clipboard
NIL(false, 15)

Produce the Avail nil during deserialization.

Link copied to clipboard
BIG_INTEGER(14, BIG_INTEGER_DATA.named("constituent ints"))

An Avail integer that cannot be represented as an Int.

Link copied to clipboard
INT_INTEGER(false, 13, SIGNED_INT.named("int's value"))

An Avail integer in the range -231 through 2^31-1, except the range 0..65535 which have their own special cases already.

Link copied to clipboard
SHORT_INTEGER(false, 12, UNCOMPRESSED_SHORT.named("the unsigned short"))

An Avail integer in the range 256..65535. Note that 0..255 have their own special cases already which require less space. Don't try to compress the short value for this reason.

Link copied to clipboard
BYTE_INTEGER(false, 11, BYTE.named("only byte"))

An Avail integer in the range 11..255. Note that 0..10 have their own special cases already which require very little space.

Link copied to clipboard
TEN_INTEGER(false, 10)

The Avail integer 10. Note that there are no operands, since the value is encoded in the choice of instruction itself.

Link copied to clipboard
NINE_INTEGER(false, 9)

The Avail integer 9. Note that there are no operands, since the value is encoded in the choice of instruction itself.

Link copied to clipboard
EIGHT_INTEGER(false, 8)

The Avail integer 8. Note that there are no operands, since the value is encoded in the choice of instruction itself.

Link copied to clipboard
SEVEN_INTEGER(false, 7)

The Avail integer 7. Note that there are no operands, since the value is encoded in the choice of instruction itself.

Link copied to clipboard
SIX_INTEGER(false, 6)

The Avail integer 6. Note that there are no operands, since the value is encoded in the choice of instruction itself.

Link copied to clipboard
FIVE_INTEGER(false, 5)

The Avail integer 5. Note that there are no operands, since the value is encoded in the choice of instruction itself.

Link copied to clipboard
FOUR_INTEGER(false, 4)

The Avail integer 4. Note that there are no operands, since the value is encoded in the choice of instruction itself.

Link copied to clipboard
THREE_INTEGER(false, 3)

The Avail integer 3. Note that there are no operands, since the value is encoded in the choice of instruction itself.

Link copied to clipboard
TWO_INTEGER(false, 2)

The Avail integer 2. Note that there are no operands, since the value is encoded in the choice of instruction itself.

Link copied to clipboard
ONE_INTEGER(false, 1)

The Avail integer 1. Note that there are no operands, since the value is encoded in the choice of instruction itself.

Link copied to clipboard
ZERO_INTEGER(false, 0)

The Avail integer 0. Note that there are no operands, since the value is encoded in the choice of instruction itself.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
val name: String
Link copied to clipboard
val ordinal: Int
Link copied to clipboard
val shouldCaptureObject: Boolean