parsed_source_t to hold an ast directly instead of through unique_ptr

We have untangled the dependency loop and so now parsed_source_t no longer
requires indirection.
This commit is contained in:
ridiculousfish 2020-07-07 16:16:45 -07:00
parent 5308223212
commit 71a8eb0aa4
4 changed files with 5 additions and 4 deletions

View File

@ -164,7 +164,7 @@ class parse_execution_context_t {
const wcstring &get_source() const { return pstree->src; }
/// Return the parsed ast.
const ast::ast_t &ast() const { return *pstree->ast; }
const ast::ast_t &ast() const { return pstree->ast; }
/// Start executing at the given node. Returns 0 if there was no error, 1 if there was an
/// error.

View File

@ -203,7 +203,7 @@ wcstring parse_token_t::user_presentable_description() const {
}
parsed_source_t::parsed_source_t(wcstring s, ast::ast_t &&ast)
: src(std::move(s)), ast(make_unique<ast::ast_t>(std::move(ast))) {}
: src(std::move(s)), ast(std::move(ast)) {}
parsed_source_t::~parsed_source_t() = default;

View File

@ -10,6 +10,7 @@
#include <memory>
#include <vector>
#include "ast.h"
#include "common.h"
#include "maybe.h"
#include "parse_constants.h"
@ -62,7 +63,7 @@ class ast_t;
/// A type wrapping up a parse tree and the original source behind it.
struct parsed_source_t {
wcstring src;
std::unique_ptr<ast::ast_t> ast;
ast::ast_t ast;
parsed_source_t(wcstring s, ast::ast_t &&ast);
~parsed_source_t();

View File

@ -655,7 +655,7 @@ eval_res_t parser_t::eval(const wcstring &cmd, const io_chain_t &io,
eval_res_t parser_t::eval(const parsed_source_ref_t &ps, const io_chain_t &io,
const job_group_ref_t &job_group, enum block_type_t block_type) {
assert(block_type == block_type_t::top || block_type == block_type_t::subst);
const auto *job_list = ps->ast->top()->as<ast::job_list_t>();
const auto *job_list = ps->ast.top()->as<ast::job_list_t>();
if (!job_list->empty()) {
// Execute the top job list.
return this->eval_node(ps, *job_list, io, job_group, block_type);