xo-reader2: construct LambdaExpr to complete LambdaSsm + utest

This commit is contained in:
Roland Conybeare 2026-02-01 00:16:37 -05:00
commit c6c05ab633
4 changed files with 51 additions and 3 deletions

View file

@ -1,10 +1,12 @@
/** @file DLambda.cpp
/** @file DLambdaExpr.cpp
*
* @author Roland Conybeare, Jan 2026
**/
#include "DLambdaExpr.hpp"
#include "detail/IExpression_DLambdaExpr.hpp"
#include "DLocalSymtab.hpp"
#include "symtab/IPrintable_DLocalSymtab.hpp"
#include <xo/alloc2/Allocator.hpp>
#include <xo/printable2/Printable.hpp>
#include <xo/facet/FacetRegistry.hpp>
@ -17,6 +19,7 @@ namespace xo {
using xo::reflect::TypeDescrBase;
using xo::reflect::FunctionTdxInfo;
using xo::reflect::typeseq;
using xo::print::quot;
namespace scm {
@ -139,9 +142,14 @@ namespace xo {
AExpression>(body_expr_);
if (name_ && body) {
auto local_symtab_pr
= obj<APrintable,DLocalSymtab>(local_symtab_);
return ppii.pps()->pretty_struct(ppii,
"LambdaExpr",
refrtag("name", name_),
refrtag("tref", typeref_),
refrtag("name", quot(std::string_view(*name_))),
refrtag("local_symtab", local_symtab_pr),
//refrtag("argv", local_env_->argv()),
refrtag("body", body));
} else {

View file

@ -6,6 +6,7 @@
#include "DSequenceExpr.hpp"
#include "detail/IExpression_DSequenceExpr.hpp"
#include <xo/object2/array/IGCObject_DArray.hpp>
#include <xo/object2/array/IPrintable_DArray.hpp>
#include <xo/gc/GCObject.hpp>
#include <xo/alloc2/Allocator.hpp>
#include <xo/printable2/Printable.hpp>
@ -15,6 +16,7 @@
namespace xo {
using xo::mm::AGCObject;
using xo::print::APrintable;
using xo::facet::FacetRegistry;
using xo::reflect::typeseq;
@ -95,9 +97,12 @@ namespace xo {
{
using xo::print::ppstate;
auto expr_v_pr = obj<APrintable,DArray>(expr_v_);
return ppii.pps()->pretty_struct
(ppii,
"DSequenceExpr");
"DSequenceExpr",
refrtag("expr_v", expr_v_pr));
}
// gc hooks for IGCObject_DSequenceExpr

View file

@ -72,6 +72,36 @@ namespace xo {
return nullptr;
}
const DUniqueString *
StringTable::gensym(std::string_view prefix)
{
static std::size_t s_counter = 0;
while (true) {
++s_counter;
char buf[80];
assert(prefix.size() + 20 < sizeof(buf));
int n = snprintf(buf, sizeof(buf),
"%s:%lu",
prefix.data(), s_counter);
if ((0 < n) && (std::size_t(n) < sizeof(buf)))
buf[n] = '\0';
else
buf[sizeof(buf)-1] = '\0';
std::string_view sv(buf);
const DUniqueString * retval = this->lookup(sv);
if (!retval) {
/* not already in string view -> we have viable candidate */
retval = this->intern(sv);
return retval;
}
}
}
bool
StringTable::verify_ok(verify_policy policy) const
{