From a33f75f6f4d2f3976d9ba2e4ca1bf51114e46874 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 6 Jun 2026 22:10:01 -0400 Subject: [PATCH] git subrepo clone git@github.com:Rconybea/xo-expression2.git xo-expression2 subrepo: subdir: "xo-expression2" merged: "9823ce36" upstream: origin: "git@github.com:Rconybea/xo-expression2.git" branch: "main" commit: "9823ce36" git-subrepo: version: "0.4.9" origin: "???" commit: "???" --- xo-expression2/.gitrepo | 12 + xo-expression2/CMakeLists.txt | 332 +++++++++++++++++ .../cmake/xo-bootstrap-macros.cmake | 33 ++ .../cmake/xo_expression2Config.cmake.in | 20 + xo-expression2/idl/Expression.json5 | 74 ++++ .../idl/IExpression_DApplyExpr.json5 | 15 + .../idl/IExpression_DConstant.json5 | 15 + .../idl/IExpression_DDefineExpr.json5 | 15 + .../idl/IExpression_DIfElseExpr.json5 | 15 + .../idl/IExpression_DLambdaExpr.json5 | 15 + .../idl/IExpression_DSequenceExpr.json5 | 15 + xo-expression2/idl/IExpression_DVarRef.json5 | 15 + .../idl/IExpression_DVariable.json5 | 15 + xo-expression2/idl/IGCObject_DApplyExpr.json5 | 18 + xo-expression2/idl/IGCObject_DConstant.json5 | 18 + .../idl/IGCObject_DDefineExpr.json5 | 18 + .../idl/IGCObject_DGlobalSymtab.json5 | 18 + .../idl/IGCObject_DIfElseExpr.json5 | 18 + .../idl/IGCObject_DLambdaExpr.json5 | 18 + .../idl/IGCObject_DLocalSymtab.json5 | 18 + .../idl/IGCObject_DSequenceExpr.json5 | 18 + xo-expression2/idl/IGCObject_DTypename.json5 | 18 + xo-expression2/idl/IGCObject_DVarRef.json5 | 18 + xo-expression2/idl/IGCObject_DVariable.json5 | 18 + .../idl/IPrintable_DApplyExpr.json5 | 16 + xo-expression2/idl/IPrintable_DConstant.json5 | 16 + .../idl/IPrintable_DDefineExpr.json5 | 16 + .../idl/IPrintable_DGlobalSymtab.json5 | 16 + .../idl/IPrintable_DIfElseExpr.json5 | 16 + .../idl/IPrintable_DLambdaExpr.json5 | 16 + .../idl/IPrintable_DLocalSymtab.json5 | 16 + .../idl/IPrintable_DSequenceExpr.json5 | 16 + xo-expression2/idl/IPrintable_DTypename.json5 | 16 + xo-expression2/idl/IPrintable_DVarRef.json5 | 16 + xo-expression2/idl/IPrintable_DVariable.json5 | 16 + .../idl/ISymbolTable_DGlobalSymtab.json5 | 15 + .../idl/ISymbolTable_DLocalSymtab.json5 | 15 + xo-expression2/idl/SymbolTable.json5 | 63 ++++ .../include/xo/expression2/.gitkeep | 0 .../include/xo/expression2/ApplyExpr.hpp | 13 + .../include/xo/expression2/Binding.hpp | 65 ++++ .../include/xo/expression2/Constant.hpp | 13 + .../include/xo/expression2/DApplyExpr.hpp | 113 ++++++ .../include/xo/expression2/DConstant.hpp | 91 +++++ .../include/xo/expression2/DDefineExpr.hpp | 108 ++++++ .../include/xo/expression2/DGlobalSymtab.hpp | 161 ++++++++ .../include/xo/expression2/DIfElseExpr.hpp | 248 +++++++++++++ .../include/xo/expression2/DLambdaExpr.hpp | 133 +++++++ .../include/xo/expression2/DLocalSymtab.hpp | 128 +++++++ .../include/xo/expression2/DSequenceExpr.hpp | 93 +++++ .../include/xo/expression2/DTypename.hpp | 78 ++++ .../include/xo/expression2/DVarRef.hpp | 85 +++++ .../include/xo/expression2/DVariable.hpp | 93 +++++ .../include/xo/expression2/DefineExpr.hpp | 13 + .../include/xo/expression2/Expression.hpp | 22 ++ .../include/xo/expression2/GlobalSymtab.hpp | 13 + .../include/xo/expression2/IfElseExpr.hpp | 13 + .../include/xo/expression2/LambdaExpr.hpp | 13 + .../include/xo/expression2/LocalSymtab.hpp | 13 + .../include/xo/expression2/SequenceExpr.hpp | 14 + .../xo/expression2/SetupExpression2.hpp | 25 ++ .../include/xo/expression2/SymbolTable.hpp | 22 ++ .../include/xo/expression2/TypeRef.hpp | 111 ++++++ .../include/xo/expression2/Typename.hpp | 12 + .../include/xo/expression2/VarRef.hpp | 13 + .../include/xo/expression2/Variable.hpp | 13 + .../define/IGCObject_DDefineExpr.hpp | 69 ++++ .../xo/expression2/detail/AExpression.hpp | 89 +++++ .../xo/expression2/detail/IExpression_Any.hpp | 92 +++++ .../detail/IExpression_DApplyExpr.hpp | 66 ++++ .../detail/IExpression_DConstant.hpp | 66 ++++ .../detail/IExpression_DDefineExpr.hpp | 66 ++++ .../detail/IExpression_DIfElseExpr.hpp | 66 ++++ .../detail/IExpression_DLambdaExpr.hpp | 66 ++++ .../detail/IExpression_DSequenceExpr.hpp | 66 ++++ .../detail/IExpression_DVarRef.hpp | 66 ++++ .../expression2/detail/IExpression_Xfer.hpp | 103 ++++++ .../detail/IGCObject_DApplyExpr.hpp | 69 ++++ .../detail/IGCObject_DConstant.hpp | 69 ++++ .../detail/IGCObject_DIfElseExpr.hpp | 69 ++++ .../detail/IGCObject_DLambdaExpr.hpp | 69 ++++ .../detail/IGCObject_DSequenceExpr.hpp | 69 ++++ .../expression2/detail/IGCObject_DVarRef.hpp | 69 ++++ .../detail/IPrintable_DApplyExpr.hpp | 62 ++++ .../detail/IPrintable_DConstant.hpp | 62 ++++ .../detail/IPrintable_DDefineExpr.hpp | 62 ++++ .../detail/IPrintable_DIfElseExpr.hpp | 62 ++++ .../detail/IPrintable_DLambdaExpr.hpp | 62 ++++ .../detail/IPrintable_DSequenceExpr.hpp | 62 ++++ .../expression2/detail/IPrintable_DVarRef.hpp | 62 ++++ .../xo/expression2/detail/RExpression.hpp | 94 +++++ .../expression2_register_types.hpp | 15 + .../include/xo/expression2/exprtype.hpp | 98 +++++ .../xo/expression2/init_expression2.hpp | 21 ++ .../xo/expression2/symtab/ASymbolTable.hpp | 82 +++++ .../symtab/IGCObject_DGlobalSymtab.hpp | 69 ++++ .../symtab/IGCObject_DLocalSymtab.hpp | 69 ++++ .../symtab/IPrintable_DGlobalSymtab.hpp | 62 ++++ .../symtab/IPrintable_DLocalSymtab.hpp | 62 ++++ .../expression2/symtab/ISymbolTable_Any.hpp | 89 +++++ .../symtab/ISymbolTable_DGlobalSymtab.hpp | 60 +++ .../symtab/ISymbolTable_DLocalSymtab.hpp | 60 +++ .../expression2/symtab/ISymbolTable_Xfer.hpp | 95 +++++ .../xo/expression2/symtab/RSymbolTable.hpp | 87 +++++ .../typename/IGCObject_DTypename.hpp | 67 ++++ .../typename/IPrintable_DTypename.hpp | 62 ++++ .../variable/IExpression_DVariable.hpp | 66 ++++ .../variable/IGCObject_DVariable.hpp | 69 ++++ .../variable/IPrintable_DVariable.hpp | 62 ++++ xo-expression2/src/expression2/Binding.cpp | 41 +++ xo-expression2/src/expression2/CMakeLists.txt | 80 ++++ xo-expression2/src/expression2/DApplyExpr.cpp | 198 ++++++++++ xo-expression2/src/expression2/DConstant.cpp | 105 ++++++ .../src/expression2/DDefineExpr.cpp | 132 +++++++ .../src/expression2/DGlobalSymtab.cpp | 312 ++++++++++++++++ .../src/expression2/DIfElseExpr.cpp | 229 ++++++++++++ .../src/expression2/DLambdaExpr.cpp | 192 ++++++++++ .../src/expression2/DLocalSymtab.cpp | 207 +++++++++++ .../src/expression2/DSequenceExpr.cpp | 131 +++++++ xo-expression2/src/expression2/DTypename.cpp | 79 ++++ xo-expression2/src/expression2/DVarRef.cpp | 93 +++++ xo-expression2/src/expression2/DVariable.cpp | 72 ++++ .../src/expression2/IExpression_Any.cpp | 48 +++ .../expression2/IExpression_DApplyExpr.cpp | 45 +++ .../src/expression2/IExpression_DConstant.cpp | 45 +++ .../expression2/IExpression_DDefineExpr.cpp | 45 +++ .../expression2/IExpression_DIfElseExpr.cpp | 45 +++ .../expression2/IExpression_DLambdaExpr.cpp | 45 +++ .../expression2/IExpression_DSequenceExpr.cpp | 45 +++ .../src/expression2/IExpression_DVarRef.cpp | 45 +++ .../src/expression2/IGCObject_DApplyExpr.cpp | 32 ++ .../src/expression2/IGCObject_DConstant.cpp | 32 ++ .../src/expression2/IGCObject_DDefineExpr.cpp | 32 ++ .../expression2/IGCObject_DGlobalSymtab.cpp | 32 ++ .../src/expression2/IGCObject_DIfElseExpr.cpp | 32 ++ .../src/expression2/IGCObject_DLambdaExpr.cpp | 32 ++ .../expression2/IGCObject_DLocalSymtab.cpp | 32 ++ .../expression2/IGCObject_DSequenceExpr.cpp | 32 ++ .../src/expression2/IGCObject_DTypename.cpp | 32 ++ .../src/expression2/IGCObject_DVarRef.cpp | 32 ++ .../src/expression2/IPrintable_DApplyExpr.cpp | 28 ++ .../src/expression2/IPrintable_DConstant.cpp | 28 ++ .../expression2/IPrintable_DDefineExpr.cpp | 28 ++ .../expression2/IPrintable_DGlobalSymtab.cpp | 28 ++ .../expression2/IPrintable_DIfElseExpr.cpp | 28 ++ .../expression2/IPrintable_DLambdaExpr.cpp | 28 ++ .../expression2/IPrintable_DLocalSymtab.cpp | 28 ++ .../expression2/IPrintable_DSequenceExpr.cpp | 28 ++ .../src/expression2/IPrintable_DTypename.cpp | 28 ++ .../src/expression2/IPrintable_DVarRef.cpp | 28 ++ .../src/expression2/ISymbolTable_Any.cpp | 42 +++ .../ISymbolTable_DGlobalSymtab.cpp | 34 ++ .../expression2/ISymbolTable_DLocalSymtab.cpp | 34 ++ .../src/expression2/SetupExpression2.cpp | 151 ++++++++ xo-expression2/src/expression2/TypeRef.cpp | 127 +++++++ .../facet/IExpression_DVariable.cpp | 45 +++ .../expression2/facet/IGCObject_DVariable.cpp | 32 ++ .../facet/IPrintable_DVariable.cpp | 28 ++ .../src/expression2/init_expression2.cpp | 40 ++ xo-expression2/utest/CMakeLists.txt | 17 + xo-expression2/utest/DApplyExpr.test.cpp | 327 +++++++++++++++++ xo-expression2/utest/DConstant.test.cpp | 230 ++++++++++++ xo-expression2/utest/DDefineExpr.test.cpp | 317 ++++++++++++++++ xo-expression2/utest/DIfElseExpr.test.cpp | 345 ++++++++++++++++++ xo-expression2/utest/DVariable.test.cpp | 227 ++++++++++++ xo-expression2/utest/X1Collector.test.cpp | 112 ++++++ .../utest/expression2_utest_main.cpp | 24 ++ 167 files changed, 10695 insertions(+) create mode 100644 xo-expression2/.gitrepo create mode 100644 xo-expression2/CMakeLists.txt create mode 100644 xo-expression2/cmake/xo-bootstrap-macros.cmake create mode 100644 xo-expression2/cmake/xo_expression2Config.cmake.in create mode 100644 xo-expression2/idl/Expression.json5 create mode 100644 xo-expression2/idl/IExpression_DApplyExpr.json5 create mode 100644 xo-expression2/idl/IExpression_DConstant.json5 create mode 100644 xo-expression2/idl/IExpression_DDefineExpr.json5 create mode 100644 xo-expression2/idl/IExpression_DIfElseExpr.json5 create mode 100644 xo-expression2/idl/IExpression_DLambdaExpr.json5 create mode 100644 xo-expression2/idl/IExpression_DSequenceExpr.json5 create mode 100644 xo-expression2/idl/IExpression_DVarRef.json5 create mode 100644 xo-expression2/idl/IExpression_DVariable.json5 create mode 100644 xo-expression2/idl/IGCObject_DApplyExpr.json5 create mode 100644 xo-expression2/idl/IGCObject_DConstant.json5 create mode 100644 xo-expression2/idl/IGCObject_DDefineExpr.json5 create mode 100644 xo-expression2/idl/IGCObject_DGlobalSymtab.json5 create mode 100644 xo-expression2/idl/IGCObject_DIfElseExpr.json5 create mode 100644 xo-expression2/idl/IGCObject_DLambdaExpr.json5 create mode 100644 xo-expression2/idl/IGCObject_DLocalSymtab.json5 create mode 100644 xo-expression2/idl/IGCObject_DSequenceExpr.json5 create mode 100644 xo-expression2/idl/IGCObject_DTypename.json5 create mode 100644 xo-expression2/idl/IGCObject_DVarRef.json5 create mode 100644 xo-expression2/idl/IGCObject_DVariable.json5 create mode 100644 xo-expression2/idl/IPrintable_DApplyExpr.json5 create mode 100644 xo-expression2/idl/IPrintable_DConstant.json5 create mode 100644 xo-expression2/idl/IPrintable_DDefineExpr.json5 create mode 100644 xo-expression2/idl/IPrintable_DGlobalSymtab.json5 create mode 100644 xo-expression2/idl/IPrintable_DIfElseExpr.json5 create mode 100644 xo-expression2/idl/IPrintable_DLambdaExpr.json5 create mode 100644 xo-expression2/idl/IPrintable_DLocalSymtab.json5 create mode 100644 xo-expression2/idl/IPrintable_DSequenceExpr.json5 create mode 100644 xo-expression2/idl/IPrintable_DTypename.json5 create mode 100644 xo-expression2/idl/IPrintable_DVarRef.json5 create mode 100644 xo-expression2/idl/IPrintable_DVariable.json5 create mode 100644 xo-expression2/idl/ISymbolTable_DGlobalSymtab.json5 create mode 100644 xo-expression2/idl/ISymbolTable_DLocalSymtab.json5 create mode 100644 xo-expression2/idl/SymbolTable.json5 create mode 100644 xo-expression2/include/xo/expression2/.gitkeep create mode 100644 xo-expression2/include/xo/expression2/ApplyExpr.hpp create mode 100644 xo-expression2/include/xo/expression2/Binding.hpp create mode 100644 xo-expression2/include/xo/expression2/Constant.hpp create mode 100644 xo-expression2/include/xo/expression2/DApplyExpr.hpp create mode 100644 xo-expression2/include/xo/expression2/DConstant.hpp create mode 100644 xo-expression2/include/xo/expression2/DDefineExpr.hpp create mode 100644 xo-expression2/include/xo/expression2/DGlobalSymtab.hpp create mode 100644 xo-expression2/include/xo/expression2/DIfElseExpr.hpp create mode 100644 xo-expression2/include/xo/expression2/DLambdaExpr.hpp create mode 100644 xo-expression2/include/xo/expression2/DLocalSymtab.hpp create mode 100644 xo-expression2/include/xo/expression2/DSequenceExpr.hpp create mode 100644 xo-expression2/include/xo/expression2/DTypename.hpp create mode 100644 xo-expression2/include/xo/expression2/DVarRef.hpp create mode 100644 xo-expression2/include/xo/expression2/DVariable.hpp create mode 100644 xo-expression2/include/xo/expression2/DefineExpr.hpp create mode 100644 xo-expression2/include/xo/expression2/Expression.hpp create mode 100644 xo-expression2/include/xo/expression2/GlobalSymtab.hpp create mode 100644 xo-expression2/include/xo/expression2/IfElseExpr.hpp create mode 100644 xo-expression2/include/xo/expression2/LambdaExpr.hpp create mode 100644 xo-expression2/include/xo/expression2/LocalSymtab.hpp create mode 100644 xo-expression2/include/xo/expression2/SequenceExpr.hpp create mode 100644 xo-expression2/include/xo/expression2/SetupExpression2.hpp create mode 100644 xo-expression2/include/xo/expression2/SymbolTable.hpp create mode 100644 xo-expression2/include/xo/expression2/TypeRef.hpp create mode 100644 xo-expression2/include/xo/expression2/Typename.hpp create mode 100644 xo-expression2/include/xo/expression2/VarRef.hpp create mode 100644 xo-expression2/include/xo/expression2/Variable.hpp create mode 100644 xo-expression2/include/xo/expression2/define/IGCObject_DDefineExpr.hpp create mode 100644 xo-expression2/include/xo/expression2/detail/AExpression.hpp create mode 100644 xo-expression2/include/xo/expression2/detail/IExpression_Any.hpp create mode 100644 xo-expression2/include/xo/expression2/detail/IExpression_DApplyExpr.hpp create mode 100644 xo-expression2/include/xo/expression2/detail/IExpression_DConstant.hpp create mode 100644 xo-expression2/include/xo/expression2/detail/IExpression_DDefineExpr.hpp create mode 100644 xo-expression2/include/xo/expression2/detail/IExpression_DIfElseExpr.hpp create mode 100644 xo-expression2/include/xo/expression2/detail/IExpression_DLambdaExpr.hpp create mode 100644 xo-expression2/include/xo/expression2/detail/IExpression_DSequenceExpr.hpp create mode 100644 xo-expression2/include/xo/expression2/detail/IExpression_DVarRef.hpp create mode 100644 xo-expression2/include/xo/expression2/detail/IExpression_Xfer.hpp create mode 100644 xo-expression2/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp create mode 100644 xo-expression2/include/xo/expression2/detail/IGCObject_DConstant.hpp create mode 100644 xo-expression2/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp create mode 100644 xo-expression2/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp create mode 100644 xo-expression2/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp create mode 100644 xo-expression2/include/xo/expression2/detail/IGCObject_DVarRef.hpp create mode 100644 xo-expression2/include/xo/expression2/detail/IPrintable_DApplyExpr.hpp create mode 100644 xo-expression2/include/xo/expression2/detail/IPrintable_DConstant.hpp create mode 100644 xo-expression2/include/xo/expression2/detail/IPrintable_DDefineExpr.hpp create mode 100644 xo-expression2/include/xo/expression2/detail/IPrintable_DIfElseExpr.hpp create mode 100644 xo-expression2/include/xo/expression2/detail/IPrintable_DLambdaExpr.hpp create mode 100644 xo-expression2/include/xo/expression2/detail/IPrintable_DSequenceExpr.hpp create mode 100644 xo-expression2/include/xo/expression2/detail/IPrintable_DVarRef.hpp create mode 100644 xo-expression2/include/xo/expression2/detail/RExpression.hpp create mode 100644 xo-expression2/include/xo/expression2/expression2_register_types.hpp create mode 100644 xo-expression2/include/xo/expression2/exprtype.hpp create mode 100644 xo-expression2/include/xo/expression2/init_expression2.hpp create mode 100644 xo-expression2/include/xo/expression2/symtab/ASymbolTable.hpp create mode 100644 xo-expression2/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp create mode 100644 xo-expression2/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp create mode 100644 xo-expression2/include/xo/expression2/symtab/IPrintable_DGlobalSymtab.hpp create mode 100644 xo-expression2/include/xo/expression2/symtab/IPrintable_DLocalSymtab.hpp create mode 100644 xo-expression2/include/xo/expression2/symtab/ISymbolTable_Any.hpp create mode 100644 xo-expression2/include/xo/expression2/symtab/ISymbolTable_DGlobalSymtab.hpp create mode 100644 xo-expression2/include/xo/expression2/symtab/ISymbolTable_DLocalSymtab.hpp create mode 100644 xo-expression2/include/xo/expression2/symtab/ISymbolTable_Xfer.hpp create mode 100644 xo-expression2/include/xo/expression2/symtab/RSymbolTable.hpp create mode 100644 xo-expression2/include/xo/expression2/typename/IGCObject_DTypename.hpp create mode 100644 xo-expression2/include/xo/expression2/typename/IPrintable_DTypename.hpp create mode 100644 xo-expression2/include/xo/expression2/variable/IExpression_DVariable.hpp create mode 100644 xo-expression2/include/xo/expression2/variable/IGCObject_DVariable.hpp create mode 100644 xo-expression2/include/xo/expression2/variable/IPrintable_DVariable.hpp create mode 100644 xo-expression2/src/expression2/Binding.cpp create mode 100644 xo-expression2/src/expression2/CMakeLists.txt create mode 100644 xo-expression2/src/expression2/DApplyExpr.cpp create mode 100644 xo-expression2/src/expression2/DConstant.cpp create mode 100644 xo-expression2/src/expression2/DDefineExpr.cpp create mode 100644 xo-expression2/src/expression2/DGlobalSymtab.cpp create mode 100644 xo-expression2/src/expression2/DIfElseExpr.cpp create mode 100644 xo-expression2/src/expression2/DLambdaExpr.cpp create mode 100644 xo-expression2/src/expression2/DLocalSymtab.cpp create mode 100644 xo-expression2/src/expression2/DSequenceExpr.cpp create mode 100644 xo-expression2/src/expression2/DTypename.cpp create mode 100644 xo-expression2/src/expression2/DVarRef.cpp create mode 100644 xo-expression2/src/expression2/DVariable.cpp create mode 100644 xo-expression2/src/expression2/IExpression_Any.cpp create mode 100644 xo-expression2/src/expression2/IExpression_DApplyExpr.cpp create mode 100644 xo-expression2/src/expression2/IExpression_DConstant.cpp create mode 100644 xo-expression2/src/expression2/IExpression_DDefineExpr.cpp create mode 100644 xo-expression2/src/expression2/IExpression_DIfElseExpr.cpp create mode 100644 xo-expression2/src/expression2/IExpression_DLambdaExpr.cpp create mode 100644 xo-expression2/src/expression2/IExpression_DSequenceExpr.cpp create mode 100644 xo-expression2/src/expression2/IExpression_DVarRef.cpp create mode 100644 xo-expression2/src/expression2/IGCObject_DApplyExpr.cpp create mode 100644 xo-expression2/src/expression2/IGCObject_DConstant.cpp create mode 100644 xo-expression2/src/expression2/IGCObject_DDefineExpr.cpp create mode 100644 xo-expression2/src/expression2/IGCObject_DGlobalSymtab.cpp create mode 100644 xo-expression2/src/expression2/IGCObject_DIfElseExpr.cpp create mode 100644 xo-expression2/src/expression2/IGCObject_DLambdaExpr.cpp create mode 100644 xo-expression2/src/expression2/IGCObject_DLocalSymtab.cpp create mode 100644 xo-expression2/src/expression2/IGCObject_DSequenceExpr.cpp create mode 100644 xo-expression2/src/expression2/IGCObject_DTypename.cpp create mode 100644 xo-expression2/src/expression2/IGCObject_DVarRef.cpp create mode 100644 xo-expression2/src/expression2/IPrintable_DApplyExpr.cpp create mode 100644 xo-expression2/src/expression2/IPrintable_DConstant.cpp create mode 100644 xo-expression2/src/expression2/IPrintable_DDefineExpr.cpp create mode 100644 xo-expression2/src/expression2/IPrintable_DGlobalSymtab.cpp create mode 100644 xo-expression2/src/expression2/IPrintable_DIfElseExpr.cpp create mode 100644 xo-expression2/src/expression2/IPrintable_DLambdaExpr.cpp create mode 100644 xo-expression2/src/expression2/IPrintable_DLocalSymtab.cpp create mode 100644 xo-expression2/src/expression2/IPrintable_DSequenceExpr.cpp create mode 100644 xo-expression2/src/expression2/IPrintable_DTypename.cpp create mode 100644 xo-expression2/src/expression2/IPrintable_DVarRef.cpp create mode 100644 xo-expression2/src/expression2/ISymbolTable_Any.cpp create mode 100644 xo-expression2/src/expression2/ISymbolTable_DGlobalSymtab.cpp create mode 100644 xo-expression2/src/expression2/ISymbolTable_DLocalSymtab.cpp create mode 100644 xo-expression2/src/expression2/SetupExpression2.cpp create mode 100644 xo-expression2/src/expression2/TypeRef.cpp create mode 100644 xo-expression2/src/expression2/facet/IExpression_DVariable.cpp create mode 100644 xo-expression2/src/expression2/facet/IGCObject_DVariable.cpp create mode 100644 xo-expression2/src/expression2/facet/IPrintable_DVariable.cpp create mode 100644 xo-expression2/src/expression2/init_expression2.cpp create mode 100644 xo-expression2/utest/CMakeLists.txt create mode 100644 xo-expression2/utest/DApplyExpr.test.cpp create mode 100644 xo-expression2/utest/DConstant.test.cpp create mode 100644 xo-expression2/utest/DDefineExpr.test.cpp create mode 100644 xo-expression2/utest/DIfElseExpr.test.cpp create mode 100644 xo-expression2/utest/DVariable.test.cpp create mode 100644 xo-expression2/utest/X1Collector.test.cpp create mode 100644 xo-expression2/utest/expression2_utest_main.cpp diff --git a/xo-expression2/.gitrepo b/xo-expression2/.gitrepo new file mode 100644 index 00000000..611e29d2 --- /dev/null +++ b/xo-expression2/.gitrepo @@ -0,0 +1,12 @@ +; DO NOT EDIT (unless you know what you are doing) +; +; This subdirectory is a git "subrepo", and this file is maintained by the +; git-subrepo command. See https://github.com/ingydotnet/git-subrepo#readme +; +[subrepo] + remote = git@github.com:Rconybea/xo-expression2.git + branch = main + commit = 9823ce36647bb3f0bf517924e31230627f36ae50 + parent = 91b119cdef07176b576b40b878a4704617406979 + method = merge + cmdver = 0.4.9 diff --git a/xo-expression2/CMakeLists.txt b/xo-expression2/CMakeLists.txt new file mode 100644 index 00000000..b6fb40d7 --- /dev/null +++ b/xo-expression2/CMakeLists.txt @@ -0,0 +1,332 @@ +# xo-expression2/CMakeLists.txt + +cmake_minimum_required(VERSION 3.10) + +project(xo_expression2 VERSION 1.0) +enable_language(CXX) + +include(GNUInstallDirs) +include(cmake/xo-bootstrap-macros.cmake) + +xo_cxx_toplevel_options3() + +# ---------------------------------------------------------------- +# c++ settings + +# one-time project-specific c++ flags. usually empty +set(PROJECT_CXX_FLAGS "") +add_definitions(${PROJECT_CXX_FLAGS}) + +# ---------------------------------------------------------------- +# output targets + +add_subdirectory(utest) + +# note: manual target; generated code committed to git +xo_add_genfacet( + TARGET xo-expression2-facet-symboltable + FACET SymbolTable + INPUT idl/SymbolTable.json5 + OUTPUT_HPP_DIR include/xo/expression2 + OUTPUT_IMPL_SUBDIR detail + ) + +# ---------------------------------------------------------------- + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-symboltable-localsymtab + FACET_PKG xo_expression2 +# REPR LocalSymtab + INPUT idl/ISymbolTable_DLocalSymtab.json5 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-gcobject-localsymtab + FACET_PKG xo_alloc2 +# REPR LocalSymtab + INPUT idl/IGCObject_DLocalSymtab.json5 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-printable-localsymtab + FACET_PKG xo_printable2 +# REPR LocalSymtab + INPUT idl/IPrintable_DLocalSymtab.json5 +) + +# ---------------------------------------------------------------- + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-symboltable-globalsymtab + FACET_PKG xo_expression2 +# REPR GlobalSymtab + INPUT idl/ISymbolTable_DGlobalSymtab.json5 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-gcobject-globalsymtab + FACET_PKG xo_alloc2 +# REPR GlobalSymtab + INPUT idl/IGCObject_DGlobalSymtab.json5 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-printable-globalsymtab + FACET_PKG xo_printable2 +# REPR GlobalSymtab + INPUT idl/IPrintable_DGlobalSymtab.json5 +) + +# ---------------------------------------------------------------- + +# note: manual target; generated code committed to git +xo_add_genfacet( + TARGET xo-expression2-facet-expression + FACET Expression + INPUT idl/Expression.json5 + OUTPUT_HPP_DIR include/xo/expression2 + OUTPUT_IMPL_SUBDIR detail + ) + +# ---------------------------------------------------------------- + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-expression-constant + FACET_PKG xo_expression2 +# REPR Constant + INPUT idl/IExpression_DConstant.json5 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-gcobject-constant + FACET_PKG xo_alloc2 +# REPR Constant + INPUT idl/IGCObject_DConstant.json5 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-printable-constant + FACET_PKG xo_printable2 +# REPR Constant + INPUT idl/IPrintable_DConstant.json5 +) + +# ---------------------------------------------------------------- + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-expression-variable + FACET_PKG xo_expression2 +# REPR Variable + INPUT idl/IExpression_DVariable.json5 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-gcobject-variable + FACET_PKG xo_alloc2 +# REPR Variable + INPUT idl/IGCObject_DVariable.json5 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-printable-variable + FACET_PKG xo_printable2 +# REPR Variable + INPUT idl/IPrintable_DVariable.json5 +) + +# ---------------------------------------------------------------- + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-gcobject-typename + FACET_PKG xo_alloc2 +# REPR Typename + INPUT idl/IGCObject_DTypename.json5 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-printable-typename + FACET_PKG xo_printable2 +# REPR Typename + INPUT idl/IPrintable_DTypename.json5 +) + +# ---------------------------------------------------------------- + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-expression-varref + FACET_PKG xo_expression2 +# REPR VarRef + INPUT idl/IExpression_DVarRef.json5 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-gcobject-varref + FACET_PKG xo_alloc2 +# REPR VarRef + INPUT idl/IGCObject_DVarRef.json5 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-printable-varref + FACET_PKG xo_printable2 +# REPR VarRef + INPUT idl/IPrintable_DVarRef.json5 +) + +# ---------------------------------------------------------------- + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-expression-defineexpr + FACET_PKG xo_expression2 +# REPR DefineExpr + INPUT idl/IExpression_DDefineExpr.json5 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-gcobject-defineexpr + FACET_PKG xo_alloc2 +# REPR DefineExpr + INPUT idl/IGCObject_DDefineExpr.json5 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-printable-defineexpr + FACET_PKG xo_printable2 +# REPR DefineExpr + INPUT idl/IPrintable_DDefineExpr.json5 +) + +# ---------------------------------------------------------------- + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-expression-applyexpr + FACET_PKG xo_expression2 +# REPR ApplyExpr + INPUT idl/IExpression_DApplyExpr.json5 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-gcobject-applyexpr + FACET_PKG xo_alloc2 +# REPR ApplyExpr + INPUT idl/IGCObject_DApplyExpr.json5 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-printable-applyexpr + FACET_PKG xo_printable2 +# REPR ApplyExpr + INPUT idl/IPrintable_DApplyExpr.json5 +) + +# ---------------------------------------------------------------- + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-expression-lambdaexpr + FACET_PKG xo_expression2 +# REPR LambdaExpr + INPUT idl/IExpression_DLambdaExpr.json5 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-gcobject-lambdaexpr + FACET_PKG xo_alloc2 +# REPR LambdaExpr + INPUT idl/IGCObject_DLambdaExpr.json5 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-printable-lambdaexpr + FACET_PKG xo_printable2 +# REPR LambdaExpr + INPUT idl/IPrintable_DLambdaExpr.json5 +) + +# ---------------------------------------------------------------- + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-expression-ifelseexpr + FACET_PKG xo_expression2 +# REPR IfElseExpr + INPUT idl/IExpression_DIfElseExpr.json5 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-gcobject-ifelseexpr + FACET_PKG xo_alloc2 + INPUT idl/IGCObject_DIfElseExpr.json5 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-printable-ifelseexpr + FACET_PKG xo_printable2 + INPUT idl/IPrintable_DIfElseExpr.json5 +) + +# ---------------------------------------------------------------- + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-expression-sequenceexpr + FACET_PKG xo_expression2 + INPUT idl/IExpression_DSequenceExpr.json5 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-gcobject-sequenceexpr + FACET_PKG xo_alloc2 + INPUT idl/IGCObject_DSequenceExpr.json5 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-printable-sequenceexpr + FACET_PKG xo_printable2 + INPUT idl/IPrintable_DSequenceExpr.json5 +) + +# ---------------------------------------------------------------- + +xo_add_genfacet_all(xo-expression2-genfacet-all) + +# ---------------------------------------------------------------- +# shared library + +add_subdirectory(src/expression2) + +# ---------------------------------------------------------------- +# cmake helper (for external xo-expression2 users) + +xo_export_cmake_config(${PROJECT_NAME} ${PROJECT_VERSION} ${PROJECT_NAME}Targets) + +# end CMakeLists.txt diff --git a/xo-expression2/cmake/xo-bootstrap-macros.cmake b/xo-expression2/cmake/xo-bootstrap-macros.cmake new file mode 100644 index 00000000..2cf387e5 --- /dev/null +++ b/xo-expression2/cmake/xo-bootstrap-macros.cmake @@ -0,0 +1,33 @@ +# ---------------------------------------------------------------- +# for example: +# $ PREFIX=/usr/local # for example +# $ cmake -DCMAKE_MODULE_PATH=prefix -DCMAKE_INSTALL_PREFIX=$PREFIX -B .build +# +# will get +# CMAKE_MODULE_PATH +# from xo-cmake-config --cmake-module-path +# +# and expect .cmake macros in +# CMAKE_MODULE_PATH/xo_macros/xo_cxx.cmake +# ---------------------------------------------------------------- + +find_program(XO_CMAKE_CONFIG_EXECUTABLE NAMES xo-cmake-config REQUIRED) + +if (("${CMAKE_MODULE_PATH}" STREQUAL "") OR ("${CMAKE_MODULE_PATH}" STREQUAL "prefix")) + message(FATAL "could not find xo-cmake-config executable") +endif() + +if (NOT XO_SUBMODULE_BUILD) + if (("${CMAKE_MODULE_PATH}" STREQUAL "") OR ("${CMAKE_MODULE_PATH}" STREQUAL prefix)) + # default to typical install location for xo-project-macros + execute_process(COMMAND ${XO_CMAKE_CONFIG_EXECUTABLE} --cmake-module-path OUTPUT_VARIABLE CMAKE_MODULE_PATH) + message(STATUS "CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}") + endif() +endif() + +# needs to have been installed somewhere on CMAKE_MODULE_PATH, +# (e.g. from xo-cmake with the same value for CMAKE_INSTALL_PREFIX) +# +include(xo_macros/xo_cxx) + +xo_cxx_bootstrap_message() diff --git a/xo-expression2/cmake/xo_expression2Config.cmake.in b/xo-expression2/cmake/xo_expression2Config.cmake.in new file mode 100644 index 00000000..91906b58 --- /dev/null +++ b/xo-expression2/cmake/xo_expression2Config.cmake.in @@ -0,0 +1,20 @@ +@PACKAGE_INIT@ + +include(CMakeFindDependencyMacro) + +# note: changes to find_dependency() calls here +# must coordinate with xo_dependency() calls +# in CMakeLists.txt +# +find_dependency(xo_type) +find_dependency(xo_gc) +find_dependency(reflect) +find_dependency(xo_procedure2) +find_dependency(xo_printable2) +find_dependency(xo_flatstring) +find_dependency(subsys) +find_dependency(indentlog) + +include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Share.cmake") +check_required_components("@PROJECT_NAME@") diff --git a/xo-expression2/idl/Expression.json5 b/xo-expression2/idl/Expression.json5 new file mode 100644 index 00000000..66c60def --- /dev/null +++ b/xo-expression2/idl/Expression.json5 @@ -0,0 +1,74 @@ +{ + mode: "facet", + output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", + includes: [ "\"TypeRef.hpp\"", + "\"exprtype.hpp\"", + ""], + // extra includes in Expression.hpp, if any + user_hpp_includes: [], + namespace1: "xo", + namespace2: "scm", + // text after includes, before AExpression + pretext: [ "// {pretext} here" ], + facet: "Expression", + detail_subdir: "detail", + brief: "a schematika expression", + using_doxygen: true, + doc: [ + "Representation for executable Schematika expressions" + ], + types: [ + // using TypeDescr = xo::reflect::TypeDescr; + { + name: "TypeDescr", + doc: ["struct describing a type"], + definition: "xo::reflect::TypeDescr" + }, + ], + const_methods: [ + { + name: "extype", + doc: ["expression type (constant | apply | ..)"], + return_type: "exprtype", + args: [], + const: true, + noexcept: true, + attributes: [], + }, + { + name: "typeref", + doc: ["placeholder for type giving possible values for this expression"], + return_type: "TypeRef", + args: [], + const: true, + noexcept: true, + attributes: [], + }, + { + name: "valuetype", + doc: ["type giving possible values for this expression. Maybe null before typecheck"], + return_type: "TypeDescr", + args: [], + const: true, + noexcept: true, + attributes: [], + }, + ], + nonconst_methods: [ + { + name: "assign_valuetype", + doc: ["assing to valuetype member. Useful when scaffolding expressions"], + return_type: "void", + args: [ + // void assign_valuetype(TypeDescr td) + {type: "TypeDescr", name: "td"}, + ], + const: false, + noexcept: true, + attributes: [], + } + ], + router_facet_explicit_content: [ ], +} diff --git a/xo-expression2/idl/IExpression_DApplyExpr.json5 b/xo-expression2/idl/IExpression_DApplyExpr.json5 new file mode 100644 index 00000000..29762364 --- /dev/null +++ b/xo-expression2/idl/IExpression_DApplyExpr.json5 @@ -0,0 +1,15 @@ +{ + mode: "implementation", + output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", + includes: [ "\"Expression.hpp\"" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Expression.json5", + brief: "provide AExpression interface for DApplyExpr state", + using_doxygen: true, + repr: "DApplyExpr", + doc: ["doc for IExpression+DApplyExpr" ], +} diff --git a/xo-expression2/idl/IExpression_DConstant.json5 b/xo-expression2/idl/IExpression_DConstant.json5 new file mode 100644 index 00000000..bbbcc402 --- /dev/null +++ b/xo-expression2/idl/IExpression_DConstant.json5 @@ -0,0 +1,15 @@ +{ + mode: "implementation", + output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", + includes: [ "\"Expression.hpp\"" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Expression.json5", + brief: "provide AExpression interface for DConstant state", + using_doxygen: true, + repr: "DConstant", + doc: ["doc for something or other IExpression+DConstant" ], +} diff --git a/xo-expression2/idl/IExpression_DDefineExpr.json5 b/xo-expression2/idl/IExpression_DDefineExpr.json5 new file mode 100644 index 00000000..8fd6149f --- /dev/null +++ b/xo-expression2/idl/IExpression_DDefineExpr.json5 @@ -0,0 +1,15 @@ +{ + mode: "implementation", + output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", + includes: [ "\"Expression.hpp\"" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Expression.json5", + brief: "provide AExpression interface for DDefineExpr state", + using_doxygen: true, + repr: "DDefineExpr", + doc: ["doc for IExpression+DDefineExpr" ], +} diff --git a/xo-expression2/idl/IExpression_DIfElseExpr.json5 b/xo-expression2/idl/IExpression_DIfElseExpr.json5 new file mode 100644 index 00000000..431fd60a --- /dev/null +++ b/xo-expression2/idl/IExpression_DIfElseExpr.json5 @@ -0,0 +1,15 @@ +{ + mode: "implementation", + output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", + includes: [ "\"Expression.hpp\"" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Expression.json5", + brief: "provide AExpression interface for DIfElseExpr state", + using_doxygen: true, + repr: "DIfElseExpr", + doc: ["doc for IExpression+DIfElseExpr" ], +} diff --git a/xo-expression2/idl/IExpression_DLambdaExpr.json5 b/xo-expression2/idl/IExpression_DLambdaExpr.json5 new file mode 100644 index 00000000..36aa9bb4 --- /dev/null +++ b/xo-expression2/idl/IExpression_DLambdaExpr.json5 @@ -0,0 +1,15 @@ +{ + mode: "implementation", + output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", + 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/IExpression_DSequenceExpr.json5 b/xo-expression2/idl/IExpression_DSequenceExpr.json5 new file mode 100644 index 00000000..71b13aba --- /dev/null +++ b/xo-expression2/idl/IExpression_DSequenceExpr.json5 @@ -0,0 +1,15 @@ +{ + mode: "implementation", + output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", + includes: [ "\"Expression.hpp\"" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Expression.json5", + brief: "provide AExpression interface for DSequenceExpr state", + using_doxygen: true, + repr: "DSequenceExpr", + doc: ["doc for something or other IExpression+DSequenceExpr" ], +} diff --git a/xo-expression2/idl/IExpression_DVarRef.json5 b/xo-expression2/idl/IExpression_DVarRef.json5 new file mode 100644 index 00000000..7b50c7fb --- /dev/null +++ b/xo-expression2/idl/IExpression_DVarRef.json5 @@ -0,0 +1,15 @@ +{ + mode: "implementation", + output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", + includes: [ "\"Expression.hpp\"" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Expression.json5", + brief: "provide AExpression interface for DVarRef state", + using_doxygen: true, + repr: "DVarRef", + doc: ["doc for IExpression+DVarRef" ], +} diff --git a/xo-expression2/idl/IExpression_DVariable.json5 b/xo-expression2/idl/IExpression_DVariable.json5 new file mode 100644 index 00000000..cfc0b599 --- /dev/null +++ b/xo-expression2/idl/IExpression_DVariable.json5 @@ -0,0 +1,15 @@ +{ + mode: "implementation", + output_cpp_dir: "src/expression2/facet", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "variable", + includes: [ "\"Expression.hpp\"" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Expression.json5", + brief: "provide AExpression interface for DVariable state", + using_doxygen: true, + repr: "DVariable", + doc: ["doc for IExpression+DVariable" ], +} diff --git a/xo-expression2/idl/IGCObject_DApplyExpr.json5 b/xo-expression2/idl/IGCObject_DApplyExpr.json5 new file mode 100644 index 00000000..fd1d528a --- /dev/null +++ b/xo-expression2/idl/IGCObject_DApplyExpr.json5 @@ -0,0 +1,18 @@ +{ + mode: "implementation", + output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", + includes: [ + "", + "" + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for DApplyExpr", + using_doxygen: true, + repr: "DApplyExpr", + doc: [ "implement AGCObject for DApplyExpr" ], +} diff --git a/xo-expression2/idl/IGCObject_DConstant.json5 b/xo-expression2/idl/IGCObject_DConstant.json5 new file mode 100644 index 00000000..5e598b95 --- /dev/null +++ b/xo-expression2/idl/IGCObject_DConstant.json5 @@ -0,0 +1,18 @@ +{ + mode: "implementation", + output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", + includes: [ + "", + "" + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for DConstant", + using_doxygen: true, + repr: "DConstant", + doc: [ "implement AGCObject for DConstant" ], +} diff --git a/xo-expression2/idl/IGCObject_DDefineExpr.json5 b/xo-expression2/idl/IGCObject_DDefineExpr.json5 new file mode 100644 index 00000000..2509897b --- /dev/null +++ b/xo-expression2/idl/IGCObject_DDefineExpr.json5 @@ -0,0 +1,18 @@ +{ + mode: "implementation", + output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "define", + includes: [ + "", + "" + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for DDefineExpr", + using_doxygen: true, + repr: "DDefineExpr", + doc: [ "implement AGCObject for DDefineExpr" ], +} diff --git a/xo-expression2/idl/IGCObject_DGlobalSymtab.json5 b/xo-expression2/idl/IGCObject_DGlobalSymtab.json5 new file mode 100644 index 00000000..858a5eab --- /dev/null +++ b/xo-expression2/idl/IGCObject_DGlobalSymtab.json5 @@ -0,0 +1,18 @@ +{ + mode: "implementation", + output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "symtab", + 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/IGCObject_DIfElseExpr.json5 b/xo-expression2/idl/IGCObject_DIfElseExpr.json5 new file mode 100644 index 00000000..bd0b183c --- /dev/null +++ b/xo-expression2/idl/IGCObject_DIfElseExpr.json5 @@ -0,0 +1,18 @@ +{ + mode: "implementation", + output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", + includes: [ + "", + "" + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for DIfElseExpr", + using_doxygen: true, + repr: "DIfElseExpr", + doc: [ "implement AGCObject for DIfElseExpr" ], +} diff --git a/xo-expression2/idl/IGCObject_DLambdaExpr.json5 b/xo-expression2/idl/IGCObject_DLambdaExpr.json5 new file mode 100644 index 00000000..7913a6bc --- /dev/null +++ b/xo-expression2/idl/IGCObject_DLambdaExpr.json5 @@ -0,0 +1,18 @@ +{ + mode: "implementation", + output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", + includes: [ + "", + "" + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for DLambdaExpr", + using_doxygen: true, + repr: "DLambdaExpr", + doc: [ "implement AGCObject for DLambdaExpr" ], +} diff --git a/xo-expression2/idl/IGCObject_DLocalSymtab.json5 b/xo-expression2/idl/IGCObject_DLocalSymtab.json5 new file mode 100644 index 00000000..807a229a --- /dev/null +++ b/xo-expression2/idl/IGCObject_DLocalSymtab.json5 @@ -0,0 +1,18 @@ +{ + mode: "implementation", + output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "symtab", + includes: [ + "", + "" + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for DLocalSymtab", + using_doxygen: true, + repr: "DLocalSymtab", + doc: [ "implement AGCObject for DLocalSymtab" ], +} diff --git a/xo-expression2/idl/IGCObject_DSequenceExpr.json5 b/xo-expression2/idl/IGCObject_DSequenceExpr.json5 new file mode 100644 index 00000000..b8c06cbc --- /dev/null +++ b/xo-expression2/idl/IGCObject_DSequenceExpr.json5 @@ -0,0 +1,18 @@ +{ + mode: "implementation", + output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", + includes: [ + "", + "" + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for DSequenceExpr", + using_doxygen: true, + repr: "DSequenceExpr", + doc: [ "implement AGCObject for DSequenceExpr" ], +} diff --git a/xo-expression2/idl/IGCObject_DTypename.json5 b/xo-expression2/idl/IGCObject_DTypename.json5 new file mode 100644 index 00000000..ae99ef9a --- /dev/null +++ b/xo-expression2/idl/IGCObject_DTypename.json5 @@ -0,0 +1,18 @@ +{ + mode: "implementation", + output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "typename", + includes: [ +// "", +// "" + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for DTypename", + using_doxygen: true, + repr: "DTypename", + doc: [ "implement AGCObject for DTypename" ], +} diff --git a/xo-expression2/idl/IGCObject_DVarRef.json5 b/xo-expression2/idl/IGCObject_DVarRef.json5 new file mode 100644 index 00000000..2cbc4715 --- /dev/null +++ b/xo-expression2/idl/IGCObject_DVarRef.json5 @@ -0,0 +1,18 @@ +{ + mode: "implementation", + output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", + includes: [ + "", + "" + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for DVarRef", + using_doxygen: true, + repr: "DVarRef", + doc: [ "implement AGCObject for DVarRef" ], +} diff --git a/xo-expression2/idl/IGCObject_DVariable.json5 b/xo-expression2/idl/IGCObject_DVariable.json5 new file mode 100644 index 00000000..f589430f --- /dev/null +++ b/xo-expression2/idl/IGCObject_DVariable.json5 @@ -0,0 +1,18 @@ +{ + mode: "implementation", + output_cpp_dir: "src/expression2/facet", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "variable", + includes: [ + "", + "" + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for DVariable", + using_doxygen: true, + repr: "DVariable", + doc: [ "implement AGCObject for DVariable" ], +} diff --git a/xo-expression2/idl/IPrintable_DApplyExpr.json5 b/xo-expression2/idl/IPrintable_DApplyExpr.json5 new file mode 100644 index 00000000..f9d3f17d --- /dev/null +++ b/xo-expression2/idl/IPrintable_DApplyExpr.json5 @@ -0,0 +1,16 @@ +{ + mode: "implementation", + output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", + includes: [ "", + "" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Printable.json5", + brief: "provide APrintable interface for DApplyExpr", + using_doxygen: true, + repr: "DApplyExpr", + doc: [ "implement APrintable for DApplyExpr" ], +} diff --git a/xo-expression2/idl/IPrintable_DConstant.json5 b/xo-expression2/idl/IPrintable_DConstant.json5 new file mode 100644 index 00000000..ca9d7948 --- /dev/null +++ b/xo-expression2/idl/IPrintable_DConstant.json5 @@ -0,0 +1,16 @@ +{ + mode: "implementation", + output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", + includes: [ "", + "" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Printable.json5", + brief: "provide APrintable interface for DConstant", + using_doxygen: true, + repr: "DConstant", + doc: [ "implement APrintable for DConstant" ], +} diff --git a/xo-expression2/idl/IPrintable_DDefineExpr.json5 b/xo-expression2/idl/IPrintable_DDefineExpr.json5 new file mode 100644 index 00000000..c706817d --- /dev/null +++ b/xo-expression2/idl/IPrintable_DDefineExpr.json5 @@ -0,0 +1,16 @@ +{ + mode: "implementation", + output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", + includes: [ "", + "" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Printable.json5", + brief: "provide APrintable interface for DDefineExpr", + using_doxygen: true, + repr: "DDefineExpr", + doc: [ "implement APrintable for DDefineExpr" ], +} diff --git a/xo-expression2/idl/IPrintable_DGlobalSymtab.json5 b/xo-expression2/idl/IPrintable_DGlobalSymtab.json5 new file mode 100644 index 00000000..d0242e8c --- /dev/null +++ b/xo-expression2/idl/IPrintable_DGlobalSymtab.json5 @@ -0,0 +1,16 @@ +{ + mode: "implementation", + output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "symtab", + 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/IPrintable_DIfElseExpr.json5 b/xo-expression2/idl/IPrintable_DIfElseExpr.json5 new file mode 100644 index 00000000..208e7b06 --- /dev/null +++ b/xo-expression2/idl/IPrintable_DIfElseExpr.json5 @@ -0,0 +1,16 @@ +{ + mode: "implementation", + output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", + includes: [ "", + "" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Printable.json5", + brief: "provide APrintable interface for DIfElseExpr", + using_doxygen: true, + repr: "DIfElseExpr", + doc: [ "implement APrintable for DIfElseExpr" ], +} diff --git a/xo-expression2/idl/IPrintable_DLambdaExpr.json5 b/xo-expression2/idl/IPrintable_DLambdaExpr.json5 new file mode 100644 index 00000000..89b07d1c --- /dev/null +++ b/xo-expression2/idl/IPrintable_DLambdaExpr.json5 @@ -0,0 +1,16 @@ +{ + mode: "implementation", + output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", + 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/idl/IPrintable_DLocalSymtab.json5 b/xo-expression2/idl/IPrintable_DLocalSymtab.json5 new file mode 100644 index 00000000..15087c3d --- /dev/null +++ b/xo-expression2/idl/IPrintable_DLocalSymtab.json5 @@ -0,0 +1,16 @@ +{ + mode: "implementation", + output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "symtab", + includes: [ "", + "" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Printable.json5", + brief: "provide APrintable interface for DLocalSymtab", + using_doxygen: true, + repr: "DLocalSymtab", + doc: [ "implement APrintable for DLocalSymtab" ], +} diff --git a/xo-expression2/idl/IPrintable_DSequenceExpr.json5 b/xo-expression2/idl/IPrintable_DSequenceExpr.json5 new file mode 100644 index 00000000..0cfe76c9 --- /dev/null +++ b/xo-expression2/idl/IPrintable_DSequenceExpr.json5 @@ -0,0 +1,16 @@ +{ + mode: "implementation", + output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", + includes: [ "", + "" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Printable.json5", + brief: "provide APrintable interface for DSequenceExpr", + using_doxygen: true, + repr: "DSequenceExpr", + doc: [ "implement APrintable for DSequenceExpr" ], +} diff --git a/xo-expression2/idl/IPrintable_DTypename.json5 b/xo-expression2/idl/IPrintable_DTypename.json5 new file mode 100644 index 00000000..d11d8993 --- /dev/null +++ b/xo-expression2/idl/IPrintable_DTypename.json5 @@ -0,0 +1,16 @@ +{ + mode: "implementation", + output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "typename", + includes: [ "", + "" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Printable.json5", + brief: "provide APrintable interface for DTypename", + using_doxygen: true, + repr: "DTypename", + doc: [ "implement APrintable for DTypename" ], +} diff --git a/xo-expression2/idl/IPrintable_DVarRef.json5 b/xo-expression2/idl/IPrintable_DVarRef.json5 new file mode 100644 index 00000000..106b41d1 --- /dev/null +++ b/xo-expression2/idl/IPrintable_DVarRef.json5 @@ -0,0 +1,16 @@ +{ + mode: "implementation", + output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", + includes: [ "", + "" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Printable.json5", + brief: "provide APrintable interface for DVarRef", + using_doxygen: true, + repr: "DVarRef", + doc: [ "implement APrintable for DVarRef" ], +} diff --git a/xo-expression2/idl/IPrintable_DVariable.json5 b/xo-expression2/idl/IPrintable_DVariable.json5 new file mode 100644 index 00000000..b300b7be --- /dev/null +++ b/xo-expression2/idl/IPrintable_DVariable.json5 @@ -0,0 +1,16 @@ +{ + mode: "implementation", + output_cpp_dir: "src/expression2/facet", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "variable", + includes: [ "", + "" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Printable.json5", + brief: "provide APrintable interface for DVariable", + using_doxygen: true, + repr: "DVariable", + doc: [ "implement APrintable for DVariable" ], +} diff --git a/xo-expression2/idl/ISymbolTable_DGlobalSymtab.json5 b/xo-expression2/idl/ISymbolTable_DGlobalSymtab.json5 new file mode 100644 index 00000000..ff148a2f --- /dev/null +++ b/xo-expression2/idl/ISymbolTable_DGlobalSymtab.json5 @@ -0,0 +1,15 @@ +{ + mode: "implementation", + output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "symtab", + 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/idl/ISymbolTable_DLocalSymtab.json5 b/xo-expression2/idl/ISymbolTable_DLocalSymtab.json5 new file mode 100644 index 00000000..7cfcd75f --- /dev/null +++ b/xo-expression2/idl/ISymbolTable_DLocalSymtab.json5 @@ -0,0 +1,15 @@ +{ + mode: "implementation", + output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "symtab", + includes: [ ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/SymbolTable.json5", + brief: "provide ASymbolTable interface for DLocalSymtab", + using_doxygen: true, + repr: "DLocalSymtab", + doc: [ "implement ASymbolTable for DLocalSymtab" ], +} diff --git a/xo-expression2/idl/SymbolTable.json5 b/xo-expression2/idl/SymbolTable.json5 new file mode 100644 index 00000000..b299bfe7 --- /dev/null +++ b/xo-expression2/idl/SymbolTable.json5 @@ -0,0 +1,63 @@ +{ + mode: "facet", + output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "symtab", + includes: [ + "\"Binding.hpp\"", + "\"DUniqueString.hpp\"" + ], + // extra includes in SymbolTable.hpp, if any + user_hpp_includes: [], + namespace1: "xo", + namespace2: "scm", + // text after includes, before ASymbolTable + pretext: [ "// {pretext} here" ], + facet: "SymbolTable", + detail_subdir: "symtab", + brief: "symbol table derived from a set of schematika expressions", + using_doxygen: true, + doc: [ + "Map symbols to schematika expressions. Output of schematika parser" + ], + types: [ + // { name: string, doc: [ string ], definition: string }, + ], + const_methods: [ + + { + // bool is_global_symtab() const noexcept; + name: "is_global_symtab", + doc: ["true iff this is toplevel (global) symbol table."], + return_type: "bool", + args: [], + const: true, + noexcept: true, + attributes: [], + }, + + { + // Binding lookup_binding(const DUniqueString * sym) const noexcept; + name: "lookup_binding", + doc: ["report ingredients needed to address variable at runtime."], + return_type: "Binding", + args: [ + {type: "const DUniqueString *", name: "sym"}, + ], + const: true, + noexcept: true, + attributes: [], + }, + + // // + // obj lookup_var(const DUniqueString * sym) const noexcept; + + // // + // obj lookup_local(const DUniqueString * sym) const noexcept; + ], + nonconst_methods: [ + // // Variable gives both {name, type} + // void upsert_local(DVariable * target) = 0; + ], + router_facet_explicit_content: [ ], +} diff --git a/xo-expression2/include/xo/expression2/.gitkeep b/xo-expression2/include/xo/expression2/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/xo-expression2/include/xo/expression2/ApplyExpr.hpp b/xo-expression2/include/xo/expression2/ApplyExpr.hpp new file mode 100644 index 00000000..38625855 --- /dev/null +++ b/xo-expression2/include/xo/expression2/ApplyExpr.hpp @@ -0,0 +1,13 @@ +/** @file ApplyExpr.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "DApplyExpr.hpp" +#include "detail/IExpression_DApplyExpr.hpp" +#include "detail/IGCObject_DApplyExpr.hpp" +#include "detail/IPrintable_DApplyExpr.hpp" + +/* end ApplyExpr.hpp */ diff --git a/xo-expression2/include/xo/expression2/Binding.hpp b/xo-expression2/include/xo/expression2/Binding.hpp new file mode 100644 index 00000000..805ebeb9 --- /dev/null +++ b/xo-expression2/include/xo/expression2/Binding.hpp @@ -0,0 +1,65 @@ +/** @file Binding.hpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include +#include + +namespace xo { + namespace scm { + class Binding { + public: + using slot_type = int32_t; + + static constexpr int32_t c_link_sentinel = -2; + static constexpr int32_t c_link_global = -1; + + public: + Binding() : i_link_{-2}, j_slot_{-1} {} + 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(int32_t j_slot) { return Binding(c_link_global, j_slot); } + static Binding local(int32_t j_slot) { return Binding(0, j_slot); } + static Binding relative(int32_t i_link, Binding def); + + bool is_null() const { + return (i_link_ == c_link_sentinel) && (j_slot_ == -1); + } + bool is_global() const { return i_link_ == c_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_; } + + /** print human-readable repr to stream @p os **/ + void print(std::ostream & os) const; + + private: + /** + * >= 0: number of parent links to traverse + * to a fixed-size frame + * -1: resolve globally + * -2: sentinel (binding info not computed) + **/ + int32_t i_link_ = c_link_sentinel; + /** if @ref i_link_ >= 0, frame offset + * (in 'variables' not bytes). + * ignored if @ref i_link_ is global + **/ + int32_t j_slot_ = -1; + }; + + inline std::ostream & operator<< (std::ostream & os, Binding x) { + x.print(os); + return os; + } + } /*namespace scm*/ +} /*namespace xo*/ + +/* Binding.hpp */ diff --git a/xo-expression2/include/xo/expression2/Constant.hpp b/xo-expression2/include/xo/expression2/Constant.hpp new file mode 100644 index 00000000..29e6694f --- /dev/null +++ b/xo-expression2/include/xo/expression2/Constant.hpp @@ -0,0 +1,13 @@ +/** @file Constant.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "DConstant.hpp" +#include "detail/IExpression_DConstant.hpp" +#include "detail/IGCObject_DConstant.hpp" +#include "detail/IPrintable_DConstant.hpp" + +/* end Constant.hpp */ diff --git a/xo-expression2/include/xo/expression2/DApplyExpr.hpp b/xo-expression2/include/xo/expression2/DApplyExpr.hpp new file mode 100644 index 00000000..cb0be70f --- /dev/null +++ b/xo-expression2/include/xo/expression2/DApplyExpr.hpp @@ -0,0 +1,113 @@ +/** @file DApplyExpr.hpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include "Expression.hpp" +#include "TypeRef.hpp" +#include "exprtype.hpp" +#include +#include +#include +#include + +namespace xo { + namespace scm { + + /** @class DApplyExpr + * @brief syntax for a procedure/function call + **/ + class DApplyExpr { + public: + using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using VisitReason = xo::mm::VisitReason; + using AAllocator = xo::mm::AAllocator; + using TypeDescr = xo::reflect::TypeDescr; + using ppindentinfo = xo::print::ppindentinfo; + using size_type = std::uint32_t; + + public: + /** @defgroup scm-applyexpr-constructors **/ + ///@{ + + /** construct empty instance, but with argument expressions empty **/ + DApplyExpr(TypeRef typeref, + obj fn_expr, + size_type n_args); + + /** create apply for function with 2 arguments **/ + static obj make2(obj mm, + TypeRef typeref, + obj fn_expr, + obj arg1, + obj arg2); + + /** create apply for function with 2 arguments **/ + static DApplyExpr * _make2(obj mm, + TypeRef typeref, + obj fn_expr, + obj arg1, + obj arg2); + + /** scaffold incomplete instance. + * apply-expr using memory from @p mm. + * will construct instance with space for @p n_args arguments + * but expressions left empty. + * use @ref assign_arg for all arguments to complete. + **/ + static DApplyExpr * scaffold(obj mm, + TypeRef typeref, + obj fn_expr, + size_type n_args); + void assign_arg(size_type i_arg, obj expr); + + ///@} + /** @defgroup scm-applyexpr-access-methods **/ + ///@{ + + obj fn() const noexcept { return fn_; } + size_type n_args() const noexcept { return n_args_; } + obj arg(size_type i) const; + + ///@} + /** @defgroup scm-applyexpr-expression-facet **/ + ///@{ + + exprtype extype() const noexcept { return exprtype::apply; } + TypeRef typeref() const noexcept { return typeref_; } + TypeDescr valuetype() const noexcept { return typeref_.td(); } + void assign_valuetype(TypeDescr td) noexcept; + + ///@} + /** @defgroup scm-applyexpr-gcobject-facet **/ + ///@{ + + DApplyExpr * gco_shallow_move(obj gc) noexcept; + void visit_gco_children(VisitReason reason, obj gc) noexcept; + + ///@} + /** @defgroup scm-applyexpr-printable-facet **/ + ///@{ + + bool pretty(const ppindentinfo & ppii) const; + + ///@} + + private: + /** expression value always has type consistent + * with this description + **/ + TypeRef typeref_; + /** expression for function/procedure to invoke **/ + obj fn_; + /** number of arguments (not counting @ref fn_ **/ + size_type n_args_ = 0; + /** args_[i] is expression for i'th argument to @ref fn_ **/ + obj args_[]; + }; + } +} + +/* end DApplyExpr.hpp */ diff --git a/xo-expression2/include/xo/expression2/DConstant.hpp b/xo-expression2/include/xo/expression2/DConstant.hpp new file mode 100644 index 00000000..bf901537 --- /dev/null +++ b/xo-expression2/include/xo/expression2/DConstant.hpp @@ -0,0 +1,91 @@ +/** @file DConstant.hpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include "Expression.hpp" +#include "TypeRef.hpp" +#include "exprtype.hpp" +#include +#include +#include + +namespace xo { + namespace scm { + /** @class DConstant + * @brief Schematika expression respresenting a literal constant + **/ + struct DConstant { + public: + using TaggedPtr = xo::reflect::TaggedPtr; + using TypeDescr = xo::reflect::TypeDescr; + using AGCObject = xo::mm::AGCObject; + using VisitReason = xo::mm::VisitReason; + using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using AAllocator = xo::mm::AAllocator; + using typeseq = xo::reflect::typeseq; + using ppindentinfo = xo::print::ppindentinfo; + + public: + explicit DConstant(obj value) noexcept; + + /** create isntance + * @p mm memory allocator + * @p value literal constant + **/ + static obj make(obj mm, + obj value); + + /** create instance + * @p mm memory allocator + * @p value literal constant + **/ + static DConstant * _make(obj mm, + obj value); + + bool is_resolved() const noexcept { return typeref_.is_resolved(); } + + obj value() const noexcept { return value_; } + TypeDescr value_td() const noexcept { return typeref_.td(); } + TaggedPtr value_tp() const noexcept { return TaggedPtr(typeref_.td(), value_.data()); } + + /** @defgroup scm-constant-expression-facet **/ + ///@{ + + exprtype extype() const noexcept { return exprtype::constant; } + TypeRef typeref() const noexcept { return typeref_; } + TypeDescr valuetype() const noexcept { return typeref_.td(); } + void assign_valuetype(TypeDescr td) noexcept { typeref_.resolve(td); } + + ///@} + /** @defgroup scm-constant-gcobject-facet **/ + ///@{ + + DConstant * gco_shallow_move(obj gc) noexcept; + void visit_gco_children(VisitReason reason, obj gc) noexcept; + + ///@} + /** @defgroup scm-constant-printable-facet **/ + ///@{ + + bool pretty(const ppindentinfo & ppii) const; + + ///@} + + 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 DConstant.hpp */ diff --git a/xo-expression2/include/xo/expression2/DDefineExpr.hpp b/xo-expression2/include/xo/expression2/DDefineExpr.hpp new file mode 100644 index 00000000..3f0071fd --- /dev/null +++ b/xo-expression2/include/xo/expression2/DDefineExpr.hpp @@ -0,0 +1,108 @@ +/** @file DDefineExpr.hpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include "Expression.hpp" +#include "DVariable.hpp" +#include +#include +#include + +namespace xo { + namespace scm { + class DUniqueString; // see DUniqueString.hpp + + /** @class DDefineExpr + * @brief an expression that introduces a variable. + * + * Variable may optionally be declared with a type, + * and may come with an expression specifying an initial value + **/ + class DDefineExpr { + public: + using ppindentinfo = xo::print::ppindentinfo; + using ACollector = xo::mm::ACollector; + using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using VisitReason = xo::mm::VisitReason; + using AAllocator = xo::mm::AAllocator; + using TypeDescr = xo::reflect::TypeDescr; + + public: + /** @defgroup scm-defineexpr-constructors **/ + ///@{ + + /** create instance: define-expr using memory from @p mm + * with lhs name @p lhs_name and rhs expression @p rhs_expr + **/ + static DDefineExpr * make(obj mm, + const DUniqueString * lhs_name, + obj rhs_expr); + /** create empty skeleton. Rely on this for parsing + **/ + static DDefineExpr * make_empty(obj mm); + + DDefineExpr(DVariable * lhs_var, + obj rhs); + + ///@} + /** @defgroup scm-definexpr-access-methods **/ + ///@{ + + DVariable * lhs() const { return lhs_var_; } + obj rhs() const noexcept { return rhs_; } + const DUniqueString * name() const noexcept; + + ///@} + /** @defgroup scm-definexpr-bookkeeping-methods **/ + ///@{ + + void assign_lhs_name(const DUniqueString * name); + void assign_rhs(obj rhs); + + ///@} + /** @defgroup scm-defineexpr-expression-facet **/ + ///@{ + + exprtype extype() const noexcept { return exprtype::define; } + TypeRef typeref() const noexcept { return lhs_var_->typeref(); } + TypeDescr valuetype() const noexcept { return lhs_var_->typeref().td(); } + void assign_valuetype(TypeDescr td) noexcept; + + ///@} + /** @defgroup scm-defineexpr-gcobject-facet **/ + ///@{ + + DDefineExpr * gco_shallow_move(obj gc) noexcept; + void visit_gco_children(VisitReason reason, obj gc) noexcept; + + ///@} + /** @defgroup scm-defineexpr-printable-facet **/ + ///@{ + + bool pretty(const ppindentinfo & ppii) const; + + ///@} + + private: + /** @defgrouop scm-defineexpr-instance-vars **/ + ///@{ + + /** variable being defined by this expression. + **/ + DVariable * lhs_var_ = nullptr; + + /** expression for initial value of this expression + **/ + obj rhs_; + + // std::set free_var_set_; + + ///@} + }; + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DDefineExpr.hpp */ diff --git a/xo-expression2/include/xo/expression2/DGlobalSymtab.hpp b/xo-expression2/include/xo/expression2/DGlobalSymtab.hpp new file mode 100644 index 00000000..4a7fdf93 --- /dev/null +++ b/xo-expression2/include/xo/expression2/DGlobalSymtab.hpp @@ -0,0 +1,161 @@ +/** @file DGlobalSymtab.hpp +* + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include "Binding.hpp" +#include "DVariable.hpp" +#include "DTypename.hpp" +#include +#include +#include +#include + +namespace xo { + namespace scm { + class DUniqueString; + + /** @class DGlobalSymtab + * @brief symbol table for toplevel environment + * + * We're using DArenaHashMap to store pairs. + * Both of these are outside GC-space, so we don't need collector + * to traverse these. + **/ + class DGlobalSymtab { + public: + using key_type = const DUniqueString *; + using value_type = Binding; + using ArenaHashMapConfig = xo::map::ArenaHashMapConfig; + using repr_type = xo::map::DArenaHashMap; + using AGCObject = xo::mm::AGCObject; + using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using VisitReason = xo::mm::VisitReason; + using AAllocator = xo::mm::AAllocator; + using MemorySizeVisitor = xo::mm::MemorySizeVisitor; + using ppindentinfo = xo::print::ppindentinfo; + using size_type = std::uint32_t; + + public: + /** @defgroup scm-globalsymtab-ctors constructors **/ + ///@{ + + DGlobalSymtab(dp var_map, DArray * vars, + dp type_map, DArray * types); + + /** move constructor (needed because dp<> deletes copy ctor) **/ + DGlobalSymtab(DGlobalSymtab && other); + + /** create instance. + * Use memory from @p fixed_mm for @ref map_. + * Use memory from @p mm for DGlobalSymtab instance. + * Hashmap for variables per @p var_cfg; for types per @p type_cfg. + **/ + static DGlobalSymtab * _make(obj mm, + obj fixed_mm, + const ArenaHashMapConfig & var_cfg, + const ArenaHashMapConfig & type_cfg); + + /** like _make(..), but create fop **/ + static obj make(obj mm, + obj fixed_mm, + const ArenaHashMapConfig & var_cfg, + const ArenaHashMapConfig & type_cfg); + + /** non-trivial destructor for @ref map_ **/ + ~DGlobalSymtab() = default; + + ///@} + /** @defgroup scm-globalsymtab-access-methods access methods **/ + ///@{ + + size_type n_vars() const noexcept { return var_map_->size(); } + size_type var_capacity() const noexcept { return var_map_->capacity(); } + + /** visit symtab-owned memory pools; call visitor(info) for each **/ + void visit_pools(const MemorySizeVisitor & visitor) const; + + /** lookup global symbol with name @p sym **/ + DVariable * lookup_variable(const DUniqueString * sym) const noexcept; + + /** lookup global typename with name @p sym **/ + DTypename * lookup_typename(const DUniqueString * sym) const noexcept; + + ///@} + /** @defgroup scm-globalsymtab-general-methods general methods **/ + ///@{ + + /** update this symtab to associate @p var with @c var->name(). + * If there was a previous variable with the same name, + * replace it with @p var. + **/ + void upsert_variable(obj mm, + DVariable * var); + + /** update this symtab to associate typename @p type with @c type->name(). + * If there was a previous type with the same name, replace it with + * @p type. + **/ + void upsert_typename(obj mm, + DTypename * type); + + ///@} + /** @defgroup scm-globalsymtab-symboltable-facet symboltable facet **/ + ///@{ + + /** true for global symbol table **/ + bool is_global_symtab() const noexcept { return true; } + + /** lookup binding for variable @p sym **/ + Binding lookup_binding(const DUniqueString * sym) const noexcept; + + ///@} + /** @defgroup scm-globalsymtab-gcobject-facet gcobject facet **/ + ///@{ + + DGlobalSymtab * gco_shallow_move(obj gc) noexcept; + void visit_gco_children(VisitReason reason, obj gc) noexcept; + + ///@} + /** @defgroup scm-globalsymtab-printable-facet printable facet **/ + ///@{ + + /** pretty-printing support **/ + bool pretty(const ppindentinfo & ppii) const; + + ///@} + + private: + /** map variable symbol -> index into @ref vars_. + * Minor point: storing offsets instead of Variables allows us to: + * omit hash-map iteration during GC. + * Savings when map_ slots sparsely populated. + **/ + dp var_map_; + + /** array of variables. + * When S is a unique-string for a global symbol, then: + * 1. var_map_[S] is unique global index i(S) for S. + * 2. vars_[i(S)] is variable-expr var(S) for S + * 3. var(S)->name == S + **/ + DArray * vars_ = nullptr; + + /** map type name -> index values into @ref types_ **/ + dp type_map_; + + /** array of types. + * When T is a unique-string for a globally-defined type, then: + * 1. type_map_[T] is unique global index i(T) for T. + * 2. types_[i(T)] is type type(T) for T + * 3. type(T)->name == T + **/ + DArray * types_ = nullptr; + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DGlobalSymtab.hpp */ diff --git a/xo-expression2/include/xo/expression2/DIfElseExpr.hpp b/xo-expression2/include/xo/expression2/DIfElseExpr.hpp new file mode 100644 index 00000000..bc83ccd4 --- /dev/null +++ b/xo-expression2/include/xo/expression2/DIfElseExpr.hpp @@ -0,0 +1,248 @@ +/** @file DIfElseExpr.hpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include "Expression.hpp" +#include "TypeRef.hpp" +#include "exprtype.hpp" +#include +#include +#include + +namespace xo { + namespace scm { + + /** @class DIfExpr + * @brief abstract syntax tree for a function definition + **/ + class DIfElseExpr { + public: + using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using VisitReason = xo::mm::VisitReason; + using AAllocator = xo::mm::AAllocator; + using TypeDescr = xo::reflect::TypeDescr; + using ppindentinfo = xo::print::ppindentinfo; + + public: + /** @defgroup scm-ifelseexpr-constructors **/ + ///@{ + + /** + * @p ifexpr_type type for value produced by if-expression. + * same as both when_true->valuetype() and + * when_false->valuetype(). + * @p test test-expression; always execute + * @p when_true then-branch; executes only when test succeeds + * @p when_false else-branch; executes only when test fails + **/ + DIfElseExpr(TypeRef ifexpr_type, + obj test_expr, + obj when_true, + obj when_false); + + /** create if-else expression using memory from @p mm. + * @p when_false can be null + **/ + static obj make(obj mm, + obj test, + obj when_true, + obj when_false); + + /** create expression for conditional execution of + * @p when_true or @p when_false, depending on result + * of evaluating expression @p test + **/ + static DIfElseExpr * _make(obj mm, + obj test, + obj when_true, + obj when_false); + + /** create empty if-else expression using memory from @p mm **/ + static obj make_empty(obj mm); + + /** create empty if-else expression using memory from @p mm **/ + static DIfElseExpr * _make_empty(obj mm); + + ///@} + /** @defgroup scm-ifelseexpr-access-methods **/ + ///@{ + + obj test() const noexcept { return test_; } + obj when_true() const noexcept { return when_true_; } + obj when_false() const noexcept { return when_false_; } + + void assign_test(obj x) { this->test_ = x; } + void assign_when_true(obj x) { this->when_true_ = x; } + void assign_when_false(obj x) { this->when_false_ = x; } + + ///@} + /** @defgroup scm-ifelseexpr-expression-facet **/ + ///@{ + + exprtype extype() const noexcept { return exprtype::ifexpr; } + TypeRef typeref() const noexcept { return typeref_; } + TypeDescr valuetype() const noexcept { return typeref_.td(); } + void assign_valuetype(TypeDescr td) noexcept; + + ///@} + /** @defgroup scm-ifelseexpr-printable-facet **/ + ///@{ + + bool pretty(const ppindentinfo & ppii) const; + + ///@} + /** @defgroup scm-ifelseexpr-gcobject-facet **/ + ///@{ + + DIfElseExpr * gco_shallow_move(obj gc) noexcept; + void visit_gco_children(VisitReason reason, obj gc) noexcept; + + ///@} + +#ifdef NOT_YET + virtual std::set get_free_variables() const override { + std::set retval = test_->get_free_variables(); + + std::set free_vars; + free_vars = when_true_->get_free_variables(); + for (const auto & s : free_vars) + retval.insert(s); + + free_vars = when_false_->get_free_variables(); + for (const auto & s : free_vars) + retval.insert(s); + + return retval; + } + + virtual std::size_t visit_preorder(VisitFn visitor_fn) override { + std::size_t n = 1; + + visitor_fn(this); + + n += this->test_->visit_preorder(visitor_fn); + n += this->when_true_->visit_preorder(visitor_fn); + n += this->when_false_->visit_preorder(visitor_fn); + + return n; + } + + virtual std::size_t visit_layer(VisitFn visitor_fn) override { + std::size_t n = 1; + + visitor_fn(this); + + n += this->test_->visit_layer(visitor_fn); + n += this->when_true_->visit_layer(visitor_fn); + n += this->when_false_->visit_layer(visitor_fn); + + return n; + } + + virtual rp xform_layer(TransformFn xform_fn) override { + this->test_ = this->test_->xform_layer(xform_fn); + this->when_true_ = this->when_true_->xform_layer(xform_fn); + this->when_false_= this->when_false_->xform_layer(xform_fn); + + return xform_fn(this); + } + + virtual void attach_envs(bp p) override { + test_->attach_envs(p); + when_true_->attach_envs(p); + when_false_->attach_envs(p); + } +#endif + +#ifdef NOT_USING + virtual std::int32_t find_free_vars(std::set> * p_set) override { + return (test_->find_free_vars(p_set) + + when_true_->find_free_vars(p_set) + + when_false_->find_free_vars(p_set)); + } +#endif + +#ifdef NOPE + virtual void display(std::ostream & os) const override; + virtual std::uint32_t pretty_print(const ppindentinfo & ppi) const override; +#endif + + protected: +#ifdef NOT_YET + /** + * @p ifexpr_type type for value produced by if-expression. + * same as both when_true->valuetype() and + * when_false->valuetype(). + * @p test test-expression; always execute + * @p when_true then-branch; executes only when test succeeds + * @p when_false else-branch; executes only when test fails + **/ + IfExpr(TypeDescr ifexpr_type, + rp test, + rp when_true, + rp when_false) + : Expression(exprtype::ifexpr, ifexpr_type), + test_{std::move(test)}, + when_true_{std::move(when_true)}, + when_false_{std::move(when_false)} {} + + static TypeDescr check_consistent_valuetype(const rp & when_true, + const rp & when_false); + + /** determine if-expr valuetype **/ + void establish_valuetype(); +#endif + + private: + /** expression value always has type consistent + * with this description + **/ + TypeRef typeref_; + /** if: + * (if x y z) + * + * executes x; if true execute y; otherwise execute z + **/ + obj test_; + obj when_true_; + obj when_false_; + }; /*IfExpr*/ + +#ifdef NOPE + inline rp + make_ifexpr(const rp & test, + const rp & when_true, + const rp & when_false) + { + return IfExpr::make(test, when_true, when_false); + } + + class IfExprAccess : public IfExpr { + public: + static rp make(rp test, + rp when_true, + rp when_false); + static rp make_empty(); + + void assign_test(rp x) { test_ = std::move(x); } + void assign_when_true(rp x); + void assign_when_false(rp x); + + private: + IfExprAccess(TypeDescr ifexpr_type, + rp test, + rp when_true, + rp when_false) + : IfExpr(ifexpr_type, + std::move(test), + std::move(when_true), + std::move(when_false)) {} + }; +#endif + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DIfElseExpr.hpp */ diff --git a/xo-expression2/include/xo/expression2/DLambdaExpr.hpp b/xo-expression2/include/xo/expression2/DLambdaExpr.hpp new file mode 100644 index 00000000..b7fc76a8 --- /dev/null +++ b/xo-expression2/include/xo/expression2/DLambdaExpr.hpp @@ -0,0 +1,133 @@ +/** @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 +#include + +namespace xo { + namespace scm { + /** @class DLambdaExpr + * @brief syntax tree for a function/procedure definition + * + **/ + class DLambdaExpr { + public: + using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using VisitReason = xo::mm::VisitReason; + using AAllocator = xo::mm::AAllocator; + using TypeDescr = xo::reflect::TypeDescr; + using ppindentinfo = xo::print::ppindentinfo; + using size_type = DLocalSymtab::size_type; + + public: + + /** @defgroup scm-lambdaexpr-ctors **/ + ///@{ + + DLambdaExpr(TypeRef typeref, + const DUniqueString * name, + DLocalSymtab * local_symtab, + obj body); + + /** create instance using memory from @p mm **/ + static obj make(obj mm, + TypeRef typeref, + const DUniqueString * name, + DLocalSymtab * local_symtab, + obj body); + + /** create instance, using memory from @p mm **/ + static DLambdaExpr * _make(obj mm, + TypeRef typeref, + const DUniqueString * name, + DLocalSymtab * local_symtab, + obj body); + + /** create type description for lambda with arguments described by @p symtab + * and return type @p return_td. + * Load-bearing for DLambdaSsm in xo-reader2/ + **/ + static TypeDescr assemble_lambda_td(DLocalSymtab * symtab, + TypeDescr return_td); + + ///@} + /** @defgroup scm-lambdaexpr-methods **/ + ///@{ + + DLocalSymtab * local_symtab() const noexcept { return local_symtab_; } + size_type n_args() const noexcept { return local_symtab_->n_vars(); } + obj body_expr() const noexcept { return body_expr_; } + + // 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-gcobject-facet **/ + ///@{ + + std::size_t shallow_size() const noexcept; + DLambdaExpr * gco_shallow_move(obj gc) noexcept; + void visit_gco_children(VisitReason reason, obj gc) 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 // when enabled, need to visit forward_children() + /** 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 new file mode 100644 index 00000000..b658bbd5 --- /dev/null +++ b/xo-expression2/include/xo/expression2/DLocalSymtab.hpp @@ -0,0 +1,128 @@ +/** @file DLocalSymtab.hpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include "Binding.hpp" +#include "DVariable.hpp" +#include "DUniqueString.hpp" +#include +#include + +namespace xo { + namespace scm { + /** @class DLocalSymtab + * @brief symbol table for a local stack frame + **/ + struct DLocalSymtab { + public: + using DArray = xo::scm::DArray; + using ppindentinfo = xo::print::ppindentinfo; + using AGCObject = xo::mm::AGCObject; + using VisitReason = xo::mm::VisitReason; + using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using AAllocator = xo::mm::AAllocator; + /* note: uint16_t would be fine too */ + using size_type = std::uint32_t; + + struct Slot { + Slot() = default; + explicit Slot(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) + **/ + DVariable * var_ = nullptr; + }; + + public: + /** @defgroup scm-lambdaexpr-constructors **/ + ///@{ + + /** empty instance with parent @p p, using arrays @p vars for variables + * and @p types for type definitions. + **/ + DLocalSymtab(DLocalSymtab * p, DArray * nv, DArray * nt); + + /** scaffold empty symtab instance, + * capacity for @p nv vars and @p nt types, + * using memory from allocator @p mm. + * Symtab chains to parent @p p. + **/ + static DLocalSymtab * _make_empty(obj mm, + DLocalSymtab * p, + size_type nv, + size_type nt); + + ///@} + /** @defgroup scm-lambdaexpr-methods **/ + ///@{ + + DLocalSymtab * parent() const noexcept { return parent_; } + //size_type capacity() const noexcept { return capacity_; } + size_type n_vars() const noexcept { return vars_->size(); } + size_type n_types() const noexcept { return types_->size(); } + + DVariable * lookup_var(Binding ix) noexcept; + + /** increase slot size (provided below 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); + + /** increase slot size (provided below capacity) to append + * binding for one local type. Local type will be allocated + * from @p mm, named @p name, with type described by @p type. + **/ + void append_type(obj mm, + const DUniqueString * name, + obj type); + + ///@} + /** @defgroup xo-localsymtab-symboltable-facet symboltable facet**/ + ///@{ + + /** true for global symbol table **/ + bool is_global_symtab() const noexcept { return false; } + + /** lookup binding for variable @p sym **/ + Binding lookup_binding(const DUniqueString * sym) const noexcept; + + ///@} + /** @defgroup xo-localsymtab-gcobject-facet gcobject facet **/ + ///@{ + + DLocalSymtab * gco_shallow_move(obj gc) noexcept; + void visit_gco_children(VisitReason reason, obj gc) noexcept; + + ///@} + /** @defgroup xo-localsymtab-printable-facet printable facet **/ + ///@{ + + bool pretty(const ppindentinfo & ppii) const; + + ///@} + + private: + /** parent symbol table from scoping surrounding this one **/ + DLocalSymtab * parent_ = nullptr; + /** variables owned by (declared in) this symbol table + * vars_[i] is convertible to obj + **/ + DArray * vars_ = nullptr; + /** types owned by (defined in) this symbol table + * types_[i] is convertible to obj + **/ + DArray * types_ = nullptr; + }; + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DLocalSymtab.hpp */ diff --git a/xo-expression2/include/xo/expression2/DSequenceExpr.hpp b/xo-expression2/include/xo/expression2/DSequenceExpr.hpp new file mode 100644 index 00000000..e919ae13 --- /dev/null +++ b/xo-expression2/include/xo/expression2/DSequenceExpr.hpp @@ -0,0 +1,93 @@ +/** @file DSequenceExpr.hpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include "Expression.hpp" +#include "TypeRef.hpp" +#include +#include + +namespace xo { + namespace scm { + + /** syntax for a sequence of expressions + * { + * expr(1); + * expr(2); + * ... + * expr(n); + * } + **/ + class DSequenceExpr { + public: + using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using VisitReason = xo::mm::VisitReason; + using AAllocator = xo::mm::AAllocator; + using TypeDescr = xo::reflect::TypeDescr; + using size_type = DArray::size_type; + using ppindentinfo = xo::print::ppindentinfo; + + public: + DSequenceExpr() ; + DSequenceExpr(DArray * xv); + + /** create empty sequence using memory from @p mm **/ + static obj make_empty(obj mm); + + /** create empty sequence expression using mmeory from @p mm **/ + static DSequenceExpr * _make_empty(obj mm); + + size_type size() const noexcept; + obj operator[](std::size_t i) const; + + /** append @p expr to the end of this sequence; + * use memory from @p mm if need to expand storage + **/ + void push_back(obj mm, + obj expr); + + // get_free_variables(); + // visit_preorder(); + // visit_layer(); + // xform_layer() + // attach_envs() + + /** @defgroup scm-ifelseexpr-expression-facets **/ + ///@{ + + exprtype extype() const noexcept { return exprtype::sequence; } + TypeRef typeref() const noexcept { return typeref_; } + TypeDescr valuetype() const noexcept { return typeref_.td(); } + void assign_valuetype(TypeDescr td) noexcept; + + ///@} + /** @defgroup scm-sequenceexpr-printable-facet printable facet methods **/ + ///@{ + + /** pretty-printing driver; combine layout+printing **/ + bool pretty(const ppindentinfo & ppii) const; + + ///@} + /** @defgroup scm-sequenceexpr-gcobject-facet gcobject facet methods **/ + ///@{ + + DSequenceExpr * gco_shallow_move(obj gc) noexcept; + void visit_gco_children(VisitReason reason, obj gc) noexcept; + + ///@} + + private: + /** expression value always has type consistent with this description + **/ + TypeRef typeref_; + /** array of expressions **/ + DArray * expr_v_ = nullptr; + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DSequenceExpr.hpp */ diff --git a/xo-expression2/include/xo/expression2/DTypename.hpp b/xo-expression2/include/xo/expression2/DTypename.hpp new file mode 100644 index 00000000..64ec86bc --- /dev/null +++ b/xo-expression2/include/xo/expression2/DTypename.hpp @@ -0,0 +1,78 @@ +/** @file DTypename.hpp + * + * @author Roland Conybeare, Mar 2026 + **/ + +#pragma once + +#include "DUniqueString.hpp" +#include +#include +#include +#include + +namespace xo { + namespace scm { + + /** @class DTypename + * @brief Container for a named type + * + * Represents the result of syntax like + * 1. deftype Foo :: i64; + * 2. deftype FooAlias :: Foo; + **/ + class DTypename { + public: + using ppindentinfo = xo::print::ppindentinfo; + using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using VisitReason = xo::mm::VisitReason; + using AGCObject = xo::mm::AGCObject; + using AAllocator = xo::mm::AAllocator; + + public: + DTypename(const DUniqueString * name, + obj type); + + /** create instance + * @p mm memory allocator + * @p name type name + * @p type type definition + **/ + static DTypename * _make(obj mm, + const DUniqueString * name, + obj type); + /** create fop for new instance **/ + static obj make(obj mm, + const DUniqueString * name, + obj type); + + const DUniqueString * name() const noexcept { return name_; } + obj type() const noexcept { return type_; } + + void assign_name(const DUniqueString * name) { this->name_ = name; } + + + /** @defgroup scm-typename-gcobject-facet **/ + ///@{ + + DTypename * gco_shallow_move(obj gc) noexcept; + void visit_gco_children(VisitReason reason, obj gc) noexcept; + + ///@} + /** @defgroup scm-typename-printable-facet **/ + ///@{ + + bool pretty(const ppindentinfo & ppii) const; + + ///@} + + private: + /** symbol name **/ + const DUniqueString * name_ = nullptr; + /** type defintion. Everything but the name **/ + obj type_; + }; + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DTypename.hpp */ diff --git a/xo-expression2/include/xo/expression2/DVarRef.hpp b/xo-expression2/include/xo/expression2/DVarRef.hpp new file mode 100644 index 00000000..93224199 --- /dev/null +++ b/xo-expression2/include/xo/expression2/DVarRef.hpp @@ -0,0 +1,85 @@ +/** @file DVarRef.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "Variable.hpp" +#include + +namespace xo { + namespace scm { + + /** @class DVarRef + * @brief syntax for a variable reference + * + * Reference to a known variable possibly + * defined in another scope. + * For non-local non-global variables, + **/ + class DVarRef { + public: + using ppindentinfo = xo::print::ppindentinfo; + using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using VisitReason = xo::mm::VisitReason; + using AAllocator = xo::mm::AAllocator; + using TypeDescr = xo::reflect::TypeDescr; + + public: + DVarRef(DVariable * vardef, + Binding path); + + /** create instance + * @p mm memory allocator + * @p vardef variable definition (name, typeref, binding) + * @p link number of lexical scope boundaries we must cross + * to reach scope containing @p vardef. + * Only relevant for non-global vardef + **/ + static DVarRef * make(obj mm, + DVariable * vardef, + int32_t link); + + const DUniqueString * name() const; + Binding path() const { return path_; } + + /** @defgroup scm-variable-expression-facet **/ + ///@{ + + exprtype extype() const noexcept { return exprtype::varref; } + TypeRef typeref() const noexcept; + TypeDescr valuetype() const noexcept; + void assign_valuetype(TypeDescr td) noexcept; + + ///@} + /** @defgroup scm-variable-gcobject-facet **/ + ///@{ + + DVarRef * gco_shallow_move(obj gc) noexcept; + void visit_gco_children(VisitReason reason, obj gc) noexcept; + + ///@} + /** @defgroup scm-variable-printable-facet **/ + ///@{ + + bool pretty(const ppindentinfo & ppii) const; + + ///@} + + private: + /** variable definition. Created in the sccope where variable introduced. + * Has an associated @ref Binding, but that binding is only correct + * around any nested scopes. + **/ + DVariable * vardef_ = nullptr; + + /** at runtime: navigate environemnt via this path to get + * runtime memory location for this variable + **/ + Binding path_; + }; + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DVarRef.hpp */ diff --git a/xo-expression2/include/xo/expression2/DVariable.hpp b/xo-expression2/include/xo/expression2/DVariable.hpp new file mode 100644 index 00000000..158ef842 --- /dev/null +++ b/xo-expression2/include/xo/expression2/DVariable.hpp @@ -0,0 +1,93 @@ +/** @file DVariable.hpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include "DUniqueString.hpp" +#include "Binding.hpp" +#include "TypeRef.hpp" +#include "exprtype.hpp" +#include +#include +#include + +namespace xo { + namespace scm { + + /** @class DVariable + * @brief syntax for a variable reference + **/ + class DVariable { + public: + using ppindentinfo = xo::print::ppindentinfo; + using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using VisitReason = xo::mm::VisitReason; + using AAllocator = xo::mm::AAllocator; + using TypeDescr = xo::reflect::TypeDescr; + + public: + /** create instance + * @p mm memory allocator + * @p name variable name + * @p typeref type information for legal values + * (possibly just placeholder when relying on inference) + * @p path binding path to runtime value. + * This may be computed after parsing; + * mnust be resolved before execution. + **/ + static DVariable * make(obj mm, + const DUniqueString * name, + const TypeRef & typeref, + Binding path = Binding()); + + DVariable(const DUniqueString * name, + const TypeRef & typeref, + Binding path); + + const DUniqueString * name() const { return name_; } + Binding path() const { return path_; } + + void assign_name(const DUniqueString * name) { this->name_ = name; } + void assign_path(Binding b) { this->path_ = b; } + + /** @defgroup scm-variable-expression-facet **/ + ///@{ + + exprtype extype() const noexcept { return exprtype::variable; } + TypeRef typeref() const noexcept { return typeref_; } + TypeDescr valuetype() const noexcept { return typeref_.td(); }; + void assign_valuetype(TypeDescr td) noexcept; + + ///@} + /** @defgroup scm-variable-gcobject-facet **/ + ///@{ + + DVariable * gco_shallow_move(obj gc) noexcept; + void visit_gco_children(VisitReason reason, obj gc) noexcept; + + ///@} + /** @defgroup scm-variable-printable-facet **/ + ///@{ + + bool pretty(const ppindentinfo & ppii) const; + + ///@} + + private: + /** symbol name **/ + const DUniqueString * name_ = nullptr; + /** variable value always has type consistent + * with this description + **/ + TypeRef typeref_; + /** at runtime: navigate environemnt via this path to get + * runtime memory location for this variable + **/ + Binding path_; + }; + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DVariable.hpp */ diff --git a/xo-expression2/include/xo/expression2/DefineExpr.hpp b/xo-expression2/include/xo/expression2/DefineExpr.hpp new file mode 100644 index 00000000..4a0c42c2 --- /dev/null +++ b/xo-expression2/include/xo/expression2/DefineExpr.hpp @@ -0,0 +1,13 @@ +/** @file DefineExpr.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "DDefineExpr.hpp" +#include "detail/IExpression_DDefineExpr.hpp" +#include "define/IGCObject_DDefineExpr.hpp" +#include "detail/IPrintable_DDefineExpr.hpp" + +/* end DefineExpr.hpp */ diff --git a/xo-expression2/include/xo/expression2/Expression.hpp b/xo-expression2/include/xo/expression2/Expression.hpp new file mode 100644 index 00000000..6ed0e1f2 --- /dev/null +++ b/xo-expression2/include/xo/expression2/Expression.hpp @@ -0,0 +1,22 @@ +/** @file Expression.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/Expression.json5] + * 2. jinja2 template for facet .hpp file: + * [facet.hpp.j2] + * 3. idl for facet methods + * [idl/Expression.json5] + **/ + +#pragma once + +#include "detail/AExpression.hpp" +#include "detail/IExpression_Any.hpp" +#include "detail/IExpression_Xfer.hpp" +#include "detail/RExpression.hpp" + + +/* end Expression.hpp */ diff --git a/xo-expression2/include/xo/expression2/GlobalSymtab.hpp b/xo-expression2/include/xo/expression2/GlobalSymtab.hpp new file mode 100644 index 00000000..05ad9f4b --- /dev/null +++ b/xo-expression2/include/xo/expression2/GlobalSymtab.hpp @@ -0,0 +1,13 @@ +/** @file GlobalSymtab.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "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/IfElseExpr.hpp b/xo-expression2/include/xo/expression2/IfElseExpr.hpp new file mode 100644 index 00000000..901062b2 --- /dev/null +++ b/xo-expression2/include/xo/expression2/IfElseExpr.hpp @@ -0,0 +1,13 @@ +/** @file IfElseExpr.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "DIfElseExpr.hpp" +#include "detail/IExpression_DIfElseExpr.hpp" +#include "detail/IGCObject_DIfElseExpr.hpp" +#include "detail/IPrintable_DIfElseExpr.hpp" + +/* end IfElseExpr.hpp */ diff --git a/xo-expression2/include/xo/expression2/LambdaExpr.hpp b/xo-expression2/include/xo/expression2/LambdaExpr.hpp new file mode 100644 index 00000000..043ca319 --- /dev/null +++ b/xo-expression2/include/xo/expression2/LambdaExpr.hpp @@ -0,0 +1,13 @@ +/** @file LambdaExpr.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "DLambdaExpr.hpp" +#include "detail/IExpression_DLambdaExpr.hpp" +#include "detail/IGCObject_DLambdaExpr.hpp" +#include "detail/IPrintable_DLambdaExpr.hpp" + +/* end LambdaExpr.hpp */ diff --git a/xo-expression2/include/xo/expression2/LocalSymtab.hpp b/xo-expression2/include/xo/expression2/LocalSymtab.hpp new file mode 100644 index 00000000..e594a08d --- /dev/null +++ b/xo-expression2/include/xo/expression2/LocalSymtab.hpp @@ -0,0 +1,13 @@ +/** @file LocalSymtab.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "DLocalSymtab.hpp" +#include "symtab/ISymbolTable_DLocalSymtab.hpp" +#include "symtab/IGCObject_DLocalSymtab.hpp" +#include "symtab/IPrintable_DLocalSymtab.hpp" + +/* end LocalSymtab.hpp */ diff --git a/xo-expression2/include/xo/expression2/SequenceExpr.hpp b/xo-expression2/include/xo/expression2/SequenceExpr.hpp new file mode 100644 index 00000000..0cfe188c --- /dev/null +++ b/xo-expression2/include/xo/expression2/SequenceExpr.hpp @@ -0,0 +1,14 @@ +/** @file SequenceExpr.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "DSequenceExpr.hpp" +#include "detail/IExpression_DSequenceExpr.hpp" +#include "detail/IGCObject_DSequenceExpr.hpp" +#include "detail/IPrintable_DSequenceExpr.hpp" + +/* end SequenceExpr.hpp */ + diff --git a/xo-expression2/include/xo/expression2/SetupExpression2.hpp b/xo-expression2/include/xo/expression2/SetupExpression2.hpp new file mode 100644 index 00000000..819bdff6 --- /dev/null +++ b/xo-expression2/include/xo/expression2/SetupExpression2.hpp @@ -0,0 +1,25 @@ +/** @file SetupExpression2.hpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include + +namespace xo { + namespace scm { + class SetupExpression2 { + public: + using ACollector = xo::mm::ACollector; + + public: + /** Register expression2 (facet,impl) combinations with FacetRegistry **/ + static bool register_facets(); + /** Register expression2 (facet,impl) combinations with FacetRegistry **/ + static bool register_types(obj gc); + }; + } +} + +/* end SetupExpression2.hpp */ diff --git a/xo-expression2/include/xo/expression2/SymbolTable.hpp b/xo-expression2/include/xo/expression2/SymbolTable.hpp new file mode 100644 index 00000000..618cf2bf --- /dev/null +++ b/xo-expression2/include/xo/expression2/SymbolTable.hpp @@ -0,0 +1,22 @@ +/** @file SymbolTable.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/SymbolTable.json5] + * 2. jinja2 template for facet .hpp file: + * [facet.hpp.j2] + * 3. idl for facet methods + * [idl/SymbolTable.json5] + **/ + +#pragma once + +#include "symtab/ASymbolTable.hpp" +#include "symtab/ISymbolTable_Any.hpp" +#include "symtab/ISymbolTable_Xfer.hpp" +#include "symtab/RSymbolTable.hpp" + + +/* end SymbolTable.hpp */ diff --git a/xo-expression2/include/xo/expression2/TypeRef.hpp b/xo-expression2/include/xo/expression2/TypeRef.hpp new file mode 100644 index 00000000..c93158fb --- /dev/null +++ b/xo-expression2/include/xo/expression2/TypeRef.hpp @@ -0,0 +1,111 @@ +/** @file TypeRef.hpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include +#include +#include +#include +#include +#include + +namespace xo { + namespace scm { + /** @class TypeRef + * @brief name and (when established) resolution for type + * associated with an expression + * + * Type inference / unification operates on + * @ref xo::scm::TypeBlueprint instances. See also! + **/ + class TypeRef { + public: + using TypeDescr = xo::reflect::TypeDescr; + using type_var = flatstring<20>; + using prefix_type = flatstring<8>; + using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using VisitReason = xo::mm::VisitReason; + using ppindentinfo = xo::print::ppindentinfo; + + public: + TypeRef() = default; + TypeRef(const type_var & id, obj type); + + /** trivial typeref, where already resolved. + * Require: @p td non-null + **/ + static TypeRef resolved(TypeDescr td); + + /** trivial typeref, where already resolved **/ + static TypeRef resolved(obj type); + + /** if @p type is non-null + * -> type already resolved + * else + * -> generate unique typevar name, starting with @p prefix + **/ + static TypeRef dwim(prefix_type prefix, obj type); + + /** if @p td is non-null + * -> type is already resolved + * + * if type is not determined (i.e. @p td is nullptr): + * -> generate and store type variable name. + **/ + static TypeRef dwim(prefix_type prefix, TypeDescr td); + + /** generate a unique type-variable name, + * that begins with @p prefix + **/ + static type_var generate_unique(prefix_type prefix); + + const type_var & id() const noexcept { return id_; } + TypeDescr td() const noexcept { return td_; } + + /** true iff type at this location has been resolved **/ + bool is_resolved() const noexcept; + + /** resolve TypeRef by supplying final type-description **/ + void resolve(TypeDescr td) noexcept { td_ = td; } + + /** pretty-printer support **/ + bool pretty(const ppindentinfo & ppii) const; + + /** gc support **/ + void visit_gco_children(VisitReason reason, obj gc) noexcept; + + private: + TypeRef(const type_var & id, TypeDescr td); + + private: + /** unique (probably generated) name for type at this location **/ + type_var id_; + + /** Type, when resolved **/ + obj type_; + + /** Description for concrete type, once resolved. + * May be null when this TypeRef created, + * but expected to be immutable once established. + **/ + TypeDescr td_ = nullptr; + }; + } /*namespace scm*/ + + namespace print { + /** pretty printer in relies on this specialization + * to handle TypeRef instances + **/ + template <> + struct ppdetail { + static inline bool print_pretty(const ppindentinfo & ppii, const xo::scm::TypeRef x) { + return x.pretty(ppii); + } + }; + } +} /*namespace xo*/ + +/* end TypeRef.hpp */ diff --git a/xo-expression2/include/xo/expression2/Typename.hpp b/xo-expression2/include/xo/expression2/Typename.hpp new file mode 100644 index 00000000..69c90bab --- /dev/null +++ b/xo-expression2/include/xo/expression2/Typename.hpp @@ -0,0 +1,12 @@ +/** @file Typename.hpp + * + * @author Roland Conybeare, Mar 2026 + **/ + +#pragma once + +#include "DTypename.hpp" +#include "typename/IGCObject_DTypename.hpp" +#include "typename/IPrintable_DTypename.hpp" + +/* end Typename.hpp */ diff --git a/xo-expression2/include/xo/expression2/VarRef.hpp b/xo-expression2/include/xo/expression2/VarRef.hpp new file mode 100644 index 00000000..19f2d1d0 --- /dev/null +++ b/xo-expression2/include/xo/expression2/VarRef.hpp @@ -0,0 +1,13 @@ +/** @file VarRef.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "DVarRef.hpp" +#include "detail/IExpression_DVarRef.hpp" +#include "detail/IGCObject_DVarRef.hpp" +#include "detail/IPrintable_DVarRef.hpp" + +/* end VarRef.hpp */ diff --git a/xo-expression2/include/xo/expression2/Variable.hpp b/xo-expression2/include/xo/expression2/Variable.hpp new file mode 100644 index 00000000..43141578 --- /dev/null +++ b/xo-expression2/include/xo/expression2/Variable.hpp @@ -0,0 +1,13 @@ +/** @file Variable.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "DVariable.hpp" +#include "variable/IExpression_DVariable.hpp" +#include "variable/IGCObject_DVariable.hpp" +#include "variable/IPrintable_DVariable.hpp" + +/* end Variable.hpp */ diff --git a/xo-expression2/include/xo/expression2/define/IGCObject_DDefineExpr.hpp b/xo-expression2/include/xo/expression2/define/IGCObject_DDefineExpr.hpp new file mode 100644 index 00000000..e98403fe --- /dev/null +++ b/xo-expression2/include/xo/expression2/define/IGCObject_DDefineExpr.hpp @@ -0,0 +1,69 @@ +/** @file IGCObject_DDefineExpr.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DDefineExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DDefineExpr.json5] + **/ + +#pragma once + +#include "GCObject.hpp" +#include +#include +#include "DDefineExpr.hpp" + +namespace xo { namespace scm { class IGCObject_DDefineExpr; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IGCObject_DDefineExpr + **/ + class IGCObject_DDefineExpr { + public: + /** @defgroup scm-gcobject-ddefineexpr-type-traits **/ + ///@{ + using size_type = xo::mm::AGCObject::size_type; + using AAllocator = xo::mm::AGCObject::AAllocator; + using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; + using Copaque = xo::mm::AGCObject::Copaque; + using Opaque = xo::mm::AGCObject::Opaque; + ///@} + /** @defgroup scm-gcobject-ddefineexpr-methods **/ + ///@{ + // const methods + + // non-const methods + /** move instance using object visitor. +Arguably abusing the word 'visitor' here **/ + static Opaque gco_shallow_move(DDefineExpr & self, obj gc) noexcept; + /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. +Context: provides address of data pointer so it can be updated in place +when @p fn invokes garbage collector reentry point **/ + static void visit_gco_children(DDefineExpr & self, VisitReason reason, obj fn) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/xo-expression2/include/xo/expression2/detail/AExpression.hpp b/xo-expression2/include/xo/expression2/detail/AExpression.hpp new file mode 100644 index 00000000..e615fb46 --- /dev/null +++ b/xo-expression2/include/xo/expression2/detail/AExpression.hpp @@ -0,0 +1,89 @@ +/** @file AExpression.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/Expression.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [abstract_facet.hpp.j2] + * 3. idl for facet methods + * [idl/Expression.json5] + **/ + +#pragma once + +// includes (via {facet_includes}) +#include "TypeRef.hpp" +#include "exprtype.hpp" +#include +#include +#include +#include + +// {pretext} here + +namespace xo { +namespace scm { + +using Copaque = const void *; +using Opaque = void *; + +/** +Representation for executable Schematika expressions +**/ +class AExpression { +public: + /** @defgroup scm-expression-type-traits **/ + ///@{ + // types + /** integer identifying a type **/ + using typeseq = xo::facet::typeseq; + using Copaque = const void *; + using Opaque = void *; + /** struct describing a type **/ + using TypeDescr = xo::reflect::TypeDescr; + ///@} + + /** @defgroup scm-expression-methods **/ + ///@{ + // const methods + /** An uninitialized AExpression instance will have zero vtable pointer (per {linux,osx} abi). + * Use case for this is narrow. We go to some lengths to avoid null vtable pointers. For example + * obj will have non-null vtable (via IFacet_Any) with all methods terminating. + **/ + bool _has_null_vptr() const noexcept { return *reinterpret_cast(this) == nullptr; } + /** RTTI: unique id# for actual runtime data representation **/ + virtual typeseq _typeseq() const noexcept = 0; + /** destroy instance @p d; calls c++ dtor only for actual runtime type; does not recover memory **/ + virtual void _drop(Opaque d) const noexcept = 0; + /** expression type (constant | apply | ..) **/ + virtual exprtype extype(Copaque data) const noexcept = 0; + /** placeholder for type giving possible values for this expression **/ + virtual TypeRef typeref(Copaque data) const noexcept = 0; + /** type giving possible values for this expression. Maybe null before typecheck **/ + virtual TypeDescr valuetype(Copaque data) const noexcept = 0; + + // nonconst methods + /** assing to valuetype member. Useful when scaffolding expressions **/ + virtual void assign_valuetype(Opaque data, TypeDescr td) noexcept = 0; + ///@} +}; /*AExpression*/ + +/** Implementation IExpression_DRepr of AExpression for state DRepr + * should provide a specialization: + * + * template <> + * struct xo::facet::FacetImplementation { + * using Impltype = IExpression_DRepr; + * }; + * + * then IExpression_ImplType --> IExpression_DRepr + **/ +template +using IExpression_ImplType = xo::facet::FacetImplType; + +} /*namespace scm*/ +} /*namespace xo*/ + +/* AExpression.hpp */ diff --git a/xo-expression2/include/xo/expression2/detail/IExpression_Any.hpp b/xo-expression2/include/xo/expression2/detail/IExpression_Any.hpp new file mode 100644 index 00000000..827f9d9b --- /dev/null +++ b/xo-expression2/include/xo/expression2/detail/IExpression_Any.hpp @@ -0,0 +1,92 @@ +/** @file IExpression_Any.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/Expression.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/Expression.json5] + **/ + +#pragma once + +#include "AExpression.hpp" +#include + +namespace xo { namespace scm { class IExpression_Any; } } + +namespace xo { +namespace facet { + +template <> +struct FacetImplementation +{ + using ImplType = xo::scm::IExpression_Any; +}; + +} +} + +namespace xo { +namespace scm { + + /** @class IExpression_Any + * @brief AExpression implementation for empty variant instance + **/ + class IExpression_Any : public AExpression { + public: + /** @defgroup scm-expression-any-type-traits **/ + ///@{ + + /** integer identifying a type **/ + using typeseq = xo::facet::typeseq; + using TypeDescr = AExpression::TypeDescr; + + ///@} + /** @defgroup scm-expression-any-methods **/ + ///@{ + + const AExpression * iface() const { return std::launder(this); } + + // from AExpression + + // builtin methods + typeseq _typeseq() const noexcept override { return s_typeseq; } + [[noreturn]] void _drop(Opaque) const noexcept override { _fatal(); } + + // const methods + [[noreturn]] exprtype extype(Copaque) const noexcept override { _fatal(); } + [[noreturn]] TypeRef typeref(Copaque) const noexcept override { _fatal(); } + [[noreturn]] TypeDescr valuetype(Copaque) const noexcept override { _fatal(); } + + // nonconst methods + [[noreturn]] void assign_valuetype(Opaque, TypeDescr) noexcept override; + + ///@} + + private: + /** @defgraoup scm-expression-any-private-methods **/ + ///@{ + + [[noreturn]] static void _fatal(); + + ///@} + + public: + /** @defgroup scm-expression-any-member-vars **/ + ///@{ + + static typeseq s_typeseq; + static bool _valid; + + ///@} + }; + +} /*namespace scm */ +} /*namespace xo */ + +/* IExpression_Any.hpp */ diff --git a/xo-expression2/include/xo/expression2/detail/IExpression_DApplyExpr.hpp b/xo-expression2/include/xo/expression2/detail/IExpression_DApplyExpr.hpp new file mode 100644 index 00000000..49cce701 --- /dev/null +++ b/xo-expression2/include/xo/expression2/detail/IExpression_DApplyExpr.hpp @@ -0,0 +1,66 @@ +/** @file IExpression_DApplyExpr.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IExpression_DApplyExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IExpression_DApplyExpr.json5] + **/ + +#pragma once + +#include "Expression.hpp" +#include "Expression.hpp" +#include "DApplyExpr.hpp" + +namespace xo { namespace scm { class IExpression_DApplyExpr; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::scm::IExpression_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IExpression_DApplyExpr + **/ + class IExpression_DApplyExpr { + public: + /** @defgroup scm-expression-dapplyexpr-type-traits **/ + ///@{ + using TypeDescr = xo::scm::AExpression::TypeDescr; + using Copaque = xo::scm::AExpression::Copaque; + using Opaque = xo::scm::AExpression::Opaque; + ///@} + /** @defgroup scm-expression-dapplyexpr-methods **/ + ///@{ + // const methods + /** expression type (constant | apply | ..) **/ + static exprtype extype(const DApplyExpr & self) noexcept; + /** placeholder for type giving possible values for this expression **/ + static TypeRef typeref(const DApplyExpr & self) noexcept; + /** type giving possible values for this expression. Maybe null before typecheck **/ + static TypeDescr valuetype(const DApplyExpr & self) noexcept; + + // non-const methods + /** assing to valuetype member. Useful when scaffolding expressions **/ + static void assign_valuetype(DApplyExpr & self, TypeDescr td) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/xo-expression2/include/xo/expression2/detail/IExpression_DConstant.hpp b/xo-expression2/include/xo/expression2/detail/IExpression_DConstant.hpp new file mode 100644 index 00000000..c6bbd819 --- /dev/null +++ b/xo-expression2/include/xo/expression2/detail/IExpression_DConstant.hpp @@ -0,0 +1,66 @@ +/** @file IExpression_DConstant.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IExpression_DConstant.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IExpression_DConstant.json5] + **/ + +#pragma once + +#include "Expression.hpp" +#include "Expression.hpp" +#include "DConstant.hpp" + +namespace xo { namespace scm { class IExpression_DConstant; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::scm::IExpression_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IExpression_DConstant + **/ + class IExpression_DConstant { + public: + /** @defgroup scm-expression-dconstant-type-traits **/ + ///@{ + using TypeDescr = xo::scm::AExpression::TypeDescr; + using Copaque = xo::scm::AExpression::Copaque; + using Opaque = xo::scm::AExpression::Opaque; + ///@} + /** @defgroup scm-expression-dconstant-methods **/ + ///@{ + // const methods + /** expression type (constant | apply | ..) **/ + static exprtype extype(const DConstant & self) noexcept; + /** placeholder for type giving possible values for this expression **/ + static TypeRef typeref(const DConstant & self) noexcept; + /** type giving possible values for this expression. Maybe null before typecheck **/ + static TypeDescr valuetype(const DConstant & self) noexcept; + + // non-const methods + /** assing to valuetype member. Useful when scaffolding expressions **/ + static void assign_valuetype(DConstant & self, TypeDescr td) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/xo-expression2/include/xo/expression2/detail/IExpression_DDefineExpr.hpp b/xo-expression2/include/xo/expression2/detail/IExpression_DDefineExpr.hpp new file mode 100644 index 00000000..135c7bb4 --- /dev/null +++ b/xo-expression2/include/xo/expression2/detail/IExpression_DDefineExpr.hpp @@ -0,0 +1,66 @@ +/** @file IExpression_DDefineExpr.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IExpression_DDefineExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IExpression_DDefineExpr.json5] + **/ + +#pragma once + +#include "Expression.hpp" +#include "Expression.hpp" +#include "DDefineExpr.hpp" + +namespace xo { namespace scm { class IExpression_DDefineExpr; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::scm::IExpression_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IExpression_DDefineExpr + **/ + class IExpression_DDefineExpr { + public: + /** @defgroup scm-expression-ddefineexpr-type-traits **/ + ///@{ + using TypeDescr = xo::scm::AExpression::TypeDescr; + using Copaque = xo::scm::AExpression::Copaque; + using Opaque = xo::scm::AExpression::Opaque; + ///@} + /** @defgroup scm-expression-ddefineexpr-methods **/ + ///@{ + // const methods + /** expression type (constant | apply | ..) **/ + static exprtype extype(const DDefineExpr & self) noexcept; + /** placeholder for type giving possible values for this expression **/ + static TypeRef typeref(const DDefineExpr & self) noexcept; + /** type giving possible values for this expression. Maybe null before typecheck **/ + static TypeDescr valuetype(const DDefineExpr & self) noexcept; + + // non-const methods + /** assing to valuetype member. Useful when scaffolding expressions **/ + static void assign_valuetype(DDefineExpr & self, TypeDescr td) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/xo-expression2/include/xo/expression2/detail/IExpression_DIfElseExpr.hpp b/xo-expression2/include/xo/expression2/detail/IExpression_DIfElseExpr.hpp new file mode 100644 index 00000000..ca6e5705 --- /dev/null +++ b/xo-expression2/include/xo/expression2/detail/IExpression_DIfElseExpr.hpp @@ -0,0 +1,66 @@ +/** @file IExpression_DIfElseExpr.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IExpression_DIfElseExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IExpression_DIfElseExpr.json5] + **/ + +#pragma once + +#include "Expression.hpp" +#include "Expression.hpp" +#include "DIfElseExpr.hpp" + +namespace xo { namespace scm { class IExpression_DIfElseExpr; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::scm::IExpression_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IExpression_DIfElseExpr + **/ + class IExpression_DIfElseExpr { + public: + /** @defgroup scm-expression-difelseexpr-type-traits **/ + ///@{ + using TypeDescr = xo::scm::AExpression::TypeDescr; + using Copaque = xo::scm::AExpression::Copaque; + using Opaque = xo::scm::AExpression::Opaque; + ///@} + /** @defgroup scm-expression-difelseexpr-methods **/ + ///@{ + // const methods + /** expression type (constant | apply | ..) **/ + static exprtype extype(const DIfElseExpr & self) noexcept; + /** placeholder for type giving possible values for this expression **/ + static TypeRef typeref(const DIfElseExpr & self) noexcept; + /** type giving possible values for this expression. Maybe null before typecheck **/ + static TypeDescr valuetype(const DIfElseExpr & self) noexcept; + + // non-const methods + /** assing to valuetype member. Useful when scaffolding expressions **/ + static void assign_valuetype(DIfElseExpr & self, TypeDescr td) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file 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..bdb074d9 --- /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: + * [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/IExpression_DSequenceExpr.hpp b/xo-expression2/include/xo/expression2/detail/IExpression_DSequenceExpr.hpp new file mode 100644 index 00000000..6e0107dd --- /dev/null +++ b/xo-expression2/include/xo/expression2/detail/IExpression_DSequenceExpr.hpp @@ -0,0 +1,66 @@ +/** @file IExpression_DSequenceExpr.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IExpression_DSequenceExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IExpression_DSequenceExpr.json5] + **/ + +#pragma once + +#include "Expression.hpp" +#include "Expression.hpp" +#include "DSequenceExpr.hpp" + +namespace xo { namespace scm { class IExpression_DSequenceExpr; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::scm::IExpression_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IExpression_DSequenceExpr + **/ + class IExpression_DSequenceExpr { + public: + /** @defgroup scm-expression-dsequenceexpr-type-traits **/ + ///@{ + using TypeDescr = xo::scm::AExpression::TypeDescr; + using Copaque = xo::scm::AExpression::Copaque; + using Opaque = xo::scm::AExpression::Opaque; + ///@} + /** @defgroup scm-expression-dsequenceexpr-methods **/ + ///@{ + // const methods + /** expression type (constant | apply | ..) **/ + static exprtype extype(const DSequenceExpr & self) noexcept; + /** placeholder for type giving possible values for this expression **/ + static TypeRef typeref(const DSequenceExpr & self) noexcept; + /** type giving possible values for this expression. Maybe null before typecheck **/ + static TypeDescr valuetype(const DSequenceExpr & self) noexcept; + + // non-const methods + /** assing to valuetype member. Useful when scaffolding expressions **/ + static void assign_valuetype(DSequenceExpr & self, TypeDescr td) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/xo-expression2/include/xo/expression2/detail/IExpression_DVarRef.hpp b/xo-expression2/include/xo/expression2/detail/IExpression_DVarRef.hpp new file mode 100644 index 00000000..332113c1 --- /dev/null +++ b/xo-expression2/include/xo/expression2/detail/IExpression_DVarRef.hpp @@ -0,0 +1,66 @@ +/** @file IExpression_DVarRef.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IExpression_DVarRef.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IExpression_DVarRef.json5] + **/ + +#pragma once + +#include "Expression.hpp" +#include "Expression.hpp" +#include "DVarRef.hpp" + +namespace xo { namespace scm { class IExpression_DVarRef; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::scm::IExpression_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IExpression_DVarRef + **/ + class IExpression_DVarRef { + public: + /** @defgroup scm-expression-dvarref-type-traits **/ + ///@{ + using TypeDescr = xo::scm::AExpression::TypeDescr; + using Copaque = xo::scm::AExpression::Copaque; + using Opaque = xo::scm::AExpression::Opaque; + ///@} + /** @defgroup scm-expression-dvarref-methods **/ + ///@{ + // const methods + /** expression type (constant | apply | ..) **/ + static exprtype extype(const DVarRef & self) noexcept; + /** placeholder for type giving possible values for this expression **/ + static TypeRef typeref(const DVarRef & self) noexcept; + /** type giving possible values for this expression. Maybe null before typecheck **/ + static TypeDescr valuetype(const DVarRef & self) noexcept; + + // non-const methods + /** assing to valuetype member. Useful when scaffolding expressions **/ + static void assign_valuetype(DVarRef & self, TypeDescr td) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/xo-expression2/include/xo/expression2/detail/IExpression_Xfer.hpp b/xo-expression2/include/xo/expression2/detail/IExpression_Xfer.hpp new file mode 100644 index 00000000..c1e78815 --- /dev/null +++ b/xo-expression2/include/xo/expression2/detail/IExpression_Xfer.hpp @@ -0,0 +1,103 @@ +/** @file IExpression_Xfer.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/Expression.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/Expression.json5] + * + * variables: + * {facet_hpp_fname} -> Expression.hpp + * {impl_hpp_subdir} -> detail + * {facet_ns1} -> xo + * {facet_detail_subdir} -> detail + * {abstract_facet_fname} -> AExpression.hpp + **/ + +#pragma once + +#include "AExpression.hpp" +#include "TypeRef.hpp" +#include "exprtype.hpp" +#include + +namespace xo { +namespace scm { + /** @class IExpression_Xfer + **/ + template + class IExpression_Xfer : public AExpression { + public: + /** @defgroup scm-expression-xfer-type-traits **/ + ///@{ + /** actual implementation (not generated; often delegates to DRepr) **/ + using Impl = IExpression_DRepr; + /** integer identifying a type **/ + using typeseq = AExpression::typeseq; + using TypeDescr = AExpression::TypeDescr; + ///@} + + /** @defgroup scm-expression-xfer-methods **/ + ///@{ + + static const DRepr & _dcast(Copaque d) { return *(const DRepr *)d; } + static DRepr & _dcast(Opaque d) { return *(DRepr *)d; } + + // from AExpression + + // builtin methods + typeseq _typeseq() const noexcept override { return s_typeseq; } + void _drop(Opaque d) const noexcept override { _dcast(d).~DRepr(); } + + // const methods + exprtype extype(Copaque data) const noexcept override { + return I::extype(_dcast(data)); + } + TypeRef typeref(Copaque data) const noexcept override { + return I::typeref(_dcast(data)); + } + TypeDescr valuetype(Copaque data) const noexcept override { + return I::valuetype(_dcast(data)); + } + + // non-const methods + void assign_valuetype(Opaque data, TypeDescr td) noexcept override { + return I::assign_valuetype(_dcast(data), td); + } + + ///@} + + private: + using I = Impl; + + public: + /** @defgroup scm-expression-xfer-member-vars **/ + ///@{ + + /** typeseq for template parameter DRepr **/ + static typeseq s_typeseq; + /** true iff satisfies facet implementation **/ + static bool _valid; + + ///@} + }; + + template + xo::facet::typeseq + IExpression_Xfer::s_typeseq + = xo::facet::typeseq::id(); + + template + bool + IExpression_Xfer::_valid + = xo::facet::valid_facet_implementation(); + +} /*namespace scm */ +} /*namespace xo*/ + +/* end IExpression_Xfer.hpp */ diff --git a/xo-expression2/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp b/xo-expression2/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp new file mode 100644 index 00000000..9ce7cdda --- /dev/null +++ b/xo-expression2/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp @@ -0,0 +1,69 @@ +/** @file IGCObject_DApplyExpr.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DApplyExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DApplyExpr.json5] + **/ + +#pragma once + +#include "GCObject.hpp" +#include +#include +#include "DApplyExpr.hpp" + +namespace xo { namespace scm { class IGCObject_DApplyExpr; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IGCObject_DApplyExpr + **/ + class IGCObject_DApplyExpr { + public: + /** @defgroup scm-gcobject-dapplyexpr-type-traits **/ + ///@{ + using size_type = xo::mm::AGCObject::size_type; + using AAllocator = xo::mm::AGCObject::AAllocator; + using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; + using Copaque = xo::mm::AGCObject::Copaque; + using Opaque = xo::mm::AGCObject::Opaque; + ///@} + /** @defgroup scm-gcobject-dapplyexpr-methods **/ + ///@{ + // const methods + + // non-const methods + /** move instance using object visitor. +Arguably abusing the word 'visitor' here **/ + static Opaque gco_shallow_move(DApplyExpr & self, obj gc) noexcept; + /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. +Context: provides address of data pointer so it can be updated in place +when @p fn invokes garbage collector reentry point **/ + static void visit_gco_children(DApplyExpr & self, VisitReason reason, obj fn) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/xo-expression2/include/xo/expression2/detail/IGCObject_DConstant.hpp b/xo-expression2/include/xo/expression2/detail/IGCObject_DConstant.hpp new file mode 100644 index 00000000..f5c9de84 --- /dev/null +++ b/xo-expression2/include/xo/expression2/detail/IGCObject_DConstant.hpp @@ -0,0 +1,69 @@ +/** @file IGCObject_DConstant.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DConstant.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DConstant.json5] + **/ + +#pragma once + +#include "GCObject.hpp" +#include +#include +#include "DConstant.hpp" + +namespace xo { namespace scm { class IGCObject_DConstant; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IGCObject_DConstant + **/ + class IGCObject_DConstant { + public: + /** @defgroup scm-gcobject-dconstant-type-traits **/ + ///@{ + using size_type = xo::mm::AGCObject::size_type; + using AAllocator = xo::mm::AGCObject::AAllocator; + using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; + using Copaque = xo::mm::AGCObject::Copaque; + using Opaque = xo::mm::AGCObject::Opaque; + ///@} + /** @defgroup scm-gcobject-dconstant-methods **/ + ///@{ + // const methods + + // non-const methods + /** move instance using object visitor. +Arguably abusing the word 'visitor' here **/ + static Opaque gco_shallow_move(DConstant & self, obj gc) noexcept; + /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. +Context: provides address of data pointer so it can be updated in place +when @p fn invokes garbage collector reentry point **/ + static void visit_gco_children(DConstant & self, VisitReason reason, obj fn) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/xo-expression2/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp b/xo-expression2/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp new file mode 100644 index 00000000..ad5862a2 --- /dev/null +++ b/xo-expression2/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp @@ -0,0 +1,69 @@ +/** @file IGCObject_DIfElseExpr.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DIfElseExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DIfElseExpr.json5] + **/ + +#pragma once + +#include "GCObject.hpp" +#include +#include +#include "DIfElseExpr.hpp" + +namespace xo { namespace scm { class IGCObject_DIfElseExpr; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IGCObject_DIfElseExpr + **/ + class IGCObject_DIfElseExpr { + public: + /** @defgroup scm-gcobject-difelseexpr-type-traits **/ + ///@{ + using size_type = xo::mm::AGCObject::size_type; + using AAllocator = xo::mm::AGCObject::AAllocator; + using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; + using Copaque = xo::mm::AGCObject::Copaque; + using Opaque = xo::mm::AGCObject::Opaque; + ///@} + /** @defgroup scm-gcobject-difelseexpr-methods **/ + ///@{ + // const methods + + // non-const methods + /** move instance using object visitor. +Arguably abusing the word 'visitor' here **/ + static Opaque gco_shallow_move(DIfElseExpr & self, obj gc) noexcept; + /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. +Context: provides address of data pointer so it can be updated in place +when @p fn invokes garbage collector reentry point **/ + static void visit_gco_children(DIfElseExpr & self, VisitReason reason, obj fn) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/xo-expression2/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp b/xo-expression2/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp new file mode 100644 index 00000000..71b37d58 --- /dev/null +++ b/xo-expression2/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp @@ -0,0 +1,69 @@ +/** @file IGCObject_DLambdaExpr.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DLambdaExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DLambdaExpr.json5] + **/ + +#pragma once + +#include "GCObject.hpp" +#include +#include +#include "DLambdaExpr.hpp" + +namespace xo { namespace scm { class IGCObject_DLambdaExpr; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IGCObject_DLambdaExpr + **/ + class IGCObject_DLambdaExpr { + public: + /** @defgroup scm-gcobject-dlambdaexpr-type-traits **/ + ///@{ + using size_type = xo::mm::AGCObject::size_type; + using AAllocator = xo::mm::AGCObject::AAllocator; + using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; + using Copaque = xo::mm::AGCObject::Copaque; + using Opaque = xo::mm::AGCObject::Opaque; + ///@} + /** @defgroup scm-gcobject-dlambdaexpr-methods **/ + ///@{ + // const methods + + // non-const methods + /** move instance using object visitor. +Arguably abusing the word 'visitor' here **/ + static Opaque gco_shallow_move(DLambdaExpr & self, obj gc) noexcept; + /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. +Context: provides address of data pointer so it can be updated in place +when @p fn invokes garbage collector reentry point **/ + static void visit_gco_children(DLambdaExpr & self, VisitReason reason, obj fn) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/xo-expression2/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp b/xo-expression2/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp new file mode 100644 index 00000000..d11f6341 --- /dev/null +++ b/xo-expression2/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp @@ -0,0 +1,69 @@ +/** @file IGCObject_DSequenceExpr.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DSequenceExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DSequenceExpr.json5] + **/ + +#pragma once + +#include "GCObject.hpp" +#include +#include +#include "DSequenceExpr.hpp" + +namespace xo { namespace scm { class IGCObject_DSequenceExpr; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IGCObject_DSequenceExpr + **/ + class IGCObject_DSequenceExpr { + public: + /** @defgroup scm-gcobject-dsequenceexpr-type-traits **/ + ///@{ + using size_type = xo::mm::AGCObject::size_type; + using AAllocator = xo::mm::AGCObject::AAllocator; + using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; + using Copaque = xo::mm::AGCObject::Copaque; + using Opaque = xo::mm::AGCObject::Opaque; + ///@} + /** @defgroup scm-gcobject-dsequenceexpr-methods **/ + ///@{ + // const methods + + // non-const methods + /** move instance using object visitor. +Arguably abusing the word 'visitor' here **/ + static Opaque gco_shallow_move(DSequenceExpr & self, obj gc) noexcept; + /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. +Context: provides address of data pointer so it can be updated in place +when @p fn invokes garbage collector reentry point **/ + static void visit_gco_children(DSequenceExpr & self, VisitReason reason, obj fn) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/xo-expression2/include/xo/expression2/detail/IGCObject_DVarRef.hpp b/xo-expression2/include/xo/expression2/detail/IGCObject_DVarRef.hpp new file mode 100644 index 00000000..9b3172d8 --- /dev/null +++ b/xo-expression2/include/xo/expression2/detail/IGCObject_DVarRef.hpp @@ -0,0 +1,69 @@ +/** @file IGCObject_DVarRef.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DVarRef.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DVarRef.json5] + **/ + +#pragma once + +#include "GCObject.hpp" +#include +#include +#include "DVarRef.hpp" + +namespace xo { namespace scm { class IGCObject_DVarRef; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IGCObject_DVarRef + **/ + class IGCObject_DVarRef { + public: + /** @defgroup scm-gcobject-dvarref-type-traits **/ + ///@{ + using size_type = xo::mm::AGCObject::size_type; + using AAllocator = xo::mm::AGCObject::AAllocator; + using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; + using Copaque = xo::mm::AGCObject::Copaque; + using Opaque = xo::mm::AGCObject::Opaque; + ///@} + /** @defgroup scm-gcobject-dvarref-methods **/ + ///@{ + // const methods + + // non-const methods + /** move instance using object visitor. +Arguably abusing the word 'visitor' here **/ + static Opaque gco_shallow_move(DVarRef & self, obj gc) noexcept; + /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. +Context: provides address of data pointer so it can be updated in place +when @p fn invokes garbage collector reentry point **/ + static void visit_gco_children(DVarRef & self, VisitReason reason, obj fn) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/xo-expression2/include/xo/expression2/detail/IPrintable_DApplyExpr.hpp b/xo-expression2/include/xo/expression2/detail/IPrintable_DApplyExpr.hpp new file mode 100644 index 00000000..930846ce --- /dev/null +++ b/xo-expression2/include/xo/expression2/detail/IPrintable_DApplyExpr.hpp @@ -0,0 +1,62 @@ +/** @file IPrintable_DApplyExpr.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DApplyExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DApplyExpr.json5] + **/ + +#pragma once + +#include "Printable.hpp" +#include +#include +#include "DApplyExpr.hpp" + +namespace xo { namespace scm { class IPrintable_DApplyExpr; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IPrintable_DApplyExpr + **/ + class IPrintable_DApplyExpr { + public: + /** @defgroup scm-printable-dapplyexpr-type-traits **/ + ///@{ + using ppindentinfo = xo::print::APrintable::ppindentinfo; + using Copaque = xo::print::APrintable::Copaque; + using Opaque = xo::print::APrintable::Opaque; + ///@} + /** @defgroup scm-printable-dapplyexpr-methods **/ + ///@{ + // const methods + /** Pretty-printing support for this object. +See [xo-indentlog/xo/indentlog/pretty.hpp] **/ + static bool pretty(const DApplyExpr & 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/detail/IPrintable_DConstant.hpp b/xo-expression2/include/xo/expression2/detail/IPrintable_DConstant.hpp new file mode 100644 index 00000000..dc907b89 --- /dev/null +++ b/xo-expression2/include/xo/expression2/detail/IPrintable_DConstant.hpp @@ -0,0 +1,62 @@ +/** @file IPrintable_DConstant.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DConstant.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DConstant.json5] + **/ + +#pragma once + +#include "Printable.hpp" +#include +#include +#include "DConstant.hpp" + +namespace xo { namespace scm { class IPrintable_DConstant; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IPrintable_DConstant + **/ + class IPrintable_DConstant { + public: + /** @defgroup scm-printable-dconstant-type-traits **/ + ///@{ + using ppindentinfo = xo::print::APrintable::ppindentinfo; + using Copaque = xo::print::APrintable::Copaque; + using Opaque = xo::print::APrintable::Opaque; + ///@} + /** @defgroup scm-printable-dconstant-methods **/ + ///@{ + // const methods + /** Pretty-printing support for this object. +See [xo-indentlog/xo/indentlog/pretty.hpp] **/ + static bool pretty(const DConstant & 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/detail/IPrintable_DDefineExpr.hpp b/xo-expression2/include/xo/expression2/detail/IPrintable_DDefineExpr.hpp new file mode 100644 index 00000000..f399c743 --- /dev/null +++ b/xo-expression2/include/xo/expression2/detail/IPrintable_DDefineExpr.hpp @@ -0,0 +1,62 @@ +/** @file IPrintable_DDefineExpr.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DDefineExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DDefineExpr.json5] + **/ + +#pragma once + +#include "Printable.hpp" +#include +#include +#include "DDefineExpr.hpp" + +namespace xo { namespace scm { class IPrintable_DDefineExpr; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IPrintable_DDefineExpr + **/ + class IPrintable_DDefineExpr { + public: + /** @defgroup scm-printable-ddefineexpr-type-traits **/ + ///@{ + using ppindentinfo = xo::print::APrintable::ppindentinfo; + using Copaque = xo::print::APrintable::Copaque; + using Opaque = xo::print::APrintable::Opaque; + ///@} + /** @defgroup scm-printable-ddefineexpr-methods **/ + ///@{ + // const methods + /** Pretty-printing support for this object. +See [xo-indentlog/xo/indentlog/pretty.hpp] **/ + static bool pretty(const DDefineExpr & 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/detail/IPrintable_DIfElseExpr.hpp b/xo-expression2/include/xo/expression2/detail/IPrintable_DIfElseExpr.hpp new file mode 100644 index 00000000..f4045504 --- /dev/null +++ b/xo-expression2/include/xo/expression2/detail/IPrintable_DIfElseExpr.hpp @@ -0,0 +1,62 @@ +/** @file IPrintable_DIfElseExpr.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DIfElseExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DIfElseExpr.json5] + **/ + +#pragma once + +#include "Printable.hpp" +#include +#include +#include "DIfElseExpr.hpp" + +namespace xo { namespace scm { class IPrintable_DIfElseExpr; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IPrintable_DIfElseExpr + **/ + class IPrintable_DIfElseExpr { + public: + /** @defgroup scm-printable-difelseexpr-type-traits **/ + ///@{ + using ppindentinfo = xo::print::APrintable::ppindentinfo; + using Copaque = xo::print::APrintable::Copaque; + using Opaque = xo::print::APrintable::Opaque; + ///@} + /** @defgroup scm-printable-difelseexpr-methods **/ + ///@{ + // const methods + /** Pretty-printing support for this object. +See [xo-indentlog/xo/indentlog/pretty.hpp] **/ + static bool pretty(const DIfElseExpr & 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/detail/IPrintable_DLambdaExpr.hpp b/xo-expression2/include/xo/expression2/detail/IPrintable_DLambdaExpr.hpp new file mode 100644 index 00000000..c14cfefe --- /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: + * [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/detail/IPrintable_DSequenceExpr.hpp b/xo-expression2/include/xo/expression2/detail/IPrintable_DSequenceExpr.hpp new file mode 100644 index 00000000..a27ba9a4 --- /dev/null +++ b/xo-expression2/include/xo/expression2/detail/IPrintable_DSequenceExpr.hpp @@ -0,0 +1,62 @@ +/** @file IPrintable_DSequenceExpr.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DSequenceExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DSequenceExpr.json5] + **/ + +#pragma once + +#include "Printable.hpp" +#include +#include +#include "DSequenceExpr.hpp" + +namespace xo { namespace scm { class IPrintable_DSequenceExpr; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IPrintable_DSequenceExpr + **/ + class IPrintable_DSequenceExpr { + public: + /** @defgroup scm-printable-dsequenceexpr-type-traits **/ + ///@{ + using ppindentinfo = xo::print::APrintable::ppindentinfo; + using Copaque = xo::print::APrintable::Copaque; + using Opaque = xo::print::APrintable::Opaque; + ///@} + /** @defgroup scm-printable-dsequenceexpr-methods **/ + ///@{ + // const methods + /** Pretty-printing support for this object. +See [xo-indentlog/xo/indentlog/pretty.hpp] **/ + static bool pretty(const DSequenceExpr & 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/detail/IPrintable_DVarRef.hpp b/xo-expression2/include/xo/expression2/detail/IPrintable_DVarRef.hpp new file mode 100644 index 00000000..50034312 --- /dev/null +++ b/xo-expression2/include/xo/expression2/detail/IPrintable_DVarRef.hpp @@ -0,0 +1,62 @@ +/** @file IPrintable_DVarRef.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DVarRef.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DVarRef.json5] + **/ + +#pragma once + +#include "Printable.hpp" +#include +#include +#include "DVarRef.hpp" + +namespace xo { namespace scm { class IPrintable_DVarRef; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IPrintable_DVarRef + **/ + class IPrintable_DVarRef { + public: + /** @defgroup scm-printable-dvarref-type-traits **/ + ///@{ + using ppindentinfo = xo::print::APrintable::ppindentinfo; + using Copaque = xo::print::APrintable::Copaque; + using Opaque = xo::print::APrintable::Opaque; + ///@} + /** @defgroup scm-printable-dvarref-methods **/ + ///@{ + // const methods + /** Pretty-printing support for this object. +See [xo-indentlog/xo/indentlog/pretty.hpp] **/ + static bool pretty(const DVarRef & 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/detail/RExpression.hpp b/xo-expression2/include/xo/expression2/detail/RExpression.hpp new file mode 100644 index 00000000..89a8990f --- /dev/null +++ b/xo-expression2/include/xo/expression2/detail/RExpression.hpp @@ -0,0 +1,94 @@ +/** @file RExpression.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/Expression.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/Expression.json5] + **/ + +#pragma once + +#include "AExpression.hpp" + +namespace xo { +namespace scm { + +/** @class RExpression + **/ +template +class RExpression : public Object { +private: + using O = Object; + +public: + /** @defgroup scm-expression-router-type-traits **/ + ///@{ + using ObjectType = Object; + using DataPtr = Object::DataPtr; + using typeseq = xo::reflect::typeseq; + using TypeDescr = AExpression::TypeDescr; + ///@} + + /** @defgroup scm-expression-router-ctors **/ + ///@{ + RExpression() {} + RExpression(Object::DataPtr data) : Object{std::move(data)} {} + RExpression(const AExpression * iface, void * data) + requires std::is_same_v + : Object(iface, data) {} + + ///@} + /** @defgroup scm-expression-router-methods **/ + ///@{ + + // explicit injected content + + // builtin methods + typeseq _typeseq() const noexcept { return O::iface()->_typeseq(); } + void _drop() const noexcept { O::iface()->_drop(O::data()); } + + // const methods + exprtype extype() const noexcept { + return O::iface()->extype(O::data()); + } + TypeRef typeref() const noexcept { + return O::iface()->typeref(O::data()); + } + TypeDescr valuetype() const noexcept { + return O::iface()->valuetype(O::data()); + } + + // non-const methods (still const in router!) + void assign_valuetype(TypeDescr td) noexcept { + return O::iface()->assign_valuetype(O::data(), td); + } + + ///@} + /** @defgroup scm-expression-member-vars **/ + ///@{ + + static bool _valid; + + ///@} +}; + +template +bool +RExpression::_valid = xo::facet::valid_object_router(); + +} /*namespace scm*/ +} /*namespace xo*/ + +namespace xo { namespace facet { + template + struct RoutingFor { + using RoutingType = xo::scm::RExpression; + }; +} } + +/* end RExpression.hpp */ diff --git a/xo-expression2/include/xo/expression2/expression2_register_types.hpp b/xo-expression2/include/xo/expression2/expression2_register_types.hpp new file mode 100644 index 00000000..c19c3863 --- /dev/null +++ b/xo-expression2/include/xo/expression2/expression2_register_types.hpp @@ -0,0 +1,15 @@ +/** @file expression2_register_types.hpp + * + * @author Roland Conybeare, Dec 2025 + **/ + +#pragma once + +#include + +namespace xo { + namespace scm { + } +} + +/* end expression2_register_types.hpp */ diff --git a/xo-expression2/include/xo/expression2/exprtype.hpp b/xo-expression2/include/xo/expression2/exprtype.hpp new file mode 100644 index 00000000..8b1778fb --- /dev/null +++ b/xo-expression2/include/xo/expression2/exprtype.hpp @@ -0,0 +1,98 @@ +/** @file exprtype.hpp + * + * Author: Roland Conybeare + **/ + +#pragma once + +#include +//#include + +namespace xo { + namespace scm { + /** @enum exprtype + * @brief enum to identify subclasses of xo::scm::Expression. + * + **/ + enum class exprtype { + /** sentinel value **/ + invalid = -1, + + /** literal constant. must satisfy both standard_layout_type + trivial **/ + constant, +#ifdef NOT_YET + /** a literal constant that refers to a linkable named function **/ + primitive, +#endif + /** variable/function definition **/ + define, +#ifdef NOT_YET + /** variable assignment **/ + assign, +#endif + /** function call **/ + apply, + + /** function definition **/ + lambda, + + /** variable definition **/ + variable, + /** variabele reference (possibly non-local) **/ + varref, + /** if-then-else **/ + ifexpr, + /** sequence **/ + sequence, +#ifdef NOT_YET + ) /** type conversion **/ + convert, +#endif + + /** not an expression. comes last, counts entries **/ + N + }; + + inline const char * + expr2str(exprtype x) + { + switch(x) { + case exprtype::invalid: return "?exprtype"; + case exprtype::constant: return "constant"; +#ifdef NOT_YET + case exprtype::primitive: return "primitive"; +#endif + case exprtype::define: return "define"; +#ifdef NOT_YET + case exprtype::assign: return "assign"; +#endif + case exprtype::apply: return "apply"; + case exprtype::lambda: return "lambda"; + case exprtype::variable: return "variable"; + case exprtype::varref: return "varref"; + case exprtype::ifexpr: return "if_expr"; + case exprtype::sequence: return "sequence"; +#ifdef NOT_YET + case exprtype::convert: return "convert"; +#endif + case exprtype::N: break; + //default: break; + } + + return "???exprtype???"; + } + + /** @brief number of built-in expression types, repr convenient for array sizing **/ + static constexpr std::size_t n_exprtype = static_cast(exprtype::N); + + inline std::ostream & + operator<<(std::ostream & os, + exprtype x) + { + os << expr2str(x); + return os; + } + } /*namespace scm*/ +} /*namespace xo*/ + +/* end exprtype.hpp */ diff --git a/xo-expression2/include/xo/expression2/init_expression2.hpp b/xo-expression2/include/xo/expression2/init_expression2.hpp new file mode 100644 index 00000000..c5e290a8 --- /dev/null +++ b/xo-expression2/include/xo/expression2/init_expression2.hpp @@ -0,0 +1,21 @@ +/** @file init_expression2.hpp +* + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include + +namespace xo { + /* tag to represent the xo-expression2/ subsystem within ordered initialization */ + enum S_expression2_tag {}; + + template <> + struct InitSubsys { + static void init(); + static InitEvidence require(); + }; +} /*namespace xo*/ + +/* end init_expression2.hpp */ diff --git a/xo-expression2/include/xo/expression2/symtab/ASymbolTable.hpp b/xo-expression2/include/xo/expression2/symtab/ASymbolTable.hpp new file mode 100644 index 00000000..40349861 --- /dev/null +++ b/xo-expression2/include/xo/expression2/symtab/ASymbolTable.hpp @@ -0,0 +1,82 @@ +/** @file ASymbolTable.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/SymbolTable.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [abstract_facet.hpp.j2] + * 3. idl for facet methods + * [idl/SymbolTable.json5] + **/ + +#pragma once + +// includes (via {facet_includes}) +#include "Binding.hpp" +#include "DUniqueString.hpp" +#include +#include +#include + +// {pretext} here + +namespace xo { +namespace scm { + +using Copaque = const void *; +using Opaque = void *; + +/** +Map symbols to schematika expressions. Output of schematika parser +**/ +class ASymbolTable { +public: + /** @defgroup scm-symboltable-type-traits **/ + ///@{ + // types + /** integer identifying a type **/ + using typeseq = xo::facet::typeseq; + using Copaque = const void *; + using Opaque = void *; + ///@} + + /** @defgroup scm-symboltable-methods **/ + ///@{ + // const methods + /** An uninitialized ASymbolTable instance will have zero vtable pointer (per {linux,osx} abi). + * Use case for this is narrow. We go to some lengths to avoid null vtable pointers. For example + * obj will have non-null vtable (via IFacet_Any) with all methods terminating. + **/ + bool _has_null_vptr() const noexcept { return *reinterpret_cast(this) == nullptr; } + /** RTTI: unique id# for actual runtime data representation **/ + virtual typeseq _typeseq() const noexcept = 0; + /** destroy instance @p d; calls c++ dtor only for actual runtime type; does not recover memory **/ + virtual void _drop(Opaque d) const noexcept = 0; + /** true iff this is toplevel (global) symbol table. **/ + virtual bool is_global_symtab(Copaque data) const noexcept = 0; + /** report ingredients needed to address variable at runtime. **/ + virtual Binding lookup_binding(Copaque data, const DUniqueString * sym) const noexcept = 0; + + // nonconst methods + ///@} +}; /*ASymbolTable*/ + +/** Implementation ISymbolTable_DRepr of ASymbolTable for state DRepr + * should provide a specialization: + * + * template <> + * struct xo::facet::FacetImplementation { + * using Impltype = ISymbolTable_DRepr; + * }; + * + * then ISymbolTable_ImplType --> ISymbolTable_DRepr + **/ +template +using ISymbolTable_ImplType = xo::facet::FacetImplType; + +} /*namespace scm*/ +} /*namespace xo*/ + +/* ASymbolTable.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..0731ab56 --- /dev/null +++ b/xo-expression2/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp @@ -0,0 +1,69 @@ +/** @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 AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; + using Copaque = xo::mm::AGCObject::Copaque; + using Opaque = xo::mm::AGCObject::Opaque; + ///@} + /** @defgroup scm-gcobject-dglobalsymtab-methods **/ + ///@{ + // const methods + + // non-const methods + /** move instance using object visitor. +Arguably abusing the word 'visitor' here **/ + static Opaque gco_shallow_move(DGlobalSymtab & self, obj gc) noexcept; + /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. +Context: provides address of data pointer so it can be updated in place +when @p fn invokes garbage collector reentry point **/ + static void visit_gco_children(DGlobalSymtab & self, VisitReason reason, obj fn) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/xo-expression2/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp b/xo-expression2/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp new file mode 100644 index 00000000..92226d63 --- /dev/null +++ b/xo-expression2/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp @@ -0,0 +1,69 @@ +/** @file IGCObject_DLocalSymtab.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DLocalSymtab.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DLocalSymtab.json5] + **/ + +#pragma once + +#include "GCObject.hpp" +#include +#include +#include "DLocalSymtab.hpp" + +namespace xo { namespace scm { class IGCObject_DLocalSymtab; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IGCObject_DLocalSymtab + **/ + class IGCObject_DLocalSymtab { + public: + /** @defgroup scm-gcobject-dlocalsymtab-type-traits **/ + ///@{ + using size_type = xo::mm::AGCObject::size_type; + using AAllocator = xo::mm::AGCObject::AAllocator; + using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; + using Copaque = xo::mm::AGCObject::Copaque; + using Opaque = xo::mm::AGCObject::Opaque; + ///@} + /** @defgroup scm-gcobject-dlocalsymtab-methods **/ + ///@{ + // const methods + + // non-const methods + /** move instance using object visitor. +Arguably abusing the word 'visitor' here **/ + static Opaque gco_shallow_move(DLocalSymtab & self, obj gc) noexcept; + /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. +Context: provides address of data pointer so it can be updated in place +when @p fn invokes garbage collector reentry point **/ + static void visit_gco_children(DLocalSymtab & self, VisitReason reason, obj fn) 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/IPrintable_DLocalSymtab.hpp b/xo-expression2/include/xo/expression2/symtab/IPrintable_DLocalSymtab.hpp new file mode 100644 index 00000000..729534c0 --- /dev/null +++ b/xo-expression2/include/xo/expression2/symtab/IPrintable_DLocalSymtab.hpp @@ -0,0 +1,62 @@ +/** @file IPrintable_DLocalSymtab.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [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 +#include +#include "DLocalSymtab.hpp" + +namespace xo { namespace scm { class IPrintable_DLocalSymtab; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +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 */ \ No newline at end of file diff --git a/xo-expression2/include/xo/expression2/symtab/ISymbolTable_Any.hpp b/xo-expression2/include/xo/expression2/symtab/ISymbolTable_Any.hpp new file mode 100644 index 00000000..2d873ea1 --- /dev/null +++ b/xo-expression2/include/xo/expression2/symtab/ISymbolTable_Any.hpp @@ -0,0 +1,89 @@ +/** @file ISymbolTable_Any.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/SymbolTable.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/SymbolTable.json5] + **/ + +#pragma once + +#include "ASymbolTable.hpp" +#include + +namespace xo { namespace scm { class ISymbolTable_Any; } } + +namespace xo { +namespace facet { + +template <> +struct FacetImplementation +{ + using ImplType = xo::scm::ISymbolTable_Any; +}; + +} +} + +namespace xo { +namespace scm { + + /** @class ISymbolTable_Any + * @brief ASymbolTable implementation for empty variant instance + **/ + class ISymbolTable_Any : public ASymbolTable { + public: + /** @defgroup scm-symboltable-any-type-traits **/ + ///@{ + + /** integer identifying a type **/ + using typeseq = xo::facet::typeseq; + + ///@} + /** @defgroup scm-symboltable-any-methods **/ + ///@{ + + const ASymbolTable * iface() const { return std::launder(this); } + + // from ASymbolTable + + // builtin methods + typeseq _typeseq() const noexcept override { return s_typeseq; } + [[noreturn]] void _drop(Opaque) const noexcept override { _fatal(); } + + // const methods + [[noreturn]] bool is_global_symtab(Copaque) const noexcept override { _fatal(); } + [[noreturn]] Binding lookup_binding(Copaque, const DUniqueString *) const noexcept override { _fatal(); } + + // nonconst methods + + ///@} + + private: + /** @defgraoup scm-symboltable-any-private-methods **/ + ///@{ + + [[noreturn]] static void _fatal(); + + ///@} + + public: + /** @defgroup scm-symboltable-any-member-vars **/ + ///@{ + + static typeseq s_typeseq; + static bool _valid; + + ///@} + }; + +} /*namespace scm */ +} /*namespace xo */ + +/* ISymbolTable_Any.hpp */ 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/include/xo/expression2/symtab/ISymbolTable_DLocalSymtab.hpp b/xo-expression2/include/xo/expression2/symtab/ISymbolTable_DLocalSymtab.hpp new file mode 100644 index 00000000..9c9a2f0d --- /dev/null +++ b/xo-expression2/include/xo/expression2/symtab/ISymbolTable_DLocalSymtab.hpp @@ -0,0 +1,60 @@ +/** @file ISymbolTable_DLocalSymtab.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [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 + { + using ImplType = xo::scm::ISymbolTable_Xfer + ; + }; + } +} + +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 */ \ No newline at end of file diff --git a/xo-expression2/include/xo/expression2/symtab/ISymbolTable_Xfer.hpp b/xo-expression2/include/xo/expression2/symtab/ISymbolTable_Xfer.hpp new file mode 100644 index 00000000..03b32ada --- /dev/null +++ b/xo-expression2/include/xo/expression2/symtab/ISymbolTable_Xfer.hpp @@ -0,0 +1,95 @@ +/** @file ISymbolTable_Xfer.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/SymbolTable.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/SymbolTable.json5] + * + * variables: + * {facet_hpp_fname} -> SymbolTable.hpp + * {impl_hpp_subdir} -> symtab + * {facet_ns1} -> xo + * {facet_detail_subdir} -> symtab + * {abstract_facet_fname} -> ASymbolTable.hpp + **/ + +#pragma once + +#include "ASymbolTable.hpp" +#include "Binding.hpp" +#include "DUniqueString.hpp" + +namespace xo { +namespace scm { + /** @class ISymbolTable_Xfer + **/ + template + class ISymbolTable_Xfer : public ASymbolTable { + public: + /** @defgroup scm-symboltable-xfer-type-traits **/ + ///@{ + /** actual implementation (not generated; often delegates to DRepr) **/ + using Impl = ISymbolTable_DRepr; + /** integer identifying a type **/ + using typeseq = ASymbolTable::typeseq; + ///@} + + /** @defgroup scm-symboltable-xfer-methods **/ + ///@{ + + static const DRepr & _dcast(Copaque d) { return *(const DRepr *)d; } + static DRepr & _dcast(Opaque d) { return *(DRepr *)d; } + + // from ASymbolTable + + // builtin methods + typeseq _typeseq() const noexcept override { return s_typeseq; } + void _drop(Opaque d) const noexcept override { _dcast(d).~DRepr(); } + + // const methods + bool is_global_symtab(Copaque data) const noexcept override { + return I::is_global_symtab(_dcast(data)); + } + Binding lookup_binding(Copaque data, const DUniqueString * sym) const noexcept override { + return I::lookup_binding(_dcast(data), sym); + } + + // non-const methods + + ///@} + + private: + using I = Impl; + + public: + /** @defgroup scm-symboltable-xfer-member-vars **/ + ///@{ + + /** typeseq for template parameter DRepr **/ + static typeseq s_typeseq; + /** true iff satisfies facet implementation **/ + static bool _valid; + + ///@} + }; + + template + xo::facet::typeseq + ISymbolTable_Xfer::s_typeseq + = xo::facet::typeseq::id(); + + template + bool + ISymbolTable_Xfer::_valid + = xo::facet::valid_facet_implementation(); + +} /*namespace scm */ +} /*namespace xo*/ + +/* end ISymbolTable_Xfer.hpp */ diff --git a/xo-expression2/include/xo/expression2/symtab/RSymbolTable.hpp b/xo-expression2/include/xo/expression2/symtab/RSymbolTable.hpp new file mode 100644 index 00000000..31405e89 --- /dev/null +++ b/xo-expression2/include/xo/expression2/symtab/RSymbolTable.hpp @@ -0,0 +1,87 @@ +/** @file RSymbolTable.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/SymbolTable.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/SymbolTable.json5] + **/ + +#pragma once + +#include "ASymbolTable.hpp" + +namespace xo { +namespace scm { + +/** @class RSymbolTable + **/ +template +class RSymbolTable : public Object { +private: + using O = Object; + +public: + /** @defgroup scm-symboltable-router-type-traits **/ + ///@{ + using ObjectType = Object; + using DataPtr = Object::DataPtr; + using typeseq = xo::reflect::typeseq; + ///@} + + /** @defgroup scm-symboltable-router-ctors **/ + ///@{ + RSymbolTable() {} + RSymbolTable(Object::DataPtr data) : Object{std::move(data)} {} + RSymbolTable(const ASymbolTable * iface, void * data) + requires std::is_same_v + : Object(iface, data) {} + + ///@} + /** @defgroup scm-symboltable-router-methods **/ + ///@{ + + // explicit injected content + + // builtin methods + typeseq _typeseq() const noexcept { return O::iface()->_typeseq(); } + void _drop() const noexcept { O::iface()->_drop(O::data()); } + + // const methods + bool is_global_symtab() const noexcept { + return O::iface()->is_global_symtab(O::data()); + } + Binding lookup_binding(const DUniqueString * sym) const noexcept { + return O::iface()->lookup_binding(O::data(), sym); + } + + // non-const methods (still const in router!) + + ///@} + /** @defgroup scm-symboltable-member-vars **/ + ///@{ + + static bool _valid; + + ///@} +}; + +template +bool +RSymbolTable::_valid = xo::facet::valid_object_router(); + +} /*namespace scm*/ +} /*namespace xo*/ + +namespace xo { namespace facet { + template + struct RoutingFor { + using RoutingType = xo::scm::RSymbolTable; + }; +} } + +/* end RSymbolTable.hpp */ diff --git a/xo-expression2/include/xo/expression2/typename/IGCObject_DTypename.hpp b/xo-expression2/include/xo/expression2/typename/IGCObject_DTypename.hpp new file mode 100644 index 00000000..14c0f336 --- /dev/null +++ b/xo-expression2/include/xo/expression2/typename/IGCObject_DTypename.hpp @@ -0,0 +1,67 @@ +/** @file IGCObject_DTypename.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DTypename.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DTypename.json5] + **/ + +#pragma once + +#include "GCObject.hpp" +#include "DTypename.hpp" + +namespace xo { namespace scm { class IGCObject_DTypename; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IGCObject_DTypename + **/ + class IGCObject_DTypename { + public: + /** @defgroup scm-gcobject-dtypename-type-traits **/ + ///@{ + using size_type = xo::mm::AGCObject::size_type; + using AAllocator = xo::mm::AGCObject::AAllocator; + using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; + using Copaque = xo::mm::AGCObject::Copaque; + using Opaque = xo::mm::AGCObject::Opaque; + ///@} + /** @defgroup scm-gcobject-dtypename-methods **/ + ///@{ + // const methods + + // non-const methods + /** move instance using object visitor. +Arguably abusing the word 'visitor' here **/ + static Opaque gco_shallow_move(DTypename & self, obj gc) noexcept; + /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. +Context: provides address of data pointer so it can be updated in place +when @p fn invokes garbage collector reentry point **/ + static void visit_gco_children(DTypename & self, VisitReason reason, obj fn) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/xo-expression2/include/xo/expression2/typename/IPrintable_DTypename.hpp b/xo-expression2/include/xo/expression2/typename/IPrintable_DTypename.hpp new file mode 100644 index 00000000..88504191 --- /dev/null +++ b/xo-expression2/include/xo/expression2/typename/IPrintable_DTypename.hpp @@ -0,0 +1,62 @@ +/** @file IPrintable_DTypename.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DTypename.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DTypename.json5] + **/ + +#pragma once + +#include "Printable.hpp" +#include +#include +#include "DTypename.hpp" + +namespace xo { namespace scm { class IPrintable_DTypename; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IPrintable_DTypename + **/ + class IPrintable_DTypename { + public: + /** @defgroup scm-printable-dtypename-type-traits **/ + ///@{ + using ppindentinfo = xo::print::APrintable::ppindentinfo; + using Copaque = xo::print::APrintable::Copaque; + using Opaque = xo::print::APrintable::Opaque; + ///@} + /** @defgroup scm-printable-dtypename-methods **/ + ///@{ + // const methods + /** Pretty-printing support for this object. +See [xo-indentlog/xo/indentlog/pretty.hpp] **/ + static bool pretty(const DTypename & 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/variable/IExpression_DVariable.hpp b/xo-expression2/include/xo/expression2/variable/IExpression_DVariable.hpp new file mode 100644 index 00000000..cacd4be2 --- /dev/null +++ b/xo-expression2/include/xo/expression2/variable/IExpression_DVariable.hpp @@ -0,0 +1,66 @@ +/** @file IExpression_DVariable.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IExpression_DVariable.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IExpression_DVariable.json5] + **/ + +#pragma once + +#include "Expression.hpp" +#include "Expression.hpp" +#include "DVariable.hpp" + +namespace xo { namespace scm { class IExpression_DVariable; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::scm::IExpression_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IExpression_DVariable + **/ + class IExpression_DVariable { + public: + /** @defgroup scm-expression-dvariable-type-traits **/ + ///@{ + using TypeDescr = xo::scm::AExpression::TypeDescr; + using Copaque = xo::scm::AExpression::Copaque; + using Opaque = xo::scm::AExpression::Opaque; + ///@} + /** @defgroup scm-expression-dvariable-methods **/ + ///@{ + // const methods + /** expression type (constant | apply | ..) **/ + static exprtype extype(const DVariable & self) noexcept; + /** placeholder for type giving possible values for this expression **/ + static TypeRef typeref(const DVariable & self) noexcept; + /** type giving possible values for this expression. Maybe null before typecheck **/ + static TypeDescr valuetype(const DVariable & self) noexcept; + + // non-const methods + /** assing to valuetype member. Useful when scaffolding expressions **/ + static void assign_valuetype(DVariable & self, TypeDescr td) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/xo-expression2/include/xo/expression2/variable/IGCObject_DVariable.hpp b/xo-expression2/include/xo/expression2/variable/IGCObject_DVariable.hpp new file mode 100644 index 00000000..fbb60525 --- /dev/null +++ b/xo-expression2/include/xo/expression2/variable/IGCObject_DVariable.hpp @@ -0,0 +1,69 @@ +/** @file IGCObject_DVariable.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DVariable.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DVariable.json5] + **/ + +#pragma once + +#include "GCObject.hpp" +#include +#include +#include "DVariable.hpp" + +namespace xo { namespace scm { class IGCObject_DVariable; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IGCObject_DVariable + **/ + class IGCObject_DVariable { + public: + /** @defgroup scm-gcobject-dvariable-type-traits **/ + ///@{ + using size_type = xo::mm::AGCObject::size_type; + using AAllocator = xo::mm::AGCObject::AAllocator; + using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; + using Copaque = xo::mm::AGCObject::Copaque; + using Opaque = xo::mm::AGCObject::Opaque; + ///@} + /** @defgroup scm-gcobject-dvariable-methods **/ + ///@{ + // const methods + + // non-const methods + /** move instance using object visitor. +Arguably abusing the word 'visitor' here **/ + static Opaque gco_shallow_move(DVariable & self, obj gc) noexcept; + /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. +Context: provides address of data pointer so it can be updated in place +when @p fn invokes garbage collector reentry point **/ + static void visit_gco_children(DVariable & self, VisitReason reason, obj fn) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/xo-expression2/include/xo/expression2/variable/IPrintable_DVariable.hpp b/xo-expression2/include/xo/expression2/variable/IPrintable_DVariable.hpp new file mode 100644 index 00000000..10bbecca --- /dev/null +++ b/xo-expression2/include/xo/expression2/variable/IPrintable_DVariable.hpp @@ -0,0 +1,62 @@ +/** @file IPrintable_DVariable.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DVariable.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DVariable.json5] + **/ + +#pragma once + +#include "Printable.hpp" +#include +#include +#include "DVariable.hpp" + +namespace xo { namespace scm { class IPrintable_DVariable; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IPrintable_DVariable + **/ + class IPrintable_DVariable { + public: + /** @defgroup scm-printable-dvariable-type-traits **/ + ///@{ + using ppindentinfo = xo::print::APrintable::ppindentinfo; + using Copaque = xo::print::APrintable::Copaque; + using Opaque = xo::print::APrintable::Opaque; + ///@} + /** @defgroup scm-printable-dvariable-methods **/ + ///@{ + // const methods + /** Pretty-printing support for this object. +See [xo-indentlog/xo/indentlog/pretty.hpp] **/ + static bool pretty(const DVariable & self, const ppindentinfo & ppii); + + // non-const methods + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/xo-expression2/src/expression2/Binding.cpp b/xo-expression2/src/expression2/Binding.cpp new file mode 100644 index 00000000..94be9b6b --- /dev/null +++ b/xo-expression2/src/expression2/Binding.cpp @@ -0,0 +1,41 @@ +/** @file Binding.cpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#include "Binding.hpp" +#include + +namespace xo { + namespace scm { + + Binding + Binding::relative(int32_t i_link, Binding def) + { + if (def.i_link_ == Binding::c_link_global) { + // for globally defined vars, i_link always -1 + return def; + } else if (def.i_link_ >= 0) { + return Binding(i_link + def.i_link_, def.j_slot_); + } else { + assert(false); + return Binding(); + } + } + + void + Binding::print(std::ostream & os) const + { + if (i_link_ == c_link_global) { + os << "{path:global:" << j_slot_ << "}"; + } else if (i_link_ == c_link_sentinel) { + os << "{path}"; + } else { + os << "{path:" << i_link_ << ":" << j_slot_ << "}"; + } + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end Binding.cpp */ diff --git a/xo-expression2/src/expression2/CMakeLists.txt b/xo-expression2/src/expression2/CMakeLists.txt new file mode 100644 index 00000000..6372ca28 --- /dev/null +++ b/xo-expression2/src/expression2/CMakeLists.txt @@ -0,0 +1,80 @@ +# expression2/CMakeLists.txt + +set(SELF_LIB xo_expression2) +set(SELF_SRCS + init_expression2.cpp + SetupExpression2.cpp + + DConstant.cpp + DVarRef.cpp + DApplyExpr.cpp + + TypeRef.cpp + Binding.cpp + + IExpression_Any.cpp + ISymbolTable_Any.cpp + + IExpression_DConstant.cpp + IGCObject_DConstant.cpp + IPrintable_DConstant.cpp + + DVariable.cpp + facet/IExpression_DVariable.cpp + facet/IGCObject_DVariable.cpp + facet/IPrintable_DVariable.cpp + + IExpression_DVarRef.cpp + IGCObject_DVarRef.cpp + IPrintable_DVarRef.cpp + + DDefineExpr.cpp + IExpression_DDefineExpr.cpp + IGCObject_DDefineExpr.cpp + IPrintable_DDefineExpr.cpp + + IExpression_DApplyExpr.cpp + IGCObject_DApplyExpr.cpp + IPrintable_DApplyExpr.cpp + + DLambdaExpr.cpp + IExpression_DLambdaExpr.cpp + IGCObject_DLambdaExpr.cpp + IPrintable_DLambdaExpr.cpp + + DIfElseExpr.cpp + IExpression_DIfElseExpr.cpp + IGCObject_DIfElseExpr.cpp + IPrintable_DIfElseExpr.cpp + + DSequenceExpr.cpp + IExpression_DSequenceExpr.cpp + IGCObject_DSequenceExpr.cpp + IPrintable_DSequenceExpr.cpp + + DLocalSymtab.cpp + ISymbolTable_DLocalSymtab.cpp + IGCObject_DLocalSymtab.cpp + IPrintable_DLocalSymtab.cpp + + DGlobalSymtab.cpp + ISymbolTable_DGlobalSymtab.cpp + IGCObject_DGlobalSymtab.cpp + IPrintable_DGlobalSymtab.cpp + + DTypename.cpp + IGCObject_DTypename.cpp + IPrintable_DTypename.cpp + + ) + +xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 ${SELF_SRCS}) +# note: deps here must also appear in cmake/xo_expression2Config.cmake.in +xo_dependency(${SELF_LIB} xo_gc) +xo_dependency(${SELF_LIB} xo_type) +xo_dependency(${SELF_LIB} reflect) +xo_dependency(${SELF_LIB} xo_procedure2) +xo_dependency(${SELF_LIB} xo_printable2) +xo_dependency(${SELF_LIB} xo_flatstring) +xo_dependency(${SELF_LIB} subsys) +xo_dependency(${SELF_LIB} indentlog) diff --git a/xo-expression2/src/expression2/DApplyExpr.cpp b/xo-expression2/src/expression2/DApplyExpr.cpp new file mode 100644 index 00000000..0f9a5c5c --- /dev/null +++ b/xo-expression2/src/expression2/DApplyExpr.cpp @@ -0,0 +1,198 @@ +/** @file DApplyExpr.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include "Expression.hpp" +#include "DApplyExpr.hpp" +#include "detail/IExpression_DApplyExpr.hpp" +#include +#include + +namespace xo { + using xo::print::APrintable; + using xo::facet::FacetRegistry; + using xo::reflect::typeseq; + using xo::mm::AGCObject; + + namespace scm { + obj + DApplyExpr::make2(obj mm, + TypeRef typeref, + obj fn_expr, + obj arg1, + obj arg2) + { + return obj + (DApplyExpr::_make2(mm, typeref, fn_expr, arg1, arg2)); + } + + DApplyExpr * + DApplyExpr::_make2(obj mm, + TypeRef typeref, + obj fn_expr, + obj arg1, + obj arg2) + { + DApplyExpr * result + = DApplyExpr::scaffold(mm, typeref, fn_expr, 2 /*n_args*/); + + result->assign_arg(0, arg1); + result->assign_arg(1, arg2); + + return result; + } + + /* incomplete, in the sense that does not populate args_[] */ + DApplyExpr::DApplyExpr(TypeRef typeref, + obj fn_expr, + size_type n_args) : typeref_{typeref}, + fn_{fn_expr}, + n_args_{n_args} + {} + + DApplyExpr * + DApplyExpr::scaffold(obj mm, + TypeRef typeref, + obj fn_expr, + size_type n_args) + { + void * mem = mm.alloc(typeseq::id(), + sizeof(DApplyExpr) + (n_args * sizeof(obj))); + + DApplyExpr * result = new (mem) DApplyExpr(typeref, + fn_expr, + n_args); + + return result; + } + + void + DApplyExpr::assign_arg(size_type i_arg, + obj expr) + { + if (i_arg < n_args_) { + this->args_[i_arg] = expr; + } else { + assert(false); + + throw std::runtime_error(tostr("assign out-of-range argument i_arg where [0..n_args) expected", + xtag("i_arg", i_arg), + xtag("expr", expr), + xtag("n_args", n_args_))); + + } + } + + obj + DApplyExpr::arg(size_type i) const + { + if (i >= n_args_) [[unlikely]] { + throw std::runtime_error(tostr("attempt to fetch argument i where [0..n) expected", + xtag("i", i), + xtag("n", n_args_), + xtag("src", "DApplyExpr::arg"))); + } + + return args_[i]; + } + + void + DApplyExpr::assign_valuetype(TypeDescr td) noexcept { + typeref_.resolve(td); + } + + // ----- gcobject facet ----- + + DApplyExpr * + DApplyExpr::gco_shallow_move(obj gc) noexcept { + // note: not using ACollector.std_copy_for() here, + // flexible array -> not move-constructible + + DApplyExpr * copy = (DApplyExpr *)gc.alloc_copy_for(this); + + if (copy) { + copy->typeref_ = typeref_; + copy->fn_ = fn_; + copy->n_args_ = n_args_; + + constexpr auto c_obj_z = sizeof(obj); + + ::memcpy((void*)&(copy->args_[0]), (void*)&(args_[0]), n_args_ * c_obj_z); + } + + return copy; + } + + void + DApplyExpr::visit_gco_children(VisitReason reason, obj gc) noexcept + { + typeref_.visit_gco_children(reason, gc); + + gc.visit_poly_child(reason, &fn_); + + for (size_type i = 0; i < n_args_; ++i) { + obj & arg = args_[i]; + + gc.visit_poly_child(reason, &arg); + } + } + + // ----- printable facet ----- + + bool + DApplyExpr::pretty(const ppindentinfo & ppii) const { + using xo::print::ppstate; + + ppstate * pps = ppii.pps(); + + if (ppii.upto()) { + /* perhaps print on one line */ + if (!pps->print_upto(" fn + = FacetRegistry::instance().variant(fn_); + if (!pps->print_upto(refrtag("fn", fn))) + return false; + } + + for (size_t i_arg = 0; i_arg < n_args_; ++i_arg) { + obj arg_i + = FacetRegistry::instance().variant(args_[i_arg]); + + if (!pps->print_upto(refrtag(concat("arg", 1+i_arg), arg_i))) + return false; + } + + pps->write(">"); + + return true; + } else { + pps->write(" fn + = FacetRegistry::instance().variant(fn_); + + pps->newline_indent(ppii.ci1()); + pps->pretty(refrtag("fn", fn)); + + for (size_t i_arg = 0; i_arg < n_args_; ++i_arg) { + obj arg_i + = FacetRegistry::instance().variant(args_[i_arg]); + + pps->newline_indent(ppii.ci1()); + pps->pretty(refrtag(concat("arg", 1+i_arg), arg_i)); + } + + pps->write(">"); + + return false; + } + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DApplyExpr.cpp */ diff --git a/xo-expression2/src/expression2/DConstant.cpp b/xo-expression2/src/expression2/DConstant.cpp new file mode 100644 index 00000000..441d24a0 --- /dev/null +++ b/xo-expression2/src/expression2/DConstant.cpp @@ -0,0 +1,105 @@ +/** @file DConstant.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include "Constant.hpp" +//#include "detail/IExpression_DConstant.hpp" +#include "TypeDescr.hpp" +#include +#include +#include +#include +#include +#include +#include + +namespace xo { + using xo::scm::DFloat; + using xo::scm::DInteger; + using xo::print::APrintable; + using xo::facet::FacetRegistry; + using xo::reflect::Reflect; + using xo::reflect::TypeDescr; + using xo::reflect::typeseq; + + namespace scm { + DConstant::DConstant(obj value) noexcept + : + //typeref_{TypeRef::resolved(td)}, + value_{value} + { + // todo: use ObjectConverter here + + auto tseq = value_._typeseq(); + + TypeDescr td = this->_lookup_td(tseq); + + if (td) { + typeref_ = TypeRef::resolved(td); + } + } + + obj + DConstant::make(obj mm, + obj value) + { + return obj(_make(mm, value)); + } + + DConstant * + DConstant::_make(obj mm, + obj value) + { + void * mem = mm.alloc(typeseq::id(), + sizeof(DConstant)); + + return new (mem) DConstant(value); + } + + TypeDescr + DConstant::_lookup_td(typeseq tseq) + { + if (tseq == typeseq::id()) { + /* double */ + return Reflect::require(); + } else if (tseq == typeseq::id()) { + /* long */ + return Reflect::require(); + } + + return nullptr; + } + + DConstant * + DConstant::gco_shallow_move(obj gc) noexcept + { + return gc.std_move_for(this); + } + + void + DConstant::visit_gco_children(VisitReason reason, + obj gc) noexcept + { + typeref_.visit_gco_children(reason, gc); + + gc.visit_child(reason, &value_); + } + + bool + DConstant::pretty(const ppindentinfo & ppii) const + { + obj value_pr + = FacetRegistry::instance().variant(value_); + + return ppii.pps()->pretty_struct + (ppii, + "DConstant", + refrtag("value_.tseq", value_._typeseq()), + refrtag("value.tseq", value_pr._typeseq()), + refrtag("value", value_pr)); + } + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DConstant.cpp */ diff --git a/xo-expression2/src/expression2/DDefineExpr.cpp b/xo-expression2/src/expression2/DDefineExpr.cpp new file mode 100644 index 00000000..7bcf817b --- /dev/null +++ b/xo-expression2/src/expression2/DDefineExpr.cpp @@ -0,0 +1,132 @@ +/** @file DDefineExpr.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include "DDefineExpr.hpp" +#include "Variable.hpp" +#include +#include +#include +#include +#include +#include + +namespace xo { + using xo::mm::poly_forward_inplace; + using xo::print::APrintable; + using xo::facet::FacetRegistry; + using xo::facet::typeseq; + + namespace scm { + + DDefineExpr::DDefineExpr(DVariable * lhs_var, + obj rhs) + : lhs_var_{lhs_var}, rhs_{rhs} + {} + + DDefineExpr * + DDefineExpr::make(obj mm, + const DUniqueString * lhs_name, + obj rhs_expr) + { + void * mem = mm.alloc(typeseq::id(), + sizeof(DDefineExpr)); + + TypeRef rhs_tref; + if (rhs_expr) + rhs_tref = rhs_expr.typeref(); + + auto lhs_var = DVariable::make(mm, + lhs_name, + rhs_tref); + + return new (mem) DDefineExpr(lhs_var, rhs_expr); + } + + DDefineExpr * + DDefineExpr::make_empty(obj mm) + { + return make(mm, + nullptr /*lhs_name*/, + obj() /*rhs_expr*/); + } + + const DUniqueString * + DDefineExpr::name() const noexcept + { + return lhs_var_->name(); + } + + void + DDefineExpr::assign_lhs_name(const DUniqueString * name) + { + lhs_var_->assign_name(name); + } + + void + DDefineExpr::assign_valuetype(TypeDescr td) noexcept + { + lhs_var_->assign_valuetype(td); + } + + void + DDefineExpr::assign_rhs(obj x) + { + this->rhs_ = x; + } + + // ----- GCObject facet ----- + + DDefineExpr * + DDefineExpr::gco_shallow_move(obj gc) noexcept + { + return gc.std_move_for(this); + } + + void + DDefineExpr::visit_gco_children(VisitReason reason, + obj gc) noexcept + { + gc.visit_child(reason, &lhs_var_); + gc.visit_poly_child(reason, &rhs_); + } + + bool + DDefineExpr::pretty(const ppindentinfo & ppii) const + { + assert(lhs_var_); + + auto lhs = obj(lhs_var_); + auto rhs = FacetRegistry::instance().try_variant(rhs_); + + if (lhs_var_) + assert(lhs.data()); + + if (rhs_) + assert(rhs.data()); + + // note: xo::print::cond() doesn't resolve the way we want here + + if (rhs) { + return ppii.pps()->pretty_struct + (ppii, + "DDefineExpr" + , refrtag("lhs", lhs) + , refrtag("rhs", rhs) + ); + } else { + return ppii.pps()->pretty_struct + (ppii, + "DDefineExpr" + , refrtag("lhs", lhs) + ); + + } + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DDefineExpr.cpp */ diff --git a/xo-expression2/src/expression2/DGlobalSymtab.cpp b/xo-expression2/src/expression2/DGlobalSymtab.cpp new file mode 100644 index 00000000..f4704fa6 --- /dev/null +++ b/xo-expression2/src/expression2/DGlobalSymtab.cpp @@ -0,0 +1,312 @@ +/** @file DGlobalSymtab.cpp +* + * @author Roland Conybeare, Jan 2026 + **/ + +#include "GlobalSymtab.hpp" +#include "Typename.hpp" +#include "Binding.hpp" +#include "DUniqueString.hpp" +#include +#include +#include +#include +#include +#include + +namespace xo { + using xo::map::DArenaHashMap; + using xo::mm::ACollector; + using xo::mm::AGCObject; + + namespace scm { + + DGlobalSymtab::DGlobalSymtab(dp var_map, + DArray * vars, + dp type_map, + DArray * types) + : var_map_{std::move(var_map)}, vars_{vars}, + type_map_{std::move(type_map)}, types_{types} + { + } + + DGlobalSymtab::DGlobalSymtab(DGlobalSymtab && other) + : var_map_{std::move(other.var_map_)}, + vars_{std::move(other.vars_)}, + type_map_{std::move(other.type_map_)}, + types_{std::move(other.types_)} + { + } + + DGlobalSymtab * + DGlobalSymtab::_make(obj mm, + obj aux_mm, + const ArenaHashMapConfig & var_cfg, + const ArenaHashMapConfig & type_cfg) + { + /* note: using aux_mm for DArenaHashMap superstructure. + * {variable, type} storage allocated from mm. + */ + + auto var_map = dp::make(aux_mm, var_cfg); + assert(var_map); + + /* choosing same capacity for hash, vars */ + DArray * vars = DArray::_empty(mm, var_map->capacity()); + assert(vars); + + auto type_map = dp::make(aux_mm, type_cfg); + assert(type_map); + + DArray * types = DArray::_empty(mm, type_map->capacity()); + + void * mem = mm.alloc_for(); + + auto symtab = new (mem) DGlobalSymtab(std::move(var_map), + vars, + std::move(type_map), + types); + assert(symtab); + + return symtab; + } + + obj + DGlobalSymtab::make(obj mm, + obj aux_mm, + const ArenaHashMapConfig & var_cfg, + const ArenaHashMapConfig & type_cfg) + { + return obj(_make(mm, aux_mm, var_cfg, type_cfg)); + } + + void + DGlobalSymtab::visit_pools(const MemorySizeVisitor & visitor) const + { + if (var_map_) + var_map_->visit_pools(visitor); + if (type_map_) + type_map_->visit_pools(visitor); + } + + DVariable * + DGlobalSymtab::lookup_variable(const DUniqueString * sym) const noexcept + { + Binding existing = this->lookup_binding(sym); + + if (existing.is_null()) + return nullptr; + + auto var_gco = obj::from((*vars_)[existing.j_slot()]); + + //auto var = var_gco.to_facet(); + //assert(var.data()); + + return var_gco.data(); + } + + void + DGlobalSymtab::upsert_variable(obj mm, + DVariable * var) + { + scope log(XO_DEBUG(false), std::string_view(*var->name())); + + // It's possible there's already a global variable + // with the same name. + // + // For example redefining a variable in an interactive session. + // In this case use the established binding. + // + DVariable * existing = this->lookup_variable(var->name()); + + if (existing) { + log && log("variable with this symbol already exists"); + + if (existing == var) { + // impossible, but.. noop, right? + return; + } + + // adopt the existing binding + var->assign_path(existing->path()); + + // stash new definition (possibly has different type), + // replacing previous one + // + log && log("STUB: need write barrier"); + vars_->assign_at(mm, + existing->path().j_slot(), + obj(var)); + //(*vars_)[existing->path().j_slot()] = obj(var); + } else { + log && log("variable is new"); + + DArray::size_type n = vars_->size(); + + // NOTE: expansion of var_ array here is moot at present (Feb 2026), + // since the feature isn't yet implemented in ArenaHashMap + + /** make sure vars_ has room **/ + if (n == vars_->capacity()) { + // DArray is out of room. Reallocate with more capacity + DArray * vars_2x = DArray::copy(mm, vars_, vars_->capacity() * 2); + + if (!vars_2x) { + assert(false); + + // in any case, we can't make progress + return; + } + + this->vars_ = vars_2x; + } + + /** now we know binding for var **/ + Binding binding = Binding::global(n); + + var->assign_path(binding); + + // need slot# in .map_ for this unique symbol + (*var_map_)[var->name()] = binding.j_slot(); + + vars_->push_back(mm, obj(var)); + } + } + + DTypename * + DGlobalSymtab::lookup_typename(const DUniqueString * sym) const noexcept + { + auto ix = type_map_->find(sym); + + if (ix == type_map_->end()) + return nullptr; + + Binding::slot_type i_slot = ix->second; + + auto tname_gco = obj::from((*types_)[i_slot]); + + return tname_gco.data(); + } + + void + DGlobalSymtab::upsert_typename(obj mm, + DTypename * tname) + { + scope log(XO_DEBUG(true), + std::string_view(*tname->name())); + + auto ix = type_map_->find(tname->name()); + + if (ix == type_map_->end()) { + log && log("typename is new"); + + DArray::size_type n = types_->size(); + + /** make sure types_ has room **/ + if (n == types_->capacity()) { + // DArray is out of room. + // Reallocate with more capacity + DArray * types_2x = DArray::copy(mm, types_, types_->capacity() * 2); + + if (!types_2x) { + assert(false); + + // in any case, we can't make progress + return; + } + + log && log("STUB: need write barrier"); + this->types_ = types_2x; + } + + (*type_map_)[tname->name()] = n; + + log && log("STUB: need write barrier"); + types_->push_back(mm, obj(tname)); + } else { + Binding::slot_type i_slot = ix->second; + + log && log("STUB: need write barrier"); + types_->assign_at(mm, i_slot, + obj(tname)); + } + } + +#ifdef NOT_USING // don't know if we need this path + DVariable * + DGlobalSymtab::establish_variable(obj mm, + const DUniqueString * sym, + TypeRef typeref) + { + DVariable * var = this->lookup_variable(sym); + + if (!var) { + assert(vars_); + + xxx; + } + + return var; + } +#endif + + Binding + DGlobalSymtab::lookup_binding(const DUniqueString * sym) const noexcept + { + assert(sym); + + scope log(XO_DEBUG(false), std::string_view(*sym)); + + auto ix = var_map_->find(sym); + + if (ix == var_map_->end()) + return Binding::null(); + + return Binding::global(ix->second); + } + + // ----- gcobject facet ----- + + DGlobalSymtab * + DGlobalSymtab::gco_shallow_move(obj gc) noexcept + { + return gc.std_move_for(this); + } + + void + DGlobalSymtab::visit_gco_children(VisitReason reason, + obj gc) noexcept + { + // map_ doesn't contain any gc-owned data, can skip + +#ifdef __APPLE__ + // clang not recognizing these as comptime eligible + assert(var_map_.is_gc_eligible() == false); + assert(type_map_.is_gc_eligible() == false); +#else + static_assert(var_map_.is_gc_eligible() == false); + static_assert(type_map_.is_gc_eligible() == false); +#endif + + gc.visit_child(reason, &vars_); + gc.visit_child(reason, &types_); + } + + // ----- printable facet ----- + + bool + DGlobalSymtab::pretty(const ppindentinfo & ppii) const + { + return ppii.pps()->pretty_struct + (ppii, + "DGlobalSymtab", + refrtag("nvar", vars_->size()), + refrtag("var_capacity", vars_->capacity()), + refrtag("ntype", types_->size()), + refrtag("type_capacity", types_->capacity())); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DGlobalSymtab.cpp */ diff --git a/xo-expression2/src/expression2/DIfElseExpr.cpp b/xo-expression2/src/expression2/DIfElseExpr.cpp new file mode 100644 index 00000000..6042104b --- /dev/null +++ b/xo-expression2/src/expression2/DIfElseExpr.cpp @@ -0,0 +1,229 @@ +/** @file DIfElseExpr.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include "DIfElseExpr.hpp" +#include "detail/IExpression_DIfElseExpr.hpp" +#include +#include +#include +#include + +namespace xo { + using xo::mm::AGCObject; + using xo::print::APrintable; + using xo::reflect::typeseq; + using xo::facet::FacetRegistry; + + namespace scm { + DIfElseExpr::DIfElseExpr(TypeRef ifexpr_tref, + obj test_expr, + obj when_true, + obj when_false) + : typeref_{ifexpr_tref}, + test_{test_expr}, + when_true_{when_true}, + when_false_{when_false} + {} + + obj + DIfElseExpr::make(obj mm, + obj test, + obj when_true, + obj when_false) + { + return obj + (_make(mm, + test, when_true, when_false)); + } + + DIfElseExpr * + DIfElseExpr::_make(obj mm, + obj test, + obj when_true, + obj when_false) + { + void * mem = mm.alloc(typeseq::id(), + sizeof(DIfElseExpr)); + + // just crete typevar here, then rely on type checking + // later + + auto prefix = TypeRef::prefix_type::from_chars("if"); + TypeRef tref = TypeRef::dwim(prefix, nullptr); + + return new (mem) DIfElseExpr(tref, + test, + when_true, + when_false); + } + + obj + DIfElseExpr::make_empty(obj mm) + { + return obj(_make_empty(mm)); + } + + DIfElseExpr * + DIfElseExpr::_make_empty(obj mm) + { + return _make(mm, + obj() /*test*/, + obj() /*when_true*/, + obj() /*when_false*/); + } + + void + DIfElseExpr::assign_valuetype(TypeDescr td) noexcept + { + typeref_.resolve(td); + } + + // GCObject facet + + DIfElseExpr * + DIfElseExpr::gco_shallow_move(obj gc) noexcept + { + return gc.std_move_for(this); + } + + void + DIfElseExpr::visit_gco_children(VisitReason reason, + obj gc) noexcept + { + typeref_.visit_gco_children(reason, gc); + + // GC needs to locate AGCObject iface for each member. + gc.visit_poly_child(reason, &test_); + gc.visit_poly_child(reason, &when_true_); + gc.visit_poly_child(reason, &when_false_); + } + + // ----- printable facet ----- + + bool + DIfElseExpr::pretty(const ppindentinfo & ppii) const + { + auto test + = FacetRegistry::instance().try_variant(test_); + auto when_true + = FacetRegistry::instance().try_variant(when_true_); + auto when_false + = FacetRegistry::instance().try_variant(when_false_); + + bool test_present = test; + bool when_true_present = when_true; + bool when_false_present = when_false; + + return ppii.pps()->pretty_struct + (ppii, + "DIfElseExpr", + refrtag("typeref", typeref_), + refrtag("test", test, test_present), + refrtag("when_true", when_true, when_true_present), + refrtag("when_false", when_false, when_false_present)); + } + + // ---------------------------------------------------------------- + +#ifdef NOPE + auto IfExpr::check_consistent_valuetype(const rp & when_true, + const rp & when_false) -> TypeDescr + { + if (when_true->valuetype() != when_false->valuetype()) + return nullptr; + + return when_true->valuetype(); + } + + void IfExpr::establish_valuetype() + { + if (this->when_true_.get() && this->when_false_.get()) + this->assign_valuetype(check_consistent_valuetype(this->when_true_, this->when_false_)); + } + + rp + IfExpr::make(const rp & test, + const rp & when_true, + const rp & when_false) + { + /** TODO: verify test returns _boolean_ type **/ + + if (when_true->valuetype() != when_false->valuetype()) { + throw std::runtime_error + (tostr("IfExpr::make:" + " types {T1,T2} found for branches of if-expr" + " where equal types expected", + xtag("T1", when_true->valuetype()->canonical_name()), + xtag("T2", when_false->valuetype()->canonical_name()))); + } + + /* arbitrary choice here */ + auto ifexpr_type = when_true->valuetype(); + + return new IfExpr(ifexpr_type, + test, + when_true, + when_false); + } /*make*/ + + void + IfExpr::display(std::ostream & os) const { + os << ""; + } /*display*/ + + std::uint32_t + IfExpr::pretty_print(const ppindentinfo & ppii) const { + return ppii.pps()->pretty_struct(ppii, "IfExpr"); +#ifdef NOT_YET + return ppii.pps()->pretty_struct(ppii, "IfExpr", + refrtag("test", test_), + refrtag("when_true", when_true_), + refrtag("when_false", when_false_)); +#endif + } + + rp + IfExprAccess::make(rp test, + rp when_true, + rp when_false) + { + auto ifexpr_type = check_consistent_valuetype(when_true, when_false); + + return new IfExprAccess(ifexpr_type, std::move(test), std::move(when_true), std::move(when_false)); + } + + rp + IfExprAccess::make_empty() + { + return new IfExprAccess(nullptr /*ifexpr_valuetype*/, + nullptr /*test*/, + nullptr /*when_true*/, + nullptr /*when_false*/); + } + + void + IfExprAccess::assign_when_true(rp x) + { + this->when_true_ = std::move(x); + } + + void + IfExprAccess::assign_when_false(rp x) + { + this->when_false_ = std::move(x); + } +#endif + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DIfElseExpr.cpp */ diff --git a/xo-expression2/src/expression2/DLambdaExpr.cpp b/xo-expression2/src/expression2/DLambdaExpr.cpp new file mode 100644 index 00000000..1b512b0c --- /dev/null +++ b/xo-expression2/src/expression2/DLambdaExpr.cpp @@ -0,0 +1,192 @@ +/** @file DLambdaExpr.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include "LambdaExpr.hpp" +#include "LocalSymtab.hpp" +#include "UniqueString.hpp" +#include +#include +#include +#include + +namespace xo { + using xo::mm::AGCObject; + using xo::mm::AGCObjectVisitor; + using xo::print::APrintable; + using xo::facet::FacetRegistry; + using xo::reflect::TypeDescr; + using xo::reflect::TypeDescrBase; + using xo::reflect::FunctionTdxInfo; + using xo::reflect::typeseq; + using xo::print::quot; + + 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} + { + } + + obj + DLambdaExpr::make(obj mm, + TypeRef typeref, + const DUniqueString * name, + DLocalSymtab * local_symtab, + obj body) + { + return obj(_make(mm, typeref, + name, local_symtab, body)); + } + + 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); + } + + TypeDescr + DLambdaExpr::assemble_lambda_td(DLocalSymtab * symtab, + TypeDescr return_td) + { + assert(return_td); + + std::vector arg_td_v; + { + DLocalSymtab::size_type z = symtab->n_vars(); + + arg_td_v.reserve(z); + + for (DLocalSymtab::size_type i = 0; i < z; ++i) { + auto param = symtab->lookup_var(Binding::local(i)); + + assert(param); + arg_td_v.push_back(param->valuetype()); + } + } + + auto function_tdx = FunctionTdxInfo(return_td, arg_td_v, false /*!is_noexcept*/); + + TypeDescr lambda_td = TypeDescrBase::require_by_fn_info(function_tdx); + + return lambda_td; + } + + 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); + } + + std::size_t + DLambdaExpr::shallow_size() const noexcept { + return sizeof(DLambdaExpr); + } + + DLambdaExpr * + DLambdaExpr::gco_shallow_move(obj gc) noexcept { + return gc.std_move_for(this); + } + + void + DLambdaExpr::visit_gco_children(VisitReason reason, + obj gc) noexcept { + typeref_.visit_gco_children(reason, gc); + + gc.visit_child(reason, &name_); + // type_name_str_ + + gc.visit_child(reason, &local_symtab_); + gc.visit_poly_child(reason, &body_expr_); + + // xxx free_var_set + // xxx captured_var_set + // xxx layer_var_map + // xxx nested_lambda_map + } + + bool + DLambdaExpr::pretty(const ppindentinfo & ppii) const + { + auto body + = FacetRegistry::instance().try_variant(body_expr_); + + if (name_ && body) { + auto local_symtab_pr + = obj(local_symtab_); + + return ppii.pps()->pretty_struct(ppii, + "LambdaExpr", + refrtag("tref", typeref_), + refrtag("name", quot(std::string_view(*name_))), + refrtag("local_symtab", local_symtab_pr), + //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 new file mode 100644 index 00000000..1cb69b84 --- /dev/null +++ b/xo-expression2/src/expression2/DLocalSymtab.cpp @@ -0,0 +1,207 @@ +/** @file DLocalSymtab.cpp +* + * @author Roland Conybeare, Jan 2026 + **/ + +#include "LocalSymtab.hpp" +#include "Variable.hpp" +#include "Typename.hpp" +#include "DUniqueString.hpp" +#include +#include +#include +#include + +namespace xo { + using xo::mm::ACollector; + using xo::mm::AGCObject; + using xo::print::APrintable; + using xo::print::ppstate; + + namespace scm { + + DLocalSymtab::DLocalSymtab(DLocalSymtab * p, + DArray * vars, DArray * types) + : parent_{p}, vars_{vars}, types_{types} + { + } + + DLocalSymtab * + DLocalSymtab::_make_empty(obj mm, + DLocalSymtab * p, + size_type nv, + size_type nt) + { + void * mem = mm.alloc_for(); + + DArray * vars = DArray::_empty(mm, nv); + DArray * types = DArray::_empty(mm, nt); + + return new (mem) DLocalSymtab(p, vars, types); + } + + DVariable * + DLocalSymtab::lookup_var(Binding ix) noexcept + { + assert(ix.i_link() == 0); + assert(ix.j_slot() < static_cast(vars_->size())); + + auto var = obj::from((*vars_)[ix.j_slot()]); + + assert(var); + + return var.data(); + } + + Binding + DLocalSymtab::append_var(obj mm, + const DUniqueString * name, + TypeRef typeref) + { + assert(name); + + if (vars_->size() >= vars_->capacity() || !name) { + assert(false); + + return Binding::null(); + } else { + //size_type i_slot = (this->size_)++; + Binding binding = Binding::local(vars_->size()); + + DVariable * var = DVariable::make(mm, name, typeref, binding); + + vars_->push_back(mm, obj(var)); + + return binding; + } + } + + void + DLocalSymtab::append_type(obj mm, + const DUniqueString * name, + obj type) + { + assert(name); + + if (types_->size() >= types_->capacity() || !name) { + assert(false); + } else { + obj tname = DTypename::make(mm, name, type); + + types_->push_back(mm, tname); + } + } + + Binding + DLocalSymtab::lookup_binding(const DUniqueString * sym) const noexcept + { + assert(sym); + + if (sym) { + for (size_type i = 0, n = vars_->size(); i < n; ++i) { + auto var_i = obj::from((*vars_)[i]); + + assert(var_i); + + if (*sym == *(var_i->name())) + return var_i->path(); + } + } + + return Binding(); + } + + // ----- gcobject facet ----- + + DLocalSymtab * + DLocalSymtab::gco_shallow_move(obj gc) noexcept + { + return gc.std_move_for(this); + } + + void + DLocalSymtab::visit_gco_children(VisitReason reason, + obj gc) noexcept + { + gc.visit_child(reason, &parent_); + gc.visit_child(reason, &vars_); + gc.visit_child(reason, &types_); + } + + // ----- printable facet ----- + + bool + DLocalSymtab::pretty(const ppindentinfo & ppii) const + { + ppstate * pps = ppii.pps(); + + (void)pps; + + if (ppii.upto()) { + /* perhaps print on one line */ + if (!pps->print_upto("print_upto(xrefrtag("nvars", vars_->size()))) + return false; + + for (size_type i = 0, n = vars_->size(); i arg_pr = (*vars_)[i].to_facet(); + + if (!pps->print_upto(xrefrtag(buf, arg_pr))) + return false; + } + + if (!pps->print_upto(xrefrtag("ntypes", types_->size()))) + return false; + + for (size_type i = 0, n = types_->size(); i < n; ++i) { + char buf[32]; + snprintf(buf, sizeof(buf), "[%u]", i); + + obj type_pr = (*types_)[i].to_facet(); + + if (!pps->print_upto(xrefrtag(buf, type_pr))) + return false; + } + + pps->write(">"); + return true; + } else { + /* with line breaks */ + + pps->write("newline_pretty_tag(ppii.ci1(), "nvars", vars_->size()); + + for (size_type i = 0, n = vars_->size(); i < n; ++i) { + char buf[32]; + snprintf(buf, sizeof(buf), "[%u]", i); + + obj arg_pr = (*vars_)[i].to_facet(); + + pps->newline_pretty_tag(ppii.ci1(), buf, arg_pr); + } + + pps->newline_pretty_tag(ppii.ci1(), "ntypes", types_->size()); + + for (size_type i = 0, n = types_->size(); i < n; ++i) { + char buf[32]; + snprintf(buf, sizeof(buf), "[%u]", i); + + obj type_pr = (*types_)[i].to_facet(); + + pps->newline_pretty_tag(ppii.ci1(), buf, type_pr); + } + + pps->write(">"); + + return false; + } + } + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DLocalSymtab.cpp */ diff --git a/xo-expression2/src/expression2/DSequenceExpr.cpp b/xo-expression2/src/expression2/DSequenceExpr.cpp new file mode 100644 index 00000000..fd55a114 --- /dev/null +++ b/xo-expression2/src/expression2/DSequenceExpr.cpp @@ -0,0 +1,131 @@ +/** @file DSequenceExpr.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include "DSequenceExpr.hpp" +#include "detail/IExpression_DSequenceExpr.hpp" +#include +#include +#include +#include +#include +#include +#include + +namespace xo { + using xo::mm::AGCObject; + using xo::print::APrintable; + using xo::facet::FacetRegistry; + using xo::reflect::typeseq; + + namespace scm { + + DSequenceExpr::DSequenceExpr() = default; + + DSequenceExpr::DSequenceExpr(DArray * xv) + : expr_v_{xv} + {} + + obj + DSequenceExpr::make_empty(obj mm) + { + return obj(_make_empty(mm)); + } + + DSequenceExpr * + DSequenceExpr::_make_empty(obj mm) + { + void * mem = mm.alloc(typeseq::id(), + sizeof(DSequenceExpr)); + + DSequenceExpr * expr = new (mem) DSequenceExpr(); + + constexpr size_type c_hint_capacity = 8; + + /** allocate 2nd, so it comes after DSequenceExpr in + * memory. This may later allow realloc + **/ + DArray * expr_v = DArray::_empty(mm, + c_hint_capacity); + + expr->expr_v_ = expr_v; + + return expr; + } + + auto + DSequenceExpr::size() const noexcept -> size_type + { + return expr_v_->size(); + } + + obj + DSequenceExpr::operator[](std::size_t i) const + { + obj gco = (*expr_v_)[i]; + + return FacetRegistry::instance().variant(gco); + } + + void + DSequenceExpr::push_back(obj mm, + obj expr) + { + if (expr_v_->size() == expr_v_->capacity()) { + /* reallocate+expand */ + + DArray * expr_2x_v + = DArray::_empty(mm, 2 * expr_v_->capacity()); + + for (size_type i = 0, z = expr_v_->size(); i < z; ++i) { + expr_2x_v->push_back(mm, (*expr_2x_v)[i]); + } + + this->expr_v_ = expr_2x_v; + } + + obj expr_gco = expr.to_facet(); + + this->expr_v_->push_back(mm, expr_gco); + } + + void + DSequenceExpr::assign_valuetype(TypeDescr td) noexcept + { + typeref_.resolve(td); + } + + bool + DSequenceExpr::pretty(const ppindentinfo & ppii) const + { + using xo::print::ppstate; + + auto expr_v_pr = obj(expr_v_); + + return ppii.pps()->pretty_struct + (ppii, + "DSequenceExpr", + refrtag("expr_v", expr_v_pr)); + } + + // gc hooks for IGCObject_DSequenceExpr + + DSequenceExpr * + DSequenceExpr::gco_shallow_move(obj gc) noexcept + { + return gc.std_move_for(this); + } + + void + DSequenceExpr::visit_gco_children(VisitReason reason, obj gc) noexcept + { + typeref_.visit_gco_children(reason, gc); + + gc.visit_child(reason, &expr_v_); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DSequenceExpr.cpp */ diff --git a/xo-expression2/src/expression2/DTypename.cpp b/xo-expression2/src/expression2/DTypename.cpp new file mode 100644 index 00000000..c8debab9 --- /dev/null +++ b/xo-expression2/src/expression2/DTypename.cpp @@ -0,0 +1,79 @@ +/** @file DTypename.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include "Typename.hpp" +#include +#include +#include +#include +#include + +namespace xo { + using xo::mm::ACollector; + using xo::mm::AGCObject; + using xo::print::APrintable; + + namespace scm { + + DTypename * + DTypename::_make(obj mm, + const DUniqueString * name, + obj type) + { + void * mem = mm.alloc_for(); + + return new (mem) DTypename(name, type); + } + + obj + DTypename::make(obj mm, + const DUniqueString * name, + obj type) + { + return obj(_make(mm, name, type)); + } + + DTypename::DTypename(const DUniqueString * name, + obj type) + : name_{name}, type_{type} + {} + + DTypename * + DTypename::gco_shallow_move(obj gc) noexcept + { + return gc.std_move_for(this); + } + + void + DTypename::visit_gco_children(VisitReason reason, + obj gc) noexcept + { + gc.visit_child(reason, &name_); + gc.visit_poly_child(reason, &type_); + } + + bool + DTypename::pretty(const ppindentinfo & ppii) const + { + using xo::print::quot; + + auto name = (name_ + ? std::string_view(*name_) + : std::string_view("")); + + auto type_pr = type_.to_facet(); + + return ppii.pps()->pretty_struct + (ppii, + "DTypename" + , refrtag("name", quot(name)) + , refrtag("type", type_pr) + ); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DTypename.cpp */ diff --git a/xo-expression2/src/expression2/DVarRef.cpp b/xo-expression2/src/expression2/DVarRef.cpp new file mode 100644 index 00000000..b73efe10 --- /dev/null +++ b/xo-expression2/src/expression2/DVarRef.cpp @@ -0,0 +1,93 @@ +/** @file DVarRef.cpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#include "DVarRef.hpp" + +namespace xo { + using xo::mm::AGCObject; + using xo::reflect::TypeDescr; + + namespace scm { + + DVarRef::DVarRef(DVariable * vardef, + Binding path) + : vardef_{vardef}, + path_{path} + {} + + DVarRef * + DVarRef::make(obj mm, + DVariable * vardef, + int32_t link) + { + assert(vardef); + + void * mem = mm.alloc_for(); + + return new (mem) DVarRef(vardef, + Binding::relative(link, + vardef->path())); + } + + const DUniqueString * + DVarRef::name() const { + return vardef_->name(); + } + + TypeRef + DVarRef::typeref() const noexcept { + assert(vardef_); + + return vardef_->typeref(); + } + + TypeDescr + DVarRef::valuetype() const noexcept + { + return this->typeref().td(); + } + + void + DVarRef::assign_valuetype(TypeDescr td) noexcept + { + assert(vardef_); + vardef_->assign_valuetype(td); + } + + // gcobject facet + + DVarRef * + DVarRef::gco_shallow_move(obj gc) noexcept + { + return gc.std_move_for(this); + } + + void + DVarRef::visit_gco_children(VisitReason reason, + obj gc) noexcept + { + gc.visit_child(reason, &vardef_); + //auto iface = xo::facet::impl_for(); + //gc.forward_inplace(&iface, (void **)vardef_.data_); + + // TODO: concept to indicate that no gc pointers in Binding + } + + // printable facet + + bool + DVarRef::pretty(const ppindentinfo & ppii) const + { + return ppii.pps()->pretty_struct + (ppii, + "DVarRef", + refrtag("name", std::string_view(*(this->name()))), + refrtag("path", this->path_)); + } + + } +} /*namespace xo*/ + +/* end DVarRef.cpp */ diff --git a/xo-expression2/src/expression2/DVariable.cpp b/xo-expression2/src/expression2/DVariable.cpp new file mode 100644 index 00000000..066aeb50 --- /dev/null +++ b/xo-expression2/src/expression2/DVariable.cpp @@ -0,0 +1,72 @@ +/** @file DVariable.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include "DVariable.hpp" +#include "exprtype.hpp" +#include +#include + +namespace xo { + using xo::facet::typeseq; + + namespace scm { + + DVariable * + DVariable::make(obj mm, + const DUniqueString * name, + const TypeRef & typeref, + Binding path) + { + void * mem = mm.alloc(typeseq::id(), + sizeof(DVariable)); + + return new (mem) DVariable(name, typeref, path); + } + + DVariable::DVariable(const DUniqueString * name, + const TypeRef & typeref, + Binding path) + : name_{name}, typeref_{typeref}, path_{path} + {} + + void + DVariable::assign_valuetype(TypeDescr td) noexcept + { + typeref_.resolve(td); + } + + DVariable * + DVariable::gco_shallow_move(obj gc) noexcept + { + return gc.std_move_for(this); + } + + void + DVariable::visit_gco_children(VisitReason reason, obj gc) noexcept + { + typeref_.visit_gco_children(reason, gc); + } + + bool + DVariable::pretty(const ppindentinfo & ppii) const + { + using xo::print::quot; + + auto name = (name_ + ? std::string_view(*name_) + : std::string_view("")); + + return ppii.pps()->pretty_struct + (ppii, + "DVariable" + , refrtag("name", quot(name)) + , refrtag("typeref", typeref_) + ); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DVariable.cpp */ diff --git a/xo-expression2/src/expression2/IExpression_Any.cpp b/xo-expression2/src/expression2/IExpression_Any.cpp new file mode 100644 index 00000000..fe245c76 --- /dev/null +++ b/xo-expression2/src/expression2/IExpression_Any.cpp @@ -0,0 +1,48 @@ +/** @file IExpression_Any.cpp + * + **/ + +#include "detail/IExpression_Any.hpp" +#include +#include + +namespace xo { +namespace scm { + +using xo::facet::DVariantPlaceholder; +using xo::facet::typeseq; +using xo::facet::valid_facet_implementation; + +void +IExpression_Any::_fatal() +{ + /* control here on uninitialized IAllocator_Any. + * Initialized instance will have specific implementation type + */ + std::cerr << "fatal" + << ": attempt to call uninitialized" + << " IExpression_Any method" + << std::endl; + std::terminate(); +} + +typeseq +IExpression_Any::s_typeseq = typeseq::id(); + +bool +IExpression_Any::_valid + = valid_facet_implementation(); + +// nonconst methods + +auto +IExpression_Any::assign_valuetype(Opaque, TypeDescr) noexcept -> void +{ + _fatal(); +} + + +} /*namespace scm*/ +} /*namespace xo*/ + +/* end IExpression_Any.cpp */ diff --git a/xo-expression2/src/expression2/IExpression_DApplyExpr.cpp b/xo-expression2/src/expression2/IExpression_DApplyExpr.cpp new file mode 100644 index 00000000..4ee365e0 --- /dev/null +++ b/xo-expression2/src/expression2/IExpression_DApplyExpr.cpp @@ -0,0 +1,45 @@ +/** @file IExpression_DApplyExpr.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IExpression_DApplyExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IExpression_DApplyExpr.json5] +**/ + +#include "detail/IExpression_DApplyExpr.hpp" + +namespace xo { + namespace scm { + auto + IExpression_DApplyExpr::extype(const DApplyExpr & self) noexcept -> exprtype + { + return self.extype(); + } + + auto + IExpression_DApplyExpr::typeref(const DApplyExpr & self) noexcept -> TypeRef + { + return self.typeref(); + } + + auto + IExpression_DApplyExpr::valuetype(const DApplyExpr & self) noexcept -> TypeDescr + { + return self.valuetype(); + } + + auto + IExpression_DApplyExpr::assign_valuetype(DApplyExpr & self, TypeDescr td) noexcept -> void + { + self.assign_valuetype(td); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IExpression_DApplyExpr.cpp */ diff --git a/xo-expression2/src/expression2/IExpression_DConstant.cpp b/xo-expression2/src/expression2/IExpression_DConstant.cpp new file mode 100644 index 00000000..836a6aee --- /dev/null +++ b/xo-expression2/src/expression2/IExpression_DConstant.cpp @@ -0,0 +1,45 @@ +/** @file IExpression_DConstant.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IExpression_DConstant.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IExpression_DConstant.json5] +**/ + +#include "detail/IExpression_DConstant.hpp" + +namespace xo { + namespace scm { + auto + IExpression_DConstant::extype(const DConstant & self) noexcept -> exprtype + { + return self.extype(); + } + + auto + IExpression_DConstant::typeref(const DConstant & self) noexcept -> TypeRef + { + return self.typeref(); + } + + auto + IExpression_DConstant::valuetype(const DConstant & self) noexcept -> TypeDescr + { + return self.valuetype(); + } + + auto + IExpression_DConstant::assign_valuetype(DConstant & self, TypeDescr td) noexcept -> void + { + self.assign_valuetype(td); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IExpression_DConstant.cpp */ diff --git a/xo-expression2/src/expression2/IExpression_DDefineExpr.cpp b/xo-expression2/src/expression2/IExpression_DDefineExpr.cpp new file mode 100644 index 00000000..f8f2429c --- /dev/null +++ b/xo-expression2/src/expression2/IExpression_DDefineExpr.cpp @@ -0,0 +1,45 @@ +/** @file IExpression_DDefineExpr.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IExpression_DDefineExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IExpression_DDefineExpr.json5] +**/ + +#include "detail/IExpression_DDefineExpr.hpp" + +namespace xo { + namespace scm { + auto + IExpression_DDefineExpr::extype(const DDefineExpr & self) noexcept -> exprtype + { + return self.extype(); + } + + auto + IExpression_DDefineExpr::typeref(const DDefineExpr & self) noexcept -> TypeRef + { + return self.typeref(); + } + + auto + IExpression_DDefineExpr::valuetype(const DDefineExpr & self) noexcept -> TypeDescr + { + return self.valuetype(); + } + + auto + IExpression_DDefineExpr::assign_valuetype(DDefineExpr & self, TypeDescr td) noexcept -> void + { + self.assign_valuetype(td); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IExpression_DDefineExpr.cpp */ diff --git a/xo-expression2/src/expression2/IExpression_DIfElseExpr.cpp b/xo-expression2/src/expression2/IExpression_DIfElseExpr.cpp new file mode 100644 index 00000000..947ca8de --- /dev/null +++ b/xo-expression2/src/expression2/IExpression_DIfElseExpr.cpp @@ -0,0 +1,45 @@ +/** @file IExpression_DIfElseExpr.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IExpression_DIfElseExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IExpression_DIfElseExpr.json5] +**/ + +#include "detail/IExpression_DIfElseExpr.hpp" + +namespace xo { + namespace scm { + auto + IExpression_DIfElseExpr::extype(const DIfElseExpr & self) noexcept -> exprtype + { + return self.extype(); + } + + auto + IExpression_DIfElseExpr::typeref(const DIfElseExpr & self) noexcept -> TypeRef + { + return self.typeref(); + } + + auto + IExpression_DIfElseExpr::valuetype(const DIfElseExpr & self) noexcept -> TypeDescr + { + return self.valuetype(); + } + + auto + IExpression_DIfElseExpr::assign_valuetype(DIfElseExpr & self, TypeDescr td) noexcept -> void + { + self.assign_valuetype(td); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IExpression_DIfElseExpr.cpp */ diff --git a/xo-expression2/src/expression2/IExpression_DLambdaExpr.cpp b/xo-expression2/src/expression2/IExpression_DLambdaExpr.cpp new file mode 100644 index 00000000..1b177c91 --- /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: + * [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 */ diff --git a/xo-expression2/src/expression2/IExpression_DSequenceExpr.cpp b/xo-expression2/src/expression2/IExpression_DSequenceExpr.cpp new file mode 100644 index 00000000..5ae4f3f7 --- /dev/null +++ b/xo-expression2/src/expression2/IExpression_DSequenceExpr.cpp @@ -0,0 +1,45 @@ +/** @file IExpression_DSequenceExpr.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IExpression_DSequenceExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IExpression_DSequenceExpr.json5] +**/ + +#include "detail/IExpression_DSequenceExpr.hpp" + +namespace xo { + namespace scm { + auto + IExpression_DSequenceExpr::extype(const DSequenceExpr & self) noexcept -> exprtype + { + return self.extype(); + } + + auto + IExpression_DSequenceExpr::typeref(const DSequenceExpr & self) noexcept -> TypeRef + { + return self.typeref(); + } + + auto + IExpression_DSequenceExpr::valuetype(const DSequenceExpr & self) noexcept -> TypeDescr + { + return self.valuetype(); + } + + auto + IExpression_DSequenceExpr::assign_valuetype(DSequenceExpr & self, TypeDescr td) noexcept -> void + { + self.assign_valuetype(td); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IExpression_DSequenceExpr.cpp */ diff --git a/xo-expression2/src/expression2/IExpression_DVarRef.cpp b/xo-expression2/src/expression2/IExpression_DVarRef.cpp new file mode 100644 index 00000000..843a0653 --- /dev/null +++ b/xo-expression2/src/expression2/IExpression_DVarRef.cpp @@ -0,0 +1,45 @@ +/** @file IExpression_DVarRef.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IExpression_DVarRef.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IExpression_DVarRef.json5] +**/ + +#include "detail/IExpression_DVarRef.hpp" + +namespace xo { + namespace scm { + auto + IExpression_DVarRef::extype(const DVarRef & self) noexcept -> exprtype + { + return self.extype(); + } + + auto + IExpression_DVarRef::typeref(const DVarRef & self) noexcept -> TypeRef + { + return self.typeref(); + } + + auto + IExpression_DVarRef::valuetype(const DVarRef & self) noexcept -> TypeDescr + { + return self.valuetype(); + } + + auto + IExpression_DVarRef::assign_valuetype(DVarRef & self, TypeDescr td) noexcept -> void + { + self.assign_valuetype(td); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IExpression_DVarRef.cpp */ diff --git a/xo-expression2/src/expression2/IGCObject_DApplyExpr.cpp b/xo-expression2/src/expression2/IGCObject_DApplyExpr.cpp new file mode 100644 index 00000000..610b675b --- /dev/null +++ b/xo-expression2/src/expression2/IGCObject_DApplyExpr.cpp @@ -0,0 +1,32 @@ +/** @file IGCObject_DApplyExpr.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DApplyExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DApplyExpr.json5] +**/ + +#include "detail/IGCObject_DApplyExpr.hpp" + +namespace xo { + namespace scm { + auto + IGCObject_DApplyExpr::gco_shallow_move(DApplyExpr & self, obj gc) noexcept -> Opaque + { + return self.gco_shallow_move(gc); + } + auto + IGCObject_DApplyExpr::visit_gco_children(DApplyExpr & self, VisitReason reason, obj fn) noexcept -> void + { + self.visit_gco_children(reason, fn); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DApplyExpr.cpp */ diff --git a/xo-expression2/src/expression2/IGCObject_DConstant.cpp b/xo-expression2/src/expression2/IGCObject_DConstant.cpp new file mode 100644 index 00000000..20c71341 --- /dev/null +++ b/xo-expression2/src/expression2/IGCObject_DConstant.cpp @@ -0,0 +1,32 @@ +/** @file IGCObject_DConstant.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DConstant.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DConstant.json5] +**/ + +#include "detail/IGCObject_DConstant.hpp" + +namespace xo { + namespace scm { + auto + IGCObject_DConstant::gco_shallow_move(DConstant & self, obj gc) noexcept -> Opaque + { + return self.gco_shallow_move(gc); + } + auto + IGCObject_DConstant::visit_gco_children(DConstant & self, VisitReason reason, obj fn) noexcept -> void + { + self.visit_gco_children(reason, fn); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DConstant.cpp */ diff --git a/xo-expression2/src/expression2/IGCObject_DDefineExpr.cpp b/xo-expression2/src/expression2/IGCObject_DDefineExpr.cpp new file mode 100644 index 00000000..8540ab25 --- /dev/null +++ b/xo-expression2/src/expression2/IGCObject_DDefineExpr.cpp @@ -0,0 +1,32 @@ +/** @file IGCObject_DDefineExpr.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DDefineExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DDefineExpr.json5] +**/ + +#include "define/IGCObject_DDefineExpr.hpp" + +namespace xo { + namespace scm { + auto + IGCObject_DDefineExpr::gco_shallow_move(DDefineExpr & self, obj gc) noexcept -> Opaque + { + return self.gco_shallow_move(gc); + } + auto + IGCObject_DDefineExpr::visit_gco_children(DDefineExpr & self, VisitReason reason, obj fn) noexcept -> void + { + self.visit_gco_children(reason, fn); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DDefineExpr.cpp */ diff --git a/xo-expression2/src/expression2/IGCObject_DGlobalSymtab.cpp b/xo-expression2/src/expression2/IGCObject_DGlobalSymtab.cpp new file mode 100644 index 00000000..01153218 --- /dev/null +++ b/xo-expression2/src/expression2/IGCObject_DGlobalSymtab.cpp @@ -0,0 +1,32 @@ +/** @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::gco_shallow_move(DGlobalSymtab & self, obj gc) noexcept -> Opaque + { + return self.gco_shallow_move(gc); + } + auto + IGCObject_DGlobalSymtab::visit_gco_children(DGlobalSymtab & self, VisitReason reason, obj fn) noexcept -> void + { + self.visit_gco_children(reason, fn); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DGlobalSymtab.cpp */ diff --git a/xo-expression2/src/expression2/IGCObject_DIfElseExpr.cpp b/xo-expression2/src/expression2/IGCObject_DIfElseExpr.cpp new file mode 100644 index 00000000..22878fea --- /dev/null +++ b/xo-expression2/src/expression2/IGCObject_DIfElseExpr.cpp @@ -0,0 +1,32 @@ +/** @file IGCObject_DIfElseExpr.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DIfElseExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DIfElseExpr.json5] +**/ + +#include "detail/IGCObject_DIfElseExpr.hpp" + +namespace xo { + namespace scm { + auto + IGCObject_DIfElseExpr::gco_shallow_move(DIfElseExpr & self, obj gc) noexcept -> Opaque + { + return self.gco_shallow_move(gc); + } + auto + IGCObject_DIfElseExpr::visit_gco_children(DIfElseExpr & self, VisitReason reason, obj fn) noexcept -> void + { + self.visit_gco_children(reason, fn); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DIfElseExpr.cpp */ diff --git a/xo-expression2/src/expression2/IGCObject_DLambdaExpr.cpp b/xo-expression2/src/expression2/IGCObject_DLambdaExpr.cpp new file mode 100644 index 00000000..05bd85a0 --- /dev/null +++ b/xo-expression2/src/expression2/IGCObject_DLambdaExpr.cpp @@ -0,0 +1,32 @@ +/** @file IGCObject_DLambdaExpr.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DLambdaExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DLambdaExpr.json5] +**/ + +#include "detail/IGCObject_DLambdaExpr.hpp" + +namespace xo { + namespace scm { + auto + IGCObject_DLambdaExpr::gco_shallow_move(DLambdaExpr & self, obj gc) noexcept -> Opaque + { + return self.gco_shallow_move(gc); + } + auto + IGCObject_DLambdaExpr::visit_gco_children(DLambdaExpr & self, VisitReason reason, obj fn) noexcept -> void + { + self.visit_gco_children(reason, fn); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DLambdaExpr.cpp */ diff --git a/xo-expression2/src/expression2/IGCObject_DLocalSymtab.cpp b/xo-expression2/src/expression2/IGCObject_DLocalSymtab.cpp new file mode 100644 index 00000000..7ccadca0 --- /dev/null +++ b/xo-expression2/src/expression2/IGCObject_DLocalSymtab.cpp @@ -0,0 +1,32 @@ +/** @file IGCObject_DLocalSymtab.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DLocalSymtab.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DLocalSymtab.json5] +**/ + +#include "symtab/IGCObject_DLocalSymtab.hpp" + +namespace xo { + namespace scm { + auto + IGCObject_DLocalSymtab::gco_shallow_move(DLocalSymtab & self, obj gc) noexcept -> Opaque + { + return self.gco_shallow_move(gc); + } + auto + IGCObject_DLocalSymtab::visit_gco_children(DLocalSymtab & self, VisitReason reason, obj fn) noexcept -> void + { + self.visit_gco_children(reason, fn); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DLocalSymtab.cpp */ diff --git a/xo-expression2/src/expression2/IGCObject_DSequenceExpr.cpp b/xo-expression2/src/expression2/IGCObject_DSequenceExpr.cpp new file mode 100644 index 00000000..0cc84faa --- /dev/null +++ b/xo-expression2/src/expression2/IGCObject_DSequenceExpr.cpp @@ -0,0 +1,32 @@ +/** @file IGCObject_DSequenceExpr.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DSequenceExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DSequenceExpr.json5] +**/ + +#include "detail/IGCObject_DSequenceExpr.hpp" + +namespace xo { + namespace scm { + auto + IGCObject_DSequenceExpr::gco_shallow_move(DSequenceExpr & self, obj gc) noexcept -> Opaque + { + return self.gco_shallow_move(gc); + } + auto + IGCObject_DSequenceExpr::visit_gco_children(DSequenceExpr & self, VisitReason reason, obj fn) noexcept -> void + { + self.visit_gco_children(reason, fn); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DSequenceExpr.cpp */ diff --git a/xo-expression2/src/expression2/IGCObject_DTypename.cpp b/xo-expression2/src/expression2/IGCObject_DTypename.cpp new file mode 100644 index 00000000..accbfc6e --- /dev/null +++ b/xo-expression2/src/expression2/IGCObject_DTypename.cpp @@ -0,0 +1,32 @@ +/** @file IGCObject_DTypename.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DTypename.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DTypename.json5] +**/ + +#include "typename/IGCObject_DTypename.hpp" + +namespace xo { + namespace scm { + auto + IGCObject_DTypename::gco_shallow_move(DTypename & self, obj gc) noexcept -> Opaque + { + return self.gco_shallow_move(gc); + } + auto + IGCObject_DTypename::visit_gco_children(DTypename & self, VisitReason reason, obj fn) noexcept -> void + { + self.visit_gco_children(reason, fn); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DTypename.cpp */ diff --git a/xo-expression2/src/expression2/IGCObject_DVarRef.cpp b/xo-expression2/src/expression2/IGCObject_DVarRef.cpp new file mode 100644 index 00000000..e169c37f --- /dev/null +++ b/xo-expression2/src/expression2/IGCObject_DVarRef.cpp @@ -0,0 +1,32 @@ +/** @file IGCObject_DVarRef.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DVarRef.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DVarRef.json5] +**/ + +#include "detail/IGCObject_DVarRef.hpp" + +namespace xo { + namespace scm { + auto + IGCObject_DVarRef::gco_shallow_move(DVarRef & self, obj gc) noexcept -> Opaque + { + return self.gco_shallow_move(gc); + } + auto + IGCObject_DVarRef::visit_gco_children(DVarRef & self, VisitReason reason, obj fn) noexcept -> void + { + self.visit_gco_children(reason, fn); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DVarRef.cpp */ diff --git a/xo-expression2/src/expression2/IPrintable_DApplyExpr.cpp b/xo-expression2/src/expression2/IPrintable_DApplyExpr.cpp new file mode 100644 index 00000000..06b7b752 --- /dev/null +++ b/xo-expression2/src/expression2/IPrintable_DApplyExpr.cpp @@ -0,0 +1,28 @@ +/** @file IPrintable_DApplyExpr.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DApplyExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DApplyExpr.json5] +**/ + +#include "detail/IPrintable_DApplyExpr.hpp" + +namespace xo { + namespace scm { + auto + IPrintable_DApplyExpr::pretty(const DApplyExpr & self, const ppindentinfo & ppii) -> bool + { + return self.pretty(ppii); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IPrintable_DApplyExpr.cpp */ diff --git a/xo-expression2/src/expression2/IPrintable_DConstant.cpp b/xo-expression2/src/expression2/IPrintable_DConstant.cpp new file mode 100644 index 00000000..57bd271f --- /dev/null +++ b/xo-expression2/src/expression2/IPrintable_DConstant.cpp @@ -0,0 +1,28 @@ +/** @file IPrintable_DConstant.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DConstant.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DConstant.json5] +**/ + +#include "detail/IPrintable_DConstant.hpp" + +namespace xo { + namespace scm { + auto + IPrintable_DConstant::pretty(const DConstant & self, const ppindentinfo & ppii) -> bool + { + return self.pretty(ppii); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IPrintable_DConstant.cpp */ diff --git a/xo-expression2/src/expression2/IPrintable_DDefineExpr.cpp b/xo-expression2/src/expression2/IPrintable_DDefineExpr.cpp new file mode 100644 index 00000000..2774e610 --- /dev/null +++ b/xo-expression2/src/expression2/IPrintable_DDefineExpr.cpp @@ -0,0 +1,28 @@ +/** @file IPrintable_DDefineExpr.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DDefineExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DDefineExpr.json5] +**/ + +#include "detail/IPrintable_DDefineExpr.hpp" + +namespace xo { + namespace scm { + auto + IPrintable_DDefineExpr::pretty(const DDefineExpr & self, const ppindentinfo & ppii) -> bool + { + return self.pretty(ppii); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IPrintable_DDefineExpr.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/IPrintable_DIfElseExpr.cpp b/xo-expression2/src/expression2/IPrintable_DIfElseExpr.cpp new file mode 100644 index 00000000..52694cb5 --- /dev/null +++ b/xo-expression2/src/expression2/IPrintable_DIfElseExpr.cpp @@ -0,0 +1,28 @@ +/** @file IPrintable_DIfElseExpr.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DIfElseExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DIfElseExpr.json5] +**/ + +#include "detail/IPrintable_DIfElseExpr.hpp" + +namespace xo { + namespace scm { + auto + IPrintable_DIfElseExpr::pretty(const DIfElseExpr & self, const ppindentinfo & ppii) -> bool + { + return self.pretty(ppii); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IPrintable_DIfElseExpr.cpp */ diff --git a/xo-expression2/src/expression2/IPrintable_DLambdaExpr.cpp b/xo-expression2/src/expression2/IPrintable_DLambdaExpr.cpp new file mode 100644 index 00000000..049a81c8 --- /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: + * [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 */ diff --git a/xo-expression2/src/expression2/IPrintable_DLocalSymtab.cpp b/xo-expression2/src/expression2/IPrintable_DLocalSymtab.cpp new file mode 100644 index 00000000..0e178e09 --- /dev/null +++ b/xo-expression2/src/expression2/IPrintable_DLocalSymtab.cpp @@ -0,0 +1,28 @@ +/** @file IPrintable_DLocalSymtab.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DLocalSymtab.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DLocalSymtab.json5] +**/ + +#include "symtab/IPrintable_DLocalSymtab.hpp" + +namespace xo { + namespace scm { + auto + IPrintable_DLocalSymtab::pretty(const DLocalSymtab & self, const ppindentinfo & ppii) -> bool + { + return self.pretty(ppii); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IPrintable_DLocalSymtab.cpp */ diff --git a/xo-expression2/src/expression2/IPrintable_DSequenceExpr.cpp b/xo-expression2/src/expression2/IPrintable_DSequenceExpr.cpp new file mode 100644 index 00000000..a3471232 --- /dev/null +++ b/xo-expression2/src/expression2/IPrintable_DSequenceExpr.cpp @@ -0,0 +1,28 @@ +/** @file IPrintable_DSequenceExpr.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DSequenceExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DSequenceExpr.json5] +**/ + +#include "detail/IPrintable_DSequenceExpr.hpp" + +namespace xo { + namespace scm { + auto + IPrintable_DSequenceExpr::pretty(const DSequenceExpr & self, const ppindentinfo & ppii) -> bool + { + return self.pretty(ppii); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IPrintable_DSequenceExpr.cpp */ diff --git a/xo-expression2/src/expression2/IPrintable_DTypename.cpp b/xo-expression2/src/expression2/IPrintable_DTypename.cpp new file mode 100644 index 00000000..8d753b0e --- /dev/null +++ b/xo-expression2/src/expression2/IPrintable_DTypename.cpp @@ -0,0 +1,28 @@ +/** @file IPrintable_DTypename.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DTypename.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DTypename.json5] +**/ + +#include "typename/IPrintable_DTypename.hpp" + +namespace xo { + namespace scm { + auto + IPrintable_DTypename::pretty(const DTypename & self, const ppindentinfo & ppii) -> bool + { + return self.pretty(ppii); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IPrintable_DTypename.cpp */ diff --git a/xo-expression2/src/expression2/IPrintable_DVarRef.cpp b/xo-expression2/src/expression2/IPrintable_DVarRef.cpp new file mode 100644 index 00000000..a2027a2a --- /dev/null +++ b/xo-expression2/src/expression2/IPrintable_DVarRef.cpp @@ -0,0 +1,28 @@ +/** @file IPrintable_DVarRef.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DVarRef.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DVarRef.json5] +**/ + +#include "detail/IPrintable_DVarRef.hpp" + +namespace xo { + namespace scm { + auto + IPrintable_DVarRef::pretty(const DVarRef & self, const ppindentinfo & ppii) -> bool + { + return self.pretty(ppii); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IPrintable_DVarRef.cpp */ diff --git a/xo-expression2/src/expression2/ISymbolTable_Any.cpp b/xo-expression2/src/expression2/ISymbolTable_Any.cpp new file mode 100644 index 00000000..31d324de --- /dev/null +++ b/xo-expression2/src/expression2/ISymbolTable_Any.cpp @@ -0,0 +1,42 @@ +/** @file ISymbolTable_Any.cpp + * + **/ + +#include "symtab/ISymbolTable_Any.hpp" +#include +#include + +namespace xo { +namespace scm { + +using xo::facet::DVariantPlaceholder; +using xo::facet::typeseq; +using xo::facet::valid_facet_implementation; + +void +ISymbolTable_Any::_fatal() +{ + /* control here on uninitialized IAllocator_Any. + * Initialized instance will have specific implementation type + */ + std::cerr << "fatal" + << ": attempt to call uninitialized" + << " ISymbolTable_Any method" + << std::endl; + std::terminate(); +} + +typeseq +ISymbolTable_Any::s_typeseq = typeseq::id(); + +bool +ISymbolTable_Any::_valid + = valid_facet_implementation(); + +// nonconst methods + + +} /*namespace scm*/ +} /*namespace xo*/ + +/* end ISymbolTable_Any.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/ISymbolTable_DLocalSymtab.cpp b/xo-expression2/src/expression2/ISymbolTable_DLocalSymtab.cpp new file mode 100644 index 00000000..b67ada5c --- /dev/null +++ b/xo-expression2/src/expression2/ISymbolTable_DLocalSymtab.cpp @@ -0,0 +1,34 @@ +/** @file ISymbolTable_DLocalSymtab.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/ISymbolTable_DLocalSymtab.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/ISymbolTable_DLocalSymtab.json5] +**/ + +#include "symtab/ISymbolTable_DLocalSymtab.hpp" + +namespace xo { + namespace scm { + auto + ISymbolTable_DLocalSymtab::is_global_symtab(const DLocalSymtab & self) noexcept -> bool + { + return self.is_global_symtab(); + } + + auto + ISymbolTable_DLocalSymtab::lookup_binding(const DLocalSymtab & self, const DUniqueString * sym) noexcept -> Binding + { + return self.lookup_binding(sym); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end ISymbolTable_DLocalSymtab.cpp */ diff --git a/xo-expression2/src/expression2/SetupExpression2.cpp b/xo-expression2/src/expression2/SetupExpression2.cpp new file mode 100644 index 00000000..e43d01ec --- /dev/null +++ b/xo-expression2/src/expression2/SetupExpression2.cpp @@ -0,0 +1,151 @@ +/** @file SetupExpression2.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include "SetupExpression2.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include +#include +#include +#include + +namespace xo { + using xo::mm::AGCObject; + using xo::print::APrintable; + using xo::facet::FacetRegistry; + using xo::facet::TypeRegistry; + using xo::facet::typeseq; + using xo::facet::impl_for; + + namespace scm { + bool + SetupExpression2::register_facets() + { + scope log(XO_DEBUG(true)); + + // Expression + // +- Constant + // +- Variable + // +- VarRef + // +- DefineExpr + // +- ApplyExpr + // +- LambdaExpr + // +- IfElseExpr + // \- SequenceExpr + + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + + // Typename + + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + + // SymbolTable + // +- LocalSymtab + // \- GlobalSymtab + + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + + // until we register facets + TypeRegistry::register_type(); + + TypeRegistry::register_type(); + + log && log(xtag("DUniqueString.tseq", typeseq::id())); + log && log(xtag("DDefineExpr.tseq", typeseq::id())); + log && log(xtag("DVariable.tseq", typeseq::id())); + log && log(xtag("DTypename.tseq", typeseq::id())); + log && log(xtag("DVarRef.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("DSequenceExpr.tseq", typeseq::id())); + + log && log(xtag("DGlobalSymtab.tseq", typeseq::id())); + log && log(xtag("DLocalSymtab.tseq", typeseq::id())); + + log && log(xtag("AExpression.tseq", typeseq::id())); + log && log(xtag("ASymbolTable.tseq", typeseq::id())); + + return true; + } + + bool + SetupExpression2::register_types(obj gc) + { + scope log(XO_DEBUG(true)); + + bool ok = true; + + ok &= gc.install_type(impl_for()); + ok &= gc.install_type(impl_for()); + ok &= gc.install_type(impl_for()); + ok &= gc.install_type(impl_for()); + ok &= gc.install_type(impl_for()); + ok &= gc.install_type(impl_for()); + ok &= gc.install_type(impl_for()); + ok &= gc.install_type(impl_for()); + ok &= gc.install_type(impl_for()); + + ok &= gc.install_type(impl_for()); + ok &= gc.install_type(impl_for()); + + return ok; + } } /*namespace scm*/ +} /*namespace xo*/ + +/* end SetupExpression2.cpp */ diff --git a/xo-expression2/src/expression2/TypeRef.cpp b/xo-expression2/src/expression2/TypeRef.cpp new file mode 100644 index 00000000..e3178b7f --- /dev/null +++ b/xo-expression2/src/expression2/TypeRef.cpp @@ -0,0 +1,127 @@ +/** @file TypeRef.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include "TypeRef.hpp" +#include +#include +#include +#include +#include +#include + +namespace xo { + using xo::mm::AGCObject; + using xo::facet::FacetRegistry; + + namespace scm { + TypeRef::TypeRef(const type_var & id, obj type) + : id_{id}, type_{type} + {} + + TypeRef::TypeRef(const type_var & id, TypeDescr td) + : id_{id}, td_{td} + {} + + TypeRef + TypeRef::resolved(obj type) + { + assert(type); + + type_var null; + return TypeRef(null, type); + } + + TypeRef + TypeRef::resolved(TypeDescr td) + { + assert(td); + + type_var null; + return TypeRef(null, td); + } + + TypeRef + TypeRef::dwim(prefix_type prefix, obj type) + { + if (type) { + /* type already resolved + * -> we don't need a type variable name + */ + return TypeRef::resolved(type); + } else { + /* type is not resolved yet. + * -> give it a unique name, + * to seed unification + */ + return TypeRef(generate_unique(prefix), type); + } + } + + TypeRef + TypeRef::dwim(prefix_type prefix, TypeDescr td) + { + if (td) { + /* type already resolved + * -> we don't need a type variable name + */ + return TypeRef::resolved(td); + } else { + /* type is not resolved yet. + * -> give it a unique name, + * to seed unification + */ + return TypeRef(generate_unique(prefix), td); + } + } + + auto + TypeRef::generate_unique(prefix_type prefix) -> type_var + { + static uint32_t s_counter = 0; + + s_counter = (1 + s_counter) % 1000000000; + + char buf[type_var::fixed_capacity]; + int n = snprintf(buf, sizeof(buf), "%s:%u", prefix.c_str(), s_counter); + (void)n;; + + assert(n < static_cast(type_var::fixed_capacity)); + + // not necessary, but to remove all doubt. + buf [sizeof(buf) - 1] = '\0'; + + return type_var(buf); + } + + bool + TypeRef::is_resolved() const noexcept + { + return (td_ != nullptr); + } + + void + TypeRef::visit_gco_children(VisitReason reason, + obj gc) noexcept + { + gc.visit_poly_child(reason, &type_); + } + + bool + TypeRef::pretty(const ppindentinfo & ppii) const + { + using xo::print::quot; + + return ppii.pps()->pretty_struct + (ppii, + "TypeRef" + , refrtag("id", quot(id_)) + , refrtag("td", cond(td_, td_, "null")) + ); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end TypeRef.cpp */ diff --git a/xo-expression2/src/expression2/facet/IExpression_DVariable.cpp b/xo-expression2/src/expression2/facet/IExpression_DVariable.cpp new file mode 100644 index 00000000..49b9cfbc --- /dev/null +++ b/xo-expression2/src/expression2/facet/IExpression_DVariable.cpp @@ -0,0 +1,45 @@ +/** @file IExpression_DVariable.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IExpression_DVariable.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IExpression_DVariable.json5] +**/ + +#include "variable/IExpression_DVariable.hpp" + +namespace xo { + namespace scm { + auto + IExpression_DVariable::extype(const DVariable & self) noexcept -> exprtype + { + return self.extype(); + } + + auto + IExpression_DVariable::typeref(const DVariable & self) noexcept -> TypeRef + { + return self.typeref(); + } + + auto + IExpression_DVariable::valuetype(const DVariable & self) noexcept -> TypeDescr + { + return self.valuetype(); + } + + auto + IExpression_DVariable::assign_valuetype(DVariable & self, TypeDescr td) noexcept -> void + { + self.assign_valuetype(td); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IExpression_DVariable.cpp */ diff --git a/xo-expression2/src/expression2/facet/IGCObject_DVariable.cpp b/xo-expression2/src/expression2/facet/IGCObject_DVariable.cpp new file mode 100644 index 00000000..8734ca7a --- /dev/null +++ b/xo-expression2/src/expression2/facet/IGCObject_DVariable.cpp @@ -0,0 +1,32 @@ +/** @file IGCObject_DVariable.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DVariable.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DVariable.json5] +**/ + +#include "variable/IGCObject_DVariable.hpp" + +namespace xo { + namespace scm { + auto + IGCObject_DVariable::gco_shallow_move(DVariable & self, obj gc) noexcept -> Opaque + { + return self.gco_shallow_move(gc); + } + auto + IGCObject_DVariable::visit_gco_children(DVariable & self, VisitReason reason, obj fn) noexcept -> void + { + self.visit_gco_children(reason, fn); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DVariable.cpp */ diff --git a/xo-expression2/src/expression2/facet/IPrintable_DVariable.cpp b/xo-expression2/src/expression2/facet/IPrintable_DVariable.cpp new file mode 100644 index 00000000..e7dc3d07 --- /dev/null +++ b/xo-expression2/src/expression2/facet/IPrintable_DVariable.cpp @@ -0,0 +1,28 @@ +/** @file IPrintable_DVariable.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DVariable.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DVariable.json5] +**/ + +#include "variable/IPrintable_DVariable.hpp" + +namespace xo { + namespace scm { + auto + IPrintable_DVariable::pretty(const DVariable & self, const ppindentinfo & ppii) -> bool + { + return self.pretty(ppii); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IPrintable_DVariable.cpp */ diff --git a/xo-expression2/src/expression2/init_expression2.cpp b/xo-expression2/src/expression2/init_expression2.cpp new file mode 100644 index 00000000..a80d6625 --- /dev/null +++ b/xo-expression2/src/expression2/init_expression2.cpp @@ -0,0 +1,40 @@ +/** @file init_expression2.cpp +* + * @author Roland Conybeare, Jan 2026 + **/ + +#include "init_expression2.hpp" +#include "SetupExpression2.hpp" +#include "expression2_register_types.hpp" + +#include +#include + +namespace xo { + using xo::scm::SetupExpression2; + using xo::mm::CollectorTypeRegistry; + + void + InitSubsys::init() + { + SetupExpression2::register_facets(); + + CollectorTypeRegistry::instance().register_types(&SetupExpression2::register_types); + } + + InitEvidence + InitSubsys::require() + { + InitEvidence retval; + + /* direct subsystem deps for xo-object2/ */ + retval ^= InitSubsys::require(); + + /* xo-expression2/'s own initialization code */ + retval ^= Subsystem::provide("expression2", &init); + + return retval; + } +} /*namespace xo*/ + +/* end init_expression2.cpp */ diff --git a/xo-expression2/utest/CMakeLists.txt b/xo-expression2/utest/CMakeLists.txt new file mode 100644 index 00000000..4273fa9a --- /dev/null +++ b/xo-expression2/utest/CMakeLists.txt @@ -0,0 +1,17 @@ +# built unittest xo-expression2/utest + +set(UTEST_EXE utest.expression2) +set(UTEST_SRCS + expression2_utest_main.cpp + X1Collector.test.cpp + DConstant.test.cpp + DVariable.test.cpp + DApplyExpr.test.cpp + DDefineExpr.test.cpp + DIfElseExpr.test.cpp +) + +xo_add_utest_executable(${UTEST_EXE} ${UTEST_SRCS}) +xo_self_dependency(${UTEST_EXE} xo_expression2) +xo_dependency(${UTEST_EXE} xo_numeric) +xo_external_target_dependency(${UTEST_EXE} Catch2 Catch2::Catch2) diff --git a/xo-expression2/utest/DApplyExpr.test.cpp b/xo-expression2/utest/DApplyExpr.test.cpp new file mode 100644 index 00000000..d3638da3 --- /dev/null +++ b/xo-expression2/utest/DApplyExpr.test.cpp @@ -0,0 +1,327 @@ +/** @file DApplyExpr.test.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include "init_expression2.hpp" +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include +#include + +#include + +#include +#include +//#include +//#include + +#include +#include +#include + +#include + +#include + +#include + +namespace ut { + using xo::S_expression2_tag; + using xo::scm::DApplyExpr; + using xo::scm::DConstant; + using xo::scm::DFloat; + using xo::scm::AExpression; + using xo::scm::TypeRef; + using xo::scm::NumericPrimitives; + using xo::scm::Primitives; + using xo::scm::DPrimitive_gco_2_gco_gco; + using xo::scm::StringTable; + using xo::mm::CollectorTypeRegistry; + using xo::mm::AAllocator; + using xo::mm::ACollector; + using xo::mm::AGCObject; + using xo::mm::DX1Collector; + using xo::mm::X1CollectorConfig; + using xo::mm::ArenaConfig; + using xo::print::APrintable; + using xo::print::ppstate_standalone; + using xo::print::ppconfig; + using xo::facet::FacetRegistry; + using xo::facet::with_facet; + using xo::facet::obj; + using xo::reflect::Reflect; + using xo::InitEvidence; + using xo::InitSubsys; + using xo::scope; + + static InitEvidence s_init = InitSubsys::require(); + + TEST_CASE("DApplyExpr-init", "[expression2][DApplyExpr]") + { + REQUIRE(s_init.evidence()); + } + + TEST_CASE("DApplyExpr-make2", "[expression2][DApplyExpr]") + { + REQUIRE(s_init.evidence()); + + X1CollectorConfig cfg{ + .name_ = "dapplyexpr_make2_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + auto stbl = StringTable(1024 /*hint_max_capacity*/, false /*!debug_flag*/); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + // wrap primitive as GCObject, then as expression + obj prim_gco + = with_facet::mkobj(NumericPrimitives::make_multiply_pm(alloc, &stbl)); + obj fn_expr = DConstant::make(alloc, prim_gco); + REQUIRE(fn_expr.data() != nullptr); + + // create argument expressions + obj val1 = DFloat::box(alloc, 3.0); + obj val2 = DFloat::box(alloc, 7.0); + obj arg1 = DConstant::make(alloc, val1); + obj arg2 = DConstant::make(alloc, val2); + REQUIRE(arg1.data() != nullptr); + REQUIRE(arg2.data() != nullptr); + + // create apply expression: mul(3.0, 7.0) + TypeRef result_type = TypeRef::resolved(Reflect::require()); + auto apply_expr = DApplyExpr::make2(alloc, result_type, fn_expr, arg1, arg2); + REQUIRE(apply_expr.data() != nullptr); + } + + TEST_CASE("DApplyExpr-extype", "[expression2][DApplyExpr]") + { + REQUIRE(s_init.evidence()); + + X1CollectorConfig cfg{ + .name_ = "dapplyexpr_extype_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + auto stbl = StringTable(1024 /*hint_max_capacity*/, false /*!debug_flag*/); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + obj prim_gco + = with_facet::mkobj(NumericPrimitives::make_multiply_pm(alloc, &stbl)); + obj fn_expr = DConstant::make(alloc, prim_gco); + + obj val1 = DFloat::box(alloc, 3.0); + obj val2 = DFloat::box(alloc, 7.0); + obj arg1 = DConstant::make(alloc, val1); + obj arg2 = DConstant::make(alloc, val2); + + TypeRef result_type = TypeRef::resolved(Reflect::require()); + auto apply_expr = DApplyExpr::make2(alloc, result_type, fn_expr, arg1, arg2); + + REQUIRE(apply_expr.data()->extype() == xo::scm::exprtype::apply); + } + + TEST_CASE("DApplyExpr-n_args", "[expression2][DApplyExpr]") + { + REQUIRE(s_init.evidence()); + + X1CollectorConfig cfg{ + .name_ = "dapplyexpr_n_args_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + auto stbl = StringTable(1024 /*hint_max_capacity*/, false /*!debug_flag*/); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + obj prim_gco + = with_facet::mkobj(NumericPrimitives::make_multiply_pm(alloc, &stbl)); + obj fn_expr = DConstant::make(alloc, prim_gco); + + obj val1 = DFloat::box(alloc, 3.0); + obj val2 = DFloat::box(alloc, 7.0); + obj arg1 = DConstant::make(alloc, val1); + obj arg2 = DConstant::make(alloc, val2); + + TypeRef result_type = TypeRef::resolved(Reflect::require()); + auto apply_expr = DApplyExpr::make2(alloc, result_type, fn_expr, arg1, arg2); + + REQUIRE(apply_expr.data()->n_args() == 2); + } + + TEST_CASE("DApplyExpr-fn", "[expression2][DApplyExpr]") + { + REQUIRE(s_init.evidence()); + + X1CollectorConfig cfg{ + .name_ = "dapplyexpr_fn_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + auto stbl = StringTable(1024 /*hint_max_capacity*/, false /*!debug_flag*/); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + obj prim_gco + = with_facet::mkobj(NumericPrimitives::make_multiply_pm(alloc, &stbl)); + obj fn_expr = DConstant::make(alloc, prim_gco); + + obj val1 = DFloat::box(alloc, 3.0); + obj val2 = DFloat::box(alloc, 7.0); + obj arg1 = DConstant::make(alloc, val1); + obj arg2 = DConstant::make(alloc, val2); + + TypeRef result_type = TypeRef::resolved(Reflect::require()); + auto apply_expr = DApplyExpr::make2(alloc, result_type, fn_expr, arg1, arg2); + + // verify fn() returns an expression + obj fn = apply_expr.data()->fn(); + REQUIRE(fn.data() != nullptr); + REQUIRE(fn.extype() == xo::scm::exprtype::constant); + } + + TEST_CASE("DApplyExpr-arg", "[expression2][DApplyExpr]") + { + REQUIRE(s_init.evidence()); + + X1CollectorConfig cfg{ + .name_ = "dapplyexpr_arg_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + auto stbl = StringTable(1024 /*hint_max_capacity*/, false /*!debug_flag*/); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + obj prim_gco + = with_facet::mkobj(NumericPrimitives::make_multiply_pm(alloc, &stbl)); + obj fn_expr = DConstant::make(alloc, prim_gco); + + obj val1 = DFloat::box(alloc, 3.0); + obj val2 = DFloat::box(alloc, 7.0); + obj arg1 = DConstant::make(alloc, val1); + obj arg2 = DConstant::make(alloc, val2); + + TypeRef result_type = TypeRef::resolved(Reflect::require()); + auto apply_expr = DApplyExpr::make2(alloc, result_type, fn_expr, arg1, arg2); + + // verify arg(0) and arg(1) return expressions + obj a0 = apply_expr.data()->arg(0); + obj a1 = apply_expr.data()->arg(1); + + REQUIRE(a0.data() != nullptr); + REQUIRE(a1.data() != nullptr); + REQUIRE(a0.extype() == xo::scm::exprtype::constant); + REQUIRE(a1.extype() == xo::scm::exprtype::constant); + } + + TEST_CASE("DApplyExpr-pretty", "[expression2][DApplyExpr][pp]") + { + scope log(XO_DEBUG(false)); + + REQUIRE(s_init.evidence()); + + X1CollectorConfig cfg{ + .name_ = "dapplyexpr_pretty_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + auto stbl = StringTable(1024 /*hint_max_capacity*/, false /*!debug_flag*/); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + obj prim_gco + = with_facet::mkobj(NumericPrimitives::make_multiply_pm(alloc, &stbl)); + obj fn_expr = DConstant::make(alloc, prim_gco); + + obj val1 = DFloat::box(alloc, 3.0); + obj val2 = DFloat::box(alloc, 7.0); + obj arg1 = DConstant::make(alloc, val1); + obj arg2 = DConstant::make(alloc, val2); + + TypeRef result_type = TypeRef::resolved(Reflect::require()); + auto apply_expr = DApplyExpr::make2(alloc, result_type, fn_expr, arg1, arg2); + + std::stringstream ss; + ppconfig ppc; + ppstate_standalone pps(&ss, 0, &ppc); + + obj expr_pr(apply_expr.data()); + pps.pretty(expr_pr); + + std::string output = ss.str(); + + log && log(output); + + CHECK(output.find("ApplyExpr") != std::string::npos); + } +} + +/* end DApplyExpr.test.cpp */ diff --git a/xo-expression2/utest/DConstant.test.cpp b/xo-expression2/utest/DConstant.test.cpp new file mode 100644 index 00000000..a45d39d8 --- /dev/null +++ b/xo-expression2/utest/DConstant.test.cpp @@ -0,0 +1,230 @@ +/** @file DConstant.test.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include "init_expression2.hpp" +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include + +#include + +#include + +namespace ut { + using xo::S_expression2_tag; + using xo::scm::DConstant; + using xo::scm::DFloat; + using xo::scm::DInteger; + using xo::scm::AExpression; + using xo::mm::CollectorTypeRegistry; + using xo::mm::AAllocator; + using xo::mm::ACollector; + using xo::mm::AGCObject; + using xo::mm::DX1Collector; + using xo::mm::X1CollectorConfig; + using xo::mm::ArenaConfig; + using xo::print::APrintable; + using xo::print::ppstate_standalone; + using xo::print::ppconfig; + using xo::facet::FacetRegistry; + using xo::facet::with_facet; + using xo::facet::obj; + using xo::facet::typeseq; + using xo::reflect::Reflect; + using xo::InitEvidence; + using xo::InitSubsys; + using xo::scope; + + // Ensure subsystem initialized before tests + static InitEvidence s_init = InitSubsys::require(); + + TEST_CASE("DConstant-init", "[expression2][DConstant]") + { + // Verify subsystem initialization succeeded + REQUIRE(s_init.evidence()); + } + + TEST_CASE("DConstant-from-float", "[expression2][DConstant]") + { + REQUIRE(s_init.evidence()); + + X1CollectorConfig cfg{ + .name_ = "dconstant_float_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + // Box a float value + obj fval = DFloat::box(alloc, 3.14); + REQUIRE(fval.data() != nullptr); + + // Create DConstant from the boxed float + auto expr = DConstant::make(alloc, fval); + REQUIRE(expr.data() != nullptr); + + // Verify expression type + REQUIRE(expr.data()->extype() == xo::scm::exprtype::constant); + + // Verify valuetype is double (DFloat::value_type) + REQUIRE(expr.data()->valuetype() == Reflect::require()); + + // Verify value is accessible + REQUIRE(expr.data()->value().data() != nullptr); + } + + TEST_CASE("DConstant-from-integer", "[expression2][DConstant]") + { + REQUIRE(s_init.evidence()); + + X1CollectorConfig cfg{ + .name_ = "dconstant_int_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + // Box an integer value + obj ival = DInteger::box(alloc, 42); + REQUIRE(ival.data() != nullptr); + + // Create DConstant from the boxed integer + auto expr = DConstant::make(alloc, ival); + REQUIRE(expr.data() != nullptr); + + // Verify expression type + REQUIRE(expr.data()->extype() == xo::scm::exprtype::constant); + + // Verify valuetype is long (DInteger::value_type) + REQUIRE(expr.data()->valuetype() == Reflect::require()); + + // Verify value is accessible + REQUIRE(expr.data()->value().data() != nullptr); + } + + TEST_CASE("DConstant-pretty-float", "[expression2][DConstant][pp]") + { + scope log(XO_DEBUG(true)); + + REQUIRE(s_init.evidence()); + + X1CollectorConfig cfg{ + .name_ = "dconstant_pp_float_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + // Box a float value + obj fval = DFloat::box(alloc, 2.718); + auto expr = DConstant::make(alloc, fval); + REQUIRE(expr.data() != nullptr); + + // Pretty print + std::stringstream ss; + ppconfig ppc; + ppstate_standalone pps(&ss, 0, &ppc); + + obj expr_pr(expr.data()); + pps.pretty(expr_pr); + + std::string output = ss.str(); + + log && log(output); + + // Output should contain "DConstant" struct name + CHECK(output.find("DConstant") != std::string::npos); + } + + TEST_CASE("DConstant-pretty-integer", "[expression2][DConstant][pp]") + { + scope log(XO_DEBUG(false)); + + REQUIRE(s_init.evidence()); + + X1CollectorConfig cfg{ + .name_ = "dconstant_pp_int_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + // Box an integer value + obj ival = DInteger::box(alloc, 123); + auto expr = DConstant::make(alloc, ival); + REQUIRE(expr.data() != nullptr); + + // Pretty print + std::stringstream ss; + ppconfig ppc; + ppstate_standalone pps(&ss, 0, &ppc); + + obj expr_pr(expr.data()); + pps.pretty(expr_pr); + + std::string output = ss.str(); + + log && log(output); + + // Output should contain "DConstant" struct name + CHECK(output.find("DConstant") != std::string::npos); + } +} + +/* end DConstant.test.cpp */ diff --git a/xo-expression2/utest/DDefineExpr.test.cpp b/xo-expression2/utest/DDefineExpr.test.cpp new file mode 100644 index 00000000..184c7556 --- /dev/null +++ b/xo-expression2/utest/DDefineExpr.test.cpp @@ -0,0 +1,317 @@ +/** @file DDefineExpr.test.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include "init_expression2.hpp" +#include +#include +#include +#include +//#include + +#include +//#include + +#include + +#include + +#include + +#include +#include +#include + +#include + +#include + +#include +#include + +namespace ut { + using xo::S_expression2_tag; + using xo::scm::DDefineExpr; + using xo::scm::DConstant; + using xo::scm::DFloat; + using xo::scm::DVariable; + using xo::scm::DUniqueString; + using xo::scm::StringTable; + using xo::scm::AExpression; + using xo::mm::CollectorTypeRegistry; + using xo::mm::AAllocator; + using xo::mm::ACollector; + using xo::mm::AGCObject; + using xo::mm::DX1Collector; + using xo::mm::X1CollectorConfig; + using xo::mm::ArenaConfig; + using xo::print::APrintable; + using xo::print::ppstate_standalone; + using xo::print::ppconfig; + using xo::facet::FacetRegistry; + using xo::facet::with_facet; + using xo::facet::obj; + using xo::reflect::Reflect; + using xo::InitEvidence; + using xo::InitSubsys; + using xo::scope; + + static InitEvidence s_init = InitSubsys::require(); + + TEST_CASE("DDefineExpr-init", "[expression2][DDefineExpr]") + { + REQUIRE(s_init.evidence()); + } + + TEST_CASE("DDefineExpr-make", "[expression2][DDefineExpr]") + { + REQUIRE(s_init.evidence()); + + X1CollectorConfig cfg{ + .name_ = "ddefineexpr_make_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + StringTable table(1024); + const DUniqueString * name = table.intern("x"); + REQUIRE(name != nullptr); + + // Create rhs expression: constant 42.0 + obj fval = DFloat::box(alloc, 42.0); + auto rhs_expr = DConstant::make(alloc, fval); + REQUIRE(rhs_expr.data() != nullptr); + + // Create define expression: def x = 42.0 + DDefineExpr * def = DDefineExpr::make(alloc, name, rhs_expr); + REQUIRE(def != nullptr); + } + + TEST_CASE("DDefineExpr-lhs", "[expression2][DDefineExpr]") + { + REQUIRE(s_init.evidence()); + + X1CollectorConfig cfg{ + .name_ = "ddefineexpr_lhs_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + StringTable table(1024); + const DUniqueString * name = table.intern("myvar"); + + obj fval = DFloat::box(alloc, 3.14); + auto rhs_expr = DConstant::make(alloc, fval); + + DDefineExpr * def = DDefineExpr::make(alloc, name, rhs_expr); + REQUIRE(def != nullptr); + + DVariable * lhs = def->lhs(); + REQUIRE(lhs != nullptr); + REQUIRE(lhs->name() == name); + } + + TEST_CASE("DDefineExpr-rhs", "[expression2][DDefineExpr]") + { + REQUIRE(s_init.evidence()); + + X1CollectorConfig cfg{ + .name_ = "ddefineexpr_rhs_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + StringTable table(1024); + const DUniqueString * name = table.intern("y"); + + obj fval = DFloat::box(alloc, 2.718); + auto rhs_expr = DConstant::make(alloc, fval); + + DDefineExpr * def = DDefineExpr::make(alloc, name, rhs_expr); + REQUIRE(def != nullptr); + + obj rhs = def->rhs(); + REQUIRE(rhs.data() != nullptr); + // Verify rhs expression type is constant + REQUIRE(rhs.extype() == xo::scm::exprtype::constant); + } + + TEST_CASE("DDefineExpr-name", "[expression2][DDefineExpr]") + { + REQUIRE(s_init.evidence()); + + X1CollectorConfig cfg{ + .name_ = "ddefineexpr_name_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + StringTable table(1024); + const DUniqueString * name = table.intern("foo"); + + obj fval = DFloat::box(alloc, 1.0); + auto rhs_expr = DConstant::make(alloc, fval); + + DDefineExpr * def = DDefineExpr::make(alloc, name, rhs_expr); + REQUIRE(def != nullptr); + REQUIRE(def->name() == name); + REQUIRE(std::strcmp(def->name()->chars(), "foo") == 0); + } + + TEST_CASE("DDefineExpr-extype", "[expression2][DDefineExpr]") + { + REQUIRE(s_init.evidence()); + + X1CollectorConfig cfg{ + .name_ = "ddefineexpr_extype_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + StringTable table(1024); + const DUniqueString * name = table.intern("z"); + + obj fval = DFloat::box(alloc, 0.0); + auto rhs_expr = DConstant::make(alloc, fval); + + DDefineExpr * def = DDefineExpr::make(alloc, name, rhs_expr); + REQUIRE(def != nullptr); + REQUIRE(def->extype() == xo::scm::exprtype::define); + } + + TEST_CASE("DDefineExpr-valuetype", "[expression2][DDefineExpr]") + { + REQUIRE(s_init.evidence()); + + X1CollectorConfig cfg{ + .name_ = "ddefineexpr_valuetype_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + StringTable table(1024); + const DUniqueString * name = table.intern("w"); + + obj fval = DFloat::box(alloc, 99.9); + auto rhs_expr = DConstant::make(alloc, fval); + + DDefineExpr * def = DDefineExpr::make(alloc, name, rhs_expr); + REQUIRE(def != nullptr); + REQUIRE(def->valuetype() == Reflect::require()); + } + + TEST_CASE("DDefineExpr-pretty", "[expression2][DDefineExpr][pp]") + { + scope log(XO_DEBUG(true)); + + REQUIRE(s_init.evidence()); + + X1CollectorConfig cfg{ + .name_ = "ddefineexpr_pretty_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + StringTable table(1024); + const DUniqueString * name = table.intern("bar"); + + obj fval = DFloat::box(alloc, 123.456); + auto rhs_expr = DConstant::make(alloc, fval); + + DDefineExpr * def = DDefineExpr::make(alloc, name, rhs_expr); + REQUIRE(def != nullptr); + + std::stringstream ss; + ppconfig ppc; + ppstate_standalone pps(&ss, 0, &ppc); + + obj def_pr(def); + pps.pretty(def_pr); + + std::string output = ss.str(); + + log && log(output); + + CHECK(output.find("DDefineExpr") != std::string::npos); + } +} + +/* end DDefineExpr.test.cpp */ diff --git a/xo-expression2/utest/DIfElseExpr.test.cpp b/xo-expression2/utest/DIfElseExpr.test.cpp new file mode 100644 index 00000000..4a7dcf70 --- /dev/null +++ b/xo-expression2/utest/DIfElseExpr.test.cpp @@ -0,0 +1,345 @@ +/** @file DIfElseExpr.test.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include "init_expression2.hpp" +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +//#include +//#include + +#include +#include +#include + +#include + +#include + +#include + +namespace ut { + using xo::S_expression2_tag; + using xo::scm::DIfElseExpr; + using xo::scm::DConstant; + using xo::scm::DFloat; + using xo::scm::DBoolean; + using xo::scm::AExpression; + using xo::mm::CollectorTypeRegistry; + using xo::mm::AAllocator; + using xo::mm::ACollector; + using xo::mm::AGCObject; + using xo::mm::DX1Collector; + using xo::mm::X1CollectorConfig; + using xo::mm::ArenaConfig; + using xo::print::APrintable; + using xo::print::ppstate_standalone; + using xo::print::ppconfig; + //using xo::facet::FacetRegistry; + using xo::facet::with_facet; + using xo::facet::obj; + //using xo::reflect::Reflect; + using xo::InitEvidence; + using xo::InitSubsys; + using xo::scope; + + static InitEvidence s_init = InitSubsys::require(); + + TEST_CASE("DIfElseExpr-init", "[expression2][DIfElseExpr]") + { + REQUIRE(s_init.evidence()); + } + + TEST_CASE("DIfElseExpr-make", "[expression2][DIfElseExpr]") + { + REQUIRE(s_init.evidence()); + + X1CollectorConfig cfg{ + .name_ = "difelseexpr_make_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + // Create test expression: constant true + obj bval = DBoolean::box(alloc, true); + auto test_expr = DConstant::make(alloc, bval); + REQUIRE(test_expr.data() != nullptr); + + // Create when_true expression: constant 1.0 + obj fval1 = DFloat::box(alloc, 1.0); + auto when_true_expr = DConstant::make(alloc, fval1); + REQUIRE(when_true_expr.data() != nullptr); + + // Create when_false expression: constant 2.0 + obj fval2 = DFloat::box(alloc, 2.0); + auto when_false_expr = DConstant::make(alloc, fval2); + REQUIRE(when_false_expr.data() != nullptr); + + // Create if-else expression: if true then 1.0 else 2.0 + auto ifexpr = DIfElseExpr::make(alloc, test_expr, when_true_expr, when_false_expr); + REQUIRE(ifexpr.data() != nullptr); + } + + TEST_CASE("DIfElseExpr-test", "[expression2][DIfElseExpr]") + { + REQUIRE(s_init.evidence()); + + X1CollectorConfig cfg{ + .name_ = "difelseexpr_test_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + obj bval = DBoolean::box(alloc, true); + auto test_expr = DConstant::make(alloc, bval); + + obj fval1 = DFloat::box(alloc, 1.0); + auto when_true_expr = DConstant::make(alloc, fval1); + + obj fval2 = DFloat::box(alloc, 2.0); + auto when_false_expr = DConstant::make(alloc, fval2); + + auto ifexpr = DIfElseExpr::make(alloc, test_expr, when_true_expr, when_false_expr); + REQUIRE(ifexpr.data() != nullptr); + + obj test = ifexpr.data()->test(); + REQUIRE(test.data() != nullptr); + REQUIRE(test.extype() == xo::scm::exprtype::constant); + } + + TEST_CASE("DIfElseExpr-when-true", "[expression2][DIfElseExpr]") + { + REQUIRE(s_init.evidence()); + + X1CollectorConfig cfg{ + .name_ = "difelseexpr_when_true_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + obj bval = DBoolean::box(alloc, true); + auto test_expr = DConstant::make(alloc, bval); + + obj fval1 = DFloat::box(alloc, 1.0); + auto when_true_expr = DConstant::make(alloc, fval1); + + obj fval2 = DFloat::box(alloc, 2.0); + auto when_false_expr = DConstant::make(alloc, fval2); + + auto ifexpr = DIfElseExpr::make(alloc, test_expr, when_true_expr, when_false_expr); + REQUIRE(ifexpr.data() != nullptr); + + obj wt = ifexpr.data()->when_true(); + REQUIRE(wt.data() != nullptr); + REQUIRE(wt.extype() == xo::scm::exprtype::constant); + } + + TEST_CASE("DIfElseExpr-when-false", "[expression2][DIfElseExpr]") + { + REQUIRE(s_init.evidence()); + + X1CollectorConfig cfg{ + .name_ = "difelseexpr_when_false_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + obj bval = DBoolean::box(alloc, false); + auto test_expr = DConstant::make(alloc, bval); + + obj fval1 = DFloat::box(alloc, 1.0); + auto when_true_expr = DConstant::make(alloc, fval1); + + obj fval2 = DFloat::box(alloc, 2.0); + auto when_false_expr = DConstant::make(alloc, fval2); + + auto ifexpr = DIfElseExpr::make(alloc, test_expr, when_true_expr, when_false_expr); + REQUIRE(ifexpr.data() != nullptr); + + obj wf = ifexpr.data()->when_false(); + REQUIRE(wf.data() != nullptr); + REQUIRE(wf.extype() == xo::scm::exprtype::constant); + } + + TEST_CASE("DIfElseExpr-extype", "[expression2][DIfElseExpr]") + { + REQUIRE(s_init.evidence()); + + X1CollectorConfig cfg{ + .name_ = "difelseexpr_extype_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + obj bval = DBoolean::box(alloc, true); + auto test_expr = DConstant::make(alloc, bval); + + obj fval1 = DFloat::box(alloc, 1.0); + auto when_true_expr = DConstant::make(alloc, fval1); + + obj fval2 = DFloat::box(alloc, 2.0); + auto when_false_expr = DConstant::make(alloc, fval2); + + auto ifexpr = DIfElseExpr::make(alloc, test_expr, when_true_expr, when_false_expr); + REQUIRE(ifexpr.data() != nullptr); + REQUIRE(ifexpr.data()->extype() == xo::scm::exprtype::ifexpr); + } + + TEST_CASE("DIfElseExpr-valuetype", "[expression2][DIfElseExpr]") + { + REQUIRE(s_init.evidence()); + + X1CollectorConfig cfg{ + .name_ = "difelseexpr_valuetype_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + obj bval = DBoolean::box(alloc, true); + auto test_expr = DConstant::make(alloc, bval); + + obj fval1 = DFloat::box(alloc, 1.0); + auto when_true_expr = DConstant::make(alloc, fval1); + + obj fval2 = DFloat::box(alloc, 2.0); + auto when_false_expr = DConstant::make(alloc, fval2); + + auto ifexpr = DIfElseExpr::make(alloc, test_expr, when_true_expr, when_false_expr); + REQUIRE(ifexpr.data() != nullptr); + + // valuetype may be null before type resolution + // just verify we can call it + ifexpr.data()->valuetype(); + } + + TEST_CASE("DIfElseExpr-pretty", "[expression2][DIfElseExpr][pp]") + { + scope log(XO_DEBUG(true)); + + REQUIRE(s_init.evidence()); + + X1CollectorConfig cfg{ + .name_ = "difelseexpr_pretty_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + obj bval = DBoolean::box(alloc, true); + auto test_expr = DConstant::make(alloc, bval); + + obj fval1 = DFloat::box(alloc, 1.0); + auto when_true_expr = DConstant::make(alloc, fval1); + + obj fval2 = DFloat::box(alloc, 2.0); + auto when_false_expr = DConstant::make(alloc, fval2); + + auto ifexpr = DIfElseExpr::make(alloc, + test_expr, + when_true_expr, when_false_expr); + REQUIRE(ifexpr.data() != nullptr); + + std::stringstream ss; + ppconfig ppc; + ppstate_standalone pps(&ss, 0, &ppc); + + obj ifexpr_pr(ifexpr.data()); + pps.pretty(ifexpr_pr); + + std::string output = ss.str(); + + log && log(output); + + CHECK(output.find("DIfElseExpr") != std::string::npos); + } +} + +/* end DIfElseExpr.test.cpp */ diff --git a/xo-expression2/utest/DVariable.test.cpp b/xo-expression2/utest/DVariable.test.cpp new file mode 100644 index 00000000..31f11301 --- /dev/null +++ b/xo-expression2/utest/DVariable.test.cpp @@ -0,0 +1,227 @@ +/** @file DVariable.test.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include "init_expression2.hpp" +#include +//#include +//#include + +#include + +#include +#include + +#include + +#include +#include + +#include + +#include + +#include +#include + +namespace ut { + using xo::S_expression2_tag; + using xo::scm::DVariable; + using xo::scm::DUniqueString; + using xo::scm::StringTable; + using xo::scm::TypeRef; + using xo::scm::Binding; + using xo::scm::AExpression; + using xo::mm::CollectorTypeRegistry; + using xo::mm::AAllocator; + using xo::mm::ACollector; + using xo::mm::DX1Collector; + using xo::mm::X1CollectorConfig; + using xo::mm::ArenaConfig; + using xo::print::APrintable; + using xo::print::ppstate_standalone; + using xo::print::ppconfig; + using xo::facet::FacetRegistry; + using xo::facet::with_facet; + using xo::facet::obj; + using xo::reflect::Reflect; + using xo::InitEvidence; + using xo::InitSubsys; + using xo::scope; + + static InitEvidence s_init = InitSubsys::require(); + + TEST_CASE("DVariable-init", "[expression2][DVariable]") + { + REQUIRE(s_init.evidence()); + } + + TEST_CASE("DVariable-make", "[expression2][DVariable]") + { + REQUIRE(s_init.evidence()); + + X1CollectorConfig cfg{ + .name_ = "dvariable_make_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + StringTable table(1024); + const DUniqueString * name = table.intern("x"); + REQUIRE(name != nullptr); + + TypeRef typeref = TypeRef::resolved(Reflect::require()); + + DVariable * var = DVariable::make(alloc, name, typeref); + REQUIRE(var != nullptr); + } + + TEST_CASE("DVariable-extype", "[expression2][DVariable]") + { + REQUIRE(s_init.evidence()); + + X1CollectorConfig cfg{ + .name_ = "dvariable_extype_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + StringTable table(1024); + const DUniqueString * name = table.intern("y"); + TypeRef typeref = TypeRef::resolved(Reflect::require()); + + DVariable * var = DVariable::make(alloc, name, typeref); + REQUIRE(var != nullptr); + REQUIRE(var->extype() == xo::scm::exprtype::variable); + } + + TEST_CASE("DVariable-valuetype", "[expression2][DVariable]") + { + REQUIRE(s_init.evidence()); + + X1CollectorConfig cfg{ + .name_ = "dvariable_valuetype_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + StringTable table(1024); + const DUniqueString * name = table.intern("z"); + TypeRef typeref = TypeRef::resolved(Reflect::require()); + + DVariable * var = DVariable::make(alloc, name, typeref); + REQUIRE(var != nullptr); + REQUIRE(var->valuetype() == Reflect::require()); + } + + TEST_CASE("DVariable-name", "[expression2][DVariable]") + { + REQUIRE(s_init.evidence()); + + X1CollectorConfig cfg{ + .name_ = "dvariable_name_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + StringTable table(1024); + const DUniqueString * name = table.intern("myvar"); + TypeRef typeref = TypeRef::resolved(Reflect::require()); + + DVariable * var = DVariable::make(alloc, name, typeref); + REQUIRE(var != nullptr); + REQUIRE(var->name() == name); + REQUIRE(std::strcmp(var->name()->chars(), "myvar") == 0); + } + + TEST_CASE("DVariable-pretty", "[expression2][DVariable][pp]") + { + scope log(XO_DEBUG(false)); + + REQUIRE(s_init.evidence()); + + X1CollectorConfig cfg{ + .name_ = "dvariable_pretty_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + StringTable table(1024); + const DUniqueString * name = table.intern("foo"); + TypeRef typeref = TypeRef::resolved(Reflect::require()); + + DVariable * var = DVariable::make(alloc, name, typeref); + REQUIRE(var != nullptr); + + std::stringstream ss; + ppconfig ppc; + ppstate_standalone pps(&ss, 0, &ppc); + + obj var_pr(var); + pps.pretty(var_pr); + + std::string output = ss.str(); + + log && log(output); + + CHECK(output.find("DVariable") != std::string::npos); + } +} + +/* end DVariable.test.cpp */ diff --git a/xo-expression2/utest/X1Collector.test.cpp b/xo-expression2/utest/X1Collector.test.cpp new file mode 100644 index 00000000..9534667e --- /dev/null +++ b/xo-expression2/utest/X1Collector.test.cpp @@ -0,0 +1,112 @@ +/** @file X1Collector.test.cpp + * + * Minimal collector test for DUniqueString + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include "init_expression2.hpp" + +#include +#include +#include + +#include + +#include +#include +#include + +#include +#include + +#include + +#include + +namespace ut { + using xo::S_expression2_tag; + using xo::scm::StringTable; + using xo::scm::DUniqueString; + using xo::scm::DFloat; + using xo::scm::DInteger; + using xo::scm::DList; + using xo::scm::DString; + using xo::mm::CollectorTypeRegistry; + using xo::mm::AAllocator; + using xo::mm::ACollector; + using xo::mm::AGCObject; + using xo::mm::DX1Collector; + using xo::mm::X1CollectorConfig; + using xo::mm::ArenaConfig; + using xo::facet::with_facet; + using xo::facet::typeseq; + using xo::InitEvidence; + using xo::InitSubsys; + + // Ensure subsystem initialized before tests + static InitEvidence s_init = InitSubsys::require(); + + TEST_CASE("x1_duniquestring", "[gc][x1][expression2]") + { + REQUIRE(s_init.evidence()); + + // Create collector + X1CollectorConfig cfg{ .name_ = "x1_duniquestring_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{1024, 1024}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + + auto gc_o = with_facet::mkobj(&gc); + auto c_o = with_facet::mkobj(&gc); + + // Install types from CollectorTypeRegistry + bool ok = CollectorTypeRegistry::instance().install_types(c_o); + REQUIRE(ok); + + // Verify types from object2 are installed + ok = c_o.is_type_installed(typeseq::id()); + REQUIRE(ok); + ok = c_o.is_type_installed(typeseq::id()); + REQUIRE(ok); + ok = c_o.is_type_installed(typeseq::id()); + REQUIRE(ok); + ok = c_o.is_type_installed(typeseq::id()); + REQUIRE(ok); + + // Verify DUniqueString from expression2 is installed + ok = c_o.is_type_installed(typeseq::id()); + REQUIRE(ok); + + // Create DUniqueString via StringTable + StringTable table(1024); + const DUniqueString * ustr = table.intern("hello"); + REQUIRE(ustr != nullptr); + REQUIRE(ustr->size() == 5); + + // Wrap as obj + // Note: const_cast is safe here since DUniqueString is immutable by design, + // and we're only wrapping for facet access, not modification + auto ustr_o = with_facet::mkobj(const_cast(ustr)); + REQUIRE(ustr_o.iface() != nullptr); + REQUIRE(ustr_o.data() != nullptr); + + // verify unique string contents + REQUIRE(strcmp(ustr_o.data()->chars(), "hello") == 0); + + // Add as gc root + c_o.add_gc_root(&ustr_o); + + // Verify string content accessible through wrapped object + REQUIRE(ustr_o.data()->size() == 5); + REQUIRE(std::strcmp(ustr_o.data()->chars(), "hello") == 0); + } +} + +/* end X1Collector.test.cpp */ diff --git a/xo-expression2/utest/expression2_utest_main.cpp b/xo-expression2/utest/expression2_utest_main.cpp new file mode 100644 index 00000000..004d2598 --- /dev/null +++ b/xo-expression2/utest/expression2_utest_main.cpp @@ -0,0 +1,24 @@ +/* file expression2_utest_main.cpp */ + +#include + +#define CATCH_CONFIG_RUNNER +#include "catch2/catch.hpp" + +int +main(int argc, char* argv[]) +{ + using xo::Subsystem; + + // Your custom initialization code here + Subsystem::initialize_all(); + + // Run Catch2's test session + int result = Catch::Session().run(argc, argv); + + // cleanup here, if any + + return result; +} + +/* end expression2_utest_main.cpp */