xo-interpreter2 stack: work on runtime error representation [WIP]

This commit is contained in:
Roland Conybeare 2026-02-12 18:46:43 -05:00
commit ce5232efd9
18 changed files with 524 additions and 27 deletions

View file

@ -5,29 +5,41 @@ set(SELF_SRCS
init_object2.cpp
object2_register_types.cpp
object2_register_facets.cpp
GCObjectConversion_DFloat.cpp
GCObjectConversion_DInteger.cpp
IGCObject_DArray.cpp
IGCObject_DFloat.cpp
IGCObject_DBoolean.cpp
IGCObject_DInteger.cpp
IGCObject_DList.cpp
IGCObject_DString.cpp
ISequence_Any.cpp
ISequence_DArray.cpp
ISequence_DList.cpp
IPrintable_DArray.cpp
IPrintable_DList.cpp
IPrintable_DBoolean.cpp
IPrintable_DFloat.cpp
IPrintable_DInteger.cpp
IPrintable_DString.cpp
DArray.cpp
ISequence_DArray.cpp
IGCObject_DArray.cpp
IPrintable_DArray.cpp
DList.cpp
ISequence_DList.cpp
IGCObject_DList.cpp
IPrintable_DList.cpp
DFloat.cpp
IGCObject_DFloat.cpp
IPrintable_DFloat.cpp
DInteger.cpp
IGCObject_DInteger.cpp
IPrintable_DInteger.cpp
DBoolean.cpp
IGCObject_DBoolean.cpp
IPrintable_DBoolean.cpp
DString.cpp
IGCObject_DString.cpp
IPrintable_DString.cpp
DRuntimeError.cpp
IGCObject_DRuntimeError.cpp
IPrintable_DRuntimeError.cpp
)
xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 ${SELF_SRCS})

View file

@ -148,6 +148,8 @@ namespace xo {
}
}
// ----- GCObject facet ------
auto
DList::shallow_size() const noexcept -> size_type
{
@ -175,7 +177,7 @@ namespace xo {
auto iface = xo::facet::impl_for<AGCObject,DList>();
gc.forward_inplace(&iface, (void **)(&rest_));
return shallow_size();
return this->shallow_size();
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -0,0 +1,82 @@
/** @file DRuntimeError.cpp
*
* @author Roland Conybeare, Feb 2026
**/
#include "DRuntimeError.hpp"
namespace xo {
using xo::mm::AGCObject;
using xo::facet::typeseq;
namespace scm {
DRuntimeError *
DRuntimeError::_make(obj<AAllocator> mm,
DString * src_fn,
DString * error_descr)
{
void * mem
= mm.alloc(typeseq::id<DRuntimeError>(),
sizeof(DRuntimeError));
DRuntimeError * err
= new (mem) DRuntimeError(src_fn, error_descr);
return err;
}
DRuntimeError::DRuntimeError(DString * src_fn,
DString * error_descr) : src_function_{src_fn},
error_descr_{error_descr}
{}
// ----- GCObject facet -----
std::size_t
DRuntimeError::shallow_size() const noexcept
{
return sizeof(DRuntimeError);
}
DRuntimeError *
DRuntimeError::shallow_copy(obj<AAllocator> mm) const noexcept
{
DRuntimeError * copy = (DRuntimeError *)mm.alloc_copy((std::byte *)this);
if (copy)
*copy = *this;
return copy;
}
std::size_t
DRuntimeError::forward_children(obj<ACollector> gc) noexcept
{
{
auto iface = xo::facet::impl_for<AGCObject,DString>();
gc.forward_inplace(&iface, (void **)(&src_function_));
}
{
auto iface = xo::facet::impl_for<AGCObject,DString>();
gc.forward_inplace(&iface, (void **)(&error_descr_));
}
return this->shallow_size();
}
// ----- Printable facet -----
bool
DRuntimeError::pretty(const ppindentinfo & ppii) const
{
return ppii.pps()->pretty_struct(ppii,
"DRuntimeError");
}
} /*namespace scm*/
} /*namespace xo*/
/* end DRuntimeError.cpp */

View file

@ -0,0 +1,39 @@
/** @file IGCObject_DRuntimeError.cpp
*
* Generated automagically from ingredients:
* 1. code generator:
* [xo-facet/codegen/genfacet]
* arguments:
* --input [idl/IGCObject_DRuntimeError.json5]
* 2. jinja2 template for abstract facet .hpp file:
* [iface_facet_any.hpp.j2]
* 3. idl for facet methods
* [idl/IGCObject_DRuntimeError.json5]
**/
#include "error/IGCObject_DRuntimeError.hpp"
namespace xo {
namespace scm {
auto
IGCObject_DRuntimeError::shallow_size(const DRuntimeError & self) noexcept -> size_type
{
return self.shallow_size();
}
auto
IGCObject_DRuntimeError::shallow_copy(const DRuntimeError & self, obj<AAllocator> mm) noexcept -> Opaque
{
return self.shallow_copy(mm);
}
auto
IGCObject_DRuntimeError::forward_children(DRuntimeError & self, obj<ACollector> gc) noexcept -> size_type
{
return self.forward_children(gc);
}
} /*namespace scm*/
} /*namespace xo*/
/* end IGCObject_DRuntimeError.cpp */

View file

@ -0,0 +1,28 @@
/** @file IPrintable_DRuntimeError.cpp
*
* Generated automagically from ingredients:
* 1. code generator:
* [xo-facet/codegen/genfacet]
* arguments:
* --input [idl/IPrintable_DRuntimeError.json5]
* 2. jinja2 template for abstract facet .hpp file:
* [iface_facet_any.hpp.j2]
* 3. idl for facet methods
* [idl/IPrintable_DRuntimeError.json5]
**/
#include "error/IPrintable_DRuntimeError.hpp"
namespace xo {
namespace scm {
auto
IPrintable_DRuntimeError::pretty(const DRuntimeError & self, const ppindentinfo & ppii) -> bool
{
return self.pretty(ppii);
}
} /*namespace scm*/
} /*namespace xo*/
/* end IPrintable_DRuntimeError.cpp */

View file

@ -4,6 +4,7 @@
**/
#include "object2_register_facets.hpp"
#include "RuntimeError.hpp"
#include <xo/object2/array/IGCObject_DArray.hpp>
#include <xo/object2/list/IGCObject_DList.hpp>
@ -66,6 +67,9 @@ namespace xo {
FacetRegistry::register_impl<APrintable, DArray>();
FacetRegistry::register_impl<ASequence, DArray>();
FacetRegistry::register_impl<AGCObject, DRuntimeError>();
FacetRegistry::register_impl<APrintable, DRuntimeError>();
log && log(xtag("DVariantPlaceholder.tseq", typeseq::id<DVariantPlaceholder>()));
log && log(xtag("DList.tseq", typeseq::id<DList>()));
@ -74,6 +78,7 @@ namespace xo {
log && log(xtag("DInteger.tseq", typeseq::id<DInteger>()));
log && log(xtag("DString.tseq", typeseq::id<DString>()));
log && log(xtag("DArray.tseq", typeseq::id<DArray>()));
log && log(xtag("DRuntimeError.tseq", typeseq::id<DRuntimeError>()));
log && log(xtag("AAllocator.tseq", typeseq::id<AAllocator>()));
log && log(xtag("APrintable.tseq", typeseq::id<APrintable>()));