xo-reader2 stack: expand symbol table to store typedefs

+ typedef utest
+ misc qol policy choices
This commit is contained in:
Roland Conybeare 2026-03-11 07:49:14 -05:00
commit 99c30bf975
28 changed files with 226 additions and 72 deletions

View file

@ -2,6 +2,7 @@
include(CMakeFindDependencyMacro)
find_dependency(xo_object2)
find_dependnecy(reflect)
find_dependency(xo_alloc2)
find_dependency(xo_facet)
find_dependency(subsys)

View file

@ -4,7 +4,8 @@
output_hpp_dir: "include/xo/type",
output_impl_subdir: "type",
includes: [
"<xo/type/Metatype.hpp>"
"<xo/type/Metatype.hpp>",
"<xo/reflect/TypeDescr.hpp>",
],
user_hpp_includes: [
],
@ -26,6 +27,11 @@
name: "obj_AType",
doc: [],
definition: "xo::facet::obj<AType>",
},
{
name: "TypeDescr",
doc: [],
definition: "xo::reflect::TypeDescr",
}
],
const_methods: [
@ -37,13 +43,22 @@
const: true,
noexcept: true,
},
{
name: "repr_td",
doc: ["reflected representation for instances of this type"],
return_type: "TypeDescr",
args: [],
const: true,
noexcept: true,
},
{
name: "is_equal_to",
doc: ["true iff this type is equal to y"],
return_type: "bool",
args: [
{type: "const obj_AType &", name: "y"},
]
],
const: true,
},
{
name: "is_subtype_of",
@ -51,18 +66,9 @@
return_type: "bool",
args: [
{type: "const obj_AType &", name: "y"},
]
],
const: true,
},
// TODO: define methods, e.g.:
// {
// name: "my_method",
// doc: ["description"],
// return_type: "bool",
// args: [],
// const: true,
// noexcept: true,
// },
],
nonconst_methods: [],
router_facet_explicit_content: [

View file

@ -20,6 +20,7 @@ namespace xo {
public:
using ACollector = xo::mm::ACollector;
using AAllocator = xo::mm::AAllocator;
using TypeDescr = xo::reflect::TypeDescr;
public:
/** @defgroup xo-scm-arraytype-ctors **/
@ -33,7 +34,8 @@ namespace xo {
///@}
/** @defgroup xo-scm-arraytype-type-facet **/
///@{
Metatype metatype() const noexcept { return Metatype::array(); }
Metatype metatype() const noexcept { return Metatype::t_array(); }
TypeDescr repr_td() const noexcept;
bool is_equal_to(const obj<AType> & y) const noexcept;
bool is_subtype_of(const obj<AType> & y) const noexcept;
///@}

View file

@ -23,16 +23,20 @@ namespace xo {
public:
using ACollector = xo::mm::ACollector;
using AAllocator = xo::mm::AAllocator;
using TypeDescr = xo::reflect::TypeDescr;
public:
explicit DAtomicType(Metatype m) : metatype_{m} {}
/** create instance using memory from @p mm with metatype @p mtype **/
static DAtomicType * _make(obj<AAllocator> mm, Metatype mtype);
/** create instance **/
static obj<AType,DAtomicType> make(obj<AAllocator> mm, Metatype mtype);
/** @defgroup xo-scm-atomictype-type-facet **/
///@{
Metatype metatype() const noexcept { return metatype_; }
TypeDescr repr_td() const noexcept;
bool is_equal_to(const obj<AType> & y) const noexcept;
bool is_subtype_of(const obj<AType> & y) const noexcept;
///@}

View file

@ -22,6 +22,7 @@ namespace xo {
using ACollector = xo::mm::ACollector;
using AAllocator = xo::mm::AAllocator;
using AGCObject = xo::mm::AGCObject;
using TypeDescr = xo::reflect::TypeDescr;
public:
/** @defgroup xo-scm-arraytype-ctors **/
@ -45,7 +46,8 @@ namespace xo {
///@}
/** @defgroup xo-scm-arraytype-type-facet **/
///@{
Metatype metatype() const noexcept { return Metatype::array(); }
Metatype metatype() const noexcept { return Metatype::t_array(); }
TypeDescr repr_td() const noexcept;
bool is_equal_to(obj<AType> y) const noexcept;
bool is_subtype_of(const obj<AType> & y) const noexcept;
///@}

View file

@ -7,6 +7,7 @@
#include "Type.hpp"
#include "Metatype.hpp"
#include <xo/reflect/TypeDescr.hpp>
#include <xo/alloc2/Collector.hpp>
#include <xo/alloc2/Allocator.hpp>
@ -21,6 +22,7 @@ namespace xo {
**/
class DListType {
public:
using TypeDescr = xo::reflect::TypeDescr;
using ACollector = xo::mm::ACollector;
using AAllocator = xo::mm::AAllocator;
@ -31,12 +33,14 @@ namespace xo {
explicit DListType(obj<AType> elt);
/** create instance using memory from @p mm with metatype @p mtype **/
static DListType * _make(obj<AAllocator> mm, obj<AType> elt_type);
static DListType * _make(obj<AAllocator> mm,
obj<AType> elt_type);
///@}
/** @defgroup xo-scm-listtype-type-facet **/
///@{
Metatype metatype() const noexcept { return Metatype::list(); }
Metatype metatype() const noexcept { return Metatype::t_list(); }
TypeDescr repr_td() const noexcept;
bool is_equal_to(const obj<AType> & y) const noexcept;
bool is_subtype_of(const obj<AType> & y) const noexcept;
///@}

View file

@ -14,12 +14,21 @@ namespace xo {
enum class code {
/* void */
t_unit,
t_bool,
t_i64,
t_f64,
t_str,
/* int16_t */
t_i16,
/* int32_t */
t_i32,
/* int64_t */
t_i64,
/* float */
t_f32,
/* double */
t_f64,
/* discriminated union */
t_sum,
/* list<T> */
@ -38,16 +47,24 @@ namespace xo {
public:
explicit Metatype(code x) : code_{x} {}
static Metatype unit() { return Metatype(code::t_unit); }
static Metatype t_bool() { return Metatype(code::t_bool); }
static Metatype i64() { return Metatype(code::t_i64); }
static Metatype f64() { return Metatype(code::t_f64); }
static Metatype str() { return Metatype(code::t_str); }
static Metatype any() { return Metatype(code::t_any); }
static Metatype t_unit() { return Metatype(code::t_unit); }
static Metatype t_bool() { return Metatype(code::t_bool); }
static Metatype t_str() { return Metatype(code::t_str); }
static Metatype list() { return Metatype(code::t_list); }
static Metatype array() { return Metatype(code::t_array); }
static Metatype function() { return Metatype(code::t_function); }
static Metatype t_i16() { return Metatype(code::t_i16); }
static Metatype t_i32() { return Metatype(code::t_i32); }
static Metatype t_i64() { return Metatype(code::t_i64); }
static Metatype t_f32() { return Metatype(code::t_f32); }
static Metatype t_f64() { return Metatype(code::t_f64); }
static Metatype t_sum() { return Metatype(code::t_sum); }
static Metatype t_list() { return Metatype(code::t_list); }
static Metatype t_array() { return Metatype(code::t_array); }
static Metatype t_function() { return Metatype(code::t_function); }
static Metatype t_struct() { return Metatype(code::t_struct); }
static Metatype t_any() { return Metatype(code::t_any); }
/** description string for this type category **/
const char * _descr() const noexcept;

View file

@ -40,6 +40,7 @@ namespace xo {
/** @defgroup scm-type-darraytype-type-traits **/
///@{
using obj_AType = xo::scm::AType::obj_AType;
using TypeDescr = xo::scm::AType::TypeDescr;
using Copaque = xo::scm::AType::Copaque;
using Opaque = xo::scm::AType::Opaque;
///@}
@ -48,6 +49,8 @@ namespace xo {
// const methods
/** category for this type **/
static Metatype metatype(const DArrayType & self) noexcept;
/** reflected representation for instances of this type **/
static TypeDescr repr_td(const DArrayType & self) noexcept;
/** true iff this type is equal to y **/
static bool is_equal_to(const DArrayType & self, const obj_AType & y);
/** true iff this is a subtype of y **/

View file

@ -40,6 +40,7 @@ namespace xo {
/** @defgroup scm-type-datomictype-type-traits **/
///@{
using obj_AType = xo::scm::AType::obj_AType;
using TypeDescr = xo::scm::AType::TypeDescr;
using Copaque = xo::scm::AType::Copaque;
using Opaque = xo::scm::AType::Opaque;
///@}
@ -48,6 +49,8 @@ namespace xo {
// const methods
/** category for this type **/
static Metatype metatype(const DAtomicType & self) noexcept;
/** reflected representation for instances of this type **/
static TypeDescr repr_td(const DAtomicType & self) noexcept;
/** true iff this type is equal to y **/
static bool is_equal_to(const DAtomicType & self, const obj_AType & y);
/** true iff this is a subtype of y **/

View file

@ -40,6 +40,7 @@ namespace xo {
/** @defgroup scm-type-dfunctiontype-type-traits **/
///@{
using obj_AType = xo::scm::AType::obj_AType;
using TypeDescr = xo::scm::AType::TypeDescr;
using Copaque = xo::scm::AType::Copaque;
using Opaque = xo::scm::AType::Opaque;
///@}
@ -48,6 +49,8 @@ namespace xo {
// const methods
/** category for this type **/
static Metatype metatype(const DFunctionType & self) noexcept;
/** reflected representation for instances of this type **/
static TypeDescr repr_td(const DFunctionType & self) noexcept;
/** true iff this type is equal to y **/
static bool is_equal_to(const DFunctionType & self, const obj_AType & y);
/** true iff this is a subtype of y **/

View file

@ -40,6 +40,7 @@ namespace xo {
/** @defgroup scm-type-dlisttype-type-traits **/
///@{
using obj_AType = xo::scm::AType::obj_AType;
using TypeDescr = xo::scm::AType::TypeDescr;
using Copaque = xo::scm::AType::Copaque;
using Opaque = xo::scm::AType::Opaque;
///@}
@ -48,6 +49,8 @@ namespace xo {
// const methods
/** category for this type **/
static Metatype metatype(const DListType & self) noexcept;
/** reflected representation for instances of this type **/
static TypeDescr repr_td(const DListType & self) noexcept;
/** true iff this type is equal to y **/
static bool is_equal_to(const DListType & self, const obj_AType & y);
/** true iff this is a subtype of y **/

View file

@ -15,6 +15,7 @@
// includes (via {facet_includes})
#include <xo/type/Metatype.hpp>
#include <xo/reflect/TypeDescr.hpp>
#include <xo/facet/obj.hpp>
#include <xo/facet/facet_implementation.hpp>
#include <xo/facet/typeseq.hpp>
@ -42,6 +43,8 @@ public:
using Opaque = void *;
/** **/
using obj_AType = xo::facet::obj<AType>;
/** **/
using TypeDescr = xo::reflect::TypeDescr;
///@}
/** @defgroup scm-type-methods **/
@ -53,10 +56,12 @@ public:
virtual void _drop(Opaque d) const noexcept = 0;
/** category for this type **/
virtual Metatype metatype(Copaque data) const noexcept = 0;
/** reflected representation for instances of this type **/
virtual TypeDescr repr_td(Copaque data) const noexcept = 0;
/** true iff this type is equal to y **/
virtual bool is_equal_to(Copaque data, const obj_AType & y) = 0;
virtual bool is_equal_to(Copaque data, const obj_AType & y) const = 0;
/** true iff this is a subtype of y **/
virtual bool is_subtype_of(Copaque data, const obj_AType & y) = 0;
virtual bool is_subtype_of(Copaque data, const obj_AType & y) const = 0;
// nonconst methods
///@}

View file

@ -45,6 +45,7 @@ namespace scm {
/** integer identifying a type **/
using typeseq = xo::facet::typeseq;
using obj_AType = AType::obj_AType;
using TypeDescr = AType::TypeDescr;
///@}
/** @defgroup scm-type-any-methods **/
@ -60,8 +61,9 @@ namespace scm {
// const methods
[[noreturn]] Metatype metatype(Copaque) const noexcept override { _fatal(); }
[[noreturn]] bool is_equal_to(Copaque, const obj_AType &) override { _fatal(); }
[[noreturn]] bool is_subtype_of(Copaque, const obj_AType &) override { _fatal(); }
[[noreturn]] TypeDescr repr_td(Copaque) const noexcept override { _fatal(); }
[[noreturn]] bool is_equal_to(Copaque, const obj_AType &) const override { _fatal(); }
[[noreturn]] bool is_subtype_of(Copaque, const obj_AType &) const override { _fatal(); }
// nonconst methods

View file

@ -14,6 +14,7 @@
#pragma once
#include <xo/type/Metatype.hpp>
#include <xo/reflect/TypeDescr.hpp>
namespace xo {
namespace scm {
@ -29,6 +30,7 @@ namespace scm {
/** integer identifying a type **/
using typeseq = AType::typeseq;
using obj_AType = AType::obj_AType;
using TypeDescr = AType::TypeDescr;
///@}
/** @defgroup scm-type-xfer-methods **/
@ -47,10 +49,13 @@ namespace scm {
Metatype metatype(Copaque data) const noexcept override {
return I::metatype(_dcast(data));
}
bool is_equal_to(Copaque data, const obj_AType & y) override {
TypeDescr repr_td(Copaque data) const noexcept override {
return I::repr_td(_dcast(data));
}
bool is_equal_to(Copaque data, const obj_AType & y) const override {
return I::is_equal_to(_dcast(data), y);
}
bool is_subtype_of(Copaque data, const obj_AType & y) override {
bool is_subtype_of(Copaque data, const obj_AType & y) const override {
return I::is_subtype_of(_dcast(data), y);
}

View file

@ -32,6 +32,7 @@ public:
using DataPtr = Object::DataPtr;
using typeseq = xo::reflect::typeseq;
using obj_AType = AType::obj_AType;
using TypeDescr = AType::TypeDescr;
///@}
/** @defgroup scm-type-router-ctors **/
@ -56,10 +57,13 @@ public:
Metatype metatype() const noexcept {
return O::iface()->metatype(O::data());
}
bool is_equal_to(const obj_AType & y) {
TypeDescr repr_td() const noexcept {
return O::iface()->repr_td(O::data());
}
bool is_equal_to(const obj_AType & y) const {
return O::iface()->is_equal_to(O::data(), y);
}
bool is_subtype_of(const obj_AType & y) {
bool is_subtype_of(const obj_AType & y) const {
return O::iface()->is_subtype_of(O::data(), y);
}

View file

@ -31,6 +31,7 @@ xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 $
# xo-type/cmake/xo_typeConfig.cmake.in
xo_dependency(${SELF_LIB} xo_object2)
xo_dependency(${SELF_LIB} reflect)
xo_dependency(${SELF_LIB} xo_alloc2)
xo_dependency(${SELF_LIB} xo_facet)
xo_dependency(${SELF_LIB} subsys)

View file

@ -5,18 +5,24 @@
#include "Type.hpp"
#include "ArrayType.hpp"
#include "TypeDescr.hpp"
#include <xo/reflect/Reflect.hpp>
#include <xo/alloc2/Collector.hpp>
#include <xo/alloc2/Allocator.hpp>
#include <xo/facet/FacetRegistry.hpp>
namespace xo {
using xo::reflect::Reflect;
using xo::reflect::TypeDescr;
using xo::mm::AGCObject;
using xo::mm::AAllocator;
using xo::facet::FacetRegistry;
namespace scm {
DArrayType::DArrayType(obj<AType> elt) : elt_type_{elt} {}
DArrayType::DArrayType(obj<AType> elt)
: elt_type_{elt}
{}
DArrayType *
DArrayType::_make(obj<AAllocator> mm,
@ -29,12 +35,18 @@ namespace xo {
// ----- type facet -----
TypeDescr
DArrayType::repr_td() const noexcept
{
return Reflect::require<void *>();
}
bool
DArrayType::is_equal_to(const obj<AType> & y_arg) const noexcept
{
Metatype y_mtype = y_arg.metatype();
if (y_mtype != Metatype::array())
if (y_mtype != Metatype::t_array())
return false;
auto y = obj<AType,DArrayType>::from(y_arg);
@ -49,10 +61,10 @@ namespace xo {
{
Metatype y_mtype = y_arg.metatype();
if (y_mtype == Metatype::any())
if (y_mtype == Metatype::t_any())
return true;
if (y_mtype != Metatype::array())
if (y_mtype != Metatype::t_array())
return false;
auto y = obj<AType,DArrayType>::from(y_arg);
@ -81,7 +93,7 @@ namespace xo {
{
{
auto e = FacetRegistry::instance().variant<AGCObject,AType>(elt_type_);
gc.forward_inplace(e.iface(), (void **)&(e.data_));
gc.forward_inplace(e.iface(), (void **)&(elt_type_.data_));
}
return this->shallow_size();

View file

@ -4,8 +4,12 @@
**/
#include "AtomicType.hpp"
#include <xo/reflect/Reflect.hpp>
namespace xo {
using xo::reflect::Reflect;
using xo::reflect::TypeDescr;
namespace scm {
DAtomicType *
@ -16,8 +20,20 @@ namespace xo {
return new (mem) DAtomicType(mtype);
}
obj<AType,DAtomicType>
DAtomicType::make(obj<AAllocator> mm, Metatype mtype)
{
return obj<AType,DAtomicType>(_make(mm, mtype));
}
// ----- Type facet -----
TypeDescr
DAtomicType::repr_td() const noexcept
{
return Reflect::require<void *>();
}
bool
DAtomicType::is_equal_to(const obj<AType> & y) const noexcept
{

View file

@ -4,21 +4,30 @@
**/
#include "FunctionType.hpp"
#include <xo/reflect/Reflect.hpp>
#include <xo/facet/FacetRegistry.hpp>
namespace xo {
using xo::reflect::Reflect;
using xo::reflect::TypeDescr;
using xo::facet::FacetRegistry;
namespace scm {
// ----- type facet -----
TypeDescr
DFunctionType::repr_td() const noexcept
{
return Reflect::require<void *>();
}
bool
DFunctionType::is_equal_to(obj<AType> y_arg) const noexcept
{
Metatype y_mtype = y_arg.metatype();
if (y_mtype != Metatype::function())
if (y_mtype != Metatype::t_function())
return false;
auto y = obj<AType,DFunctionType>::from(y_arg);
@ -48,10 +57,10 @@ namespace xo {
{
Metatype y_mtype = y_arg.metatype();
if (y_mtype == Metatype::any())
if (y_mtype == Metatype::t_any())
return true;
if (y_mtype != Metatype::function())
if (y_mtype != Metatype::t_function())
return false;
auto y = obj<AType,DFunctionType>::from(y_arg);
@ -95,7 +104,7 @@ namespace xo {
{
{
auto e = FacetRegistry::instance().variant<AGCObject,AType>(return_type_);
gc.forward_inplace(e.iface(), (void **)&(e.data_));
gc.forward_inplace(e.iface(), (void **)&(return_type_.data_));
}
gc.forward_inplace(&arg_types_);

View file

@ -5,11 +5,15 @@
#include "Type.hpp"
#include "ListType.hpp"
#include "TypeDescr.hpp"
#include <xo/reflect/Reflect.hpp>
#include <xo/alloc2/Collector.hpp>
#include <xo/alloc2/Allocator.hpp>
#include <xo/facet/FacetRegistry.hpp>
namespace xo {
using xo::reflect::Reflect;
using xo::reflect::TypeDescr;
using xo::mm::AGCObject;
using xo::mm::AAllocator;
using xo::facet::FacetRegistry;
@ -29,12 +33,18 @@ namespace xo {
// ----- type facet -----
TypeDescr
DListType::repr_td() const noexcept
{
return Reflect::require<void *>();
}
bool
DListType::is_equal_to(const obj<AType> & y_arg) const noexcept
{
Metatype y_mtype = y_arg.metatype();
if (y_mtype != Metatype::list())
if (y_mtype != Metatype::t_list())
return false;
auto y = obj<AType,DListType>::from(y_arg);
@ -49,10 +59,10 @@ namespace xo {
{
Metatype y_mtype = y_arg.metatype();
if (y_mtype == Metatype::any())
if (y_mtype == Metatype::t_any())
return true;
if (y_mtype != Metatype::list())
if (y_mtype != Metatype::t_list())
return false;
auto y = obj<AType,DListType>::from(y_arg);
@ -81,7 +91,7 @@ namespace xo {
{
{
auto e = FacetRegistry::instance().variant<AGCObject,AType>(elt_type_);
gc.forward_inplace(e.iface(), (void **)&(e.data_));
gc.forward_inplace(e.iface(), (void **)&(elt_type_.data_));
}
return this->shallow_size();

View file

@ -21,6 +21,12 @@ namespace xo {
return self.metatype();
}
auto
IType_DArrayType::repr_td(const DArrayType & self) noexcept -> TypeDescr
{
return self.repr_td();
}
auto
IType_DArrayType::is_equal_to(const DArrayType & self, const obj_AType & y) -> bool
{

View file

@ -21,6 +21,12 @@ namespace xo {
return self.metatype();
}
auto
IType_DAtomicType::repr_td(const DAtomicType & self) noexcept -> TypeDescr
{
return self.repr_td();
}
auto
IType_DAtomicType::is_equal_to(const DAtomicType & self, const obj_AType & y) -> bool
{

View file

@ -21,6 +21,12 @@ namespace xo {
return self.metatype();
}
auto
IType_DFunctionType::repr_td(const DFunctionType & self) noexcept -> TypeDescr
{
return self.repr_td();
}
auto
IType_DFunctionType::is_equal_to(const DFunctionType & self, const obj_AType & y) -> bool
{

View file

@ -21,6 +21,12 @@ namespace xo {
return self.metatype();
}
auto
IType_DListType::repr_td(const DListType & self) noexcept -> TypeDescr
{
return self.repr_td();
}
auto
IType_DListType::is_equal_to(const DListType & self, const obj_AType & y) -> bool
{

View file

@ -12,17 +12,24 @@ namespace xo {
Metatype::_descr() const noexcept
{
switch (code_) {
case code::t_any: return "any";
case code::t_unit: return "unit";
case code::t_bool: return "bool";
case code::t_i64: return "i64";
case code::t_f64: return "f64";
case code::t_str: return "str";
case code::t_i16: return "i16";
case code::t_i32: return "i32";
case code::t_i64: return "i64";
case code::t_f32: return "f32";
case code::t_f64: return "f64";
case code::t_sum: return "sum";
case code::t_list: return "list";
case code::t_array: return "array";
case code::t_function: return "function";
case code::t_struct: return "struct";
case code::t_unit: return "unit";
case code::t_any: return "any";
}
}
@ -30,16 +37,26 @@ namespace xo {
Metatype::is_atomic() const noexcept
{
switch (code_) {
case code::t_any:
return true;
case code::t_unit:
return false;
case code::t_bool:
return true;
case code::t_i64:
return true;
case code::t_f64:
return true;
case code::t_str:
return true;
case code::t_i16:
return true;
case code::t_i32:
return true;
case code::t_i64:
return true;
case code::t_f32:
return true;
case code::t_f64:
return true;
case code::t_sum:
return false;
case code::t_list:
@ -50,8 +67,9 @@ namespace xo {
return false;
case code::t_struct:
return false;
case code::t_unit:
return false;
case code::t_any:
return true;
}
}

View file

@ -31,7 +31,7 @@ namespace xo {
DArena arena = DArena::map(cfg);
auto alloc = obj<AAllocator,DArena>(&arena);
auto i64_type = TypeOps::atomic_type(alloc, Metatype::i64());
auto i64_type = TypeOps::atomic_type(alloc, Metatype::t_i64());
auto array_i64_type = TypeOps::array_type(alloc, i64_type);
REQUIRE(array_i64_type);
@ -43,7 +43,7 @@ namespace xo {
REQUIRE(array_bool_type);
REQUIRE(array_bool_type.is_equal_to(array_bool_type));
auto any_type = TypeOps::atomic_type(alloc, Metatype::any());
auto any_type = TypeOps::atomic_type(alloc, Metatype::t_any());
auto array_any_type = TypeOps::array_type(alloc, any_type);
REQUIRE(array_any_type);

View file

@ -28,14 +28,14 @@ namespace xo {
DArena arena = DArena::map(cfg);
auto alloc = obj<AAllocator,DArena>(&arena);
auto unit_type = obj<AType,DAtomicType>(DAtomicType::_make(alloc, Metatype::unit()));
auto i64_type = obj<AType,DAtomicType>(DAtomicType::_make(alloc, Metatype::i64()));
auto f64_type = obj<AType,DAtomicType>(DAtomicType::_make(alloc, Metatype::f64()));
auto str_type = obj<AType,DAtomicType>(DAtomicType::_make(alloc, Metatype::str()));
auto any_type = obj<AType,DAtomicType>(DAtomicType::_make(alloc, Metatype::any()));
auto unit_type = obj<AType,DAtomicType>(DAtomicType::_make(alloc, Metatype::t_unit()));
auto i64_type = obj<AType,DAtomicType>(DAtomicType::_make(alloc, Metatype::t_i64()));
auto f64_type = obj<AType,DAtomicType>(DAtomicType::_make(alloc, Metatype::t_f64()));
auto str_type = obj<AType,DAtomicType>(DAtomicType::_make(alloc, Metatype::t_str()));
auto any_type = obj<AType,DAtomicType>(DAtomicType::_make(alloc, Metatype::t_any()));
{
REQUIRE(unit_type);
REQUIRE(unit_type.metatype().code() == Metatype::unit().code());
REQUIRE(unit_type.metatype().code() == Metatype::t_unit().code());
REQUIRE(unit_type.is_equal_to(unit_type));
REQUIRE(unit_type.is_subtype_of(unit_type));
@ -43,7 +43,7 @@ namespace xo {
{
REQUIRE(i64_type);
REQUIRE(i64_type.metatype().code() == Metatype::i64().code());
REQUIRE(i64_type.metatype().code() == Metatype::t_i64().code());
REQUIRE(i64_type.is_equal_to(i64_type));
REQUIRE(i64_type.is_subtype_of(i64_type));
@ -54,7 +54,7 @@ namespace xo {
{
REQUIRE(f64_type);
REQUIRE(f64_type.metatype().code() == Metatype::f64().code());
REQUIRE(f64_type.metatype().code() == Metatype::t_f64().code());
REQUIRE(f64_type.is_equal_to(f64_type));
REQUIRE(f64_type.is_subtype_of(f64_type));
@ -67,7 +67,7 @@ namespace xo {
{
REQUIRE(str_type);
REQUIRE(str_type.metatype().code() == Metatype::str().code());
REQUIRE(str_type.metatype().code() == Metatype::t_str().code());
REQUIRE(str_type.is_equal_to(str_type));
REQUIRE(str_type.is_subtype_of(str_type));
@ -83,7 +83,7 @@ namespace xo {
{
REQUIRE(any_type);
REQUIRE(any_type.metatype().code() == Metatype::any().code());
REQUIRE(any_type.metatype().code() == Metatype::t_any().code());
REQUIRE(any_type.is_equal_to(any_type));
REQUIRE(any_type.is_subtype_of(any_type));

View file

@ -32,7 +32,7 @@ namespace xo {
DArena arena = DArena::map(cfg);
auto alloc = obj<AAllocator,DArena>(&arena);
auto i64_type = TypeOps::atomic_type(alloc, Metatype::i64());
auto i64_type = TypeOps::atomic_type(alloc, Metatype::t_i64());
auto list_i64_type = TypeOps::list_type(alloc, i64_type);
REQUIRE(list_i64_type);
@ -44,7 +44,7 @@ namespace xo {
REQUIRE(list_bool_type);
REQUIRE(list_bool_type.is_equal_to(list_bool_type));
auto any_type = TypeOps::atomic_type(alloc, Metatype::any());
auto any_type = TypeOps::atomic_type(alloc, Metatype::t_any());
auto list_any_type = TypeOps::list_type(alloc, any_type);
REQUIRE(list_any_type);