From 0d23fa97b8d3a8661a9d6829ea14a310e02250e3 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 26 Jan 2026 15:45:40 -0500 Subject: [PATCH] xo-expression2: + DApplyExpr::make --- xo-expression2/src/expression2/DApplyExpr.cpp | 32 +++++++++++++++++-- xo-reader2/src/reader2/DProgressSsm.cpp | 28 ++++++++++++++-- 2 files changed, 55 insertions(+), 5 deletions(-) diff --git a/xo-expression2/src/expression2/DApplyExpr.cpp b/xo-expression2/src/expression2/DApplyExpr.cpp index ce5e1951..ffc6372a 100644 --- a/xo-expression2/src/expression2/DApplyExpr.cpp +++ b/xo-expression2/src/expression2/DApplyExpr.cpp @@ -3,8 +3,9 @@ * @author Roland Conybeare, Jan 2026 **/ -#include "DApplyExpr.hpp" #include "Expression.hpp" +#include "DApplyExpr.hpp" +#include "detail/IExpression_DApplyExpr.hpp" #include #include @@ -15,7 +16,34 @@ namespace xo { using xo::mm::AGCObject; namespace scm { - /* incomplete! */ + 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}, diff --git a/xo-reader2/src/reader2/DProgressSsm.cpp b/xo-reader2/src/reader2/DProgressSsm.cpp index cfed858f..cc0fc14b 100644 --- a/xo-reader2/src/reader2/DProgressSsm.cpp +++ b/xo-reader2/src/reader2/DProgressSsm.cpp @@ -9,9 +9,15 @@ #include "DExpectExprSsm.hpp" #include "ssm/ISyntaxStateMachine_DExpectExprSsm.hpp" +#include +#include #include #include + +#include // for xo::scm::Primitives +#include + #ifdef NOT_YET #include "DApplySsm.hpp" #include "ssm/ISyntaxStateMachine_DApplySsm.hpp" @@ -1179,20 +1185,36 @@ namespace xo { break; case optype::op_multiply: -#ifdef NOT_YET { + auto pm_obj = with_facet::mkobj(&Primitives::s_mul_gco_gco_pm); + + auto fn_expr = DConstant::make(p_psm->expr_alloc(), pm_obj); + /* note: * 1. don't assume we know lhs_ / rhs_ value types yet. * perhaps have expression like * f(..) * g(..) * where f is the function that contains current ssm. + * * 2. consequence: we need representation for * polymorphic multiply on unknown numeric arguments. + * + * 3. TypeRef::dwim(..) is a placeholder. + * Plan to later provide abstract interpreter + * (ie compiler pass :) to drive type inference/unification + * + * 4. Alternatively could supply type-annotation syntax + * so human can assist inference; context here is we want + * to automate the boring stuff */ - DApplyExpr::make2(); + TypeRef tref = TypeRef::dwim + (TypeRef::prefix_type::from_chars("_mul_gco"), + nullptr); + + return DApplyExpr::make2(p_psm->expr_alloc(), + tref, fn_expr, lhs_, rhs_); } -#endif break; case optype::op_divide: