Commit 57f0ca07 authored by Adam Klein's avatar Adam Klein Committed by Commit Bot

[parser|cleanup] Remove Variable* accessors from FunctionState

These accessors are only called from the Parser, never ParserBase, so
there's no need to expose them in parser-base.h. Instead, access them
through FunctionState::scope().

This also allows removal of the Types::Variable typedefs.

Bug: v8:6460
Change-Id: I01186c53d3cc2a2737f3c07169fdd122dff5b174
Reviewed-on: https://chromium-review.googlesource.com/530034Reviewed-by: 's avatarSathya Gunasekaran <gsathya@chromium.org>
Commit-Queue: Adam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45879}
parent 2094202b
......@@ -429,14 +429,6 @@ class ParserBase {
FunctionKind kind() const { return scope()->function_kind(); }
FunctionState* outer() const { return outer_function_state_; }
typename Types::Variable* generator_object_variable() const {
return scope()->generator_object_var();
}
typename Types::Variable* promise_variable() const {
return scope()->promise_var();
}
void RewindDestructuringAssignments(int pos) {
destructuring_assignments_to_rewrite_.Rewind(pos);
}
......
......@@ -392,8 +392,8 @@ Expression* Parser::NewTargetExpression(int pos) {
Expression* Parser::FunctionSentExpression(int pos) {
// We desugar function.sent into %_GeneratorGetInputOrDebugPos(generator).
ZoneList<Expression*>* args = new (zone()) ZoneList<Expression*>(1, zone());
VariableProxy* generator =
factory()->NewVariableProxy(function_state_->generator_object_variable());
VariableProxy* generator = factory()->NewVariableProxy(
function_state_->scope()->generator_object_var());
args->Add(generator, zone());
return factory()->NewCallRuntime(Runtime::kInlineGeneratorGetInputOrDebugPos,
args, pos);
......@@ -1817,8 +1817,8 @@ void Parser::ParseAndRewriteAsyncGeneratorFunctionBody(
ZoneList<Expression*>* reject_args =
new (zone()) ZoneList<Expression*>(2, zone());
reject_args->Add(
factory()->NewVariableProxy(function_state_->generator_object_variable()),
reject_args->Add(factory()->NewVariableProxy(
function_state_->scope()->generator_object_var()),
zone());
reject_args->Add(factory()->NewVariableProxy(catch_scope->catch_variable()),
zone());
......@@ -1838,8 +1838,8 @@ void Parser::ParseAndRewriteAsyncGeneratorFunctionBody(
factory()->NewBlock(nullptr, 1, false, kNoSourcePosition);
ZoneList<Expression*>* close_args =
new (zone()) ZoneList<Expression*>(1, zone());
VariableProxy* call_proxy =
factory()->NewVariableProxy(function_state_->generator_object_variable());
VariableProxy* call_proxy = factory()->NewVariableProxy(
function_state_->scope()->generator_object_var());
close_args->Add(call_proxy, zone());
Expression* close_call = factory()->NewCallRuntime(
Runtime::kInlineGeneratorClose, close_args, kNoSourcePosition);
......@@ -3141,8 +3141,8 @@ Variable* Parser::PromiseVariable() {
// Based on the various compilation paths, there are many different code
// paths which may be the first to access the Promise temporary. Whichever
// comes first should create it and stash it in the FunctionState.
Variable* promise = function_state_->promise_variable();
if (function_state_->promise_variable() == nullptr) {
Variable* promise = function_state_->scope()->promise_var();
if (promise == nullptr) {
promise = function_state_->scope()->DeclarePromiseVar(
ast_value_factory()->empty_string());
}
......@@ -3159,8 +3159,8 @@ Variable* Parser::AsyncGeneratorAwaitVariable() {
}
Expression* Parser::BuildInitialYield(int pos, FunctionKind kind) {
Expression* yield_result =
factory()->NewVariableProxy(function_state_->generator_object_variable());
Expression* yield_result = factory()->NewVariableProxy(
function_state_->scope()->generator_object_var());
// The position of the yield is important for reporting the exception
// caused by calling the .throw method on a generator suspended at the
// initial yield (i.e. right after generator instantiation).
......@@ -3822,7 +3822,7 @@ void Parser::PrepareAsyncFunctionBody(ZoneList<Statement*>* body,
FunctionKind kind, int pos) {
// When parsing an async arrow function, we get here without having called
// PrepareGeneratorVariables yet, so do it now.
if (function_state_->generator_object_variable() == nullptr) {
if (function_state_->scope()->generator_object_var() == nullptr) {
PrepareGeneratorVariables();
}
}
......@@ -3874,7 +3874,7 @@ Expression* Parser::RewriteAwaitExpression(Expression* value, int await_pos) {
// for anything, but exists because of the current requirement that
// Do Expressions have a result variable.
Variable* generator_object_variable =
function_state_->generator_object_variable();
function_state_->scope()->generator_object_var();
DCHECK_NOT_NULL(generator_object_variable);
const int nopos = kNoSourcePosition;
......@@ -4471,7 +4471,7 @@ Expression* Parser::RewriteYieldStar(Expression* iterable, int pos) {
ZoneList<Expression*>* args = new (zone()) ZoneList<Expression*>(1, zone());
VariableProxy* generator = factory()->NewVariableProxy(
function_state_->generator_object_variable());
function_state_->scope()->generator_object_var());
args->Add(generator, zone());
Expression* mode = factory()->NewCallRuntime(
Runtime::kInlineGeneratorGetResumeMode, args, pos);
......
......@@ -156,8 +156,6 @@ struct ParserTypes<Parser> {
typedef ParserBase<Parser> Base;
typedef Parser Impl;
typedef v8::internal::Variable Variable;
// Return types for traversing functions.
typedef const AstRawString* Identifier;
typedef v8::internal::Expression* Expression;
......
......@@ -842,9 +842,6 @@ struct ParserTypes<PreParser> {
typedef ParserBase<PreParser> Base;
typedef PreParser Impl;
// PreParser doesn't need to store generator variables.
typedef void Variable;
// Return types for traversing functions.
typedef PreParserIdentifier Identifier;
typedef PreParserExpression Expression;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment