xo-interpreter2: + VsmApplyClosureFrame [WIP, not used]
This commit is contained in:
parent
fd0e5613dd
commit
eecc70d6eb
17 changed files with 410 additions and 12 deletions
52
include/xo/interpreter2/DVsmApplyClosureFrame.hpp
Normal file
52
include/xo/interpreter2/DVsmApplyClosureFrame.hpp
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
/** @file DVsmApplyClosureFrame.hpp
|
||||
*
|
||||
* @author Roland Conybeare, Feb 2026
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "VsmInstr.hpp"
|
||||
#include "DLocalEnv.hpp"
|
||||
#include <xo/expression2/DApplyExpr.hpp>
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
|
||||
/** Frame to preserve VSM registers:
|
||||
* (stack_, parent_, cont_)
|
||||
* while applying a closure.
|
||||
**/
|
||||
class DVsmApplyClosureFrame {
|
||||
public:
|
||||
using ACollector = xo::mm::ACollector;
|
||||
using AAllocator = xo::mm::AAllocator;
|
||||
using AGCObject = xo::mm::AGCObject;
|
||||
using ppindentinfo = xo::print::ppindentinfo;
|
||||
|
||||
public:
|
||||
DVsmApplyClosureFrame(obj<AGCObject> stack,
|
||||
VsmInstr cont,
|
||||
DLocalEnv * env);
|
||||
|
||||
/** gcobject facet **/
|
||||
std::size_t shallow_size() const noexcept;
|
||||
DVsmApplyClosureFrame * shallow_copy(obj<AAllocator> mm) const noexcept;
|
||||
std::size_t forward_children(obj<ACollector> gc) noexcept;
|
||||
|
||||
/** pretty-printing support **/
|
||||
bool pretty(const ppindentinfo & ppii) const;
|
||||
|
||||
protected:
|
||||
/** saved VSM stack_ register **/
|
||||
obj<AGCObject> stack_;
|
||||
/** saved VSM cont_ register **/
|
||||
VsmInstr cont_;
|
||||
/** saved VSM local_env_ register **/
|
||||
DLocalEnv * local_env_ = nullptr;
|
||||
};
|
||||
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end DVsmApplyClosureFrame.hpp */
|
||||
|
|
@ -9,11 +9,12 @@
|
|||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
class DVsmApplyFrame : public VsmFrame {
|
||||
class DVsmApplyFrame {
|
||||
public:
|
||||
using AProcedure = xo::scm::AProcedure;
|
||||
using ACollector = xo::mm::ACollector;
|
||||
using AAllocator = xo::mm::AAllocator;
|
||||
using AGCObject = xo::mm::AGCObject;
|
||||
using ppindentinfo = xo::print::ppindentinfo;
|
||||
|
||||
public:
|
||||
|
|
@ -27,6 +28,8 @@ namespace xo {
|
|||
VsmInstr old_cont,
|
||||
DArray * args);
|
||||
|
||||
obj<AGCObject> parent() const noexcept { return parent_; }
|
||||
VsmInstr cont() const noexcept { return cont_; }
|
||||
obj<AProcedure> fn() const noexcept { return fn_; }
|
||||
DArray * args() const noexcept { return args_; }
|
||||
|
||||
|
|
@ -40,6 +43,10 @@ namespace xo {
|
|||
bool pretty(const ppindentinfo & ppii) const;
|
||||
|
||||
private:
|
||||
/** saved VSM stack; restore when this frame consumed **/
|
||||
obj<AGCObject> parent_;
|
||||
/** saved continuation; restore when this frame consumed **/
|
||||
VsmInstr cont_;
|
||||
/** evaluated target procedure.
|
||||
*
|
||||
* note: when initially created, this will be unpopulated;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ namespace xo {
|
|||
#ifdef OBSOLETE // see DVsmError
|
||||
// TODO: move error to collected space?
|
||||
// or special arena?
|
||||
//
|
||||
//
|
||||
struct EvaluationError {
|
||||
/** source location (in vsm implementation) at which error identified **/
|
||||
std::string_view src_function_;
|
||||
|
|
@ -182,9 +182,10 @@ namespace xo {
|
|||
* stack_
|
||||
* cont_
|
||||
*
|
||||
* Other registers are not preserved
|
||||
* Other registers not preserved
|
||||
* pc_
|
||||
* expr_
|
||||
* local_env_
|
||||
* fn_
|
||||
* args_
|
||||
* value_
|
||||
|
|
@ -200,7 +201,7 @@ namespace xo {
|
|||
|
||||
/** Sidecar allocator for error reporting.
|
||||
* Separate to mitigate interference with @ref mm_
|
||||
* (separate memory so we can for example report
|
||||
* (separate memory so we can for example report
|
||||
* an out-of-memory error).
|
||||
* Likely DArena or similar
|
||||
**/
|
||||
|
|
|
|||
12
include/xo/interpreter2/VsmApplyClosureFrame.hpp
Normal file
12
include/xo/interpreter2/VsmApplyClosureFrame.hpp
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
/** @file VsmApplyClosureFrame.hpp
|
||||
*
|
||||
* @author Roland Conybeare, Feb 2026
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "DVsmApplyClosureFrame.hpp"
|
||||
#include "detail/IGCObject_DVsmApplyClosureFrame.hpp"
|
||||
#include "detail/IPrintable_DVsmApplyClosureFrame.hpp"
|
||||
|
||||
/* end VsmApplyClosureFrame.hpp */
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
/** @file IGCObject_DVsmApplyClosureFrame.hpp
|
||||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/IGCObject_DVsmApplyClosureFrame.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
* [iface_facet_repr.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/IGCObject_DVsmApplyClosureFrame.json5]
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "GCObject.hpp"
|
||||
#include <xo/gc/GCObject.hpp>
|
||||
#include <xo/alloc2/Allocator.hpp>
|
||||
#include "DVsmApplyClosureFrame.hpp"
|
||||
|
||||
namespace xo { namespace scm { class IGCObject_DVsmApplyClosureFrame; } }
|
||||
|
||||
namespace xo {
|
||||
namespace facet {
|
||||
template <>
|
||||
struct FacetImplementation<xo::mm::AGCObject,
|
||||
xo::scm::DVsmApplyClosureFrame>
|
||||
{
|
||||
using ImplType = xo::mm::IGCObject_Xfer
|
||||
<xo::scm::DVsmApplyClosureFrame,
|
||||
xo::scm::IGCObject_DVsmApplyClosureFrame>;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
/** @class IGCObject_DVsmApplyClosureFrame
|
||||
**/
|
||||
class IGCObject_DVsmApplyClosureFrame {
|
||||
public:
|
||||
/** @defgroup scm-gcobject-dvsmapplyclosureframe-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-dvsmapplyclosureframe-methods **/
|
||||
///@{
|
||||
// const methods
|
||||
/** memory consumption for this instance **/
|
||||
static size_type shallow_size(const DVsmApplyClosureFrame & self) noexcept;
|
||||
/** copy instance using allocator **/
|
||||
static Opaque shallow_copy(const DVsmApplyClosureFrame & self, obj<AAllocator> mm) noexcept;
|
||||
|
||||
// non-const methods
|
||||
/** during GC: forward immdiate children **/
|
||||
static size_type forward_children(DVsmApplyClosureFrame & self, obj<ACollector> gc) noexcept;
|
||||
///@}
|
||||
};
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end */
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
/** @file IPrintable_DVsmApplyClosureFrame.hpp
|
||||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/IPrintable_DVsmApplyClosureFrame.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
* [iface_facet_repr.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/IPrintable_DVsmApplyClosureFrame.json5]
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Printable.hpp"
|
||||
#include <xo/printable2/Printable.hpp>
|
||||
#include <xo/printable2/detail/IPrintable_Xfer.hpp>
|
||||
#include "DVsmApplyClosureFrame.hpp"
|
||||
|
||||
namespace xo { namespace scm { class IPrintable_DVsmApplyClosureFrame; } }
|
||||
|
||||
namespace xo {
|
||||
namespace facet {
|
||||
template <>
|
||||
struct FacetImplementation<xo::print::APrintable,
|
||||
xo::scm::DVsmApplyClosureFrame>
|
||||
{
|
||||
using ImplType = xo::print::IPrintable_Xfer
|
||||
<xo::scm::DVsmApplyClosureFrame,
|
||||
xo::scm::IPrintable_DVsmApplyClosureFrame>;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
/** @class IPrintable_DVsmApplyClosureFrame
|
||||
**/
|
||||
class IPrintable_DVsmApplyClosureFrame {
|
||||
public:
|
||||
/** @defgroup scm-printable-dvsmapplyclosureframe-type-traits **/
|
||||
///@{
|
||||
using ppindentinfo = xo::print::APrintable::ppindentinfo;
|
||||
using Copaque = xo::print::APrintable::Copaque;
|
||||
using Opaque = xo::print::APrintable::Opaque;
|
||||
///@}
|
||||
/** @defgroup scm-printable-dvsmapplyclosureframe-methods **/
|
||||
///@{
|
||||
// const methods
|
||||
/** Pretty-printing support for this object.
|
||||
See [xo-indentlog/xo/indentlog/pretty.hpp] **/
|
||||
static bool pretty(const DVsmApplyClosureFrame & self, const ppindentinfo & ppii);
|
||||
|
||||
// non-const methods
|
||||
///@}
|
||||
};
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end */
|
||||
Loading…
Add table
Add a link
Reference in a new issue