xo-expression: pref xo::bp to xo::ref::brw

This commit is contained in:
Roland Conybeare 2025-07-05 13:53:05 -05:00
commit a4b2299537
20 changed files with 66 additions and 60 deletions

View file

@ -74,7 +74,7 @@ namespace xo {
}
void
AssignExpr::attach_envs(ref::brw<Environment> p) {
AssignExpr::attach_envs(bp<Environment> p) {
lhs_->attach_envs(p);
rhs_->attach_envs(p);
}

View file

@ -4,6 +4,7 @@
*/
#include "DefineExpr.hpp"
#include "Variable.hpp"
namespace xo {
namespace ast {
@ -31,6 +32,12 @@ namespace xo {
this->free_var_set_ = this->calc_free_variables();
}
rp<Variable>
DefineExpr::lhs_variable() const
{
return Variable::make(lhs_name(), valuetype());
}
std::set<std::string>
DefineExpr::calc_free_variables() const
{

View file

@ -128,10 +128,10 @@ namespace xo {
this->body_
= (body_->xform_layer
([&var_map](ref::brw<Expression> x) -> rp<Expression>
([&var_map](bp<Expression> x) -> rp<Expression>
{
if (x->extype() == exprtype::variable) {
ref::brw<Variable> var = Variable::from(x);
bp<Variable> var = Variable::from(x);
auto ix = var_map.find(var->name());
if (ix == var_map.end()) {
@ -167,14 +167,14 @@ namespace xo {
this->free_var_set_ = this->calc_free_variables();
std::map<std::string, ref::brw<Lambda>> nested_lambda_map;
std::map<std::string, bp<Lambda>> nested_lambda_map;
{
this->body_->visit_layer
([&nested_lambda_map]
(ref::brw<Expression> expr)
(bp<Expression> expr)
{
if (expr->extype() == exprtype::lambda) {
ref::brw<Lambda> lm = Lambda::from(expr);
bp<Lambda> lm = Lambda::from(expr);
nested_lambda_map[lm->name()] = lm.get();
}
@ -245,14 +245,14 @@ namespace xo {
this->free_var_set_ = this->calc_free_variables();
std::map<std::string, ref::brw<Lambda>> nested_lambda_map;
std::map<std::string, bp<Lambda>> nested_lambda_map;
{
this->body_->visit_layer
([&nested_lambda_map]
(ref::brw<Expression> expr)
(bp<Expression> expr)
{
if (expr->extype() == exprtype::lambda) {
ref::brw<Lambda> lm = Lambda::from(expr);
bp<Lambda> lm = Lambda::from(expr);
nested_lambda_map[lm->name()] = lm.get();
}
@ -295,7 +295,7 @@ namespace xo {
} /*ctor*/
void
Lambda::attach_envs(ref::brw<Environment> p) {
Lambda::attach_envs(bp<Environment> p) {
local_env_->assign_parent(p);
/** establish a binding path for each variable **/

View file

@ -54,7 +54,7 @@ namespace xo {
}
void
Sequence::attach_envs(ref::brw<Environment> p) {
Sequence::attach_envs(bp<Environment> p) {
for (const auto & x : expr_v_)
x->attach_envs(p);
}

View file

@ -6,7 +6,7 @@
namespace xo {
namespace ast {
void
Variable::attach_envs(ref::brw<Environment> e) {
Variable::attach_envs(bp<Environment> e) {
/** e makes accessible all enclosing lexical scopes **/
if (this->path_.i_link_ == -2 /*sentinel*/) {
this->path_ = e->lookup_binding(this->name_);