xo-interpreter2 stack: work on apply for closures [WIP]

This commit is contained in:
Roland Conybeare 2026-02-12 20:09:22 -05:00
commit fd0e5613dd
8 changed files with 47 additions and 27 deletions

View file

@ -7,6 +7,7 @@
#include "LambdaExpr.hpp"
#include "LocalEnv.hpp"
#include "VsmRcx.hpp"
#include <xo/object2/RuntimeError.hpp>
#include <xo/indentlog/scope.hpp>
#include <cstddef>
@ -35,6 +36,8 @@ namespace xo {
DClosure::apply_nocheck(obj<ARuntimeContext> rcx,
const DArray * args)
{
(void)args;
scope log(XO_DEBUG(true));
auto vsm_rcx
@ -42,26 +45,31 @@ namespace xo {
log && log(xtag("vsm_rcx.data", (void*)vsm_rcx.data()));
// let's try a not-implemented error
// don't want to clutter Procedure facet, since it's
// lower-level than xo-interpreter2
// we already checked this stuff before calling apply_nocheck()
// assert (n_args == args->size());
#ifdef NOT_YET
// TODO: verify arguments against type signature.
// unless we have evidence that program is type correct
int32_t n_args = this->n_args();
if (n_args != args->size()) {
//
}
auto local_env
= DLocalEnv::_make(vsm_rcx->allocator(),
env_,
lambda_->local_symtab(),
args);
#endif
// plan:
// 1. push current local environment to vsm stack_
// 2. set expr_ to lambda body
// 2. set pc_ to eval
// 3. set cont_ to restore local_env_
(void)args;
auto err_mm
= vsm_rcx->error_allocator();
assert(false);
auto err
= DRuntimeError::make(err_mm,
"DClosure::apply_nocheck",
"not implemented");
return err;
}
size_t

View file

@ -22,10 +22,10 @@ namespace xo {
{}
DLocalEnv *
DLocalEnv::_make_empty(obj<AAllocator> mm,
DLocalEnv * parent,
DLocalSymtab * symtab,
DArray * args)
DLocalEnv::_make(obj<AAllocator> mm,
DLocalEnv * parent,
DLocalSymtab * symtab,
DArray * args)
{
assert(symtab);

View file

@ -19,6 +19,12 @@ namespace xo {
return vsm_->allocator();
}
obj<AAllocator>
DVsmRcx::error_allocator() const noexcept
{
return vsm_->error_allocator();
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -82,6 +82,7 @@ namespace xo {
VirtualSchematikaMachine::visit_pools(const MemorySizeVisitor & visitor) const
{
mm_.visit_pools(visitor);
error_mm_.visit_pools(visitor);
reader_.visit_pools(visitor);
}