Commit ea518290 authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

[parser] Drop is_get and is_set parameters in ParsePropertyName

The two bool parameters are used for DCHECks in most places. By
introducing more specialized enumes kAccessorGetterProperty and
kAccessorSetterProperty we can simplify the checks.

Bug: v8:7926
Change-Id: I61023f2da0d96ca5a4fba65c6ead309567144786
Reviewed-on: https://chromium-review.googlesource.com/1202822
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55648}
parent 25d06d8b
This diff is collapsed.
...@@ -297,7 +297,7 @@ class Scanner { ...@@ -297,7 +297,7 @@ class Scanner {
inline bool CurrentMatchesContextual(Token::Value token) const { inline bool CurrentMatchesContextual(Token::Value token) const {
DCHECK(Token::IsContextualKeyword(token)); DCHECK(Token::IsContextualKeyword(token));
return current().contextual_token == token; return current_contextual_token() == token;
} }
// Match the token against the contextual keyword or literal buffer. // Match the token against the contextual keyword or literal buffer.
...@@ -308,7 +308,7 @@ class Scanner { ...@@ -308,7 +308,7 @@ class Scanner {
// (which was escape-processed already). // (which was escape-processed already).
// Conveniently, !current().literal_chars.is_used() for all proper // Conveniently, !current().literal_chars.is_used() for all proper
// keywords, so this second condition should exit early in common cases. // keywords, so this second condition should exit early in common cases.
return (current().contextual_token == token) || return (current_contextual_token() == token) ||
(current().literal_chars.is_used() && (current().literal_chars.is_used() &&
current().literal_chars.Equals(Vector<const char>( current().literal_chars.Equals(Vector<const char>(
Token::String(token), Token::StringLength(token)))); Token::String(token), Token::StringLength(token))));
...@@ -320,11 +320,9 @@ class Scanner { ...@@ -320,11 +320,9 @@ class Scanner {
Vector<const char>("use strict", strlen("use strict"))); Vector<const char>("use strict", strlen("use strict")));
} }
bool IsGetOrSet(bool* is_get, bool* is_set) const { bool IsGet() { return CurrentMatchesContextual(Token::GET); }
*is_get = CurrentMatchesContextual(Token::GET);
*is_set = CurrentMatchesContextual(Token::SET); bool IsSet() { return CurrentMatchesContextual(Token::SET); }
return *is_get || *is_set;
}
bool IsLet() const { bool IsLet() const {
return CurrentMatches(Token::LET) || return CurrentMatches(Token::LET) ||
......
...@@ -244,6 +244,7 @@ class Token { ...@@ -244,6 +244,7 @@ class Token {
static bool IsAssignmentOp(Value tok) { static bool IsAssignmentOp(Value tok) {
return IsInRange(tok, INIT, ASSIGN_EXP); return IsInRange(tok, INIT, ASSIGN_EXP);
} }
static bool IsGetOrSet(Value op) { return IsInRange(op, GET, SET); }
static bool IsBinaryOp(Value op) { return IsInRange(op, COMMA, EXP); } static bool IsBinaryOp(Value op) { return IsInRange(op, COMMA, EXP); }
......
...@@ -63,8 +63,11 @@ inline bool IsInRange(T value, U lower_limit, U higher_limit) { ...@@ -63,8 +63,11 @@ inline bool IsInRange(T value, U lower_limit, U higher_limit) {
DCHECK_LE(lower_limit, higher_limit); DCHECK_LE(lower_limit, higher_limit);
STATIC_ASSERT(sizeof(U) <= sizeof(T)); STATIC_ASSERT(sizeof(U) <= sizeof(T));
typedef typename std::make_unsigned<T>::type unsigned_T; typedef typename std::make_unsigned<T>::type unsigned_T;
return static_cast<unsigned_T>(value - lower_limit) <= // Use static_cast to support enum classes.
static_cast<unsigned_T>(higher_limit - lower_limit); return static_cast<unsigned_T>(static_cast<unsigned_T>(value) -
static_cast<unsigned_T>(lower_limit)) <=
static_cast<unsigned_T>(static_cast<unsigned_T>(higher_limit) -
static_cast<unsigned_T>(lower_limit));
} }
// X must be a power of 2. Returns the number of trailing zeros. // X must be a power of 2. Returns the number of trailing zeros.
......
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