Move eval_level into parser_t

This avoids the ping-ponging of eval_level through
parse_execution_context. Simply store the global eval level in the
parser_t.
This commit is contained in:
ridiculousfish
2018-02-11 21:42:23 -08:00
parent 8bddce2633
commit 92d5c28730
4 changed files with 9 additions and 20 deletions

View File

@@ -695,15 +695,8 @@ int parser_t::eval_node(parsed_source_ref_t ps, tnode_t<T> node, const io_chain_
// Start it up
scope_block_t *scope_block = this->push_block<scope_block_t>(block_type);
// Determine the initial eval level. If this is the first context, it's -1; otherwise it's the
// eval level of the top context. This is sort of wonky because we're stitching together a
// global notion of eval level from these separate objects. A better approach would be some
// profile object that all contexts share, and that tracks the eval levels on its own.
int exec_eval_level =
(execution_contexts.empty() ? -1 : execution_contexts.back()->current_eval_level());
// Append to the execution context stack.
execution_contexts.push_back(make_unique<parse_execution_context_t>(ps, this, exec_eval_level));
execution_contexts.push_back(make_unique<parse_execution_context_t>(ps, this));
parse_execution_context_t *ctx = execution_contexts.back().get();
int result = ctx->eval_node(node, scope_block, io);