xo-reader: feat: + var lookup in envframestack, psm
This commit is contained in:
parent
3b57a1f142
commit
eed5cdf691
4 changed files with 51 additions and 0 deletions
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue