Switch parser_t to hold its variables via shared_ptr

Preparation for variable stacks with finite lifetimes.
This commit is contained in:
ridiculousfish
2019-05-20 09:27:46 -07:00
parent 261198aa3e
commit ad57133c7f
4 changed files with 14 additions and 7 deletions

View File

@@ -100,7 +100,11 @@ wcstring parser_t::user_presentable_path(const wcstring &path) const {
return replace_home_directory_with_tilde(path, vars());
}
parser_t::parser_t() : variables(env_stack_t::principal()) {}
parser_t::parser_t(std::shared_ptr<env_stack_t> vars) : variables(std::move(vars)) {
assert(variables.get() && "Null variables in parser initializer");
}
parser_t::parser_t() : parser_t(env_stack_t::principal_ref()) {}
// Out of line destructor to enable forward declaration of parse_execution_context_t
parser_t::~parser_t() = default;