From 7cc7a277a39f725d0c0f3fdea8c75fd14bca39eb Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 11 Mar 2026 07:49:14 -0500 Subject: [PATCH] xo-reader2 stack: expand symbol table to store typedefs + typedef utest + misc qol policy choices --- include/xo/interpreter2/DGlobalEnv.hpp | 4 ++-- include/xo/interpreter2/DLocalEnv.hpp | 3 ++- src/interpreter2/DGlobalEnv.cpp | 4 ++-- src/interpreter2/DLocalEnv.cpp | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/include/xo/interpreter2/DGlobalEnv.hpp b/include/xo/interpreter2/DGlobalEnv.hpp index e2df166b..da7f8536 100644 --- a/include/xo/interpreter2/DGlobalEnv.hpp +++ b/include/xo/interpreter2/DGlobalEnv.hpp @@ -47,8 +47,8 @@ namespace xo { /** @defgroup scm-globalenv-methods methods **/ ///@{ - /** symbol-table size. Is the number of distinct global symbols **/ - size_type size() const noexcept { return symtab_->size(); } + /** symbol-table size. Is the number of distinct global variables **/ + size_type n_vars() const noexcept { return symtab_->n_vars(); } /** lookup current value associated with binding @p ix **/ obj lookup_value(Binding ix) const noexcept; diff --git a/include/xo/interpreter2/DLocalEnv.hpp b/include/xo/interpreter2/DLocalEnv.hpp index eaef71c2..ab407063 100644 --- a/include/xo/interpreter2/DLocalEnv.hpp +++ b/include/xo/interpreter2/DLocalEnv.hpp @@ -41,7 +41,8 @@ namespace xo { ///@{ DLocalEnv * parent() const noexcept { return parent_; } - size_type size() const noexcept { return symtab_->size(); } + size_type n_vars() const noexcept { return symtab_->n_vars(); } + size_type n_types() const noexcept { return symtab_->n_types(); } /** lookup current value associated with binding @p ix **/ obj lookup_value(Binding ix) const noexcept; diff --git a/src/interpreter2/DGlobalEnv.cpp b/src/interpreter2/DGlobalEnv.cpp index 2ad6c1ba..fcc92efa 100644 --- a/src/interpreter2/DGlobalEnv.cpp +++ b/src/interpreter2/DGlobalEnv.cpp @@ -21,7 +21,7 @@ namespace xo { DGlobalEnv::_make(obj mm, DGlobalSymtab * symtab) { - DArray * values = DArray::empty(mm, symtab->capacity()); + DArray * values = DArray::empty(mm, symtab->var_capacity()); void * mem = mm.alloc_for(); @@ -136,7 +136,7 @@ namespace xo { return ppii.pps()->pretty_struct (ppii, "DGlobalEnv", - refrtag("size", symtab_->size())); + refrtag("n_vars", symtab_->n_vars())); } } /*namespace scm*/ diff --git a/src/interpreter2/DLocalEnv.cpp b/src/interpreter2/DLocalEnv.cpp index 8f45b38a..3831b647 100644 --- a/src/interpreter2/DLocalEnv.cpp +++ b/src/interpreter2/DLocalEnv.cpp @@ -49,7 +49,7 @@ namespace xo { if (env) { auto j = ix.j_slot(); - if (j < static_cast(env->size())) { + if (j < static_cast(env->n_vars())) { return (*(env->args_))[j]; } else { assert(false); @@ -78,7 +78,7 @@ namespace xo { if (env) { auto j = ix.j_slot(); - if (j < static_cast(env->size())) { + if (j < static_cast(env->n_vars())) { log && log("STUB: need write barrier for GC here"); (*(env->args_))[j] = x; } else {