diff --git a/xo-expression2/CMakeLists.txt b/xo-expression2/CMakeLists.txt index dd7ee89a..1b84df8d 100644 --- a/xo-expression2/CMakeLists.txt +++ b/xo-expression2/CMakeLists.txt @@ -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 xo_add_genfacet( TARGET xo-expression2-facet-expression diff --git a/xo-expression2/idl/IGCObject_DGlobalSymtab.json5 b/xo-expression2/idl/IGCObject_DGlobalSymtab.json5 new file mode 100644 index 00000000..dac8ebac --- /dev/null +++ b/xo-expression2/idl/IGCObject_DGlobalSymtab.json5 @@ -0,0 +1,16 @@ +{ + mode: "implementation", + output_cpp_dir: "src/expression2", + includes: [ + "", + "" + ], + 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" ], +} diff --git a/xo-expression2/idl/IPrintable_DGlobalSymtab.json5 b/xo-expression2/idl/IPrintable_DGlobalSymtab.json5 new file mode 100644 index 00000000..151f8a90 --- /dev/null +++ b/xo-expression2/idl/IPrintable_DGlobalSymtab.json5 @@ -0,0 +1,14 @@ +{ + mode: "implementation", + output_cpp_dir: "src/expression2", + includes: [ "", + "" ], + 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" ], +} diff --git a/xo-expression2/idl/ISymbolTable_DGlobalSymtab.json5 b/xo-expression2/idl/ISymbolTable_DGlobalSymtab.json5 new file mode 100644 index 00000000..8cc1035b --- /dev/null +++ b/xo-expression2/idl/ISymbolTable_DGlobalSymtab.json5 @@ -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" ], +} diff --git a/xo-expression2/include/xo/expression2/DGlobalSymtab.hpp b/xo-expression2/include/xo/expression2/DGlobalSymtab.hpp index 879c7073..6ae8895b 100644 --- a/xo-expression2/include/xo/expression2/DGlobalSymtab.hpp +++ b/xo-expression2/include/xo/expression2/DGlobalSymtab.hpp @@ -31,6 +31,7 @@ namespace xo { using ACollector = xo::mm::ACollector; using AAllocator = xo::mm::AAllocator; using MemorySizeVisitor = xo::mm::MemorySizeVisitor; + using ppindentinfo = xo::print::ppindentinfo; public: /** @defgroup scm-globalsymtab-ctors constructors **/ @@ -91,6 +92,13 @@ namespace xo { std::size_t forward_children(obj gc) noexcept; ///@} + /** @defgroup scm-globalsymtab-printable-facet printable facet **/ + ///@{ + + /** pretty-printing support **/ + bool pretty(const ppindentinfo & ppii) const; + + ///@} private: /** map symbols -> bindings. diff --git a/xo-expression2/include/xo/expression2/GlobalSymtab.hpp b/xo-expression2/include/xo/expression2/GlobalSymtab.hpp index 0c0dabf4..05ad9f4b 100644 --- a/xo-expression2/include/xo/expression2/GlobalSymtab.hpp +++ b/xo-expression2/include/xo/expression2/GlobalSymtab.hpp @@ -6,8 +6,8 @@ #pragma once #include "DGlobalSymtab.hpp" -//#include "symtab/ISymbolTable_DGlobalSymtab.hpp" -//#include "symtab/IGCObject_DGlobalSymtab.hpp" -//#include "symtab/IPrintable_DGlobalSymtab.hpp" +#include "symtab/ISymbolTable_DGlobalSymtab.hpp" +#include "symtab/IGCObject_DGlobalSymtab.hpp" +#include "symtab/IPrintable_DGlobalSymtab.hpp" /* end GlobalSymtab.hpp */ diff --git a/xo-expression2/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp b/xo-expression2/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp new file mode 100644 index 00000000..92149015 --- /dev/null +++ b/xo-expression2/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp @@ -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 +#include +#include "DGlobalSymtab.hpp" + +namespace xo { namespace scm { class IGCObject_DGlobalSymtab; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +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 mm) noexcept; + + // non-const methods + /** during GC: forward immdiate children **/ + static size_type forward_children(DGlobalSymtab & self, obj gc) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/xo-expression2/include/xo/expression2/symtab/IPrintable_DGlobalSymtab.hpp b/xo-expression2/include/xo/expression2/symtab/IPrintable_DGlobalSymtab.hpp new file mode 100644 index 00000000..3e6d065c --- /dev/null +++ b/xo-expression2/include/xo/expression2/symtab/IPrintable_DGlobalSymtab.hpp @@ -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 +#include +#include "DGlobalSymtab.hpp" + +namespace xo { namespace scm { class IPrintable_DGlobalSymtab; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +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 */ \ No newline at end of file diff --git a/xo-expression2/include/xo/expression2/symtab/ISymbolTable_DGlobalSymtab.hpp b/xo-expression2/include/xo/expression2/symtab/ISymbolTable_DGlobalSymtab.hpp new file mode 100644 index 00000000..64f90528 --- /dev/null +++ b/xo-expression2/include/xo/expression2/symtab/ISymbolTable_DGlobalSymtab.hpp @@ -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 + { + using ImplType = xo::scm::ISymbolTable_Xfer + ; + }; + } +} + +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 */ \ No newline at end of file diff --git a/xo-expression2/src/expression2/CMakeLists.txt b/xo-expression2/src/expression2/CMakeLists.txt index 749910e4..8aafa01a 100644 --- a/xo-expression2/src/expression2/CMakeLists.txt +++ b/xo-expression2/src/expression2/CMakeLists.txt @@ -58,6 +58,9 @@ set(SELF_SRCS IPrintable_DLocalSymtab.cpp DGlobalSymtab.cpp + ISymbolTable_DGlobalSymtab.cpp + IGCObject_DGlobalSymtab.cpp + IPrintable_DGlobalSymtab.cpp StringTable.cpp diff --git a/xo-expression2/src/expression2/DGlobalSymtab.cpp b/xo-expression2/src/expression2/DGlobalSymtab.cpp index c9897670..70b953dd 100644 --- a/xo-expression2/src/expression2/DGlobalSymtab.cpp +++ b/xo-expression2/src/expression2/DGlobalSymtab.cpp @@ -168,6 +168,18 @@ namespace xo { 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 xo*/ diff --git a/xo-expression2/src/expression2/IGCObject_DGlobalSymtab.cpp b/xo-expression2/src/expression2/IGCObject_DGlobalSymtab.cpp new file mode 100644 index 00000000..d59e6bbf --- /dev/null +++ b/xo-expression2/src/expression2/IGCObject_DGlobalSymtab.cpp @@ -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 mm) noexcept -> Opaque + { + return self.shallow_copy(mm); + } + + auto + IGCObject_DGlobalSymtab::forward_children(DGlobalSymtab & self, obj gc) noexcept -> size_type + { + return self.forward_children(gc); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DGlobalSymtab.cpp */ diff --git a/xo-expression2/src/expression2/IPrintable_DGlobalSymtab.cpp b/xo-expression2/src/expression2/IPrintable_DGlobalSymtab.cpp new file mode 100644 index 00000000..35ecf6e7 --- /dev/null +++ b/xo-expression2/src/expression2/IPrintable_DGlobalSymtab.cpp @@ -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 */ diff --git a/xo-expression2/src/expression2/ISymbolTable_DGlobalSymtab.cpp b/xo-expression2/src/expression2/ISymbolTable_DGlobalSymtab.cpp new file mode 100644 index 00000000..b735a6fb --- /dev/null +++ b/xo-expression2/src/expression2/ISymbolTable_DGlobalSymtab.cpp @@ -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 */ diff --git a/xo-expression2/src/expression2/expression2_register_facets.cpp b/xo-expression2/src/expression2/expression2_register_facets.cpp index a3a4b520..c563c9da 100644 --- a/xo-expression2/src/expression2/expression2_register_facets.cpp +++ b/xo-expression2/src/expression2/expression2_register_facets.cpp @@ -6,8 +6,8 @@ #include "expression2_register_facets.hpp" #include -#include -#include +//#include +//#include #include //#include @@ -101,6 +101,10 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + // until we register facets TypeRegistry::register_type();