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

This commit is contained in:
Roland Conybeare 2025-07-27 13:35:20 -04:00
commit dc26b97802
2 changed files with 31 additions and 6 deletions

View file

@ -240,13 +240,13 @@ namespace xo {
TypeDescrExtra * tdextra() const { return tdextra_.get(); } TypeDescrExtra * tdextra() const { return tdextra_.get(); }
Metatype metatype() const { return tdextra_->metatype(); } Metatype metatype() const { return tdextra_->metatype(); }
/* true iff the type represented by *this is the same as the type /** true iff the type represented by _c *this is the same as the type
* represented by T. * represented by @tparam T
* *
* Warning: comparing typeinfo address can give false negatives. * Warning: comparing typeinfo address can give false negatives.
* suspect this is caused by problems coalescing linker symbols * suspect this is caused by problems coalescing linker symbols
* in the clang toolchain. * in the clang toolchain.
*/ **/
template<typename T> template<typename T>
[[deprecated]] [[deprecated]]
bool is_native() const { bool is_native() const {
@ -317,6 +317,10 @@ namespace xo {
} }
} /*recover_native2*/ } /*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_pointer() const { return this->tdextra_->is_pointer(); }
bool is_vector() const { return this->tdextra_->is_vector(); } bool is_vector() const { return this->tdextra_->is_vector(); }
bool is_struct() const { return this->tdextra_->is_struct(); } 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 TaggedPtr
TypeDescrBase::most_derived_self_tp(void * object) const TypeDescrBase::most_derived_self_tp(void * object) const
{ {
@ -311,6 +327,11 @@ namespace xo {
#endif #endif
TypeDescrTable::TypeDescrTable() { TypeDescrTable::TypeDescrTable() {
/* want long == i64 */
static_assert(sizeof(long) == 8);
/* want double == f64 */
static_assert(sizeof(double) == 8);
Reflect::require<bool>(); Reflect::require<bool>();
Reflect::require<char>(); Reflect::require<char>();
Reflect::require<short>(); Reflect::require<short>();