xo-reader/include/xo/interpreter2/DVsmEvalArgsFrame.hpp
Roland Conybeare 895e8d7a34 xo-interpreter2 stack: + reason arg to visit_gco_children()
Helps streamline DX1Collector in xo-gc/.
Want both forward and verify entry points for the same
representation.
2026-04-10 01:10:03 -04:00

67 lines
2.3 KiB
C++

/** @file DVsmEvalArgsFrame.hpp
*
* @author Roland Conybeare, Feb 2026
**/
#pragma once
#include "VsmApplyFrame.hpp"
#include <xo/expression2/DApplyExpr.hpp>
namespace xo {
namespace scm {
/** frame for executing an apply expression **/
class DVsmEvalArgsFrame {
public:
using AGCObject = xo::mm::AGCObject;
using AGCObjectVisitor = xo::mm::AGCObjectVisitor;
using VisitReason = xo::mm::VisitReason;
using AAllocator = xo::mm::AAllocator;
using ppindentinfo = xo::print::ppindentinfo;
public:
/** see picture in VirtualSchematikaMachine._do_eval_apply_op()
*
* old_parent = [apply frame]
* old_cont = [xfer to called function]
*
**/
DVsmEvalArgsFrame(DVsmApplyFrame * parent,
VsmInstr cont,
DApplyExpr * apply_expr);
static DVsmEvalArgsFrame * make(obj<AAllocator> mm,
DVsmApplyFrame * apply_frame,
VsmInstr old_cont,
DApplyExpr * apply_expr);
DVsmApplyFrame * parent() const noexcept { return parent_; }
VsmInstr cont() const noexcept { return cont_; }
const DApplyExpr * apply_expr() const noexcept { return apply_expr_; }
int32_t i_arg() const noexcept { return i_arg_; }
int32_t increment_arg() { return ++i_arg_; }
DVsmEvalArgsFrame * gco_shallow_move(obj<AGCObjectVisitor> gc) noexcept;
void visit_gco_children(VisitReason reason, obj<AGCObjectVisitor> gc) noexcept;
bool pretty(const ppindentinfo & ppii) const;
protected:
/** parent stack frame **/
DVsmApplyFrame * parent_ = nullptr;
/** continuation after eval args completed (always VsmInstr::c_apply) **/
VsmInstr cont_;
/** expression being evaluated **/
DApplyExpr * apply_expr_ = nullptr;
/** next argument to be evaluated. -1 means function head **/
int32_t i_arg_ = -1;
};
} /*namespace scm*/
} /*namespace xo*/
/* end DVsmEvalArgsFrame.hpp */