patterns/includes: Update standard library and patterns to support the new bitfields (#102)

* Add `current_bit_offset()` and `read_bits(...)` to `std::mem`

* Replace deprecated BitfieldOrder enum values with new clearer names

This adds new options named `MostToLeastSignificant` and `LeastToMostSignificant` to replace the old `LeftToRight` and `RightToLeft` names. These names should be much clearer about what they affect and how.

* Throw errors when `std::core::(get|set)_bitfield_order()` are called

* Update all patterns to work with the new bitfield behaviors
This commit is contained in:
Zaggy1024
2023-04-01 04:16:54 -05:00
committed by GitHub
parent d42b87d9e6
commit 1cd7f92a5d
23 changed files with 2482 additions and 2433 deletions

View File

@@ -113,6 +113,27 @@ namespace std::mem {
};
/**
Gets the current bit offset within the current byte that a bitfield will read.
*/
fn current_bit_offset() {
return builtin::std::mem::current_bit_offset();
};
/**
Reads a number of bits from the specified bit offset within the specified byte
@param byteOffset The byte offset within the data
@param bitOffset The bit offset to start the read at within the current byte
@param bitSize The total number of bits to read
@return A u128 containing the value read
*/
fn read_bits(u128 byteOffset, u128 bitOffset, u64 bitSize) {
byteOffset += bitOffset >> 3;
bitOffset = bitOffset & 0x7;
return builtin::std::mem::read_bits(byteOffset, bitOffset, bitSize);
};
/**
Creates a new custom section with the given name
@param name The name of the section