V8 Project
v8::internal::Token Class Reference

#include <token.h>

+ Collaboration diagram for v8::internal::Token:

Public Types

enum  Value { NUM_TOKENS }
 

Static Public Member Functions

static const char * Name (Value tok)
 
static bool IsKeyword (Value tok)
 
static bool IsAssignmentOp (Value tok)
 
static bool IsBinaryOp (Value op)
 
static bool IsTruncatingBinaryOp (Value op)
 
static bool IsCompareOp (Value op)
 
static bool IsOrderedRelationalCompareOp (Value op)
 
static bool IsEqualityOp (Value op)
 
static bool IsInequalityOp (Value op)
 
static bool IsArithmeticCompareOp (Value op)
 
static Value NegateCompareOp (Value op)
 
static Value ReverseCompareOp (Value op)
 
static bool IsBitOp (Value op)
 
static bool IsUnaryOp (Value op)
 
static bool IsCountOp (Value op)
 
static bool IsShiftOp (Value op)
 
static const char * String (Value tok)
 
static int Precedence (Value tok)
 

Static Private Attributes

static const char *const name_ [NUM_TOKENS]
 
static const char *const string_ [NUM_TOKENS]
 
static const int8_t precedence_ [NUM_TOKENS]
 
static const char token_type [NUM_TOKENS]
 

Detailed Description

Definition at line 168 of file token.h.

Member Enumeration Documentation

◆ Value

Enumerator
NUM_TOKENS 

Definition at line 172 of file token.h.

172  {
173  TOKEN_LIST(T, T)
174  NUM_TOKENS
175  };
#define TOKEN_LIST(T, K)
Definition: token.h:28
#define T(name, string, precedence)
Definition: token.h:171

Member Function Documentation

◆ IsArithmeticCompareOp()

static bool v8::internal::Token::IsArithmeticCompareOp ( Value  op)
inlinestatic

Definition at line 218 of file token.h.

218  {
219  return IsOrderedRelationalCompareOp(op) ||
220  IsEqualityOp(op) || IsInequalityOp(op);
221  }
static bool IsInequalityOp(Value op)
Definition: token.h:214
static bool IsOrderedRelationalCompareOp(Value op)
Definition: token.h:206
static bool IsEqualityOp(Value op)
Definition: token.h:210

References IsEqualityOp(), IsInequalityOp(), and IsOrderedRelationalCompareOp().

Referenced by NegateCompareOp(), and ReverseCompareOp().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsAssignmentOp()

static bool v8::internal::Token::IsAssignmentOp ( Value  tok)
inlinestatic

Definition at line 190 of file token.h.

190  {
191  return INIT_VAR <= tok && tok <= ASSIGN_MOD;
192  }

Referenced by v8::internal::FINAL< kOperandKind, kNumCachedOperands >::Init(), and v8::internal::ParserBase< Traits >::ParseAssignmentExpression().

+ Here is the caller graph for this function:

◆ IsBinaryOp()

static bool v8::internal::Token::IsBinaryOp ( Value  op)
inlinestatic

Definition at line 194 of file token.h.

194  {
195  return COMMA <= op && op <= MOD;
196  }
#define COMMA

References COMMA.

Referenced by v8::internal::FINAL< kOperandKind, kNumCachedOperands >::BinaryOperation().

+ Here is the caller graph for this function:

◆ IsBitOp()

static bool v8::internal::Token::IsBitOp ( Value  op)
inlinestatic

Definition at line 257 of file token.h.

257  {
258  return (BIT_OR <= op && op <= SHR) || op == BIT_NOT;
259  }

◆ IsCompareOp()

static bool v8::internal::Token::IsCompareOp ( Value  op)
inlinestatic

◆ IsCountOp()

static bool v8::internal::Token::IsCountOp ( Value  op)
inlinestatic

Definition at line 265 of file token.h.

265  {
266  return op == INC || op == DEC;
267  }

Referenced by v8::internal::ParserBase< Traits >::ParsePostfixExpression(), and v8::internal::ParserBase< Traits >::ParseUnaryExpression().

+ Here is the caller graph for this function:

◆ IsEqualityOp()

static bool v8::internal::Token::IsEqualityOp ( Value  op)
inlinestatic

Definition at line 210 of file token.h.

210  {
211  return op == EQ || op == EQ_STRICT;
212  }

References v8::internal::EQ.

Referenced by v8::internal::HOptimizedGraphBuilder::BuildCompareInstruction(), IsArithmeticCompareOp(), v8::internal::FINAL< kOperandKind, kNumCachedOperands >::LimitFromPredecessorBlock::LimitIsIncluded(), v8::internal::MatchLiteralCompareNull(), v8::internal::MatchLiteralCompareTypeof(), and v8::internal::MatchLiteralCompareUndefined().

+ Here is the caller graph for this function:

◆ IsInequalityOp()

static bool v8::internal::Token::IsInequalityOp ( Value  op)
inlinestatic

Definition at line 214 of file token.h.

214  {
215  return op == NE || op == NE_STRICT;
216  }

Referenced by IsArithmeticCompareOp().

+ Here is the caller graph for this function:

◆ IsKeyword()

static bool v8::internal::Token::IsKeyword ( Value  tok)
inlinestatic

Definition at line 186 of file token.h.

186  {
187  return token_type[tok] == 'K';
188  }
static const char token_type[NUM_TOKENS]
Definition: token.h:292

References token_type.

Referenced by v8::internal::ParserBase< Traits >::ParseIdentifierName().

