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

@ -13,12 +13,21 @@ namespace xo {
* @brief A stack of envframe objects
**/
class envframestack {
public:
using Variable = xo::ast::Variable;
public:
envframestack() {}
bool empty() const { return stack_.empty(); }
std::size_t size() const { return stack_.size(); }
/** lookup variable in environment stack.
* Visit frames in fifo order, report first match;
* nullptr if no matches.
**/
rp<Variable> lookup(const std::string & x) const;
envframe & top_envframe();
void push_envframe(envframe x);
void pop_envframe();