xo-reader: integer arithmetic + parser + pretty-printing adds

This commit is contained in:
Roland Conybeare 2025-07-27 13:35:20 -04:00
commit 8d5a9c825f
25 changed files with 408 additions and 26 deletions

View file

@ -240,13 +240,13 @@ namespace xo {
TypeDescrExtra * tdextra() const { return tdextra_.get(); }
Metatype metatype() const { return tdextra_->metatype(); }
/* true iff the type represented by *this is the same as the type
* represented by T.
/** true iff the type represented by _c *this is the same as the type
* represented by @tparam T
*
* Warning: comparing typeinfo address can give false negatives.
* suspect this is caused by problems coalescing linker symbols
* in the clang toolchain.
*/
* Warning: comparing typeinfo address can give false negatives.
* suspect this is caused by problems coalescing linker symbols
* in the clang toolchain.
**/
template<typename T>
[[deprecated]]
bool is_native() const {
@ -317,6 +317,10 @@ namespace xo {
}
} /*recover_native2*/
bool is_i128() const;
bool is_i64() const;
bool is_f64() const;
bool is_pointer() const { return this->tdextra_->is_pointer(); }
bool is_vector() const { return this->tdextra_->is_vector(); }
bool is_struct() const { return this->tdextra_->is_struct(); }

View file

@ -254,6 +254,22 @@ namespace xo {
{
}
bool
TypeDescrBase::is_i64() const
{
static_assert(sizeof(long long) == 8);
return Reflect::is_native<long long>(this);
}
bool
TypeDescrBase::is_f64() const
{
static_assert(sizeof(double) == 8);
return Reflect::is_native<double>(this);
}
TaggedPtr
TypeDescrBase::most_derived_self_tp(void * object) const
{
@ -311,6 +327,11 @@ namespace xo {
#endif
TypeDescrTable::TypeDescrTable() {
/* want long == i64 */
static_assert(sizeof(long) == 8);
/* want double == f64 */
static_assert(sizeof(double) == 8);
Reflect::require<bool>();
Reflect::require<char>();
Reflect::require<short>();