xo-interpreter2 stack: refactor: move cons() pm to object2/

This commit is contained in:
Roland Conybeare 2026-03-15 11:51:37 -05:00
commit 7be6463835
3 changed files with 28 additions and 1 deletions

View file

@ -6,6 +6,7 @@
#include "ObjectPrimitives.hpp"
#include <xo/object2/Dictionary.hpp>
#include <xo/object2/Sequence.hpp>
#include <xo/object2/List.hpp>
#include <xo/object2/Integer.hpp>
#include <xo/printable2/Printable.hpp>
#include <xo/stringtable2/String.hpp>
@ -44,6 +45,28 @@ namespace xo {
return DPrimitive_gco_2_gco_gco::_make(mm, "nth", &xfer_nth);
}
// ----- cons -----
obj<AGCObject>
xfer_cons(obj<ARuntimeContext> rcx,
obj<AGCObject> car,
obj<AGCObject> cdr)
{
(void)rcx;
auto cdr_list = obj<AGCObject,DList>::from(cdr);
return DList::cons(rcx.allocator(),
car,
cdr_list.data());
}
DPrimitive_gco_2_gco_gco *
ObjectPrimitives::make_cons_pm(obj<AAllocator> mm)
{
return DPrimitive_gco_2_gco_gco::_make(mm, "cons", &xfer_cons);
}
// ----- dict_make -----
obj<AGCObject>