From 5ac3c03a0ccfa8e4e320955b2589423a17c5e5ba Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 9 May 2025 00:03:08 -0500 Subject: [PATCH] xo-expression: + captured-var methods --- include/xo/expression/Lambda.hpp | 2 ++ include/xo/expression/LocalEnv.hpp | 1 + 2 files changed, 3 insertions(+) diff --git a/include/xo/expression/Lambda.hpp b/include/xo/expression/Lambda.hpp index 668d1303..452cafc9 100644 --- a/include/xo/expression/Lambda.hpp +++ b/include/xo/expression/Lambda.hpp @@ -40,7 +40,9 @@ namespace xo { const std::vector> & argv() const { return local_env_->argv(); } const rp & body() const { return body_; } + const std::string& i_argname(int i_arg) const { return local_env_->lookup_arg(i_arg)->name(); } bool needs_closure_flag() const { return !free_var_set_.empty(); } + bool is_captured(const std::string& var) const { return (captured_var_set_.find(var) != captured_var_set_.end()); } // ----- FunctionInterface ----- diff --git a/include/xo/expression/LocalEnv.hpp b/include/xo/expression/LocalEnv.hpp index d4facdba..603bbfda 100644 --- a/include/xo/expression/LocalEnv.hpp +++ b/include/xo/expression/LocalEnv.hpp @@ -32,6 +32,7 @@ namespace xo { Lambda * origin() const { return origin_; } const std::vector> & argv() const { return argv_; } + const rp& lookup_arg(int i) const { return argv_[i]; } int n_arg() const { return argv_.size(); } TypeDescr fn_arg(uint32_t i) const { return argv_[i]->valuetype(); }