From 0595c7c74e3806f5e1783e9d6dc361543aee3c63 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 18 Jun 2024 17:23:32 -0400 Subject: [PATCH] xo-expression: refactor: enforce Lambda.argv must contain Variables --- include/xo/expression/Lambda.hpp | 11 ++++++----- src/expression/Lambda.cpp | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/include/xo/expression/Lambda.hpp b/include/xo/expression/Lambda.hpp index ed88b44e..cdf72ed9 100644 --- a/include/xo/expression/Lambda.hpp +++ b/include/xo/expression/Lambda.hpp @@ -6,6 +6,7 @@ #pragma once #include "Expression.hpp" +#include "Variable.hpp" #include #include //#include @@ -24,7 +25,7 @@ namespace xo { * @p body Expression for body of this function **/ static ref::rp make(const std::string & name, - const std::vector> & argv, + const std::vector> & argv, const ref::rp & body); /** downcast from Expression **/ @@ -34,7 +35,7 @@ namespace xo { const std::string & name() const { return name_; } const std::string & type_str() const { return type_str_; } - const std::vector> & argv() const { return argv_; } + const std::vector> & argv() const { return argv_; } const ref::rp & body() const { return body_; } /** return number of arguments expected by this function **/ @@ -50,7 +51,7 @@ namespace xo { **/ Lambda(const std::string & name, TypeDescr lambda_type, - const std::vector> & argv, + const std::vector> & argv, const ref::rp & body); private: @@ -67,14 +68,14 @@ namespace xo { **/ std::string type_str_; /** formal argument names **/ - std::vector> argv_; + std::vector> argv_; /** function body **/ ref::rp body_; }; /*Lambda*/ inline ref::rp make_lambda(const std::string & name, - const std::vector> & argv, + const std::vector> & argv, const ref::rp & body) { return Lambda::make(name, argv, body); diff --git a/src/expression/Lambda.cpp b/src/expression/Lambda.cpp index acc40cbe..d92ac801 100644 --- a/src/expression/Lambda.cpp +++ b/src/expression/Lambda.cpp @@ -14,7 +14,7 @@ namespace xo { namespace ast { rp Lambda::make(const std::string & name, - const std::vector> & argv, + const std::vector> & argv, const ref::rp & body) { using xo::reflect::FunctionTdx; @@ -47,7 +47,7 @@ namespace xo { Lambda::Lambda(const std::string & name, TypeDescr lambda_type, - const std::vector> & argv, + const std::vector> & argv, const ref::rp & body) : Expression(exprtype::lambda, lambda_type), name_{name},