xo-expression2 xo-reader2: local symtab stack in PSM

This commit is contained in:
Roland Conybeare 2026-01-30 10:26:35 -05:00
commit 94efaf46cd
27 changed files with 447 additions and 34 deletions

View file

@ -25,6 +25,7 @@ namespace xo {
static Binding local(int32_t j_slot) { return Binding(0, j_slot); }
bool is_global() const { return i_link_ == s_link_global; }
bool is_local() const { return (i_link_ == 0) && (j_slot_ >= 0); }
int32_t i_link() const noexcept { return i_link_; }
int32_t j_slot() const noexcept { return j_slot_; }

View file

@ -45,20 +45,23 @@ namespace xo {
/** @defgroup scm-lambdaexpr-constructors **/
///@{
/** empty instance with capacity for n slots.
/** empty instance with parent @p p and capacity for @p n slots.
* Caller must ensure that slots_[0..n) are actually addressable
**/
DLocalSymtab(size_type n);
DLocalSymtab(DLocalSymtab * p, size_type n);
/** scaffold empty symtab instance,
* with capacity for @p n slots, using memory from allocator @p mm
**/
static DLocalSymtab * _make_empty(obj<AAllocator> mm, size_type n);
static DLocalSymtab * _make_empty(obj<AAllocator> mm,
DLocalSymtab * p,
size_type n);
///@}
/** @defgroup scm-lambdaexpr-methods **/
///@{
DLocalSymtab * parent() const noexcept { return parent_; }
size_type capacity() const noexcept { return capacity_; }
size_type size() const noexcept { return size_; }
@ -96,6 +99,8 @@ namespace xo {
///@}
private:
/** parent symbol table from scoping surrounding this one **/
DLocalSymtab * parent_ = nullptr;
/** actual range of slots_[] array. Can use inices in [0,..,n) **/
size_type capacity_ = 0;
/** number of slots in use **/

View file

@ -2,7 +2,7 @@
*
* Generated automagically from ingredients:
* 1. code generator:
* [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet]
* [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet]
* arguments:
* --input [idl/IExpression_DIfElseExpr.json5]
* 2. jinja2 template for abstract facet .hpp file:

View file

@ -2,7 +2,7 @@
*
* Generated automagically from ingredients:
* 1. code generator:
* [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet]
* [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet]
* arguments:
* --input [idl/IGCObject_DVariable.json5]
* 2. jinja2 template for abstract facet .hpp file:

View file

@ -2,7 +2,7 @@
*
* Generated automagically from ingredients:
* 1. code generator:
* [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet]
* [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet]
* arguments:
* --input [idl/IPrintable_DIfElseExpr.json5]
* 2. jinja2 template for abstract facet .hpp file:

View file

@ -0,0 +1,62 @@
/** @file IPrintable_DLocalSymtab.hpp
*
* Generated automagically from ingredients:
* 1. code generator:
* [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet]
* arguments:
* --input [idl/IPrintable_DLocalSymtab.json5]
* 2. jinja2 template for abstract facet .hpp file:
* [iface_facet_repr.hpp.j2]
* 3. idl for facet methods
* [idl/IPrintable_DLocalSymtab.json5]
**/
#pragma once
#include "Printable.hpp"
#include <xo/printable2/Printable.hpp>
#include <xo/printable2/detail/IPrintable_Xfer.hpp>
#include "DLocalSymtab.hpp"
namespace xo { namespace scm { class IPrintable_DLocalSymtab; } }
namespace xo {
namespace facet {
template <>
struct FacetImplementation<xo::print::APrintable,
xo::scm::DLocalSymtab>
{
using ImplType = xo::print::IPrintable_Xfer
<xo::scm::DLocalSymtab,
xo::scm::IPrintable_DLocalSymtab>;
};
}
}
namespace xo {
namespace scm {
/** @class IPrintable_DLocalSymtab
**/
class IPrintable_DLocalSymtab {
public:
/** @defgroup scm-printable-dlocalsymtab-type-traits **/
///@{
using ppindentinfo = xo::print::APrintable::ppindentinfo;
using Copaque = xo::print::APrintable::Copaque;
using Opaque = xo::print::APrintable::Opaque;
///@}
/** @defgroup scm-printable-dlocalsymtab-methods **/
///@{
// const methods
/** Pretty-printing support for this object.
See [xo-indentlog/xo/indentlog/pretty.hpp] **/
static bool pretty(const DLocalSymtab & self, const ppindentinfo & ppii);
// non-const methods
///@}
};
} /*namespace scm*/
} /*namespace xo*/
/* end */

View file

@ -0,0 +1,60 @@
/** @file ISymbolTable_DLocalSymtab.hpp
*
* Generated automagically from ingredients:
* 1. code generator:
* [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet]
* arguments:
* --input [idl/ISymbolTable_DLocalSymtab.json5]
* 2. jinja2 template for abstract facet .hpp file:
* [iface_facet_repr.hpp.j2]
* 3. idl for facet methods
* [idl/ISymbolTable_DLocalSymtab.json5]
**/
#pragma once
#include "SymbolTable.hpp"
#include "DLocalSymtab.hpp"
namespace xo { namespace scm { class ISymbolTable_DLocalSymtab; } }
namespace xo {
namespace facet {
template <>
struct FacetImplementation<xo::scm::ASymbolTable,
xo::scm::DLocalSymtab>
{
using ImplType = xo::scm::ISymbolTable_Xfer
<xo::scm::DLocalSymtab,
xo::scm::ISymbolTable_DLocalSymtab>;
};
}
}
namespace xo {
namespace scm {
/** @class ISymbolTable_DLocalSymtab
**/
class ISymbolTable_DLocalSymtab {
public:
/** @defgroup scm-symboltable-dlocalsymtab-type-traits **/
///@{
using Copaque = xo::scm::ASymbolTable::Copaque;
using Opaque = xo::scm::ASymbolTable::Opaque;
///@}
/** @defgroup scm-symboltable-dlocalsymtab-methods **/
///@{
// const methods
/** true iff this is toplevel (global) symbol table. **/
static bool is_global_symtab(const DLocalSymtab & self) noexcept;
/** report ingredients needed to address variable at runtime. **/
static Binding lookup_binding(const DLocalSymtab & self, const DUniqueString * sym) noexcept;
// non-const methods
///@}
};
} /*namespace scm*/
} /*namespace xo*/
/* end */