Equip parser_t with a variable stack

Prepares to eliminate env_get and env_set by accessing variables through
a parser.
This commit is contained in:
ridiculousfish 2018-09-10 01:17:57 -07:00
parent bba66a3ecc
commit a47f6859bd
2 changed files with 7 additions and 2 deletions

View File

@ -100,7 +100,7 @@ static wcstring user_presentable_path(const wcstring &path) {
return replace_home_directory_with_tilde(path);
}
parser_t::parser_t() = default;
parser_t::parser_t() : variables(env_stack_t::principal()) {}
// Out of line destructor to enable forward declaration of parse_execution_context_t
parser_t::~parser_t() = default;

View File

@ -173,7 +173,8 @@ class parser_t {
std::vector<std::unique_ptr<block_t>> block_stack;
/// The 'depth' of the fish call stack.
int eval_level = -1;
/// Set of variables for the parser.
env_stack_t &variables;
#if 0
// TODO: Lint says this isn't used (which is true). Should this be removed?
/// Gets a description of the block stack, for debugging.
@ -271,6 +272,10 @@ class parser_t {
/// Get the list of jobs.
job_list_t &job_list() { return my_job_list; }
/// Get the variables.
env_stack_t &vars() { return variables; }
const env_stack_t &vars() const { return variables; }
/// Pushes a new block created with the given arguments
/// Returns a pointer to the block. The pointer is valid
/// until the call to pop_block()