2.4. Operators

TODO.

2.4.1. Instructions

target = assign op1 [operator_::Assign]
Target:any
Operator 1:any

Assigns op1 to the target. There is a short-cut syntax: instead of using the standard form t = assign op, one can just write t =         op.

clear op1 [operator_::Clear]
Operator 1:any

Resets op1 to the default value a new variable would be set to. Note: This operator is automatically defined for all value types.

target = clone op1 [operator_::Clone]
Target:any
Operator 1:any

Returns a deep copy of op1.

target = hash op1 [operator_::Hash]
Target:int<64>
Operator 1:any

Returns an integer hash of op1.

target = pack op1 op2 op3 [operator_::Pack]
Target:ref<bytes>
Operator 1:any
Operator 2:enum { }
Operator 3:[ any ]

Packs a value op1 of a particular type into binary data enclosed by the iterator tuple op1. op2 defines the binary layout as an enum of type Hilti::Packed and must be a constant. Depending on op2, op3 is may be an additional, format-specific parameter with further information about the binary layout. The operator returns a ref<bytes> with the packed data. Note: The unpack operator uses a generic implementation able to handle all data types. Different from most other operators, it’s implementation is not overloaded on a per-type based. Instead, the type specific code is implemented in the codegen::Packer.

target = unequal op1 op2 [operator_::Unequal]
Target:bool
Operator 1:any
Operator 2:any

Compares two values of the same type, returning true if they don’t match. This operator is defined for all types that offer an equal operator.

target = unpack op1 op2 op3 [operator_::Unpack]
Target:tuple<*>
Operator 1:tuple<*>
Operator 2:enum { }
Operator 3:[ any ]

Unpacks an instance of a particular type (as determined by target; see below) from the binary data enclosed by the iterator tuple op1. op2 defines the binary layout as an enum of type Hilti::Packed and must be a constant. Depending on op2, op3 is may be an additional, format-specific parameter with further information about the binary layout. The operator returns a tuple<T, iterator<bytes>>, in the first component is the newly unpacked instance and the second component is locates the first bytes that has not been consumed anymore. Raises ~~WouldBlock if there are not sufficient bytes available for unpacking the type. Can also raise UnpackError` if the raw bytes are         not as expected (and that fact can be verified).          Note: The ``unpack operator uses a generic implementation able to handle all data types. Different from most other operators, it’s implementation is not overloaded on a per-type based. Instead, the type specific code is implemented in the codegen::Unpacker.