+ Here is the caller graph for this function:

◆ IsOrderedRelationalCompareOp()

static bool v8::internal::Token::IsOrderedRelationalCompareOp ( Value  op)
inlinestatic

Definition at line 206 of file token.h.

206  {
207  return op == LT || op == LTE || op == GT || op == GTE;
208  }

Referenced by IsArithmeticCompareOp().

+ Here is the caller graph for this function:

◆ IsShiftOp()

static bool v8::internal::Token::IsShiftOp ( Value  op)
inlinestatic

Definition at line 269 of file token.h.

269  {
270  return (SHL <= op) && (op <= SHR);
271  }

◆ IsTruncatingBinaryOp()

static bool v8::internal::Token::IsTruncatingBinaryOp ( Value  op)
inlinestatic

Definition at line 198 of file token.h.

198  {
199  return BIT_OR <= op && op <= ROR;
200  }

References v8::internal::ROR.

◆ IsUnaryOp()

static bool v8::internal::Token::IsUnaryOp ( Value  op)
inlinestatic

Definition at line 261 of file token.h.

261  {
262  return (NOT <= op && op <= VOID) || op == ADD || op == SUB;
263  }
#define VOID

References v8::internal::ADD, v8::internal::NOT, v8::internal::SUB, and VOID.

Referenced by v8::internal::ParserBase< Traits >::ParseUnaryExpression(), and v8::internal::FINAL< kOperandKind, kNumCachedOperands >::UnaryOperation().

+ Here is the caller graph for this function:

◆ Name()

static const char* v8::internal::Token::Name ( Value  tok)
inlinestatic

Definition at line 180 of file token.h.

180  {
181  DCHECK(tok < NUM_TOKENS); // tok is unsigned
182  return name_[tok];
183  }
static const char *const name_[NUM_TOKENS]
Definition: token.h:289
#define DCHECK(condition)
Definition: logging.h:205

References DCHECK, name_, and NUM_TOKENS.

Referenced by v8::internal::CompareIC::UpdateCaches(), and v8::internal::HRangeAnalysisPhase::UpdateControlFlowRange().

+ Here is the caller graph for this function:

◆ NegateCompareOp()

static Value v8::internal::Token::NegateCompareOp ( Value  op)
inlinestatic

Definition at line 223 of file token.h.

223  {
225  switch (op) {
226  case EQ: return NE;
227  case NE: return EQ;
228  case EQ_STRICT: return NE_STRICT;
229  case NE_STRICT: return EQ_STRICT;
230  case LT: return GTE;
231  case GT: return LTE;
232  case LTE: return GT;
233  case GTE: return LT;
234  default:
235  UNREACHABLE();
236  return op;
237  }
238  }
static bool IsArithmeticCompareOp(Value op)
Definition: token.h:218
#define UNREACHABLE()
Definition: logging.h:30

References DCHECK, v8::internal::EQ, IsArithmeticCompareOp(), and UNREACHABLE.

Referenced by v8::internal::HRangeAnalysisPhase::InferControlFlowRange().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Precedence()

static int v8::internal::Token::Precedence ( Value  tok)
inlinestatic

Definition at line 283 of file token.h.

283  {
284  DCHECK(tok < NUM_TOKENS); // tok is unsigned.
285  return precedence_[tok];
286  }
static const int8_t precedence_[NUM_TOKENS]
Definition: token.h:291

References DCHECK, NUM_TOKENS, and precedence_.

Referenced by v8::internal::ParserBase< Traits >::Precedence().

+ Here is the caller graph for this function:

◆ ReverseCompareOp()

static Value v8::internal::Token::ReverseCompareOp ( Value  op)
inlinestatic

Definition at line 240 of file token.h.

240  {
242  switch (op) {
243  case EQ: return EQ;
244  case NE: return NE;
245  case EQ_STRICT: return EQ_STRICT;
246  case NE_STRICT: return NE_STRICT;
247  case LT: return GT;
248  case GT: return LT;
249  case LTE: return GTE;
250  case GTE: return LTE;
251  default:
252  UNREACHABLE();
253  return op;
254  }
255  }

References DCHECK, v8::internal::EQ, IsArithmeticCompareOp(), and UNREACHABLE.

Referenced by v8::internal::HRangeAnalysisPhase::InferControlFlowRange().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ String()

static const char* v8::internal::Token::String ( Value  tok)
inlinestatic

Definition at line 276 of file token.h.

276  {
277  DCHECK(tok < NUM_TOKENS); // tok is unsigned.
278  return string_[tok];
279  }
static const char *const string_[NUM_TOKENS]
Definition: token.h:290

References DCHECK, NUM_TOKENS, and string_.

Referenced by v8::internal::ParserBase< Traits >::ReportUnexpectedToken().

+ Here is the caller graph for this function:

Member Data Documentation

◆ name_

const char *const v8::internal::Token::name_
staticprivate
Initial value:
= {
}

Definition at line 289 of file token.h.

Referenced by Name().

◆ precedence_

const int8_t v8::internal::Token::precedence_
staticprivate
Initial value:
= {
}

Definition at line 291 of file token.h.

Referenced by Precedence().

◆ string_

const char *const v8::internal::Token::string_
staticprivate
Initial value:
= {
}

Definition at line 290 of file token.h.

Referenced by String().

◆ token_type

const char v8::internal::Token::token_type
staticprivate
Initial value:
= {
}

Definition at line 292 of file token.h.

Referenced by IsKeyword().


The documentation for this class was generated from the following files: