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 bdccb8bee3
13 changed files with 438 additions and 14 deletions

View file

@ -0,0 +1,61 @@
/** @file DRuntimeError.hpp
*
* @author Roland Conybeare, Feb 2026
**/
#pragma once
#include "String.hpp"
#include <xo/alloc2/Allocator.hpp>
namespace xo {
namespace scm {
/** @brief representation for runtime errors
**/
class DRuntimeError {
public:
using ACollector = xo::mm::ACollector;
using AAllocator = xo::mm::AAllocator;
using ppindentinfo = xo::print::ppindentinfo;
public:
/** create instance using memory from allocator @p mm
* @p src_fn identifies the (c++) function/method in which
* error detercted.
* @p error_descr contains human-readable error message;
* will be copied by this function.
**/
DRuntimeError * _make(obj<AAllocator> mm,
DString * src_fn,
DString * error_descr);
/** @defgroup scm-runtimeerror-printable-facet printable facet **/
///@{
bool pretty(const ppindentinfo & ppii) const;
///@}
/** @defgroup scm-runtimeerror-gcobject-facet gcobject facet **/
///@{
std::size_t shallow_size() const noexcept;
DRuntimeError * shallow_copy(obj<AAllocator> mm) const noexcept;
std::size_t forward_children(obj<ACollector> gc) noexcept;
///@}
private:
DRuntimeError(DString * src_fn, DString * error_descr);
private:
/** source location at which error identified **/
DString * src_function_ = nullptr;
/** error description (allocated from ErrorArena) **/
DString * error_descr_ = nullptr;
};
} /*namespace scm*/
} /*namespace xo*/
/* end DRuntimeError.hpp */

View file

@ -0,0 +1,12 @@
/** @file RuntimeError.hpp
*
* @author Roland Conybeare, Feb 2026
**/
#pragma once
#include "DRuntimeError.hpp"
#include "error/IGCObject_DRuntimeError.hpp"
#include "error/IPrintable_DRuntimeError.hpp"
/* end RuntimeError.hpp */

View file

@ -0,0 +1,65 @@
/** @file IGCObject_DRuntimeError.hpp
*
* 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_repr.hpp.j2]
* 3. idl for facet methods
* [idl/IGCObject_DRuntimeError.json5]
**/
#pragma once
#include "GCObject.hpp"
#include "DRuntimeError.hpp"
namespace xo { namespace scm { class IGCObject_DRuntimeError; } }
namespace xo {
namespace facet {
template <>
struct FacetImplementation<xo::mm::AGCObject,
xo::scm::DRuntimeError>
{
using ImplType = xo::mm::IGCObject_Xfer
<xo::scm::DRuntimeError,
xo::scm::IGCObject_DRuntimeError>;
};
}
}
namespace xo {
namespace scm {
/** @class IGCObject_DRuntimeError
**/
class IGCObject_DRuntimeError {
public:
/** @defgroup scm-gcobject-druntimeerror-type-traits **/
///@{
using size_type = xo::mm::AGCObject::size_type;
using AAllocator = xo::mm::AGCObject::AAllocator;
using ACollector = xo::mm::AGCObject::ACollector;
using Copaque = xo::mm::AGCObject::Copaque;
using Opaque = xo::mm::AGCObject::Opaque;
///@}
/** @defgroup scm-gcobject-druntimeerror-methods **/
///@{
// const methods
/** memory consumption for this instance **/
static size_type shallow_size(const DRuntimeError & self) noexcept;
/** copy instance using allocator **/
static Opaque shallow_copy(const DRuntimeError & self, obj<AAllocator> mm) noexcept;
// non-const methods
/** during GC: forward immdiate children **/
static size_type forward_children(DRuntimeError & self, obj<ACollector> gc) noexcept;
///@}
};
} /*namespace scm*/
} /*namespace xo*/
/* end */

View file

@ -0,0 +1,62 @@
/** @file IPrintable_DRuntimeError.hpp
*
* 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_repr.hpp.j2]
* 3. idl for facet methods
* [idl/IPrintable_DRuntimeError.json5]
**/
#pragma once
#include "Printable.hpp"
#include <xo/printable2/Printable.hpp>
#include <xo/printable2/detail/IPrintable_Xfer.hpp>
#include "DRuntimeError.hpp"
namespace xo { namespace scm { class IPrintable_DRuntimeError; } }
namespace xo {
namespace facet {
template <>
struct FacetImplementation<xo::print::APrintable,
xo::scm::DRuntimeError>
{
using ImplType = xo::print::IPrintable_Xfer
<xo::scm::DRuntimeError,
xo::scm::IPrintable_DRuntimeError>;
};
}
}
namespace xo {
namespace scm {
/** @class IPrintable_DRuntimeError
**/
class IPrintable_DRuntimeError {
public:
/** @defgroup scm-printable-druntimeerror-type-traits **/
///@{
using ppindentinfo = xo::print::APrintable::ppindentinfo;
using Copaque = xo::print::APrintable::Copaque;
using Opaque = xo::print::APrintable::Opaque;
///@}
/** @defgroup scm-printable-druntimeerror-methods **/
///@{
// const methods
/** Pretty-printing support for this object.
See [xo-indentlog/xo/indentlog/pretty.hpp] **/
static bool pretty(const DRuntimeError & self, const ppindentinfo & ppii);
// non-const methods
///@}
};
} /*namespace scm*/
} /*namespace xo*/
/* end */