xo-expression: + binding_path + assoc w/ each Variable

This commit is contained in:
Roland Conybeare 2024-07-02 16:57:07 -04:00
commit 14796663b1
8 changed files with 105 additions and 3 deletions

View file

@ -0,0 +1,31 @@
/* file LocalEnv.cpp
*
* author: Roland Conybeare
*/
#include "LocalEnv.hpp"
namespace xo {
namespace ast {
binding_path
LocalEnv::lookup_binding(const std::string & vname) const
{
int j_slot = 0;
for (const auto & arg : argv_) {
if (arg->name() == vname)
return { 0 /*i_link*/, j_slot };
++j_slot;
}
auto tmp = parent_env_->lookup_binding(vname);
if (tmp.i_link_ == -1)
return tmp;
else
return { tmp.i_link_ + 1, tmp.j_slot_ };
} /*lookup_binding*/
} /*namespace ast*/
} /*namespace xo*/
/* end LocalEnv.cpp */