From fbf88809a690ed41684b48c7da89d7118868eff4 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 27 Jan 2026 22:35:22 -0500 Subject: [PATCH] xo-expression2: + LambdaExpr ++ LocalSymtab --- xo-expression2/CMakeLists.txt | 26 ++++ .../idl/IExpression_DLambdaExpr.json5 | 12 ++ .../idl/IPrintable_DLambdaExpr.json5 | 13 ++ .../include/xo/expression2/Binding.hpp | 1 + .../include/xo/expression2/DLambdaExpr.hpp | 111 +++++++++++++++ .../include/xo/expression2/DLocalSymtab.hpp | 68 ++++++++- .../detail/IExpression_DLambdaExpr.hpp | 66 +++++++++ .../detail/IPrintable_DLambdaExpr.hpp | 62 +++++++++ .../include/xo/expression2/exprtype.hpp | 4 +- xo-expression2/src/expression2/CMakeLists.txt | 4 + .../src/expression2/DLambdaExpr.cpp | 129 ++++++++++++++++++ .../src/expression2/DLocalSymtab.cpp | 53 ++++++- .../expression2/IExpression_DLambdaExpr.cpp | 45 ++++++ .../expression2/IPrintable_DLambdaExpr.cpp | 28 ++++ .../expression2_register_facets.cpp | 8 ++ .../interpreter2/VirtualSchematikaMachine.hpp | 6 + .../interpreter2/VirtualSchematikaMachine.cpp | 10 ++ 17 files changed, 637 insertions(+), 9 deletions(-) create mode 100644 xo-expression2/idl/IExpression_DLambdaExpr.json5 create mode 100644 xo-expression2/idl/IPrintable_DLambdaExpr.json5 create mode 100644 xo-expression2/include/xo/expression2/DLambdaExpr.hpp create mode 100644 xo-expression2/include/xo/expression2/detail/IExpression_DLambdaExpr.hpp create mode 100644 xo-expression2/include/xo/expression2/detail/IPrintable_DLambdaExpr.hpp create mode 100644 xo-expression2/src/expression2/DLambdaExpr.cpp create mode 100644 xo-expression2/src/expression2/IExpression_DLambdaExpr.cpp create mode 100644 xo-expression2/src/expression2/IPrintable_DLambdaExpr.cpp diff --git a/xo-expression2/CMakeLists.txt b/xo-expression2/CMakeLists.txt index 5fc6d451..3eaff32c 100644 --- a/xo-expression2/CMakeLists.txt +++ b/xo-expression2/CMakeLists.txt @@ -150,6 +150,32 @@ xo_add_genfacetimpl( # ---------------------------------------------------------------- +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-expression-lambdaexpr + FACET_PKG xo_expression2 + FACET Expression + REPR LambdaExpr + INPUT idl/IExpression_DLambdaExpr.json5 + OUTPUT_HPP_DIR include/xo/expression2 + OUTPUT_IMPL_SUBDIR detail + OUTPUT_CPP_DIR src/expression2 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-printable-lambdaexpr + FACET_PKG xo_printable2 + FACET Printable + REPR LambdaExpr + INPUT idl/IPrintable_DLambdaExpr.json5 + OUTPUT_HPP_DIR include/xo/expression2 + OUTPUT_IMPL_SUBDIR detail + OUTPUT_CPP_DIR src/expression2 +) + +# ---------------------------------------------------------------- + # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-expression-ifelseexpr diff --git a/xo-expression2/idl/IExpression_DLambdaExpr.json5 b/xo-expression2/idl/IExpression_DLambdaExpr.json5 new file mode 100644 index 00000000..ef1b6704 --- /dev/null +++ b/xo-expression2/idl/IExpression_DLambdaExpr.json5 @@ -0,0 +1,12 @@ +{ + mode: "implementation", + includes: [ "\"Expression.hpp\"" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Expression.json5", + brief: "provide AExpression interface for DLambdaExpr state", + using_doxygen: true, + repr: "DLambdaExpr", + doc: ["doc for IExpression+DLambdaExpr" ], +} diff --git a/xo-expression2/idl/IPrintable_DLambdaExpr.json5 b/xo-expression2/idl/IPrintable_DLambdaExpr.json5 new file mode 100644 index 00000000..02a09424 --- /dev/null +++ b/xo-expression2/idl/IPrintable_DLambdaExpr.json5 @@ -0,0 +1,13 @@ +{ + mode: "implementation", + includes: [ "", + "" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Printable.json5", + brief: "provide APrintable interface for DLambdaExpr", + using_doxygen: true, + repr: "DLambdaExpr", + doc: [ "implement APrintable for DLambdaExpr" ], +} diff --git a/xo-expression2/include/xo/expression2/Binding.hpp b/xo-expression2/include/xo/expression2/Binding.hpp index 5f0f7e27..e97cc715 100644 --- a/xo-expression2/include/xo/expression2/Binding.hpp +++ b/xo-expression2/include/xo/expression2/Binding.hpp @@ -19,6 +19,7 @@ namespace xo { Binding(int32_t i_link, int32_t j_slot) : i_link_{i_link}, j_slot_{j_slot} {} + static Binding null() { return Binding(); } /** global bindings are located by symbol name **/ static Binding global() { return Binding(s_link_global, 0); } static Binding local(int32_t j_slot) { return Binding(0, j_slot); } diff --git a/xo-expression2/include/xo/expression2/DLambdaExpr.hpp b/xo-expression2/include/xo/expression2/DLambdaExpr.hpp new file mode 100644 index 00000000..72492ffb --- /dev/null +++ b/xo-expression2/include/xo/expression2/DLambdaExpr.hpp @@ -0,0 +1,111 @@ +/** @file DLambdaExpr.hpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include "Expression.hpp" +#include "TypeRef.hpp" +#include "exprtype.hpp" +#include "DLocalSymtab.hpp" +#include "DString.hpp" +#include + +namespace xo { + namespace scm { + /** @class DLambdaExpr + * @brief syntax tree for a function/procedure definition + * + **/ + class DLambdaExpr { + public: + using AAllocator = xo::mm::AAllocator; + using TypeDescr = xo::reflect::TypeDescr; + using ppindentinfo = xo::print::ppindentinfo; + + public: + + /** @defgroup scm-lambdaexpr-ctors **/ + ///@{ + + DLambdaExpr(TypeRef typeref, + const DUniqueString * name, + DLocalSymtab * local_symtab, + obj body); + +#ifdef NOT_YET + /** create instance using memory from @p mm **/ + static obj make(obj mm, + TypeRef typeref, + const DUniqueString * name, + DLocalSymtab * local_symtab, + obj body); +#endif + + /** create instance, using memory from @p mm **/ + static DLambdaExpr * _make(obj mm, + TypeRef typeref, + const DUniqueString * name, + DLocalSymtab * local_symtab, + obj body); + ///@} + /** @defgroup scm-lambdaexpr-methods **/ + ///@{ + + // get_free_variables() + // visit_preorder() + // visit_layer() + // xform_layer() + // attach_envs(SymbolTable*) + + ///@} + /** @defgroup scm-lambdaexpr-expression-facet **/ + ///@{ + + exprtype extype() const noexcept; + TypeRef typeref() const noexcept; + TypeDescr valuetype() const noexcept; + void assign_valuetype(TypeDescr td) noexcept; + + ///@} + /** @defgroup scm-lambdaexpr-printable-facet **/ + ///@{ + + bool pretty(const ppindentinfo & ppii) const; + + ///@} + + private: + /** expression value always has type consistent + * with description here + **/ + TypeRef typeref_; + + /** name for this lambda (generated if necessary) **/ + const DUniqueString * name_ = nullptr; + +#ifdef NOT_YET + /** e.g. + * i64(f64,string) + * for function of two arguments with types (f64, string) respectively, + * that returns an i64. + **/ + const DUniqueString * type_name_str_ = nullptr; +#endif + + /** symbol table for lambda arguments **/ + DLocalSymtab * local_symtab_ = nullptr;; + + /** expression for function body **/ + obj body_expr_; + + // free_var_set + // captured_var_set + // layer_var_map + // nested_lambda_map + }; + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DLambdaExpr.hpp */ diff --git a/xo-expression2/include/xo/expression2/DLocalSymtab.hpp b/xo-expression2/include/xo/expression2/DLocalSymtab.hpp index b60b6570..9eada176 100644 --- a/xo-expression2/include/xo/expression2/DLocalSymtab.hpp +++ b/xo-expression2/include/xo/expression2/DLocalSymtab.hpp @@ -6,6 +6,7 @@ #pragma once #include "Binding.hpp" +#include "DVariable.hpp" #include "DUniqueString.hpp" //#include "exprtype.hpp" //#include @@ -23,15 +24,61 @@ namespace xo { // using AGCObject = xo::mm::AGCObject; // using typeseq = xo::reflect::typeseq; + using ppindentinfo = xo::print::ppindentinfo; + using AAllocator = xo::mm::AAllocator; + /* note: uint16_t would be fine too */ + using size_type = std::uint32_t; + struct Slot { - // obj var_; - Binding binding_; + Slot() = default; + explicit Slot(const DVariable * var) : var_{var} {} + + /** variable representing a formal argument. + * binding will be correct only within the same layer + * as top-level lambda body + * (i.e. up to the doorstep of each and every nested lambda) + **/ + const DVariable * var_ = nullptr; }; public: -// explicit DLocalSymtab(obj value) noexcept; + /** @defgroup scm-lambdaexpr-constructors **/ + ///@{ - /** @defgroup xo-expression2-symboltable-facet symboltable facet**/ + /** empty instance with capacity for n slots. + * Caller must ensure that slots_[0..n) are actually addressable + **/ + DLocalSymtab(size_type n); + + /** scaffold empty symtab instance, + * with capacity for @p n slots, using memory from allocator @p mm + **/ + static DLocalSymtab * _make_empty(obj mm, size_type n); + + ///@} + /** @defgroup scm-lambdaexpr-methods **/ + ///@{ + + size_type capacity() const noexcept { return capacity_; } + size_type size() const noexcept { return size_; } + + const DVariable * lookup_var(Binding ix) const noexcept { + assert(ix.i_link() == 0); + assert(ix.j_slot() < static_cast(size_)); + + return slots_[ix.j_slot()].var_; + } + + /** increase slot size (provided beleow capacity) to append + * binding for one local variable. Local variable will be allocated + * from @p mm, named @p name, with type described by @p typeref. + **/ + Binding append_var(obj mm, + const DUniqueString * name, + TypeRef typeref); + + ///@} + /** @defgroup xo-localsymtab-symboltable-facet symboltable facet**/ ///@{ /** true for global symbol table **/ @@ -41,9 +88,20 @@ namespace xo { Binding lookup_binding(const DUniqueString * sym) const noexcept; ///@} + /** @defgroup xo-localsymtab-printable-facet printable facet **/ + ///@{ + + bool pretty(const ppindentinfo & ppii) const; + + ///@} private: - + /** actual range of slots_[] array. Can use inices in [0,..,n) **/ + size_type capacity_ = 0; + /** number of slots in use **/ + size_type size_ = 0; + /** memory for names and bindings **/ + Slot slots_[]; }; } /*namespace scm*/ } /*namespace xo*/ diff --git a/xo-expression2/include/xo/expression2/detail/IExpression_DLambdaExpr.hpp b/xo-expression2/include/xo/expression2/detail/IExpression_DLambdaExpr.hpp new file mode 100644 index 00000000..d488b6b3 --- /dev/null +++ b/xo-expression2/include/xo/expression2/detail/IExpression_DLambdaExpr.hpp @@ -0,0 +1,66 @@ +/** @file IExpression_DLambdaExpr.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IExpression_DLambdaExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IExpression_DLambdaExpr.json5] + **/ + +#pragma once + +#include "Expression.hpp" +#include "Expression.hpp" +#include "DLambdaExpr.hpp" + +namespace xo { namespace scm { class IExpression_DLambdaExpr; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::scm::IExpression_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IExpression_DLambdaExpr + **/ + class IExpression_DLambdaExpr { + public: + /** @defgroup scm-expression-dlambdaexpr-type-traits **/ + ///@{ + using TypeDescr = xo::scm::AExpression::TypeDescr; + using Copaque = xo::scm::AExpression::Copaque; + using Opaque = xo::scm::AExpression::Opaque; + ///@} + /** @defgroup scm-expression-dlambdaexpr-methods **/ + ///@{ + // const methods + /** expression type (constant | apply | ..) **/ + static exprtype extype(const DLambdaExpr & self) noexcept; + /** placeholder for type giving possible values for this expression **/ + static TypeRef typeref(const DLambdaExpr & self) noexcept; + /** type giving possible values for this expression. Maybe null before typecheck **/ + static TypeDescr valuetype(const DLambdaExpr & self) noexcept; + + // non-const methods + /** assing to valuetype member. Useful when scaffolding expressions **/ + static void assign_valuetype(DLambdaExpr & self, TypeDescr td) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/xo-expression2/include/xo/expression2/detail/IPrintable_DLambdaExpr.hpp b/xo-expression2/include/xo/expression2/detail/IPrintable_DLambdaExpr.hpp new file mode 100644 index 00000000..64ab6af1 --- /dev/null +++ b/xo-expression2/include/xo/expression2/detail/IPrintable_DLambdaExpr.hpp @@ -0,0 +1,62 @@ +/** @file IPrintable_DLambdaExpr.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DLambdaExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DLambdaExpr.json5] + **/ + +#pragma once + +#include "Printable.hpp" +#include +#include +#include "DLambdaExpr.hpp" + +namespace xo { namespace scm { class IPrintable_DLambdaExpr; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IPrintable_DLambdaExpr + **/ + class IPrintable_DLambdaExpr { + public: + /** @defgroup scm-printable-dlambdaexpr-type-traits **/ + ///@{ + using ppindentinfo = xo::print::APrintable::ppindentinfo; + using Copaque = xo::print::APrintable::Copaque; + using Opaque = xo::print::APrintable::Opaque; + ///@} + /** @defgroup scm-printable-dlambdaexpr-methods **/ + ///@{ + // const methods + /** Pretty-printing support for this object. +See [xo-indentlog/xo/indentlog/pretty.hpp] **/ + static bool pretty(const DLambdaExpr & 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/exprtype.hpp b/xo-expression2/include/xo/expression2/exprtype.hpp index 952051be..861d62bd 100644 --- a/xo-expression2/include/xo/expression2/exprtype.hpp +++ b/xo-expression2/include/xo/expression2/exprtype.hpp @@ -32,10 +32,10 @@ namespace xo { #endif /** function call **/ apply, -#ifdef NOT_YET + /** function definition **/ lambda, -#endif + /** variable reference **/ variable, /** if-then-else **/ diff --git a/xo-expression2/src/expression2/CMakeLists.txt b/xo-expression2/src/expression2/CMakeLists.txt index 840e7070..0aa357b9 100644 --- a/xo-expression2/src/expression2/CMakeLists.txt +++ b/xo-expression2/src/expression2/CMakeLists.txt @@ -7,6 +7,7 @@ set(SELF_SRCS DConstant.cpp DVariable.cpp DDefineExpr.cpp + DLambdaExpr.cpp DApplyExpr.cpp DIfElseExpr.cpp @@ -26,6 +27,9 @@ set(SELF_SRCS IExpression_DApplyExpr.cpp IPrintable_DApplyExpr.cpp + IExpression_DLambdaExpr.cpp + IPrintable_DLambdaExpr.cpp + IExpression_DIfElseExpr.cpp IPrintable_DIfElseExpr.cpp diff --git a/xo-expression2/src/expression2/DLambdaExpr.cpp b/xo-expression2/src/expression2/DLambdaExpr.cpp new file mode 100644 index 00000000..18f737ab --- /dev/null +++ b/xo-expression2/src/expression2/DLambdaExpr.cpp @@ -0,0 +1,129 @@ +/** @file DLambda.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include "DLambdaExpr.hpp" +// #include "detail/IExpression_DLambdaExpr.hpp" +#include +#include +#include +#include + +namespace xo { + using xo::print::APrintable; + using xo::facet::FacetRegistry; + using xo::reflect::TypeDescr; + using xo::reflect::typeseq; + + namespace scm { + +#ifdef NOT_YET + TypeDescr + assemble_lambda_td() + { + std::vector arg_td_v; + { + arg_td_v.reserve(local_symtab->size()); + + for (DLocalSymtab::size_type i = 0, n = local_symtab->size(); i < n; ++i) { + const DVariable * var = local_symtab->lookup_var(i); + + if (!var) + break; + + TypeDescr arg_td = var->valuetype(); + + if (!arg_td) + break; + + arg_td_v.push_back(arg_td); + } + } + } +#endif + + DLambdaExpr::DLambdaExpr(TypeRef typeref, + const DUniqueString * name, + DLocalSymtab * local_symtab, + obj body) : typeref_{typeref}, + name_{name}, + local_symtab_{local_symtab}, + body_expr_{body} + { + } + +#ifdef NOT_YET + obj + DLambdaExpr::make(obj mm, + TypeRef typeref, + const DUniqueString * name, + DLocalSymtab * local_symtab, + obj body) + { + return obj(_make(mm, typeref, + name, local_symtab, body); + } +#endif + + DLambdaExpr * + DLambdaExpr::_make(obj mm, + TypeRef typeref, + const DUniqueString * name, + DLocalSymtab * local_symtab, + obj body) + { + // in general we're not going to know argument types yet. + // perhaps want to delay this until after type resolution. + + void * mem = mm.alloc(typeseq::id(), sizeof(DLambdaExpr)); + + return new (mem) DLambdaExpr(typeref, + name, + local_symtab, + body); + } + + exprtype + DLambdaExpr::extype() const noexcept { + return exprtype::lambda; + } + + TypeRef + DLambdaExpr::typeref() const noexcept { + return typeref_; + } + + TypeDescr + DLambdaExpr::valuetype() const noexcept { + return typeref_.td(); + } + + void + DLambdaExpr::assign_valuetype(TypeDescr td) noexcept { + typeref_.resolve(td); + } + + bool + DLambdaExpr::pretty(const ppindentinfo & ppii) const + { + auto body + = FacetRegistry::instance().try_variant(body_expr_); + + if (name_ && body) { + return ppii.pps()->pretty_struct(ppii, + "LambdaExpr", + refrtag("name", name_), + //refrtag("argv", local_env_->argv()), + refrtag("body", body)); + } else { + return ppii.pps()->pretty_struct(ppii, + "LambdaExpr"); + } + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DLambda.cpp */ diff --git a/xo-expression2/src/expression2/DLocalSymtab.cpp b/xo-expression2/src/expression2/DLocalSymtab.cpp index febd1463..c38096ff 100644 --- a/xo-expression2/src/expression2/DLocalSymtab.cpp +++ b/xo-expression2/src/expression2/DLocalSymtab.cpp @@ -8,13 +8,62 @@ #include namespace xo { + using xo::facet::typeseq; + namespace scm { + DLocalSymtab::DLocalSymtab(size_type n) : capacity_{n}, size_{0} + { + for (size_type i = 0; i < n; ++i) { + void * mem = &slots_[i]; + new (mem) Slot(); + } + } + + DLocalSymtab * + DLocalSymtab::_make_empty(obj mm, size_type n) + { + void * mem = mm.alloc(typeseq::id(), + sizeof(DLocalSymtab) + (n * sizeof(Slot))); + + return new (mem) DLocalSymtab(n); + } + + Binding + DLocalSymtab::append_var(obj mm, + const DUniqueString * name, + TypeRef typeref) + { + assert(name); + + if (size_ >= capacity_ || !name) { + assert(false); + + return Binding::null(); + } else { + size_type i_slot = (this->size_)++; + Binding binding = Binding::local(i_slot); + DVariable * var = DVariable::make(mm, name, typeref, binding); + + this->slots_[i_slot] = Slot(var); + + return binding; + } + } + Binding DLocalSymtab::lookup_binding(const DUniqueString * sym) const noexcept { - scope log(XO_DEBUG(true), "stub impl"); - log && log(xtag("sym", std::string_view(*sym))); + assert(sym); + + if (sym) { + for (size_type i = 0; i < size_; ++i) { + const Slot & slot = slots_[i]; + + if (*sym == *(slot.var_->name())) + return slot.var_->path(); + } + } return Binding(); } diff --git a/xo-expression2/src/expression2/IExpression_DLambdaExpr.cpp b/xo-expression2/src/expression2/IExpression_DLambdaExpr.cpp new file mode 100644 index 00000000..273f5544 --- /dev/null +++ b/xo-expression2/src/expression2/IExpression_DLambdaExpr.cpp @@ -0,0 +1,45 @@ +/** @file IExpression_DLambdaExpr.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IExpression_DLambdaExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IExpression_DLambdaExpr.json5] +**/ + +#include "detail/IExpression_DLambdaExpr.hpp" + +namespace xo { + namespace scm { + auto + IExpression_DLambdaExpr::extype(const DLambdaExpr & self) noexcept -> exprtype + { + return self.extype(); + } + + auto + IExpression_DLambdaExpr::typeref(const DLambdaExpr & self) noexcept -> TypeRef + { + return self.typeref(); + } + + auto + IExpression_DLambdaExpr::valuetype(const DLambdaExpr & self) noexcept -> TypeDescr + { + return self.valuetype(); + } + + auto + IExpression_DLambdaExpr::assign_valuetype(DLambdaExpr & self, TypeDescr td) noexcept -> void + { + self.assign_valuetype(td); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IExpression_DLambdaExpr.cpp */ \ No newline at end of file diff --git a/xo-expression2/src/expression2/IPrintable_DLambdaExpr.cpp b/xo-expression2/src/expression2/IPrintable_DLambdaExpr.cpp new file mode 100644 index 00000000..12e6c22c --- /dev/null +++ b/xo-expression2/src/expression2/IPrintable_DLambdaExpr.cpp @@ -0,0 +1,28 @@ +/** @file IPrintable_DLambdaExpr.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DLambdaExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DLambdaExpr.json5] +**/ + +#include "detail/IPrintable_DLambdaExpr.hpp" + +namespace xo { + namespace scm { + auto + IPrintable_DLambdaExpr::pretty(const DLambdaExpr & self, const ppindentinfo & ppii) -> bool + { + return self.pretty(ppii); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IPrintable_DLambdaExpr.cpp */ \ No newline at end of file diff --git a/xo-expression2/src/expression2/expression2_register_facets.cpp b/xo-expression2/src/expression2/expression2_register_facets.cpp index 8ab2ff51..8e10e9a4 100644 --- a/xo-expression2/src/expression2/expression2_register_facets.cpp +++ b/xo-expression2/src/expression2/expression2_register_facets.cpp @@ -20,6 +20,9 @@ #include #include +#include +#include + #include #include @@ -48,6 +51,7 @@ namespace xo { // +- Variable // +- DefineExpr // +- ApplyExpr + // +- LambdaExpr // \- IfElseExpr FacetRegistry::register_impl(); @@ -62,6 +66,9 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); FacetRegistry::register_impl(); @@ -70,6 +77,7 @@ namespace xo { log && log(xtag("DVariable.tseq", typeseq::id())); log && log(xtag("DConstant.tseq", typeseq::id())); log && log(xtag("DApplyExpr.tseq", typeseq::id())); + log && log(xtag("DLambdaExpr.tseq", typeseq::id())); log && log(xtag("DIfElseExpr.tseq", typeseq::id())); log && log(xtag("AExpression.tqseq", typeseq::id())); diff --git a/xo-interpreter2/include/xo/interpreter2/VirtualSchematikaMachine.hpp b/xo-interpreter2/include/xo/interpreter2/VirtualSchematikaMachine.hpp index 066b7ffd..66a1c1e1 100644 --- a/xo-interpreter2/include/xo/interpreter2/VirtualSchematikaMachine.hpp +++ b/xo-interpreter2/include/xo/interpreter2/VirtualSchematikaMachine.hpp @@ -51,6 +51,12 @@ namespace xo { **/ void _do_eval_define_op(); + /** evaluate a lambda expression + * Require: + * - expression in @ref expr_ + **/ + void _do_eval_lambda_op(); + /** evaluate a variable expression * Require: * - expression in @ref expr_ diff --git a/xo-interpreter2/src/interpreter2/VirtualSchematikaMachine.cpp b/xo-interpreter2/src/interpreter2/VirtualSchematikaMachine.cpp index 11a60c64..fe104f9a 100644 --- a/xo-interpreter2/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/xo-interpreter2/src/interpreter2/VirtualSchematikaMachine.cpp @@ -48,6 +48,9 @@ namespace xo { case exprtype::define: _do_eval_define_op(); break; + case exprtype::lambda: + _do_eval_lambda_op(); + break; case exprtype::variable: _do_eval_variable_op(); break; @@ -77,6 +80,13 @@ namespace xo { assert(false); } + void + VirtualSchematikaMachine::_do_eval_lambda_op() + { + // not implemented + assert(false); + } + void VirtualSchematikaMachine::_do_eval_variable_op() {