Commit 48bbd1a7 authored by neis's avatar neis Committed by Commit bot

[parser,ast] Simplify MarkExpressionAsAssigned.

There's no need to return anything.

Also add a DCHECK to make sure that we never mark a variable proxy as assigned
that is already resolved (to avoid potential inconsistency with the variable's
maybe_assigned status).

R=littledan@chromium.org
CC=mstarzinger@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/2504613002
Cr-Commit-Position: refs/heads/master@{#41072}
parent 020e2c8d
......@@ -1662,6 +1662,7 @@ class VariableProxy final : public Expression {
bool is_assigned() const { return IsAssignedField::decode(bit_field_); }
void set_is_assigned() {
DCHECK(!is_resolved());
bit_field_ = IsAssignedField::update(bit_field_, true);
}
......
......@@ -2732,7 +2732,7 @@ ParserBase<Impl>::ParseAssignmentExpression(bool accept_IN, bool* ok) {
MessageTemplate::kInvalidLhsInAssignment, CHECK_OK);
}
expression = impl()->MarkExpressionAsAssigned(expression);
impl()->MarkExpressionAsAssigned(expression);
Token::Value op = Next(); // Get assignment operator.
if (op != Token::ASSIGN) {
......@@ -2973,7 +2973,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseUnaryExpression(
expression = CheckAndRewriteReferenceExpression(
expression, beg_pos, scanner()->location().end_pos,
MessageTemplate::kInvalidLhsInPrefixOp, CHECK_OK);
expression = impl()->MarkExpressionAsAssigned(expression);
impl()->MarkExpressionAsAssigned(expression);
impl()->RewriteNonPattern(CHECK_OK);
return factory()->NewCountOperation(op,
......@@ -3013,7 +3013,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParsePostfixExpression(
expression = CheckAndRewriteReferenceExpression(
expression, lhs_beg_pos, scanner()->location().end_pos,
MessageTemplate::kInvalidLhsInPostfixOp, CHECK_OK);
expression = impl()->MarkExpressionAsAssigned(expression);
impl()->MarkExpressionAsAssigned(expression);
impl()->RewriteNonPattern(CHECK_OK);
Token::Value next = Next();
......
......@@ -824,12 +824,11 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) {
// Determine if the expression is a variable proxy and mark it as being used
// in an assignment or with a increment/decrement operator.
V8_INLINE static Expression* MarkExpressionAsAssigned(
Expression* expression) {
VariableProxy* proxy =
expression != NULL ? expression->AsVariableProxy() : NULL;
if (proxy != NULL) proxy->set_is_assigned();
return expression;
V8_INLINE static void MarkExpressionAsAssigned(Expression* expression) {
DCHECK_NOT_NULL(expression);
if (expression->IsVariableProxy()) {
expression->AsVariableProxy()->set_is_assigned();
}
}
// Returns true if we have a binary expression between two numeric
......
......@@ -1205,11 +1205,10 @@ class PreParser : public ParserBase<PreParser> {
V8_INLINE static void CheckAssigningFunctionLiteralToProperty(
PreParserExpression left, PreParserExpression right) {}
V8_INLINE static PreParserExpression MarkExpressionAsAssigned(
V8_INLINE static void MarkExpressionAsAssigned(
PreParserExpression expression) {
// TODO(marja): To be able to produce the same errors, the preparser needs
// to start tracking which expressions are variables and which are assigned.
return expression;
}
V8_INLINE bool ShortcutNumericLiteralBinaryExpression(PreParserExpression* x,
......
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