xo-reader: feat: + var lookup in envframestack, psm

This commit is contained in:
Roland Conybeare 2024-08-19 18:11:28 -04:00
commit eed5cdf691
4 changed files with 51 additions and 0 deletions

View file

@ -6,6 +6,8 @@
#include "envframestack.hpp"
namespace xo {
using xo::ast::Variable;
namespace scm {
envframe &
envframestack::top_envframe() {
@ -50,6 +52,20 @@ namespace xo {
}
}
rp<Variable>
envframestack::lookup(const std::string & x) const {
for (std::size_t i = 0, z = this->size(); i < z; ++i) {
const auto & frame = (*this)[i];
auto retval = frame.lookup(x);
if (retval)
return retval;
}
return nullptr;
}
void
envframestack::print(std::ostream & os) const {
os << "<envframestack"