xo-interpreter2 stack: work on runtime error representation [WIP]
This commit is contained in:
parent
83156ef2d0
commit
ce5232efd9
18 changed files with 524 additions and 27 deletions
|
|
@ -10,6 +10,7 @@
|
||||||
#include "VsmFrame.hpp"
|
#include "VsmFrame.hpp"
|
||||||
#include "DLocalEnv.hpp"
|
#include "DLocalEnv.hpp"
|
||||||
#include "DGlobalEnv.hpp"
|
#include "DGlobalEnv.hpp"
|
||||||
|
#include <xo/object2/RuntimeError.hpp>
|
||||||
#include <xo/reader2/SchematikaReader.hpp>
|
#include <xo/reader2/SchematikaReader.hpp>
|
||||||
#include <xo/expression2/Expression.hpp>
|
#include <xo/expression2/Expression.hpp>
|
||||||
#include <xo/gc/GCObject.hpp>
|
#include <xo/gc/GCObject.hpp>
|
||||||
|
|
@ -17,6 +18,10 @@
|
||||||
|
|
||||||
namespace xo {
|
namespace xo {
|
||||||
namespace scm {
|
namespace scm {
|
||||||
|
#ifdef OBSOLETE // see DVsmError
|
||||||
|
// TODO: move error to collected space?
|
||||||
|
// or special arena?
|
||||||
|
//
|
||||||
struct EvaluationError {
|
struct EvaluationError {
|
||||||
/** source location (in vsm implementation) at which error identified **/
|
/** source location (in vsm implementation) at which error identified **/
|
||||||
std::string_view src_function_;
|
std::string_view src_function_;
|
||||||
|
|
@ -24,6 +29,7 @@ namespace xo {
|
||||||
std::string_view error_description_;
|
std::string_view error_description_;
|
||||||
// TODO: info about location in schematika source
|
// TODO: info about location in schematika source
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
/** similar to @ref xo::scm::ReaderResult **/
|
/** similar to @ref xo::scm::ReaderResult **/
|
||||||
struct VsmResult {
|
struct VsmResult {
|
||||||
|
|
@ -31,17 +37,17 @@ namespace xo {
|
||||||
using span_type = xo::mm::span<const char>;
|
using span_type = xo::mm::span<const char>;
|
||||||
|
|
||||||
VsmResult() = default;
|
VsmResult() = default;
|
||||||
VsmResult(obj<AGCObject> value) : result_{value} {}
|
explicit VsmResult(obj<AGCObject> value) : result_{value} {}
|
||||||
VsmResult(TokenizerError err) : result_{err} {}
|
explicit VsmResult(TokenizerError err) : result_{err} {}
|
||||||
|
|
||||||
bool is_value() const { return std::holds_alternative<obj<AGCObject>>(result_); }
|
bool is_value() const { return std::holds_alternative<obj<AGCObject>>(result_); }
|
||||||
bool is_tk_error() const { return std::holds_alternative<TokenizerError>(result_); }
|
bool is_tk_error() const { return std::holds_alternative<TokenizerError>(result_); }
|
||||||
bool is_eval_error() const { return std::holds_alternative<EvaluationError>(result_); }
|
bool is_eval_error() const;
|
||||||
|
|
||||||
const obj<AGCObject> * value() const { return std::get_if<obj<AGCObject>>(&result_); }
|
const obj<AGCObject> * value() const { return std::get_if<obj<AGCObject>>(&result_); }
|
||||||
|
|
||||||
/** result of evaluating first expression encountered in input **/
|
/** result of evaluating first expression encountered in input **/
|
||||||
std::variant<obj<AGCObject>, TokenizerError, EvaluationError> result_;
|
std::variant<obj<AGCObject>, TokenizerError> result_;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** vsm result + reamining span **/
|
/** vsm result + reamining span **/
|
||||||
|
|
@ -72,6 +78,8 @@ namespace xo {
|
||||||
|
|
||||||
/** allocator for schematika data **/
|
/** allocator for schematika data **/
|
||||||
obj<AAllocator> allocator() const noexcept;
|
obj<AAllocator> allocator() const noexcept;
|
||||||
|
/** allocator for runtime errors **/
|
||||||
|
obj<AAllocator> error_allocator() const noexcept;
|
||||||
|
|
||||||
/** visit vsm-owned memory pools; call visitor(info) for each **/
|
/** visit vsm-owned memory pools; call visitor(info) for each **/
|
||||||
void visit_pools(const MemorySizeVisitor & visitor) const;
|
void visit_pools(const MemorySizeVisitor & visitor) const;
|
||||||
|
|
@ -185,11 +193,19 @@ namespace xo {
|
||||||
/** configuration **/
|
/** configuration **/
|
||||||
VsmConfig config_;
|
VsmConfig config_;
|
||||||
|
|
||||||
/** allocator (likely collector) for
|
/** allocator (likely DX1Collector or similar) for
|
||||||
* expressions and values
|
* expressions and values
|
||||||
**/
|
**/
|
||||||
box<AAllocator> mm_;
|
box<AAllocator> mm_;
|
||||||
|
|
||||||
|
/** Sidecar allocator for error reporting.
|
||||||
|
* Separate to mitigate interference with @ref mm_
|
||||||
|
* (separate memory so we can for example report
|
||||||
|
* an out-of-memory error).
|
||||||
|
* Likely DArena or similar
|
||||||
|
**/
|
||||||
|
box<AAllocator> error_mm_;
|
||||||
|
|
||||||
/** runtime context for this vsm.
|
/** runtime context for this vsm.
|
||||||
* For example, provides allocator to primitives
|
* For example, provides allocator to primitives
|
||||||
**/
|
**/
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
#include <xo/reader2/ReaderConfig.hpp>
|
#include <xo/reader2/ReaderConfig.hpp>
|
||||||
#include <xo/gc/X1CollectorConfig.hpp>
|
#include <xo/gc/X1CollectorConfig.hpp>
|
||||||
|
#include <xo/arena/ArenaConfig.hpp>
|
||||||
|
|
||||||
namespace xo {
|
namespace xo {
|
||||||
namespace scm {
|
namespace scm {
|
||||||
|
|
@ -14,6 +15,7 @@ namespace xo {
|
||||||
**/
|
**/
|
||||||
struct VsmConfig {
|
struct VsmConfig {
|
||||||
using X1CollectorConfig = xo::mm::X1CollectorConfig;
|
using X1CollectorConfig = xo::mm::X1CollectorConfig;
|
||||||
|
using ArenaConfig = xo::mm::ArenaConfig;
|
||||||
|
|
||||||
VsmConfig() = default;
|
VsmConfig() = default;
|
||||||
|
|
||||||
|
|
@ -26,6 +28,10 @@ namespace xo {
|
||||||
* TODO: may want to make CollectorConfig polymorphic
|
* TODO: may want to make CollectorConfig polymorphic
|
||||||
**/
|
**/
|
||||||
X1CollectorConfig x1_config_ = X1CollectorConfig().with_size(4*1024*1024);
|
X1CollectorConfig x1_config_ = X1CollectorConfig().with_size(4*1024*1024);
|
||||||
|
/** Configuration for error allocator
|
||||||
|
* TODO: may want to make ArenaConfig polymorphic
|
||||||
|
**/
|
||||||
|
ArenaConfig error_config_ = ArenaConfig().with_size(64*1024);
|
||||||
};
|
};
|
||||||
} /*namespace scm*/
|
} /*namespace scm*/
|
||||||
} /*namespace xo*/
|
} /*namespace xo*/
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@
|
||||||
#include "Closure.hpp"
|
#include "Closure.hpp"
|
||||||
#include "LambdaExpr.hpp"
|
#include "LambdaExpr.hpp"
|
||||||
#include "LocalEnv.hpp"
|
#include "LocalEnv.hpp"
|
||||||
|
#include "VsmRcx.hpp"
|
||||||
|
#include <xo/indentlog/scope.hpp>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
namespace xo {
|
namespace xo {
|
||||||
|
|
@ -33,7 +35,30 @@ namespace xo {
|
||||||
DClosure::apply_nocheck(obj<ARuntimeContext> rcx,
|
DClosure::apply_nocheck(obj<ARuntimeContext> rcx,
|
||||||
const DArray * args)
|
const DArray * args)
|
||||||
{
|
{
|
||||||
(void)rcx;
|
scope log(XO_DEBUG(true));
|
||||||
|
|
||||||
|
auto vsm_rcx
|
||||||
|
= obj<ARuntimeContext,DVsmRcx>::from(rcx);
|
||||||
|
|
||||||
|
log && log(xtag("vsm_rcx.data", (void*)vsm_rcx.data()));
|
||||||
|
|
||||||
|
// let's try a not-implemented error
|
||||||
|
|
||||||
|
// don't want to clutter Procedure facet, since it's
|
||||||
|
// lower-level than xo-interpreter2
|
||||||
|
|
||||||
|
#ifdef NOT_YET
|
||||||
|
// TODO: verify arguments against type signature.
|
||||||
|
// unless we have evidence that program is type correct
|
||||||
|
|
||||||
|
int32_t n_args = this->n_args();
|
||||||
|
|
||||||
|
if (n_args != args->size()) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
(void)args;
|
(void)args;
|
||||||
|
|
||||||
assert(false);
|
assert(false);
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
//#include <xo/procedure2/SimpleRcx.hpp>
|
//#include <xo/procedure2/SimpleRcx.hpp>
|
||||||
#include <xo/gc/DX1Collector.hpp>
|
#include <xo/gc/DX1Collector.hpp>
|
||||||
#include <xo/gc/detail/IAllocator_DX1Collector.hpp>
|
#include <xo/gc/detail/IAllocator_DX1Collector.hpp>
|
||||||
|
#include <xo/alloc2/Arena.hpp>
|
||||||
#include <xo/printable2/Printable.hpp>
|
#include <xo/printable2/Printable.hpp>
|
||||||
#include <xo/facet/FacetRegistry.hpp>
|
#include <xo/facet/FacetRegistry.hpp>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
@ -27,12 +28,25 @@ namespace xo {
|
||||||
//using xo::mm::MemorySizeInfo; // not used yet
|
//using xo::mm::MemorySizeInfo; // not used yet
|
||||||
using xo::mm::AAllocator;
|
using xo::mm::AAllocator;
|
||||||
using xo::mm::DX1Collector;
|
using xo::mm::DX1Collector;
|
||||||
|
using xo::mm::DArena;
|
||||||
using xo::facet::FacetRegistry;
|
using xo::facet::FacetRegistry;
|
||||||
using std::cout;
|
using std::cout;
|
||||||
|
|
||||||
namespace scm {
|
namespace scm {
|
||||||
|
|
||||||
// NOTE: using heap here for {DX1Collector, DVsmRcx} instances
|
bool
|
||||||
|
VsmResult::is_eval_error() const
|
||||||
|
{
|
||||||
|
if (std::holds_alternative<obj<AGCObject>>(result_)) {
|
||||||
|
auto err = obj<AGCObject,DRuntimeError>::from(*(this->value()));
|
||||||
|
|
||||||
|
return err;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE: using heap here for {DX1Collector, DArena, DVsmRcx} instances
|
||||||
// (though DX1Collector allocations will be from explictly mmap'd memory)
|
// (though DX1Collector allocations will be from explictly mmap'd memory)
|
||||||
//
|
//
|
||||||
VirtualSchematikaMachine::VirtualSchematikaMachine(const VsmConfig & config)
|
VirtualSchematikaMachine::VirtualSchematikaMachine(const VsmConfig & config)
|
||||||
|
|
@ -41,6 +55,14 @@ namespace xo {
|
||||||
rcx_(box<ARuntimeContext,DVsmRcx>(new DVsmRcx(this))),
|
rcx_(box<ARuntimeContext,DVsmRcx>(new DVsmRcx(this))),
|
||||||
reader_{config.rdr_config_, mm_.to_op()}
|
reader_{config.rdr_config_, mm_.to_op()}
|
||||||
{
|
{
|
||||||
|
{
|
||||||
|
DArena * arena = new DArena();
|
||||||
|
assert(arena);
|
||||||
|
*arena = DArena::map(config_.error_config_);
|
||||||
|
|
||||||
|
error_mm_.adopt(obj<AAllocator,DArena>(arena));
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: allocate global_env
|
// TODO: allocate global_env
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -50,6 +72,12 @@ namespace xo {
|
||||||
return mm_.to_op();
|
return mm_.to_op();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
obj<AAllocator>
|
||||||
|
VirtualSchematikaMachine::error_allocator() const noexcept
|
||||||
|
{
|
||||||
|
return error_mm_.to_op();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
VirtualSchematikaMachine::visit_pools(const MemorySizeVisitor & visitor) const
|
VirtualSchematikaMachine::visit_pools(const MemorySizeVisitor & visitor) const
|
||||||
{
|
{
|
||||||
|
|
@ -113,7 +141,7 @@ namespace xo {
|
||||||
{
|
{
|
||||||
this->pc_ = VsmInstr::c_eval;
|
this->pc_ = VsmInstr::c_eval;
|
||||||
this->expr_ = expr;
|
this->expr_ = expr;
|
||||||
this->value_ = obj<AGCObject>();
|
this->value_ = VsmResult(obj<AGCObject>());
|
||||||
this->cont_ = VsmInstr::c_halt;
|
this->cont_ = VsmInstr::c_halt;
|
||||||
|
|
||||||
this->run();
|
this->run();
|
||||||
|
|
@ -200,7 +228,7 @@ namespace xo {
|
||||||
auto expr
|
auto expr
|
||||||
= obj<AExpression,DConstant>::from(expr_);
|
= obj<AExpression,DConstant>::from(expr_);
|
||||||
|
|
||||||
this->value_ = expr.data()->value();
|
this->value_ = VsmResult(expr.data()->value());
|
||||||
this->pc_ = this->cont_;
|
this->pc_ = this->cont_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -250,7 +278,7 @@ namespace xo {
|
||||||
local_env_);
|
local_env_);
|
||||||
|
|
||||||
this->value_
|
this->value_
|
||||||
= obj<AGCObject>(obj<AGCObject,DClosure>(closure));
|
= VsmResult(obj<AGCObject>(obj<AGCObject,DClosure>(closure)));
|
||||||
this->pc_ = this->cont_;
|
this->pc_ = this->cont_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -341,7 +369,7 @@ namespace xo {
|
||||||
|
|
||||||
// TODO: check argument types
|
// TODO: check argument types
|
||||||
|
|
||||||
this->value_ = fn_.apply_nocheck(rcx_.to_op(), args_);
|
this->value_ = VsmResult(fn_.apply_nocheck(rcx_.to_op(), args_));
|
||||||
this->pc_ = cont_;
|
this->pc_ = cont_;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -225,7 +225,6 @@ namespace xo {
|
||||||
vsm.visit_pools(visitor);
|
vsm.visit_pools(visitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef NOT_YET
|
|
||||||
TEST_CASE("VirtualSchematikaMachine-apply2", "[interpreter2][VSM]")
|
TEST_CASE("VirtualSchematikaMachine-apply2", "[interpreter2][VSM]")
|
||||||
{
|
{
|
||||||
scope log(XO_DEBUG(true));
|
scope log(XO_DEBUG(true));
|
||||||
|
|
@ -265,7 +264,6 @@ namespace xo {
|
||||||
FacetRegistry::instance().visit_pools(visitor);
|
FacetRegistry::instance().visit_pools(visitor);
|
||||||
vsm.visit_pools(visitor);
|
vsm.visit_pools(visitor);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
} /*namespace ut*/
|
} /*namespace ut*/
|
||||||
} /*namespace xo*/
|
} /*namespace xo*/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -208,6 +208,34 @@ xo_add_genfacetimpl(
|
||||||
OUTPUT_CPP_DIR src/object2
|
OUTPUT_CPP_DIR src/object2
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------
|
||||||
|
|
||||||
|
# note: manual target; generated code committed to git
|
||||||
|
xo_add_genfacetimpl(
|
||||||
|
TARGET xo-object2-facetimpl-printable-runtimeerror
|
||||||
|
FACET_PKG xo_printable2
|
||||||
|
FACET Printable
|
||||||
|
REPR RuntimeError
|
||||||
|
INPUT idl/IPrintable_DRuntimeError.json5
|
||||||
|
OUTPUT_HPP_DIR include/xo/object2
|
||||||
|
OUTPUT_IMPL_SUBDIR error
|
||||||
|
OUTPUT_CPP_DIR src/object2
|
||||||
|
)
|
||||||
|
|
||||||
|
# note: manual target; generated code committed to git
|
||||||
|
xo_add_genfacetimpl(
|
||||||
|
TARGET xo-object2-facetimpl-gcobject-runtimeerror
|
||||||
|
FACET_PKG xo_gc
|
||||||
|
FACET GCObject
|
||||||
|
REPR RuntimeError
|
||||||
|
INPUT idl/IGCObject_DRuntimeError.json5
|
||||||
|
OUTPUT_HPP_DIR include/xo/object2
|
||||||
|
OUTPUT_IMPL_SUBDIR error
|
||||||
|
OUTPUT_CPP_DIR src/object2
|
||||||
|
)
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------
|
||||||
|
|
||||||
xo_add_genfacet_all(xo-object2-genfacet-all)
|
xo_add_genfacet_all(xo-object2-genfacet-all)
|
||||||
|
|
||||||
# ----------------------------------------------------------------
|
# ----------------------------------------------------------------
|
||||||
|
|
|
||||||
15
xo-object2/idl/IGCObject_DRuntimeError.json5
Normal file
15
xo-object2/idl/IGCObject_DRuntimeError.json5
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
mode: "implementation",
|
||||||
|
includes: [
|
||||||
|
// "<xo/gc/GCObject.hpp>",
|
||||||
|
// "<xo/alloc2/Allocator.hpp>"
|
||||||
|
],
|
||||||
|
local_types: [ ],
|
||||||
|
namespace1: "xo",
|
||||||
|
namespace2: "scm",
|
||||||
|
facet_idl: "idl/GCObject.json5",
|
||||||
|
brief: "provide AGCObject interface for DRuntimeError",
|
||||||
|
using_doxygen: true,
|
||||||
|
repr: "DRuntimeError",
|
||||||
|
doc: [ "implement AGCObject for DRuntimeError" ],
|
||||||
|
}
|
||||||
13
xo-object2/idl/IPrintable_DRuntimeError.json5
Normal file
13
xo-object2/idl/IPrintable_DRuntimeError.json5
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
mode: "implementation",
|
||||||
|
includes: [ "<xo/printable2/Printable.hpp>",
|
||||||
|
"<xo/printable2/detail/IPrintable_Xfer.hpp>" ],
|
||||||
|
local_types: [ ],
|
||||||
|
namespace1: "xo",
|
||||||
|
namespace2: "scm",
|
||||||
|
facet_idl: "idl/Printable.json5",
|
||||||
|
brief: "provide APrintable interface for DRuntimeError",
|
||||||
|
using_doxygen: true,
|
||||||
|
repr: "DRuntimeError",
|
||||||
|
doc: [ "implement APrintable for DRuntimeError" ],
|
||||||
|
}
|
||||||
61
xo-object2/include/xo/object2/DRuntimeError.hpp
Normal file
61
xo-object2/include/xo/object2/DRuntimeError.hpp
Normal 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 */
|
||||||
12
xo-object2/include/xo/object2/RuntimeError.hpp
Normal file
12
xo-object2/include/xo/object2/RuntimeError.hpp
Normal 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 */
|
||||||
|
|
@ -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 */
|
||||||
|
|
@ -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 */
|
||||||
|
|
@ -5,29 +5,41 @@ set(SELF_SRCS
|
||||||
init_object2.cpp
|
init_object2.cpp
|
||||||
object2_register_types.cpp
|
object2_register_types.cpp
|
||||||
object2_register_facets.cpp
|
object2_register_facets.cpp
|
||||||
|
|
||||||
GCObjectConversion_DFloat.cpp
|
GCObjectConversion_DFloat.cpp
|
||||||
GCObjectConversion_DInteger.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_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
|
DArray.cpp
|
||||||
|
ISequence_DArray.cpp
|
||||||
|
IGCObject_DArray.cpp
|
||||||
|
IPrintable_DArray.cpp
|
||||||
|
|
||||||
DList.cpp
|
DList.cpp
|
||||||
|
ISequence_DList.cpp
|
||||||
|
IGCObject_DList.cpp
|
||||||
|
IPrintable_DList.cpp
|
||||||
|
|
||||||
DFloat.cpp
|
DFloat.cpp
|
||||||
|
IGCObject_DFloat.cpp
|
||||||
|
IPrintable_DFloat.cpp
|
||||||
|
|
||||||
DInteger.cpp
|
DInteger.cpp
|
||||||
|
IGCObject_DInteger.cpp
|
||||||
|
IPrintable_DInteger.cpp
|
||||||
|
|
||||||
DBoolean.cpp
|
DBoolean.cpp
|
||||||
|
IGCObject_DBoolean.cpp
|
||||||
|
IPrintable_DBoolean.cpp
|
||||||
|
|
||||||
DString.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})
|
xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 ${SELF_SRCS})
|
||||||
|
|
|
||||||
|
|
@ -148,6 +148,8 @@ namespace xo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----- GCObject facet ------
|
||||||
|
|
||||||
auto
|
auto
|
||||||
DList::shallow_size() const noexcept -> size_type
|
DList::shallow_size() const noexcept -> size_type
|
||||||
{
|
{
|
||||||
|
|
@ -175,7 +177,7 @@ namespace xo {
|
||||||
auto iface = xo::facet::impl_for<AGCObject,DList>();
|
auto iface = xo::facet::impl_for<AGCObject,DList>();
|
||||||
gc.forward_inplace(&iface, (void **)(&rest_));
|
gc.forward_inplace(&iface, (void **)(&rest_));
|
||||||
|
|
||||||
return shallow_size();
|
return this->shallow_size();
|
||||||
}
|
}
|
||||||
} /*namespace scm*/
|
} /*namespace scm*/
|
||||||
} /*namespace xo*/
|
} /*namespace xo*/
|
||||||
|
|
|
||||||
82
xo-object2/src/object2/DRuntimeError.cpp
Normal file
82
xo-object2/src/object2/DRuntimeError.cpp
Normal 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 */
|
||||||
|
|
||||||
39
xo-object2/src/object2/IGCObject_DRuntimeError.cpp
Normal file
39
xo-object2/src/object2/IGCObject_DRuntimeError.cpp
Normal 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 */
|
||||||
28
xo-object2/src/object2/IPrintable_DRuntimeError.cpp
Normal file
28
xo-object2/src/object2/IPrintable_DRuntimeError.cpp
Normal 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 */
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#include "object2_register_facets.hpp"
|
#include "object2_register_facets.hpp"
|
||||||
|
#include "RuntimeError.hpp"
|
||||||
|
|
||||||
#include <xo/object2/array/IGCObject_DArray.hpp>
|
#include <xo/object2/array/IGCObject_DArray.hpp>
|
||||||
#include <xo/object2/list/IGCObject_DList.hpp>
|
#include <xo/object2/list/IGCObject_DList.hpp>
|
||||||
|
|
@ -66,6 +67,9 @@ namespace xo {
|
||||||
FacetRegistry::register_impl<APrintable, DArray>();
|
FacetRegistry::register_impl<APrintable, DArray>();
|
||||||
FacetRegistry::register_impl<ASequence, 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("DVariantPlaceholder.tseq", typeseq::id<DVariantPlaceholder>()));
|
||||||
|
|
||||||
log && log(xtag("DList.tseq", typeseq::id<DList>()));
|
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("DInteger.tseq", typeseq::id<DInteger>()));
|
||||||
log && log(xtag("DString.tseq", typeseq::id<DString>()));
|
log && log(xtag("DString.tseq", typeseq::id<DString>()));
|
||||||
log && log(xtag("DArray.tseq", typeseq::id<DArray>()));
|
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("AAllocator.tseq", typeseq::id<AAllocator>()));
|
||||||
log && log(xtag("APrintable.tseq", typeseq::id<APrintable>()));
|
log && log(xtag("APrintable.tseq", typeseq::id<APrintable>()));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue