xo-expression2: + DGlobalSymtab facet support gen + files

This commit is contained in:
Roland Conybeare 2026-02-16 18:21:03 -05:00
commit 06521e5e79
15 changed files with 400 additions and 5 deletions

View file

@ -68,6 +68,41 @@ xo_add_genfacetimpl(
# ---------------------------------------------------------------- # ----------------------------------------------------------------
# note: manual target; generated code committed to git
xo_add_genfacetimpl(
TARGET xo-expression2-facetimpl-symboltable-globalsymtab
FACET_PKG xo_expression2
FACET SymbolTable
REPR GlobalSymtab
INPUT idl/ISymbolTable_DGlobalSymtab.json5
OUTPUT_HPP_DIR include/xo/expression2
OUTPUT_IMPL_SUBDIR symtab
)
# note: manual target; generated code committed to git
xo_add_genfacetimpl(
TARGET xo-expression2-facetimpl-gcobject-globalsymtab
FACET_PKG xo_gc
FACET GCObject
REPR GlobalSymtab
INPUT idl/IGCObject_DGlobalSymtab.json5
OUTPUT_HPP_DIR include/xo/expression2
OUTPUT_IMPL_SUBDIR symtab
)
# note: manual target; generated code committed to git
xo_add_genfacetimpl(
TARGET xo-expression2-facetimpl-printable-globalsymtab
FACET_PKG xo_printable2
FACET Printable
REPR GlobalSymtab
INPUT idl/IPrintable_DGlobalSymtab.json5
OUTPUT_HPP_DIR include/xo/expression2
OUTPUT_IMPL_SUBDIR symtab
)
# ----------------------------------------------------------------
# note: manual target; generated code committed to git # note: manual target; generated code committed to git
xo_add_genfacet( xo_add_genfacet(
TARGET xo-expression2-facet-expression TARGET xo-expression2-facet-expression

View file

@ -0,0 +1,16 @@
{
mode: "implementation",
output_cpp_dir: "src/expression2",
includes: [
"<xo/gc/GCObject.hpp>",
"<xo/alloc2/Allocator.hpp>"
],
local_types: [ ],
namespace1: "xo",
namespace2: "scm",
facet_idl: "idl/GCObject.json5",
brief: "provide AGCObject interface for DGlobalSymtab",
using_doxygen: true,
repr: "DGlobalSymtab",
doc: [ "implement AGCObject for DGlobalSymtab" ],
}

View file

@ -0,0 +1,14 @@
{
mode: "implementation",
output_cpp_dir: "src/expression2",
includes: [ "<xo/printable2/Printable.hpp>",
"<xo/printable2/detail/IPrintable_Xfer.hpp>" ],
local_types: [ ],
namespace1: "xo",
namespace2: "scm",
facet_idl: "idl/Printable.json5",
brief: "provide APrintable interface for DGlobalSymtab",
using_doxygen: true,
repr: "DGlobalSymtab",
doc: [ "implement APrintable for DGlobalSymtab" ],
}

View file

@ -0,0 +1,13 @@
{
mode: "implementation",
output_cpp_dir: "src/expression2",
includes: [ ],
local_types: [ ],
namespace1: "xo",
namespace2: "scm",
facet_idl: "idl/SymbolTable.json5",
brief: "provide ASymbolTable interface for DGlobalSymtab",
using_doxygen: true,
repr: "DGlobalSymtab",
doc: [ "implement ASymbolTable for DGlobalSymtab" ],
}

View file

@ -31,6 +31,7 @@ namespace xo {
using ACollector = xo::mm::ACollector; using ACollector = xo::mm::ACollector;
using AAllocator = xo::mm::AAllocator; using AAllocator = xo::mm::AAllocator;
using MemorySizeVisitor = xo::mm::MemorySizeVisitor; using MemorySizeVisitor = xo::mm::MemorySizeVisitor;
using ppindentinfo = xo::print::ppindentinfo;
public: public:
/** @defgroup scm-globalsymtab-ctors constructors **/ /** @defgroup scm-globalsymtab-ctors constructors **/
@ -91,6 +92,13 @@ namespace xo {
std::size_t forward_children(obj<ACollector> gc) noexcept; std::size_t forward_children(obj<ACollector> gc) noexcept;
///@} ///@}
/** @defgroup scm-globalsymtab-printable-facet printable facet **/
///@{
/** pretty-printing support **/
bool pretty(const ppindentinfo & ppii) const;
///@}
private: private:
/** map symbols -> bindings. /** map symbols -> bindings.

View file

@ -6,8 +6,8 @@
#pragma once #pragma once
#include "DGlobalSymtab.hpp" #include "DGlobalSymtab.hpp"
//#include "symtab/ISymbolTable_DGlobalSymtab.hpp" #include "symtab/ISymbolTable_DGlobalSymtab.hpp"
//#include "symtab/IGCObject_DGlobalSymtab.hpp" #include "symtab/IGCObject_DGlobalSymtab.hpp"
//#include "symtab/IPrintable_DGlobalSymtab.hpp" #include "symtab/IPrintable_DGlobalSymtab.hpp"
/* end GlobalSymtab.hpp */ /* end GlobalSymtab.hpp */

View file

@ -0,0 +1,67 @@
/** @file IGCObject_DGlobalSymtab.hpp
*
* Generated automagically from ingredients:
* 1. code generator:
* [xo-facet/codegen/genfacet]
* arguments:
* --input [idl/IGCObject_DGlobalSymtab.json5]
* 2. jinja2 template for abstract facet .hpp file:
* [iface_facet_repr.hpp.j2]
* 3. idl for facet methods
* [idl/IGCObject_DGlobalSymtab.json5]
**/
#pragma once
#include "GCObject.hpp"
#include <xo/gc/GCObject.hpp>
#include <xo/alloc2/Allocator.hpp>
#include "DGlobalSymtab.hpp"
namespace xo { namespace scm { class IGCObject_DGlobalSymtab; } }
namespace xo {
namespace facet {
template <>
struct FacetImplementation<xo::mm::AGCObject,
xo::scm::DGlobalSymtab>
{
using ImplType = xo::mm::IGCObject_Xfer
<xo::scm::DGlobalSymtab,
xo::scm::IGCObject_DGlobalSymtab>;
};
}
}
namespace xo {
namespace scm {
/** @class IGCObject_DGlobalSymtab
**/
class IGCObject_DGlobalSymtab {
public:
/** @defgroup scm-gcobject-dglobalsymtab-type-traits **/
///@{
using size_type = xo::mm::AGCObject::size_type;
using AAllocator = xo::mm::AGCObject::AAllocator;
using ACollector = xo::mm::AGCObject::ACollector;
using Copaque = xo::mm::AGCObject::Copaque;
using Opaque = xo::mm::AGCObject::Opaque;
///@}
/** @defgroup scm-gcobject-dglobalsymtab-methods **/
///@{
// const methods
/** memory consumption for this instance **/
static size_type shallow_size(const DGlobalSymtab & self) noexcept;
/** copy instance using allocator **/
static Opaque shallow_copy(const DGlobalSymtab & self, obj<AAllocator> mm) noexcept;
// non-const methods
/** during GC: forward immdiate children **/
static size_type forward_children(DGlobalSymtab & self, obj<ACollector> gc) noexcept;
///@}
};
} /*namespace scm*/
} /*namespace xo*/
/* end */

View file

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

View file

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

View file

@ -58,6 +58,9 @@ set(SELF_SRCS
IPrintable_DLocalSymtab.cpp IPrintable_DLocalSymtab.cpp
DGlobalSymtab.cpp DGlobalSymtab.cpp
ISymbolTable_DGlobalSymtab.cpp
IGCObject_DGlobalSymtab.cpp
IPrintable_DGlobalSymtab.cpp
StringTable.cpp StringTable.cpp

View file

@ -168,6 +168,18 @@ namespace xo {
return this->shallow_size(); return this->shallow_size();
} }
// ----- printable facet -----
bool
DGlobalSymtab::pretty(const ppindentinfo & ppii) const
{
return ppii.pps()->pretty_struct
(ppii,
"DGlobalSymtab",
refrtag("nsym", vars_->size()),
refrtag("capacity", vars_->capacity()));
}
} /*namespace scm*/ } /*namespace scm*/
} /*namespace xo*/ } /*namespace xo*/

View file

@ -0,0 +1,39 @@
/** @file IGCObject_DGlobalSymtab.cpp
*
* Generated automagically from ingredients:
* 1. code generator:
* [xo-facet/codegen/genfacet]
* arguments:
* --input [idl/IGCObject_DGlobalSymtab.json5]
* 2. jinja2 template for abstract facet .hpp file:
* [iface_facet_any.hpp.j2]
* 3. idl for facet methods
* [idl/IGCObject_DGlobalSymtab.json5]
**/
#include "symtab/IGCObject_DGlobalSymtab.hpp"
namespace xo {
namespace scm {
auto
IGCObject_DGlobalSymtab::shallow_size(const DGlobalSymtab & self) noexcept -> size_type
{
return self.shallow_size();
}
auto
IGCObject_DGlobalSymtab::shallow_copy(const DGlobalSymtab & self, obj<AAllocator> mm) noexcept -> Opaque
{
return self.shallow_copy(mm);
}
auto
IGCObject_DGlobalSymtab::forward_children(DGlobalSymtab & self, obj<ACollector> gc) noexcept -> size_type
{
return self.forward_children(gc);
}
} /*namespace scm*/
} /*namespace xo*/
/* end IGCObject_DGlobalSymtab.cpp */

View file

@ -0,0 +1,28 @@
/** @file IPrintable_DGlobalSymtab.cpp
*
* Generated automagically from ingredients:
* 1. code generator:
* [xo-facet/codegen/genfacet]
* arguments:
* --input [idl/IPrintable_DGlobalSymtab.json5]
* 2. jinja2 template for abstract facet .hpp file:
* [iface_facet_any.hpp.j2]
* 3. idl for facet methods
* [idl/IPrintable_DGlobalSymtab.json5]
**/
#include "symtab/IPrintable_DGlobalSymtab.hpp"
namespace xo {
namespace scm {
auto
IPrintable_DGlobalSymtab::pretty(const DGlobalSymtab & self, const ppindentinfo & ppii) -> bool
{
return self.pretty(ppii);
}
} /*namespace scm*/
} /*namespace xo*/
/* end IPrintable_DGlobalSymtab.cpp */

View file

@ -0,0 +1,34 @@
/** @file ISymbolTable_DGlobalSymtab.cpp
*
* Generated automagically from ingredients:
* 1. code generator:
* [xo-facet/codegen/genfacet]
* arguments:
* --input [idl/ISymbolTable_DGlobalSymtab.json5]
* 2. jinja2 template for abstract facet .hpp file:
* [iface_facet_any.hpp.j2]
* 3. idl for facet methods
* [idl/ISymbolTable_DGlobalSymtab.json5]
**/
#include "symtab/ISymbolTable_DGlobalSymtab.hpp"
namespace xo {
namespace scm {
auto
ISymbolTable_DGlobalSymtab::is_global_symtab(const DGlobalSymtab & self) noexcept -> bool
{
return self.is_global_symtab();
}
auto
ISymbolTable_DGlobalSymtab::lookup_binding(const DGlobalSymtab & self, const DUniqueString * sym) noexcept -> Binding
{
return self.lookup_binding(sym);
}
} /*namespace scm*/
} /*namespace xo*/
/* end ISymbolTable_DGlobalSymtab.cpp */

View file

@ -6,8 +6,8 @@
#include "expression2_register_facets.hpp" #include "expression2_register_facets.hpp"
#include <xo/expression2/UniqueString.hpp> #include <xo/expression2/UniqueString.hpp>
#include <xo/expression2/detail/IGCObject_DUniqueString.hpp> //#include <xo/expression2/detail/IGCObject_DUniqueString.hpp>
#include <xo/expression2/detail/IPrintable_DUniqueString.hpp> //#include <xo/expression2/detail/IPrintable_DUniqueString.hpp>
#include <xo/expression2/detail/IExpression_DDefineExpr.hpp> #include <xo/expression2/detail/IExpression_DDefineExpr.hpp>
//#include <xo/expression2/detail/IGCObject_DDefineExpr.hpp> //#include <xo/expression2/detail/IGCObject_DDefineExpr.hpp>
@ -101,6 +101,10 @@ namespace xo {
FacetRegistry::register_impl<AGCObject, DLocalSymtab>(); FacetRegistry::register_impl<AGCObject, DLocalSymtab>();
FacetRegistry::register_impl<APrintable, DLocalSymtab>(); FacetRegistry::register_impl<APrintable, DLocalSymtab>();
FacetRegistry::register_impl<ASymbolTable, DGlobalSymtab>();
FacetRegistry::register_impl<AGCObject, DGlobalSymtab>();
FacetRegistry::register_impl<APrintable, DGlobalSymtab>();
// until we register facets // until we register facets
TypeRegistry::register_type<DGlobalSymtab>(); TypeRegistry::register_type<DGlobalSymtab>();