xo-umbrella2/xo-interpreter/include/xo/interpreter/BuiltinPrimitives.hpp
Roland Conybeare 9eaae04fdf git subrepo clone git@github.com:Rconybea/xo-interpreter.git xo-interpreter
subrepo:
  subdir:   "xo-interpreter"
  merged:   "047658a5"
upstream:
  origin:   "git@github.com:Rconybea/xo-interpreter.git"
  branch:   "main"
  commit:   "047658a5"
git-subrepo:
  version:  "0.4.9"
  origin:   "???"
  commit:   "???"
2026-06-06 22:12:50 -04:00

36 lines
1,008 B
C++

/** @file BuiltinPrimitives.hpp
*
* @author Roland Conybeare, Nov 2025
**/
#include "xo/object/ObjectConverter.hpp"
#include "xo/allocutil/IAlloc.hpp"
#include "Primitive.hpp"
#include "GlobalEnv.hpp"
namespace xo {
namespace scm {
struct BuiltinPrimitives {
public:
using ObjectConverter = xo::obj::ObjectConverter;
template <typename Expr>
static void install_pm(gc::IAlloc * mm, rp<Expr> pm_expr, gp<GlobalEnv> env) {
gp<Object> rhs
= xo::obj::make_primitive(mm, pm_expr->name(), pm_expr->value());
/* store in env using this variable-expr */
rp<Variable> lhs
= Variable::make(pm_expr->name(), pm_expr->value_td());
gp<Object> * addr = env->establish_var(lhs.borrow());
*addr = rhs;
}
static void install(gc::IAlloc * mm, gp<GlobalEnv> env);
};
}
}
/* end BuiltinPrimitives.hpp */