xo-umbrella2/xo-interpreter2/include/xo/interpreter2/VsmInstr.hpp
Roland Conybeare 7f4b4e7cbd git subrepo clone (merge) git@github.com:Rconybea/xo-interpreter2.git xo-interpreter2
subrepo:
  subdir:   "xo-interpreter2"
  merged:   "e4c6ff57"
upstream:
  origin:   "git@github.com:Rconybea/xo-interpreter2.git"
  branch:   "main"
  commit:   "e4c6ff57"
git-subrepo:
  version:  "0.4.9"
  origin:   "???"
  commit:   "???"
2026-06-06 22:13:05 -04:00

63 lines
1.6 KiB
C++

/** @file VsmInstr.hpp
*
* @author Roland Conybeare, Jan 2026
**/
#pragma once
#include "VsmOpcode.hpp"
namespace xo {
namespace scm {
/**
* Thin instruction wrapper for VSM (virtual schematika machine) instructions.
* For exeuction see VirtualSchematikaMachine.cpp
**/
class VsmInstr {
public:
explicit VsmInstr(vsm_opcode oc) : opcode_{oc} {}
// instructions
static VsmInstr c_sentinel;
static VsmInstr c_halt;
static VsmInstr c_eval;
/** proceed to assignment after evaluating rhs
* of define-expression
**/
static VsmInstr c_def_cont;
static VsmInstr c_apply;
static VsmInstr c_evalargs;
/** restore VSM state for continuation of an apply expression **/
static VsmInstr c_apply_cont;
/** proceed to branch of if-else expression after evaluating
* test condition
**/
static VsmInstr c_ifelse_cont;
/** loop to evaluate members of a SequenceExpr **/
static VsmInstr c_seq_cont;
vsm_opcode opcode() const noexcept { return opcode_; }
private:
vsm_opcode opcode_;
};
inline bool
operator==(VsmInstr x, VsmInstr y) noexcept {
return x.opcode() == y.opcode();
}
inline std::ostream &
operator<<(std::ostream & os, VsmInstr x) {
os << x.opcode();
return os;
}
} /*namespace scm*/
} /*namespace xo*/
/* end VsmInstr.hpp */