From 111df958f55155e3a15bb3d740f031cf77e4e980 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 16 Jan 2026 19:04:08 -0500 Subject: [PATCH] xo-expression2: symtab scaffold [WIP] [COSMETIC] --- xo-expression2/idl/ASymbolTable.json5 | 41 ++++++++++++++ .../include/xo/expression2/DLocalSymtab.hpp | 54 +++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 xo-expression2/idl/ASymbolTable.json5 create mode 100644 xo-expression2/include/xo/expression2/DLocalSymtab.hpp diff --git a/xo-expression2/idl/ASymbolTable.json5 b/xo-expression2/idl/ASymbolTable.json5 new file mode 100644 index 00000000..ca10ef91 --- /dev/null +++ b/xo-expression2/idl/ASymbolTable.json5 @@ -0,0 +1,41 @@ +{ + mode: "facet", + includes: [ ], + + namespace1: "xo", + namespace2: "scm", + facet: "SymbolTable", + detail_subdir: "symtab", + brief: "symbol table derived from a set of schematika expressions", + using_doxygen: true, + doc: [ + "Map symbols to schematika expression. Output of schematika parser" + ], + types: [ + // { name: string, doc: [ string ], definition: string }, + ], + const_methods: [ + { + name: "is_global_symtab", + doc: ["true iff this is toplevel (global) symbol table."], + return_type: "bool", + args: [], + const: true, + noexcept: true, + attributes: [], + }, + { + name: "lookup_binding_unint", + doc: ["report ingredients needed to address variable at runtime."], + return_type: "Binding", + args: [ + {type: "DString*", name: "sym"}, + ], + const: true, + noexcept: true, + attributes: [], + }, + ], + nonconst_methods: [ + ], +} diff --git a/xo-expression2/include/xo/expression2/DLocalSymtab.hpp b/xo-expression2/include/xo/expression2/DLocalSymtab.hpp new file mode 100644 index 00000000..b8d583bf --- /dev/null +++ b/xo-expression2/include/xo/expression2/DLocalSymtab.hpp @@ -0,0 +1,54 @@ +/** @file DLocalSymtab.hpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include "TypeRef.hpp" +#include "exprtype.hpp" +#include +#include + +namespace xo { + namespace scm { + /** @class DLocalSymtab + * @brief Schematika expression respresenting a literal constant + **/ + struct DLocalSymtab { + public: + using TaggedPtr = xo::reflect::TaggedPtr; + using TypeDescr = xo::reflect::TypeDescr; + using AGCObject = xo::mm::AGCObject; + using typeseq = xo::reflect::typeseq; + + public: + explicit DLocalSymtab(obj value) noexcept; + + bool is_resolved() const noexcept { return typeref_.is_resolved(); } + + exprtype extype() const noexcept { return exprtype::constant; } + TypeDescr value_td() const noexcept { return typeref_.td(); } + TaggedPtr value_tp() const noexcept { return TaggedPtr(typeref_.td(), value_.data()); } + + TypeRef typeref() const noexcept { return typeref_; } + TypeDescr valuetype() const noexcept { return typeref_.td(); } + obj value() const noexcept { return value_; } + + void assign_valuetype(TypeDescr td) noexcept { typeref_.resolve(td); } + + private: + static TypeDescr _lookup_td(typeseq tseq); + + private: + /** type for value of this expression + * or unification breadcrumb before unification + **/ + TypeRef typeref_; + /** literal value **/ + obj value_; + }; + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DLocalSymtab.hpp */