2020-09-08 18:38:05 -07:00
|
|
|
#include "env.hpp"
|
2020-09-09 17:19:23 -07:00
|
|
|
#include <cassert>
|
2020-09-08 18:38:05 -07:00
|
|
|
|
|
|
|
int env_var::get_offset(const std::string& name) const {
|
|
|
|
if(name == this->name) return 0;
|
2020-09-09 17:19:23 -07:00
|
|
|
assert(parent);
|
|
|
|
return parent->get_offset(name) + 1;
|
2020-09-08 18:38:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool env_var::has_variable(const std::string& name) const {
|
|
|
|
if(name == this->name) return true;
|
|
|
|
if(parent) return parent->has_variable(name);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
int env_offset::get_offset(const std::string& name) const {
|
2020-09-09 17:19:23 -07:00
|
|
|
assert(parent);
|
|
|
|
return parent->get_offset(name) + offset;
|
2020-09-08 18:38:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool env_offset::has_variable(const std::string& name) const {
|
|
|
|
if(parent) return parent->has_variable(name);
|
|
|
|
return false;
|
|
|
|
}
|