This PR adds Byte as a builtin with builtin functions for equality, byte-from-nat and byte-to-nat. The standard library is updated to include this definition with instances for FromNatural, Show and Eq traits.
The FromNatural trait means that you can assign Byte values using non-negative numeric literals.
You can use byte literals in jvc files by adding the u8 suffix to a numeric value. For example, 1u8 represents a byte literal.
Arithmetic is not supported as the intention is for this type to be used to construct ByteArrays of data where isn't not appropriate to modify using arithmetic operations. We may add a separate UInt8 type in the future which supports arithmetic.
The Byte is supported in the native, rust and Anoma backend. Byte is not supported in the Cairo backend because byte-from-nat cannot be defined.
The primitive builtin ops for Byte are called OpUInt8ToInt and OpUInt8FromInt, named because these ops work on integers and in future we may reuse these for a separate unsigned 8-bit integer type that supports arithmetic.
This PR adds
Byte
as a builtin with builtin functions for equality,byte-from-nat
andbyte-to-nat
. The standard library is updated to include this definition with instances forFromNatural
,Show
andEq
traits.The
FromNatural
trait means that you can assignByte
values using non-negative numeric literals.You can use byte literals in jvc files by adding the u8 suffix to a numeric value. For example, 1u8 represents a byte literal.
Arithmetic is not supported as the intention is for this type to be used to construct ByteArrays of data where isn't not appropriate to modify using arithmetic operations. We may add a separate
UInt8
type in the future which supports arithmetic.The Byte is supported in the native, rust and Anoma backend. Byte is not supported in the Cairo backend because
byte-from-nat
cannot be defined.The primitive builtin ops for
Byte
are calledOpUInt8ToInt
andOpUInt8FromInt
, named because these ops work on integers and in future we may reuse these for a separate unsigned 8-bit integer type that supports arithmetic.Part of: