Split ETC__VBC__INLINE_INTEGER into {,un}signed

This commit is contained in:
Nigel Tao committed 2020-07-21 15:31:49 +10:00
1 parent 51a38295b6
commit c9d4e34dfc
7 files changed
+93 -45

No files matched your search

+20 -4
View File
@@ -2099,6 +2099,7 @@ typedef struct {
inline int64_t value_base_category() const;
inline uint64_t value_minor() const;
inline uint64_t value_base_detail() const;
inline int64_t value_base_detail__sign_extended() const;
inline bool continued() const;
inline uint64_t length() const;
#endif // __cplusplus
@@ -2133,7 +2134,8 @@ wuffs_base__make_token(uint64_t repr) {
#define WUFFS_BASE__TOKEN__VBC__UNICODE_CODE_POINT 3
#define WUFFS_BASE__TOKEN__VBC__LITERAL 4
#define WUFFS_BASE__TOKEN__VBC__NUMBER 5
#define WUFFS_BASE__TOKEN__VBC__INLINE_INTEGER 6
#define WUFFS_BASE__TOKEN__VBC__INLINE_INTEGER_SIGNED 6
#define WUFFS_BASE__TOKEN__VBC__INLINE_INTEGER_UNSIGNED 7
// --------
@@ -2275,6 +2277,15 @@ wuffs_base__token__value_base_detail(const wuffs_base__token* t) {
return (t->repr >> WUFFS_BASE__TOKEN__VALUE_BASE_DETAIL__SHIFT) & 0x1FFFFF;
}
static inline int64_t //
wuffs_base__token__value_base_detail__sign_extended(
const wuffs_base__token* t) {
// The VBD is 21 bits in the middle of t->repr. Left shift the high (64 - 21
// - ETC__SHIFT) bits off, then right shift (sign-extending) back down.
uint64_t u = t->repr << (43 - WUFFS_BASE__TOKEN__VALUE_BASE_DETAIL__SHIFT);
return ((int64_t)u) >> 43;
}
static inline bool //
wuffs_base__token__continued(const wuffs_base__token* t) {
return t->repr & 0x10000;
@@ -2317,6 +2328,11 @@ wuffs_base__token::value_base_detail() const {
return wuffs_base__token__value_base_detail(this);
}
inline int64_t //
wuffs_base__token::value_base_detail__sign_extended() const {
return wuffs_base__token__value_base_detail__sign_extended(this);
}
inline bool //
wuffs_base__token::continued() const {
return wuffs_base__token__continued(this);
@@ -11160,8 +11176,8 @@ wuffs_base__private_implementation__high_prec_dec__round_just_enough(
//
// On failure, it returns a negative value.
//
// The algorithm is based on an original idea by Michael Eisel and refined by
// Daniel Lemire. See
// The algorithm is based on an original idea by Michael Eisel that was refined
// by Daniel Lemire. See
// https://lemire.me/blog/2020/03/10/fast-float-parsing-in-practice/
//
// Preconditions:
@@ -16521,7 +16537,7 @@ wuffs_cbor__decoder__decode_tokens(
if (v_c_major == 0) {
if (v_c_minor < 24) {
*iop_a_dst++ = wuffs_base__make_token(
(((uint64_t)((12582912 | ((uint32_t)(v_c_minor))))) << WUFFS_BASE__TOKEN__VALUE_MINOR__SHIFT) |
(((uint64_t)((14680064 | ((uint32_t)(v_c_minor))))) << WUFFS_BASE__TOKEN__VALUE_MINOR__SHIFT) |
(((uint64_t)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
goto label__goto_parsed_a_leaf_value__break;
} else if (v_c_minor < 28) {