V8 Project
v8::internal::ParserBase< Traits > Class Template Reference

#include <preparser.h>

+ Inheritance diagram for v8::internal::ParserBase< Traits >:
+ Collaboration diagram for v8::internal::ParserBase< Traits >:

Classes

class  BASE_EMBEDDED
 
class  ObjectLiteralChecker
 

Public Types

typedef Traits::Type::Expression ExpressionT
 
typedef Traits::Type::Identifier IdentifierT
 
typedef Traits::Type::FunctionLiteral FunctionLiteralT
 
typedef Traits::Type::Literal LiteralT
 
typedef Traits::Type::ObjectLiteralProperty ObjectLiteralPropertyT
 

Public Member Functions

 ParserBase (Scanner *scanner, uintptr_t stack_limit, v8::Extension *extension, ParserRecorder *log, typename Traits::Type::Zone *zone, AstNode::IdGen *ast_node_id_gen, typename Traits::Type::Parser this_object)
 
bool allow_lazy () const
 
bool allow_natives_syntax () const
 
bool allow_arrow_functions () const
 
bool allow_modules () const
 
bool allow_harmony_scoping () const
 
bool allow_harmony_numeric_literals () const
 
bool allow_classes () const
 
bool allow_harmony_object_literals () const
 
void set_allow_lazy (bool allow)
 
void set_allow_natives_syntax (bool allow)
 
void set_allow_arrow_functions (bool allow)
 
void set_allow_modules (bool allow)
 
void set_allow_harmony_scoping (bool allow)
 
void set_allow_harmony_numeric_literals (bool allow)
 
void set_allow_classes (bool allow)
 
void set_allow_harmony_object_literals (bool allow)
 

Protected Types

enum  AllowEvalOrArgumentsAsIdentifier { kAllowEvalOrArguments , kDontAllowEvalOrArguments }
 
enum  Mode { PARSE_LAZILY , PARSE_EAGERLY }
 
enum  PropertyKind {
  kNone = 0 , kGetterProperty = 1 , kSetterProperty = 2 , kValueProperty = 7 ,
  kValueFlag = 4
}
 

Protected Member Functions

Scannerscanner () const
 
int position ()
 
int peek_position ()
 
bool stack_overflow () const
 
void set_stack_overflow ()
 
Mode mode () const
 
Traits::Type::Zone * zone () const
 
AstNode::IdGenast_node_id_gen () const
 
 INLINE (Token::Value peek())
 
 INLINE (Token::Value Next())
 
void Consume (Token::Value token)
 
bool Check (Token::Value token)
 
void Expect (Token::Value token, bool *ok)
 
void ExpectSemicolon (bool *ok)
 
bool peek_any_identifier ()
 
bool CheckContextualKeyword (Vector< const char > keyword)
 
void ExpectContextualKeyword (Vector< const char > keyword, bool *ok)
 
void CheckOctalLiteral (int beg_pos, int end_pos, bool *ok)
 
void CheckStrictFunctionNameAndParameters (IdentifierT function_name, bool function_name_is_strict_reserved, const Scanner::Location &function_name_loc, const Scanner::Location &eval_args_error_loc, const Scanner::Location &dupe_error_loc, const Scanner::Location &reserved_loc, bool *ok)
 
Traits::Type::Factory * factory ()
 
StrictMode strict_mode ()
 
bool is_generator () const
 
void ReportMessage (const char *message, const char *arg=NULL, bool is_reference_error=false)
 
void ReportMessageAt (Scanner::Location location, const char *message, bool is_reference_error=false)
 
void ReportUnexpectedToken (Token::Value token)
 
IdentifierT ParseIdentifier (AllowEvalOrArgumentsAsIdentifier, bool *ok)
 
IdentifierT ParseIdentifierOrStrictReservedWord (bool *is_strict_reserved, bool *ok)
 
IdentifierT ParseIdentifierName (bool *ok)
 
IdentifierT ParseIdentifierNameOrGetOrSet (bool *is_get, bool *is_set, bool *ok)
 
ExpressionT ParseRegExpLiteral (bool seen_equal, bool *ok)
 
ExpressionT ParsePrimaryExpression (bool *ok)
 
ExpressionT ParseExpression (bool accept_IN, bool *ok)
 
ExpressionT ParseArrayLiteral (bool *ok)
 
IdentifierT ParsePropertyName (bool *is_get, bool *is_set, bool *is_static, bool *ok)
 
ExpressionT ParseObjectLiteral (bool *ok)
 
ObjectLiteralPropertyT ParsePropertyDefinition (ObjectLiteralChecker *checker, bool in_class, bool is_static, bool *ok)
 
Traits::Type::ExpressionList ParseArguments (bool *ok)
 
ExpressionT ParseAssignmentExpression (bool accept_IN, bool *ok)
 
ExpressionT ParseYieldExpression (bool *ok)
 
ExpressionT ParseConditionalExpression (bool accept_IN, bool *ok)
 
ExpressionT ParseBinaryExpression (int prec, bool accept_IN, bool *ok)
 
ExpressionT ParseUnaryExpression (bool *ok)
 
ExpressionT ParsePostfixExpression (bool *ok)
 
ExpressionT ParseLeftHandSideExpression (bool *ok)
 
ExpressionT ParseMemberWithNewPrefixesExpression (bool *ok)
 
ExpressionT ParseMemberExpression (bool *ok)
 
ExpressionT ParseMemberExpressionContinuation (ExpressionT expression, bool *ok)
 
ExpressionT ParseArrowFunctionLiteral (int start_pos, ExpressionT params_ast, bool *ok)
 
ExpressionT ParseClassLiteral (IdentifierT name, Scanner::Location function_name_location, bool name_is_strict_reserved, int pos, bool *ok)
 
ExpressionT CheckAndRewriteReferenceExpression (ExpressionT expression, Scanner::Location location, const char *message, bool *ok)
 

Static Protected Member Functions

static int Precedence (Token::Value token, bool accept_IN)
 

Protected Attributes

bool parenthesized_function_
 
Traits::Type::Scope * scope_
 
FunctionState * function_state_
 
v8::Extensionextension_
 
FuncNameInferrerfni_
 
ParserRecorderlog_
 
Mode mode_
 
uintptr_t stack_limit_
 

Private Attributes

Scannerscanner_
 
bool stack_overflow_
 
bool allow_lazy_
 
bool allow_natives_syntax_
 
bool allow_arrow_functions_
 
bool allow_harmony_object_literals_
 
Traits::Type::Zone * zone_
 
AstNode::IdGenast_node_id_gen_
 

Friends

class Traits::Checkpoint
 

Detailed Description

template<typename Traits>
class v8::internal::ParserBase< Traits >

Definition at line 62 of file preparser.h.

Member Typedef Documentation

◆ ExpressionT

template<typename Traits >
typedef Traits::Type::Expression v8::internal::ParserBase< Traits >::ExpressionT

Definition at line 65 of file preparser.h.

◆ FunctionLiteralT

template<typename Traits >
typedef Traits::Type::FunctionLiteral v8::internal::ParserBase< Traits >::FunctionLiteralT

Definition at line 67 of file preparser.h.

◆ IdentifierT

template<typename Traits >
typedef Traits::Type::Identifier v8::internal::ParserBase< Traits >::IdentifierT

Definition at line 66 of file preparser.h.

◆ LiteralT

template<typename Traits >
typedef Traits::Type::Literal v8::internal::ParserBase< Traits >::LiteralT

Definition at line 68 of file preparser.h.

◆ ObjectLiteralPropertyT

template<typename Traits >
typedef Traits::Type::ObjectLiteralProperty v8::internal::ParserBase< Traits >::ObjectLiteralPropertyT

Definition at line 69 of file preparser.h.

Member Enumeration Documentation

◆ AllowEvalOrArgumentsAsIdentifier

template<typename Traits >
enum v8::internal::ParserBase::AllowEvalOrArgumentsAsIdentifier
protected
Enumerator
kAllowEvalOrArguments 
kDontAllowEvalOrArguments 

Definition at line 128 of file preparser.h.

◆ Mode

template<typename Traits >
enum v8::internal::ParserBase::Mode
protected
Enumerator
PARSE_LAZILY 
PARSE_EAGERLY 

Definition at line 133 of file preparser.h.

133  {
134  PARSE_LAZILY,
136  };

◆ PropertyKind

template<typename Traits >
enum v8::internal::ParserBase::PropertyKind
protected
Enumerator
kNone 
kGetterProperty 
kSetterProperty 
kValueProperty 
kValueFlag 

Definition at line 528 of file preparser.h.

528  {
529  kNone = 0,
530  // Bit patterns representing different object literal property types.
531  kGetterProperty = 1,
532  kSetterProperty = 2,
533  kValueProperty = 7,
534  // Helper constants.
535  kValueFlag = 4
536  };

Constructor & Destructor Documentation

◆ ParserBase()

template<typename Traits >
v8::internal::ParserBase< Traits >::ParserBase ( Scanner scanner,
uintptr_t  stack_limit,
v8::Extension extension,
ParserRecorder log,
typename Traits::Type::Zone *  zone,
AstNode::IdGen ast_node_id_gen,
typename Traits::Type::Parser  this_object 
)
inline

Definition at line 71 of file preparser.h.

75  : Traits(this_object),
77  scope_(NULL),
79  extension_(extension),
80  fni_(NULL),
81  log_(log),
82  mode_(PARSE_EAGERLY), // Lazy mode must be set explicitly.
83  stack_limit_(stack_limit),
85  stack_overflow_(false),
86  allow_lazy_(false),
87  allow_natives_syntax_(false),
90  zone_(zone),
v8::Extension * extension_
Definition: preparser.h:579
ParserRecorder * log_
Definition: preparser.h:581
Traits::Type::Scope * scope_
Definition: preparser.h:577
Traits::Type::Zone * zone() const
Definition: preparser.h:291
AstNode::IdGen * ast_node_id_gen() const
Definition: preparser.h:292
FuncNameInferrer * fni_
Definition: preparser.h:580
AstNode::IdGen * ast_node_id_gen_
Definition: preparser.h:595
Scanner * scanner() const
Definition: preparser.h:285
FunctionState * function_state_
Definition: preparser.h:578
Traits::Type::Zone * zone_
Definition: preparser.h:594
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be NULL

Member Function Documentation

◆ allow_arrow_functions()

template<typename Traits >
bool v8::internal::ParserBase< Traits >::allow_arrow_functions ( ) const
inline

◆ allow_classes()

template<typename Traits >
bool v8::internal::ParserBase< Traits >::allow_classes ( ) const
inline

Definition at line 103 of file preparser.h.

103 { return scanner()->HarmonyClasses(); }
bool HarmonyClasses() const
Definition: scanner.h:441

References v8::internal::Scanner::HarmonyClasses(), and v8::internal::ParserBase< Traits >::scanner().

+ Here is the call graph for this function:

◆ allow_harmony_numeric_literals()

template<typename Traits >
bool v8::internal::ParserBase< Traits >::allow_harmony_numeric_literals ( ) const
inline

Definition at line 100 of file preparser.h.

100  {
101  return scanner()->HarmonyNumericLiterals();
102  }
bool HarmonyNumericLiterals() const
Definition: scanner.h:435

References v8::internal::Scanner::HarmonyNumericLiterals(), and v8::internal::ParserBase< Traits >::scanner().

+ Here is the call graph for this function:

◆ allow_harmony_object_literals()

template<typename Traits >
bool v8::internal::ParserBase< Traits >::allow_harmony_object_literals ( ) const
inline

Definition at line 104 of file preparser.h.

104  {
106  }

References v8::internal::ParserBase< Traits >::allow_harmony_object_literals_.

◆ allow_harmony_scoping()

template<typename Traits >
bool v8::internal::ParserBase< Traits >::allow_harmony_scoping ( ) const
inline

Definition at line 99 of file preparser.h.

99 { return scanner()->HarmonyScoping(); }
bool HarmonyScoping() const
Definition: scanner.h:423

References v8::internal::Scanner::HarmonyScoping(), and v8::internal::ParserBase< Traits >::scanner().

+ Here is the call graph for this function:

◆ allow_lazy()

template<typename Traits >
bool v8::internal::ParserBase< Traits >::allow_lazy ( ) const
inline

Definition at line 95 of file preparser.h.

95 { return allow_lazy_; }

References v8::internal::ParserBase< Traits >::allow_lazy_.

◆ allow_modules()

template<typename Traits >
bool v8::internal::ParserBase< Traits >::allow_modules ( ) const
inline

Definition at line 98 of file preparser.h.

98 { return scanner()->HarmonyModules(); }
bool HarmonyModules() const
Definition: scanner.h:429

References v8::internal::Scanner::HarmonyModules(), and v8::internal::ParserBase< Traits >::scanner().

+ Here is the call graph for this function:

◆ allow_natives_syntax()

template<typename Traits >
bool v8::internal::ParserBase< Traits >::allow_natives_syntax ( ) const
inline

Definition at line 96 of file preparser.h.

96 { return allow_natives_syntax_; }

References v8::internal::ParserBase< Traits >::allow_natives_syntax_.

◆ ast_node_id_gen()

template<typename Traits >
AstNode::IdGen* v8::internal::ParserBase< Traits >::ast_node_id_gen ( ) const
inlineprotected

Definition at line 292 of file preparser.h.

292 { return ast_node_id_gen_; }

References v8::internal::ParserBase< Traits >::ast_node_id_gen_.

◆ Check()

template<typename Traits >
bool v8::internal::ParserBase< Traits >::Check ( Token::Value  token)
inlineprotected

Definition at line 319 of file preparser.h.

319  {
320  Token::Value next = peek();
321  if (next == token) {
322  Consume(next);
323  return true;
324  }
325  return false;
326  }
void Consume(Token::Value token)
Definition: preparser.h:312

References v8::internal::ParserBase< Traits >::Consume().

+ Here is the call graph for this function:

◆ CheckAndRewriteReferenceExpression()

template<typename Traits >
ParserBase< Traits >::ExpressionT v8::internal::ParserBase< Traits >::CheckAndRewriteReferenceExpression ( ExpressionT  expression,
Scanner::Location  location,
const char *  message,
bool ok 
)
protected

Definition at line 2782 of file preparser.h.

2784  {
2785  if (strict_mode() == STRICT && this->IsIdentifier(expression) &&
2786  this->IsEvalOrArguments(this->AsIdentifier(expression))) {
2787  this->ReportMessageAt(location, "strict_eval_arguments", false);
2788  *ok = false;
2789  return this->EmptyExpression();
2790  } else if (expression->IsValidReferenceExpression()) {
2791  return expression;
2792  } else if (expression->IsCall()) {
2793  // If it is a call, make it a runtime error for legacy web compatibility.
2794  // Rewrite `expr' to `expr[throw ReferenceError]'.
2795  int pos = location.beg_pos;
2796  ExpressionT error = this->NewThrowReferenceError(message, pos);
2797  return factory()->NewProperty(expression, error, pos);
2798  } else {
2799  this->ReportMessageAt(location, message, true);
2800  *ok = false;
2801  return this->EmptyExpression();
2802  }
2803 }
void ReportMessageAt(Scanner::Location location, const char *message, bool is_reference_error=false)
Definition: preparser.h:450
Traits::Type::Expression ExpressionT
Definition: preparser.h:65
StrictMode strict_mode()
Definition: preparser.h:440
Traits::Type::Factory * factory()
Definition: preparser.h:436

References v8::internal::Scanner::Location::beg_pos, and v8::internal::STRICT.

◆ CheckContextualKeyword()

template<typename Traits >
bool v8::internal::ParserBase< Traits >::CheckContextualKeyword ( Vector< const char >  keyword)
inlineprotected

Definition at line 361 of file preparser.h.

361  {
362  if (peek() == Token::IDENTIFIER &&
363  scanner()->is_next_contextual_keyword(keyword)) {
364  Consume(Token::IDENTIFIER);
365  return true;
366  }
367  return false;
368  }

References v8::internal::ParserBase< Traits >::Consume(), and v8::internal::ParserBase< Traits >::scanner().

+ Here is the call graph for this function:

◆ CheckOctalLiteral()

template<typename Traits >
void v8::internal::ParserBase< Traits >::CheckOctalLiteral ( int  beg_pos,
int  end_pos,
bool ok 
)
inlineprotected

Definition at line 381 of file preparser.h.

381  {
382  Scanner::Location octal = scanner()->octal_position();
383  if (octal.IsValid() && beg_pos <= octal.beg_pos &&
384  octal.end_pos <= end_pos) {
385  ReportMessageAt(octal, "strict_octal_literal");
387  *ok = false;
388  }
389  }
void clear_octal_position()
Definition: scanner.h:415
Location octal_position() const
Definition: scanner.h:414

References v8::internal::Scanner::Location::beg_pos, v8::internal::Scanner::clear_octal_position(), v8::internal::Scanner::Location::end_pos, v8::internal::Scanner::Location::IsValid(), v8::internal::Scanner::octal_position(), v8::internal::ParserBase< Traits >::ReportMessageAt(), and v8::internal::ParserBase< Traits >::scanner().

+ Here is the call graph for this function:

◆ CheckStrictFunctionNameAndParameters()

template<typename Traits >
void v8::internal::ParserBase< Traits >::CheckStrictFunctionNameAndParameters ( IdentifierT  function_name,
bool  function_name_is_strict_reserved,
const Scanner::Location function_name_loc,
const Scanner::Location eval_args_error_loc,
const Scanner::Location dupe_error_loc,
const Scanner::Location reserved_loc,
bool ok 
)
inlineprotected

Definition at line 394 of file preparser.h.

401  {
402  if (this->IsEvalOrArguments(function_name)) {
403  Traits::ReportMessageAt(function_name_loc, "strict_eval_arguments");
404  *ok = false;
405  return;
406  }
407  if (function_name_is_strict_reserved) {
408  Traits::ReportMessageAt(function_name_loc, "unexpected_strict_reserved");
409  *ok = false;
410  return;
411  }
412  if (eval_args_error_loc.IsValid()) {
413  Traits::ReportMessageAt(eval_args_error_loc, "strict_eval_arguments");
414  *ok = false;
415  return;
416  }
417  if (dupe_error_loc.IsValid()) {
418  Traits::ReportMessageAt(dupe_error_loc, "strict_param_dupe");
419  *ok = false;
420  return;
421  }
422  if (reserved_loc.IsValid()) {
423  Traits::ReportMessageAt(reserved_loc, "unexpected_strict_reserved");
424  *ok = false;
425  return;
426  }
427  }

References v8::internal::Scanner::Location::IsValid().

+ Here is the call graph for this function:

◆ Consume()

template<typename Traits >
void v8::internal::ParserBase< Traits >::Consume ( Token::Value  token)
inlineprotected

Definition at line 312 of file preparser.h.

312  {
313  Token::Value next = Next();
314  USE(next);
315  USE(token);
316  DCHECK(next == token);
317  }
#define DCHECK(condition)
Definition: logging.h:205
void USE(T)
Definition: macros.h:322

References DCHECK, and USE().

Referenced by v8::internal::ParserBase< Traits >::Check(), and v8::internal::ParserBase< Traits >::CheckContextualKeyword().

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

◆ Expect()

template<typename Traits >
void v8::internal::ParserBase< Traits >::Expect ( Token::Value  token,
bool ok 
)
inlineprotected

Definition at line 328 of file preparser.h.

328  {
329  Token::Value next = Next();
330  if (next != token) {
331  ReportUnexpectedToken(next);
332  *ok = false;
333  }
334  }
void ReportUnexpectedToken(Token::Value token)
Definition: preparser.h:1608

References v8::internal::ParserBase< Traits >::ReportUnexpectedToken().

Referenced by v8::internal::ParserBase< Traits >::ExpectContextualKeyword(), and v8::internal::ParserBase< Traits >::ExpectSemicolon().

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

◆ ExpectContextualKeyword()

template<typename Traits >
void v8::internal::ParserBase< Traits >::ExpectContextualKeyword ( Vector< const char >  keyword,
bool ok 
)
inlineprotected

Definition at line 370 of file preparser.h.

370  {
371  Expect(Token::IDENTIFIER, ok);
372  if (!*ok) return;
373  if (!scanner()->is_literal_contextual_keyword(keyword)) {
374  ReportUnexpectedToken(scanner()->current_token());
375  *ok = false;
376  }
377  }
void Expect(Token::Value token, bool *ok)
Definition: preparser.h:328

References v8::internal::ParserBase< Traits >::Expect(), v8::internal::ParserBase< Traits >::ReportUnexpectedToken(), and v8::internal::ParserBase< Traits >::scanner().

+ Here is the call graph for this function:

◆ ExpectSemicolon()

template<typename Traits >
void v8::internal::ParserBase< Traits >::ExpectSemicolon ( bool ok)
inlineprotected

Definition at line 336 of file preparser.h.

336  {
337  // Check for automatic semicolon insertion according to
338  // the rules given in ECMA-262, section 7.9, page 21.
339  Token::Value tok = peek();
340  if (tok == Token::SEMICOLON) {
341  Next();
342  return;
343  }
344  if (scanner()->HasAnyLineTerminatorBeforeNext() ||
345  tok == Token::RBRACE ||
346  tok == Token::EOS) {
347  return;
348  }
349  Expect(Token::SEMICOLON, ok);
350  }

References v8::internal::ParserBase< Traits >::Expect(), and v8::internal::ParserBase< Traits >::scanner().

+ Here is the call graph for this function:

◆ factory()

template<typename Traits >
Traits::Type::Factory* v8::internal::ParserBase< Traits >::factory ( )
inlineprotected

Definition at line 436 of file preparser.h.

436  {
437  return function_state_->factory();
438  }

References v8::internal::ParserBase< Traits >::function_state_.

Referenced by v8::internal::ParserTraits::NewThrowError().

+ Here is the caller graph for this function:

◆ INLINE() [1/2]

template<typename Traits >
v8::internal::ParserBase< Traits >::INLINE ( Token::Value   Next())
inlineprotected

Definition at line 299 of file preparser.h.

299  {
300  if (stack_overflow_) return Token::ILLEGAL;
301  {
303  // Any further calls to Next or peek will return the illegal token.
304  // The current call must return the next token, which might already
305  // have been peek'ed.
306  stack_overflow_ = true;
307  }
308  }
309  return scanner()->Next();
310  }
Token::Value Next()
Definition: scanner.cc:219
DISABLE_ASAN uintptr_t GetCurrentStackPosition()
Definition: utils.h:1460

References v8::internal::GetCurrentStackPosition(), v8::internal::Scanner::Next(), v8::internal::ParserBase< Traits >::scanner(), v8::internal::ParserBase< Traits >::stack_limit_, and v8::internal::ParserBase< Traits >::stack_overflow_.

+ Here is the call graph for this function:

◆ INLINE() [2/2]

template<typename Traits >
v8::internal::ParserBase< Traits >::INLINE ( Token::Value   peek())
inlineprotected

Definition at line 294 of file preparser.h.

294  {
295  if (stack_overflow_) return Token::ILLEGAL;
296  return scanner()->peek();
297  }
Token::Value peek() const
Definition: scanner.h:361

References v8::internal::Scanner::peek(), v8::internal::ParserBase< Traits >::scanner(), and v8::internal::ParserBase< Traits >::stack_overflow_.

+ Here is the call graph for this function:

◆ is_generator()

template<typename Traits >
bool v8::internal::ParserBase< Traits >::is_generator ( ) const
inlineprotected

Definition at line 441 of file preparser.h.

441 { return function_state_->is_generator(); }

References v8::internal::ParserBase< Traits >::function_state_.

Referenced by v8::internal::ParserBase< Traits >::BASE_EMBEDDED::set_generator_object_variable(), and v8::internal::ParserBase< Traits >::BASE_EMBEDDED::set_is_generator().

+ Here is the caller graph for this function:

◆ mode()

template<typename Traits >
Mode v8::internal::ParserBase< Traits >::mode ( ) const
inlineprotected

Definition at line 290 of file preparser.h.

290 { return mode_; }

References v8::internal::ParserBase< Traits >::mode_.

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

+ Here is the caller graph for this function:

◆ ParseArguments()

template<class Traits >
Traits::Type::ExpressionList v8::internal::ParserBase< Traits >::ParseArguments ( bool ok)
protected

Definition at line 2106 of file preparser.h.

2107  {
2108  // Arguments ::
2109  // '(' (AssignmentExpression)*[','] ')'
2110 
2111  typename Traits::Type::ExpressionList result =
2112  this->NewExpressionList(4, zone_);
2113  Expect(Token::LPAREN, CHECK_OK_CUSTOM(NullExpressionList));
2114  bool done = (peek() == Token::RPAREN);
2115  while (!done) {
2116  ExpressionT argument = this->ParseAssignmentExpression(
2117  true, CHECK_OK_CUSTOM(NullExpressionList));
2118  result->Add(argument, zone_);
2119  if (result->length() > Code::kMaxArguments) {
2120  ReportMessage("too_many_arguments");
2121  *ok = false;
2122  return this->NullExpressionList();
2123  }
2124  done = (peek() == Token::RPAREN);
2125  if (!done) {
2126  // Need {} because of the CHECK_OK_CUSTOM macro.
2127  Expect(Token::COMMA, CHECK_OK_CUSTOM(NullExpressionList));
2128  }
2129  }
2130  Expect(Token::RPAREN, CHECK_OK_CUSTOM(NullExpressionList));
2131  return result;
2132 }
static const int kMaxArguments
Definition: objects.h:5445
ExpressionT ParseAssignmentExpression(bool accept_IN, bool *ok)
Definition: preparser.h:2137
void ReportMessage(const char *message, const char *arg=NULL, bool is_reference_error=false)
Definition: preparser.h:444
#define COMMA
#define CHECK_OK_CUSTOM(x)
Definition: preparser.h:1742

References CHECK_OK_CUSTOM, COMMA, and v8::internal::Code::kMaxArguments.

◆ ParseArrayLiteral()

template<class Traits >
ParserBase< Traits >::ExpressionT v8::internal::ParserBase< Traits >::ParseArrayLiteral ( bool ok)
protected

Definition at line 1888 of file preparser.h.

1889  {
1890  // ArrayLiteral ::
1891  // '[' Expression? (',' Expression?)* ']'
1892 
1893  int pos = peek_position();
1894  typename Traits::Type::ExpressionList values =
1895  this->NewExpressionList(4, zone_);
1896  Expect(Token::LBRACK, CHECK_OK);
1897  while (peek() != Token::RBRACK) {
1898  ExpressionT elem = this->EmptyExpression();
1899  if (peek() == Token::COMMA) {
1900  elem = this->GetLiteralTheHole(peek_position(), factory());
1901  } else {
1902  elem = this->ParseAssignmentExpression(true, CHECK_OK);
1903  }
1904  values->Add(elem, zone_);
1905  if (peek() != Token::RBRACK) {
1907  }
1908  }
1909  Expect(Token::RBRACK, CHECK_OK);
1910 
1911  // Update the scope information before the pre-parsing bailout.
1912  int literal_index = function_state_->NextMaterializedLiteralIndex();
1913 
1914  return factory()->NewArrayLiteral(values, literal_index, pos);
1915 }
#define CHECK_OK
Definition: preparser.h:1735

References CHECK_OK, and COMMA.

◆ ParseArrowFunctionLiteral()

template<class Traits >
ParserBase< Traits >::ExpressionT v8::internal::ParserBase< Traits >::ParseArrowFunctionLiteral ( int  start_pos,
ExpressionT  params_ast,
bool ok 
)
protected

Definition at line 2610 of file preparser.h.

2611  {
2612  // TODO(aperez): Change this to use ARROW_SCOPE
2613  typename Traits::Type::ScopePtr scope =
2614  this->NewScope(scope_, FUNCTION_SCOPE);
2615  typename Traits::Type::StatementList body;
2616  typename Traits::Type::AstProperties ast_properties;
2617  BailoutReason dont_optimize_reason = kNoReason;
2618  int num_parameters = -1;
2619  int materialized_literal_count = -1;
2620  int expected_property_count = -1;
2621  int handler_count = 0;
2622 
2623  {
2624  FunctionState function_state(&function_state_, &scope_, &scope, zone(),
2625  this->ast_value_factory(), ast_node_id_gen_);
2626  Scanner::Location dupe_error_loc = Scanner::Location::invalid();
2627  num_parameters = Traits::DeclareArrowParametersFromExpression(
2628  params_ast, scope_, &dupe_error_loc, ok);
2629  if (!*ok) {
2631  Scanner::Location(start_pos, scanner()->location().beg_pos),
2632  "malformed_arrow_function_parameter_list");
2633  return this->EmptyExpression();
2634  }
2635 
2636  if (num_parameters > Code::kMaxArguments) {
2637  ReportMessageAt(Scanner::Location(params_ast->position(), position()),
2638  "too_many_parameters");
2639  *ok = false;
2640  return this->EmptyExpression();
2641  }
2642 
2643  Expect(Token::ARROW, CHECK_OK);
2644 
2645  if (peek() == Token::LBRACE) {
2646  // Multiple statemente body
2647  Consume(Token::LBRACE);
2648  bool is_lazily_parsed =
2649  (mode() == PARSE_LAZILY && scope_->AllowsLazyCompilation());
2650  if (is_lazily_parsed) {
2651  body = this->NewStatementList(0, zone());
2652  this->SkipLazyFunctionBody(this->EmptyIdentifier(),
2653  &materialized_literal_count,
2654  &expected_property_count, CHECK_OK);
2655  } else {
2656  body = this->ParseEagerFunctionBody(
2657  this->EmptyIdentifier(), RelocInfo::kNoPosition, NULL,
2658  Token::INIT_VAR, false, // Not a generator.
2659  CHECK_OK);
2660  materialized_literal_count =
2661  function_state.materialized_literal_count();
2662  expected_property_count = function_state.expected_property_count();
2663  handler_count = function_state.handler_count();
2664  }
2665  } else {
2666  // Single-expression body
2667  int pos = position();
2668  parenthesized_function_ = false;
2669  ExpressionT expression = ParseAssignmentExpression(true, CHECK_OK);
2670  body = this->NewStatementList(1, zone());
2671  body->Add(factory()->NewReturnStatement(expression, pos), zone());
2672  materialized_literal_count = function_state.materialized_literal_count();
2673  expected_property_count = function_state.expected_property_count();
2674  handler_count = function_state.handler_count();
2675  }
2676 
2677  scope->set_start_position(start_pos);
2678  scope->set_end_position(scanner()->location().end_pos);
2679 
2680  // Arrow function *parameter lists* are always checked as in strict mode.
2681  bool function_name_is_strict_reserved = false;
2682  Scanner::Location function_name_loc = Scanner::Location::invalid();
2683  Scanner::Location eval_args_error_loc = Scanner::Location::invalid();
2684  Scanner::Location reserved_loc = Scanner::Location::invalid();
2686  this->EmptyIdentifier(), function_name_is_strict_reserved,
2687  function_name_loc, eval_args_error_loc, dupe_error_loc, reserved_loc,
2688  CHECK_OK);
2689 
2690  // Validate strict mode.
2691  if (strict_mode() == STRICT) {
2692  CheckOctalLiteral(start_pos, scanner()->location().end_pos, CHECK_OK);
2693  }
2694 
2696  this->CheckConflictingVarDeclarations(scope, CHECK_OK);
2697 
2698  ast_properties = *factory()->visitor()->ast_properties();
2699  dont_optimize_reason = factory()->visitor()->dont_optimize_reason();
2700  }
2701 
2702  FunctionLiteralT function_literal = factory()->NewFunctionLiteral(
2703  this->EmptyIdentifierString(), this->ast_value_factory(), scope, body,
2704  materialized_literal_count, expected_property_count, handler_count,
2705  num_parameters, FunctionLiteral::kNoDuplicateParameters,
2706  FunctionLiteral::ANONYMOUS_EXPRESSION, FunctionLiteral::kIsFunction,
2707  FunctionLiteral::kNotParenthesized, FunctionKind::kArrowFunction,
2708  start_pos);
2709 
2710  function_literal->set_function_token_position(start_pos);
2711  function_literal->set_ast_properties(&ast_properties);
2712  function_literal->set_dont_optimize_reason(dont_optimize_reason);
2713 
2714  if (fni_ != NULL) this->InferFunctionName(fni_, function_literal);
2715 
2716  return function_literal;
2717 }
bool allow_harmony_scoping() const
Definition: preparser.h:99
Traits::Type::FunctionLiteral FunctionLiteralT
Definition: preparser.h:67
void CheckOctalLiteral(int beg_pos, int end_pos, bool *ok)
Definition: preparser.h:381
void CheckStrictFunctionNameAndParameters(IdentifierT function_name, bool function_name_is_strict_reserved, const Scanner::Location &function_name_loc, const Scanner::Location &eval_args_error_loc, const Scanner::Location &dupe_error_loc, const Scanner::Location &reserved_loc, bool *ok)
Definition: preparser.h:394
static const int kNoPosition
Definition: assembler.h:317
@ FUNCTION_SCOPE
Definition: globals.h:647
@ kArrowFunction
Definition: globals.h:777
static Location invalid()
Definition: scanner.h:337

References CHECK_OK, v8::internal::FUNCTION_SCOPE, v8::internal::Scanner::Location::invalid(), v8::internal::kArrowFunction, v8::internal::Code::kMaxArguments, v8::internal::RelocInfo::kNoPosition, mode(), NULL, and v8::internal::STRICT.

+ Here is the call graph for this function:

◆ ParseAssignmentExpression()

template<class Traits >
ParserBase< Traits >::ExpressionT v8::internal::ParserBase< Traits >::ParseAssignmentExpression ( bool  accept_IN,
bool ok 
)
protected

Definition at line 2137 of file preparser.h.

2137  {
2138  // AssignmentExpression ::
2139  // ConditionalExpression
2140  // ArrowFunction
2141  // YieldExpression
2142  // LeftHandSideExpression AssignmentOperator AssignmentExpression
2143 
2144  Scanner::Location lhs_location = scanner()->peek_location();
2145 
2146  if (peek() == Token::YIELD && is_generator()) {
2147  return this->ParseYieldExpression(ok);
2148  }
2149 
2150  if (fni_ != NULL) fni_->Enter();
2151  typename Traits::Checkpoint checkpoint(this);
2152  ExpressionT expression =
2153  this->ParseConditionalExpression(accept_IN, CHECK_OK);
2154 
2155  if (allow_arrow_functions() && peek() == Token::ARROW) {
2156  checkpoint.Restore();
2157  expression = this->ParseArrowFunctionLiteral(lhs_location.beg_pos,
2158  expression, CHECK_OK);
2159  return expression;
2160  }
2161 
2162  if (!Token::IsAssignmentOp(peek())) {
2163  if (fni_ != NULL) fni_->Leave();
2164  // Parsed conditional expression only (no assignment).
2165  return expression;
2166  }
2167 
2168  expression = this->CheckAndRewriteReferenceExpression(
2169  expression, lhs_location, "invalid_lhs_in_assignment", CHECK_OK);
2170  expression = this->MarkExpressionAsAssigned(expression);
2171 
2172  Token::Value op = Next(); // Get assignment operator.
2173  int pos = position();
2174  ExpressionT right = this->ParseAssignmentExpression(accept_IN, CHECK_OK);
2175 
2176  // TODO(1231235): We try to estimate the set of properties set by
2177  // constructors. We define a new property whenever there is an
2178  // assignment to a property of 'this'. We should probably only add
2179  // properties if we haven't seen them before. Otherwise we'll
2180  // probably overestimate the number of properties.
2181  if (op == Token::ASSIGN && this->IsThisProperty(expression)) {
2182  function_state_->AddProperty();
2183  }
2184 
2185  this->CheckAssigningFunctionLiteralToProperty(expression, right);
2186 
2187  if (fni_ != NULL) {
2188  // Check if the right hand side is a call to avoid inferring a
2189  // name if we're dealing with "a = function(){...}();"-like
2190  // expression.
2191  if ((op == Token::INIT_VAR
2192  || op == Token::INIT_CONST_LEGACY
2193  || op == Token::ASSIGN)
2194  && (!right->IsCall() && !right->IsCallNew())) {
2195  fni_->Infer();
2196  } else {
2198  }
2199  fni_->Leave();
2200  }
2201 
2202  return factory()->NewAssignment(op, expression, right, pos);
2203 }
ExpressionT ParseConditionalExpression(bool accept_IN, bool *ok)
Definition: preparser.h:2255
ExpressionT ParseArrowFunctionLiteral(int start_pos, ExpressionT params_ast, bool *ok)
Definition: preparser.h:2610
ExpressionT ParseYieldExpression(bool *ok)
Definition: preparser.h:2207
bool is_generator() const
Definition: preparser.h:441
ExpressionT CheckAndRewriteReferenceExpression(ExpressionT expression, Scanner::Location location, const char *message, bool *ok)
Definition: preparser.h:2782
bool allow_arrow_functions() const
Definition: preparser.h:97
friend class Traits::Checkpoint
Definition: preparser.h:126
Location peek_location() const
Definition: scanner.h:363
static bool IsAssignmentOp(Value tok)
Definition: token.h:190

References v8::internal::Scanner::Location::beg_pos, CHECK_OK, v8::internal::Token::IsAssignmentOp(), NULL, and v8::internal::YIELD.

+ Here is the call graph for this function:

◆ ParseBinaryExpression()

template<class Traits >
ParserBase< Traits >::ExpressionT v8::internal::ParserBase< Traits >::ParseBinaryExpression ( int  prec,
bool  accept_IN,
bool ok 
)
protected

Definition at line 2278 of file preparser.h.

2278  {
2279  DCHECK(prec >= 4);
2281  for (int prec1 = Precedence(peek(), accept_IN); prec1 >= prec; prec1--) {
2282  // prec1 >= 4
2283  while (Precedence(peek(), accept_IN) == prec1) {
2284  Token::Value op = Next();
2285  int pos = position();
2286  ExpressionT y = ParseBinaryExpression(prec1 + 1, accept_IN, CHECK_OK);
2287 
2288  if (this->ShortcutNumericLiteralBinaryExpression(&x, y, op, pos,
2289  factory())) {
2290  continue;
2291  }
2292 
2293  // For now we distinguish between comparisons and other binary
2294  // operations. (We could combine the two and get rid of this
2295  // code and AST node eventually.)
2296  if (Token::IsCompareOp(op)) {
2297  // We have a comparison.
2298  Token::Value cmp = op;
2299  switch (op) {
2300  case Token::NE: cmp = Token::EQ; break;
2301  case Token::NE_STRICT: cmp = Token::EQ_STRICT; break;
2302  default: break;
2303  }
2304  x = factory()->NewCompareOperation(cmp, x, y, pos);
2305  if (cmp != op) {
2306  // The comparison was negated - add a NOT.
2307  x = factory()->NewUnaryOperation(Token::NOT, x, pos);
2308  }
2309 
2310  } else {
2311  // We have a "normal" binary operation.
2312  x = factory()->NewBinaryOperation(op, x, y, pos);
2313  }
2314  }
2315  }
2316  return x;
2317 }
ExpressionT ParseBinaryExpression(int prec, bool accept_IN, bool *ok)
Definition: preparser.h:2278
static int Precedence(Token::Value token, bool accept_IN)
Definition: preparser.h:430
ExpressionT ParseUnaryExpression(bool *ok)
Definition: preparser.h:2322
static bool IsCompareOp(Value op)
Definition: token.h:202

References CHECK_OK, DCHECK, v8::internal::EQ, v8::internal::Token::IsCompareOp(), v8::internal::NOT, and v8::base::internal::y.

+ Here is the call graph for this function:

◆ ParseClassLiteral()

template<class Traits >
ParserBase< Traits >::ExpressionT v8::internal::ParserBase< Traits >::ParseClassLiteral ( IdentifierT  name,
Scanner::Location  function_name_location,
bool  name_is_strict_reserved,
int  pos,
bool ok 
)
protected

Definition at line 2721 of file preparser.h.

2723  {
2724  // All parts of a ClassDeclaration or a ClassExpression are strict code.
2725  if (name_is_strict_reserved) {
2726  ReportMessageAt(class_name_location, "unexpected_strict_reserved");
2727  *ok = false;
2728  return this->EmptyExpression();
2729  }
2730  if (this->IsEvalOrArguments(name)) {
2731  ReportMessageAt(class_name_location, "strict_eval_arguments");
2732  *ok = false;
2733  return this->EmptyExpression();
2734  }
2735 
2736  // TODO(arv): Implement scopes and name binding in class body only.
2737  // TODO(arv): Maybe add CLASS_SCOPE?
2738  typename Traits::Type::ScopePtr extends_scope =
2739  this->NewScope(scope_, BLOCK_SCOPE);
2740  FunctionState extends_function_state(
2741  &function_state_, &scope_, &extends_scope, zone(),
2742  this->ast_value_factory(), ast_node_id_gen_);
2743  scope_->SetStrictMode(STRICT);
2744  scope_->SetScopeName(name);
2745 
2746  ExpressionT extends = this->EmptyExpression();
2747  if (Check(Token::EXTENDS)) {
2748  extends = this->ParseLeftHandSideExpression(CHECK_OK);
2749  }
2750 
2751  ObjectLiteralChecker checker(this, STRICT);
2752  typename Traits::Type::PropertyList properties =
2753  this->NewPropertyList(4, zone_);
2754  FunctionLiteralT constructor = this->EmptyFunctionLiteral();
2755 
2756  Expect(Token::LBRACE, CHECK_OK);
2757  while (peek() != Token::RBRACE) {
2758  if (Check(Token::SEMICOLON)) continue;
2759  if (fni_ != NULL) fni_->Enter();
2760 
2761  const bool in_class = true;
2762  const bool is_static = false;
2763  ObjectLiteralPropertyT property =
2764  this->ParsePropertyDefinition(&checker, in_class, is_static, CHECK_OK);
2765 
2766  properties->Add(property, zone());
2767 
2768  if (fni_ != NULL) {
2769  fni_->Infer();
2770  fni_->Leave();
2771  }
2772  }
2773  Expect(Token::RBRACE, CHECK_OK);
2774 
2775  return this->ClassLiteral(name, extends, constructor, properties, pos,
2776  factory());
2777 }
bool Check(Token::Value token)
Definition: preparser.h:319
Traits::Type::ObjectLiteralProperty ObjectLiteralPropertyT
Definition: preparser.h:69
ObjectLiteralPropertyT ParsePropertyDefinition(ObjectLiteralChecker *checker, bool in_class, bool is_static, bool *ok)
Definition: preparser.h:1942
ExpressionT ParseLeftHandSideExpression(bool *ok)
Definition: preparser.h:2397
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be expose gc extension under the specified name show built in functions in stack traces use random jit cookie to mask large constants minimum length for automatic enable preparsing CPU profiler sampling interval in microseconds trace out of bounds accesses to external arrays default size of stack region v8 is allowed to maximum length of function source code printed in a stack trace min size of a semi the new space consists of two semi spaces print one trace line following each garbage collection do not print trace line after scavenger collection print cumulative GC statistics in name

References v8::internal::BLOCK_SCOPE, CHECK_OK, name, NULL, and v8::internal::STRICT.

◆ ParseConditionalExpression()

template<class Traits >
ParserBase< Traits >::ExpressionT v8::internal::ParserBase< Traits >::ParseConditionalExpression ( bool  accept_IN,
bool ok 
)
protected

Definition at line 2255 of file preparser.h.

2255  {
2256  // ConditionalExpression ::
2257  // LogicalOrExpression
2258  // LogicalOrExpression '?' AssignmentExpression ':' AssignmentExpression
2259 
2260  int pos = peek_position();
2261  // We start using the binary expression parser for prec >= 4 only!
2262  ExpressionT expression = this->ParseBinaryExpression(4, accept_IN, CHECK_OK);
2263  if (peek() != Token::CONDITIONAL) return expression;
2264  Consume(Token::CONDITIONAL);
2265  // In parsing the first assignment expression in conditional
2266  // expressions we always accept the 'in' keyword; see ECMA-262,
2267  // section 11.12, page 58.
2269  Expect(Token::COLON, CHECK_OK);
2270  ExpressionT right = ParseAssignmentExpression(accept_IN, CHECK_OK);
2271  return factory()->NewConditional(expression, left, right, pos);
2272 }

References CHECK_OK.

◆ ParseExpression()

template<class Traits >
ParserBase< Traits >::ExpressionT v8::internal::ParserBase< Traits >::ParseExpression ( bool  accept_IN,
bool ok 
)
protected

Definition at line 1870 of file preparser.h.

1871  {
1872  // Expression ::
1873  // AssignmentExpression
1874  // Expression ',' AssignmentExpression
1875 
1876  ExpressionT result = this->ParseAssignmentExpression(accept_IN, CHECK_OK);
1877  while (peek() == Token::COMMA) {
1879  int pos = position();
1880  ExpressionT right = this->ParseAssignmentExpression(accept_IN, CHECK_OK);
1881  result = factory()->NewBinaryOperation(Token::COMMA, result, right, pos);
1882  }
1883  return result;
1884 }

References CHECK_OK, and COMMA.

◆ ParseIdentifier()

template<class Traits >
ParserBase< Traits >::IdentifierT v8::internal::ParserBase< Traits >::ParseIdentifier ( AllowEvalOrArgumentsAsIdentifier  allow_eval_or_arguments,
bool ok 
)
protected

Definition at line 1637 of file preparser.h.

1639  {
1640  Token::Value next = Next();
1641  if (next == Token::IDENTIFIER) {
1642  IdentifierT name = this->GetSymbol(scanner());
1643  if (allow_eval_or_arguments == kDontAllowEvalOrArguments &&
1644  strict_mode() == STRICT && this->IsEvalOrArguments(name)) {
1645  ReportMessage("strict_eval_arguments");
1646  *ok = false;
1647  }
1648  return name;
1649  } else if (strict_mode() == SLOPPY &&
1650  (next == Token::FUTURE_STRICT_RESERVED_WORD ||
1651  (next == Token::LET) ||
1652  (next == Token::YIELD && !is_generator()))) {
1653  return this->GetSymbol(scanner());
1654  } else {
1655  this->ReportUnexpectedToken(next);
1656  *ok = false;
1657  return Traits::EmptyIdentifier();
1658  }
1659 }
Traits::Type::Identifier IdentifierT
Definition: preparser.h:66

References v8::internal::LET, name, v8::internal::SLOPPY, v8::internal::STRICT, and v8::internal::YIELD.

◆ ParseIdentifierName()

template<class Traits >
ParserBase< Traits >::IdentifierT v8::internal::ParserBase< Traits >::ParseIdentifierName ( bool ok)
protected

Definition at line 1684 of file preparser.h.

1684  {
1685  Token::Value next = Next();
1686  if (next != Token::IDENTIFIER && next != Token::FUTURE_RESERVED_WORD &&
1687  next != Token::LET && next != Token::YIELD &&
1688  next != Token::FUTURE_STRICT_RESERVED_WORD && !Token::IsKeyword(next)) {
1689  this->ReportUnexpectedToken(next);
1690  *ok = false;
1691  return Traits::EmptyIdentifier();
1692  }
1693  return this->GetSymbol(scanner());
1694 }
static bool IsKeyword(Value tok)
Definition: token.h:186

References v8::internal::Token::IsKeyword(), v8::internal::LET, and v8::internal::YIELD.

+ Here is the call graph for this function:

◆ ParseIdentifierNameOrGetOrSet()

template<class Traits >
ParserBase< Traits >::IdentifierT v8::internal::ParserBase< Traits >::ParseIdentifierNameOrGetOrSet ( bool is_get,
bool is_set,
bool ok 
)
protected

Definition at line 1699 of file preparser.h.

1701  {
1702  IdentifierT result = ParseIdentifierName(ok);
1703  if (!*ok) return Traits::EmptyIdentifier();
1704  scanner()->IsGetOrSet(is_get, is_set);
1705  return result;
1706 }
IdentifierT ParseIdentifierName(bool *ok)
Definition: preparser.h:1684
void IsGetOrSet(bool *is_get, bool *is_set)
Definition: scanner.h:397

◆ ParseIdentifierOrStrictReservedWord()

template<class Traits >
ParserBase< Traits >::IdentifierT v8::internal::ParserBase< Traits >::ParseIdentifierOrStrictReservedWord ( bool is_strict_reserved,
bool ok 
)
protected

Definition at line 1664 of file preparser.h.

1665  {
1666  Token::Value next = Next();
1667  if (next == Token::IDENTIFIER) {
1668  *is_strict_reserved = false;
1669  } else if (next == Token::FUTURE_STRICT_RESERVED_WORD ||
1670  next == Token::LET ||
1671  (next == Token::YIELD && !this->is_generator())) {
1672  *is_strict_reserved = true;
1673  } else {
1674  ReportUnexpectedToken(next);
1675  *ok = false;
1676  return Traits::EmptyIdentifier();
1677  }
1678  return this->GetSymbol(scanner());
1679 }

References v8::internal::LET, and v8::internal::YIELD.

◆ ParseLeftHandSideExpression()

template<class Traits >
ParserBase< Traits >::ExpressionT v8::internal::ParserBase< Traits >::ParseLeftHandSideExpression ( bool ok)
protected

Definition at line 2397 of file preparser.h.

2397  {
2398  // LeftHandSideExpression ::
2399  // (NewExpression | MemberExpression) ...
2400 
2402 
2403  while (true) {
2404  switch (peek()) {
2405  case Token::LBRACK: {
2406  Consume(Token::LBRACK);
2407  int pos = position();
2408  ExpressionT index = ParseExpression(true, CHECK_OK);
2409  result = factory()->NewProperty(result, index, pos);
2410  Expect(Token::RBRACK, CHECK_OK);
2411  break;
2412  }
2413 
2414  case Token::LPAREN: {
2415  int pos;
2416  if (scanner()->current_token() == Token::IDENTIFIER) {
2417  // For call of an identifier we want to report position of
2418  // the identifier as position of the call in the stack trace.
2419  pos = position();
2420  } else {
2421  // For other kinds of calls we record position of the parenthesis as
2422  // position of the call. Note that this is extremely important for
2423  // expressions of the form function(){...}() for which call position
2424  // should not point to the closing brace otherwise it will intersect
2425  // with positions recorded for function literal and confuse debugger.
2426  pos = peek_position();
2427  // Also the trailing parenthesis are a hint that the function will
2428  // be called immediately. If we happen to have parsed a preceding
2429  // function literal eagerly, we can also compile it eagerly.
2430  if (result->IsFunctionLiteral() && mode() == PARSE_EAGERLY) {
2431  result->AsFunctionLiteral()->set_parenthesized();
2432  }
2433  }
2434  typename Traits::Type::ExpressionList args = ParseArguments(CHECK_OK);
2435 
2436  // Keep track of eval() calls since they disable all local variable
2437  // optimizations.
2438  // The calls that need special treatment are the
2439  // direct eval calls. These calls are all of the form eval(...), with
2440  // no explicit receiver.
2441  // These calls are marked as potentially direct eval calls. Whether
2442  // they are actually direct calls to eval is determined at run time.
2443  this->CheckPossibleEvalCall(result, scope_);
2444  result = factory()->NewCall(result, args, pos);
2445  if (fni_ != NULL) fni_->RemoveLastFunction();
2446  break;
2447  }
2448 
2449  case Token::PERIOD: {
2450  Consume(Token::PERIOD);
2451  int pos = position();
2453  result = factory()->NewProperty(
2454  result, factory()->NewStringLiteral(name, pos), pos);
2455  if (fni_ != NULL) this->PushLiteralName(fni_, name);
2456  break;
2457  }
2458 
2459  default:
2460  return result;
2461  }
2462  }
2463 }
Traits::Type::ExpressionList ParseArguments(bool *ok)
Definition: preparser.h:2106
ExpressionT ParseExpression(bool accept_IN, bool *ok)
Definition: preparser.h:1870
ExpressionT ParseMemberWithNewPrefixesExpression(bool *ok)
Definition: preparser.h:2468

References CHECK_OK, mode(), name, and NULL.

+ Here is the call graph for this function:

◆ ParseMemberExpression()

template<class Traits >
ParserBase< Traits >::ExpressionT v8::internal::ParserBase< Traits >::ParseMemberExpression ( bool ok)
protected

Definition at line 2515 of file preparser.h.

2515  {
2516  // MemberExpression ::
2517  // (PrimaryExpression | FunctionLiteral | ClassLiteral)
2518  // ('[' Expression ']' | '.' Identifier | Arguments)*
2519 
2520  // The '[' Expression ']' and '.' Identifier parts are parsed by
2521  // ParseMemberExpressionContinuation, and the Arguments part is parsed by the
2522  // caller.
2523 
2524  // Parse the initial primary or function expression.
2525  ExpressionT result = this->EmptyExpression();
2526  if (peek() == Token::FUNCTION) {
2527  Consume(Token::FUNCTION);
2529  bool is_generator = Check(Token::MUL);
2530  IdentifierT name = this->EmptyIdentifier();
2531  bool is_strict_reserved_name = false;
2532  Scanner::Location function_name_location = Scanner::Location::invalid();
2533  FunctionLiteral::FunctionType function_type =
2534  FunctionLiteral::ANONYMOUS_EXPRESSION;
2535  if (peek_any_identifier()) {
2536  name = ParseIdentifierOrStrictReservedWord(&is_strict_reserved_name,
2537  CHECK_OK);
2538  function_name_location = scanner()->location();
2539  function_type = FunctionLiteral::NAMED_EXPRESSION;
2540  }
2541  result = this->ParseFunctionLiteral(
2542  name, function_name_location, is_strict_reserved_name,
2545  function_token_position, function_type, FunctionLiteral::NORMAL_ARITY,
2546  CHECK_OK);
2547  } else if (peek() == Token::SUPER) {
2548  int beg_pos = position();
2549  Consume(Token::SUPER);
2550  Token::Value next = peek();
2551  if (next == Token::PERIOD || next == Token::LBRACK ||
2552  next == Token::LPAREN) {
2553  result = this->SuperReference(scope_, factory());
2554  } else {
2555  ReportMessageAt(Scanner::Location(beg_pos, position()),
2556  "unexpected_super");
2557  *ok = false;
2558  return this->EmptyExpression();
2559  }
2560  } else {
2561  result = ParsePrimaryExpression(CHECK_OK);
2562  }
2563 
2564  result = ParseMemberExpressionContinuation(result, CHECK_OK);
2565  return result;
2566 }
IdentifierT ParseIdentifierOrStrictReservedWord(bool *is_strict_reserved, bool *ok)
Definition: preparser.h:1664
ExpressionT ParsePrimaryExpression(bool *ok)
Definition: preparser.h:1750
ExpressionT ParseMemberExpressionContinuation(ExpressionT expression, bool *ok)
Definition: preparser.h:2571
Location location() const
Definition: scanner.h:356
kExpectedNofPropertiesOffset function_token_position
Definition: objects-inl.h:5513
@ kNormalFunction
Definition: globals.h:776
@ kGeneratorFunction
Definition: globals.h:778

References CHECK_OK, v8::internal::function_token_position, v8::internal::Scanner::Location::invalid(), v8::internal::kGeneratorFunction, v8::internal::kNormalFunction, v8::internal::MUL, and name.

+ Here is the call graph for this function:

◆ ParseMemberExpressionContinuation()

template<class Traits >
ParserBase< Traits >::ExpressionT v8::internal::ParserBase< Traits >::ParseMemberExpressionContinuation ( ExpressionT  expression,
bool ok 
)
protected

Definition at line 2571 of file preparser.h.

2572  {
2573  // Parses this part of MemberExpression:
2574  // ('[' Expression ']' | '.' Identifier)*
2575  while (true) {
2576  switch (peek()) {
2577  case Token::LBRACK: {
2578  Consume(Token::LBRACK);
2579  int pos = position();
2580  ExpressionT index = this->ParseExpression(true, CHECK_OK);
2581  expression = factory()->NewProperty(expression, index, pos);
2582  if (fni_ != NULL) {
2583  this->PushPropertyName(fni_, index);
2584  }
2585  Expect(Token::RBRACK, CHECK_OK);
2586  break;
2587  }
2588  case Token::PERIOD: {
2589  Consume(Token::PERIOD);
2590  int pos = position();
2592  expression = factory()->NewProperty(
2593  expression, factory()->NewStringLiteral(name, pos), pos);
2594  if (fni_ != NULL) {
2595  this->PushLiteralName(fni_, name);
2596  }
2597  break;
2598  }
2599  default:
2600  return expression;
2601  }
2602  }
2603  DCHECK(false);
2604  return this->EmptyExpression();
2605 }

References CHECK_OK, DCHECK, name, and NULL.

◆ ParseMemberWithNewPrefixesExpression()

template<class Traits >
ParserBase< Traits >::ExpressionT v8::internal::ParserBase< Traits >::ParseMemberWithNewPrefixesExpression ( bool ok)
protected

Definition at line 2468 of file preparser.h.

2468  {
2469  // NewExpression ::
2470  // ('new')+ MemberExpression
2471 
2472  // The grammar for new expressions is pretty warped. We can have several 'new'
2473  // keywords following each other, and then a MemberExpression. When we see '('
2474  // after the MemberExpression, it's associated with the rightmost unassociated
2475  // 'new' to create a NewExpression with arguments. However, a NewExpression
2476  // can also occur without arguments.
2477 
2478  // Examples of new expression:
2479  // new foo.bar().baz means (new (foo.bar)()).baz
2480  // new foo()() means (new foo())()
2481  // new new foo()() means (new (new foo())())
2482  // new new foo means new (new foo)
2483  // new new foo() means new (new foo())
2484  // new new foo().bar().baz means (new (new foo()).bar()).baz
2485 
2486  if (peek() == Token::NEW) {
2487  Consume(Token::NEW);
2488  int new_pos = position();
2489  ExpressionT result = this->EmptyExpression();
2490  if (Check(Token::SUPER)) {
2491  result = this->SuperReference(scope_, factory());
2492  } else {
2494  }
2495  if (peek() == Token::LPAREN) {
2496  // NewExpression with arguments.
2497  typename Traits::Type::ExpressionList args =
2498  this->ParseArguments(CHECK_OK);
2499  result = factory()->NewCallNew(result, args, new_pos);
2500  // The expression can still continue with . or [ after the arguments.
2501  result = this->ParseMemberExpressionContinuation(result, CHECK_OK);
2502  return result;
2503  }
2504  // NewExpression without arguments.
2505  return factory()->NewCallNew(result, this->NewExpressionList(0, zone_),
2506  new_pos);
2507  }
2508  // No 'new' or 'super' keyword.
2509  return this->ParseMemberExpression(ok);
2510 }
ExpressionT ParseMemberExpression(bool *ok)
Definition: preparser.h:2515

References CHECK_OK.

◆ ParseObjectLiteral()

template<class Traits >
ParserBase< Traits >::ExpressionT v8::internal::ParserBase< Traits >::ParseObjectLiteral ( bool ok)
protected

Definition at line 2047 of file preparser.h.

2048  {
2049  // ObjectLiteral ::
2050  // '{' (PropertyDefinition (',' PropertyDefinition)* ','? )? '}'
2051 
2052  int pos = peek_position();
2053  typename Traits::Type::PropertyList properties =
2054  this->NewPropertyList(4, zone_);
2055  int number_of_boilerplate_properties = 0;
2056  bool has_function = false;
2057 
2058  ObjectLiteralChecker checker(this, strict_mode());
2059 
2060  Expect(Token::LBRACE, CHECK_OK);
2061 
2062  while (peek() != Token::RBRACE) {
2063  if (fni_ != NULL) fni_->Enter();
2064 
2065  const bool in_class = false;
2066  const bool is_static = false;
2067  ObjectLiteralPropertyT property =
2068  this->ParsePropertyDefinition(&checker, in_class, is_static, CHECK_OK);
2069 
2070  // Mark top-level object literals that contain function literals and
2071  // pretenure the literal so it can be added as a constant function
2072  // property. (Parser only.)
2073  this->CheckFunctionLiteralInsideTopLevelObjectLiteral(scope_, property,
2074  &has_function);
2075 
2076  // Count CONSTANT or COMPUTED properties to maintain the enumeration order.
2077  if (this->IsBoilerplateProperty(property)) {
2078  number_of_boilerplate_properties++;
2079  }
2080  properties->Add(property, zone());
2081 
2082  if (peek() != Token::RBRACE) {
2083  // Need {} because of the CHECK_OK macro.
2085  }
2086 
2087  if (fni_ != NULL) {
2088  fni_->Infer();
2089  fni_->Leave();
2090  }
2091  }
2092  Expect(Token::RBRACE, CHECK_OK);
2093 
2094  // Computation of literal_index must happen before pre parse bailout.
2095  int literal_index = function_state_->NextMaterializedLiteralIndex();
2096 
2097  return factory()->NewObjectLiteral(properties,
2098  literal_index,
2099  number_of_boilerplate_properties,
2100  has_function,
2101  pos);
2102 }

References CHECK_OK, COMMA, and NULL.

◆ ParsePostfixExpression()

template<class Traits >
ParserBase< Traits >::ExpressionT v8::internal::ParserBase< Traits >::ParsePostfixExpression ( bool ok)
protected

Definition at line 2372 of file preparser.h.

2372  {
2373  // PostfixExpression ::
2374  // LeftHandSideExpression ('++' | '--')?
2375 
2376  Scanner::Location lhs_location = scanner()->peek_location();
2377  ExpressionT expression = this->ParseLeftHandSideExpression(CHECK_OK);
2378  if (!scanner()->HasAnyLineTerminatorBeforeNext() &&
2379  Token::IsCountOp(peek())) {
2380  expression = this->CheckAndRewriteReferenceExpression(
2381  expression, lhs_location, "invalid_lhs_in_postfix_op", CHECK_OK);
2382  expression = this->MarkExpressionAsAssigned(expression);
2383 
2384  Token::Value next = Next();
2385  expression =
2386  factory()->NewCountOperation(next,
2387  false /* postfix */,
2388  expression,
2389  position());
2390  }
2391  return expression;
2392 }
static bool IsCountOp(Value op)
Definition: token.h:265

References CHECK_OK, and v8::internal::Token::IsCountOp().

+ Here is the call graph for this function:

◆ ParsePrimaryExpression()

template<class Traits >
ParserBase< Traits >::ExpressionT v8::internal::ParserBase< Traits >::ParsePrimaryExpression ( bool ok)
protected

Definition at line 1750 of file preparser.h.

1750  {
1751  // PrimaryExpression ::
1752  // 'this'
1753  // 'null'
1754  // 'true'
1755  // 'false'
1756  // Identifier
1757  // Number
1758  // String
1759  // ArrayLiteral
1760  // ObjectLiteral
1761  // RegExpLiteral
1762  // ClassLiteral
1763  // '(' Expression ')'
1764 
1765  int pos = peek_position();
1766  ExpressionT result = this->EmptyExpression();
1767  Token::Value token = peek();
1768  switch (token) {
1769  case Token::THIS: {
1770  Consume(Token::THIS);
1771  result = this->ThisExpression(scope_, factory());
1772  break;
1773  }
1774 
1775  case Token::NULL_LITERAL:
1776  case Token::TRUE_LITERAL:
1777  case Token::FALSE_LITERAL:
1778  case Token::NUMBER:
1779  Next();
1780  result = this->ExpressionFromLiteral(token, pos, scanner(), factory());
1781  break;
1782 
1783  case Token::IDENTIFIER:
1784  case Token::LET:
1785  case Token::YIELD:
1786  case Token::FUTURE_STRICT_RESERVED_WORD: {
1787  // Using eval or arguments in this context is OK even in strict mode.
1789  result = this->ExpressionFromIdentifier(name, pos, scope_, factory());
1790  break;
1791  }
1792 
1793  case Token::STRING: {
1795  result = this->ExpressionFromString(pos, scanner(), factory());
1796  break;
1797  }
1798 
1799  case Token::ASSIGN_DIV:
1800  result = this->ParseRegExpLiteral(true, CHECK_OK);
1801  break;
1802 
1803  case Token::DIV:
1804  result = this->ParseRegExpLiteral(false, CHECK_OK);
1805  break;
1806 
1807  case Token::LBRACK:
1808  result = this->ParseArrayLiteral(CHECK_OK);
1809  break;
1810 
1811  case Token::LBRACE:
1812  result = this->ParseObjectLiteral(CHECK_OK);
1813  break;
1814 
1815  case Token::LPAREN:
1816  Consume(Token::LPAREN);
1817  if (allow_arrow_functions() && peek() == Token::RPAREN) {
1818  // Arrow functions are the only expression type constructions
1819  // for which an empty parameter list "()" is valid input.
1820  Consume(Token::RPAREN);
1821  result = this->ParseArrowFunctionLiteral(
1822  pos, this->EmptyArrowParamList(), CHECK_OK);
1823  } else {
1824  // Heuristically try to detect immediately called functions before
1825  // seeing the call parentheses.
1826  parenthesized_function_ = (peek() == Token::FUNCTION);
1827  result = this->ParseExpression(true, CHECK_OK);
1828  result->increase_parenthesization_level();
1829  Expect(Token::RPAREN, CHECK_OK);
1830  }
1831  break;
1832 
1833  case Token::CLASS: {
1834  Consume(Token::CLASS);
1835  int class_token_position = position();
1836  IdentifierT name = this->EmptyIdentifier();
1837  bool is_strict_reserved_name = false;
1838  Scanner::Location class_name_location = Scanner::Location::invalid();
1839  if (peek_any_identifier()) {
1840  name = ParseIdentifierOrStrictReservedWord(&is_strict_reserved_name,
1841  CHECK_OK);
1842  class_name_location = scanner()->location();
1843  }
1844  result = this->ParseClassLiteral(name, class_name_location,
1845  is_strict_reserved_name,
1846  class_token_position, CHECK_OK);
1847  break;
1848  }
1849 
1850  case Token::MOD:
1851  if (allow_natives_syntax() || extension_ != NULL) {
1852  result = this->ParseV8Intrinsic(CHECK_OK);
1853  break;
1854  }
1855  // If we're not allowing special syntax we fall-through to the
1856  // default case.
1857 
1858  default: {
1859  Next();
1860  ReportUnexpectedToken(token);
1861  *ok = false;
1862  }
1863  }
1864 
1865  return result;
1866 }
ExpressionT ParseClassLiteral(IdentifierT name, Scanner::Location function_name_location, bool name_is_strict_reserved, int pos, bool *ok)
Definition: preparser.h:2721
ExpressionT ParseObjectLiteral(bool *ok)
Definition: preparser.h:2047
bool allow_natives_syntax() const
Definition: preparser.h:96
IdentifierT ParseIdentifier(AllowEvalOrArgumentsAsIdentifier, bool *ok)
Definition: preparser.h:1637
ExpressionT ParseArrayLiteral(bool *ok)
Definition: preparser.h:1888
ExpressionT ParseRegExpLiteral(bool seen_equal, bool *ok)
Definition: preparser.h:1710
@ STRING

References CHECK_OK, v8::internal::DIV, v8::internal::Scanner::Location::invalid(), v8::internal::LET, name, NULL, STRING, and v8::internal::YIELD.

+ Here is the call graph for this function:

◆ ParsePropertyDefinition()

template<class Traits >
ParserBase< Traits >::ObjectLiteralPropertyT v8::internal::ParserBase< Traits >::ParsePropertyDefinition ( ObjectLiteralChecker checker,
bool  in_class,
bool  is_static,
bool ok 
)
protected

Definition at line 1942 of file preparser.h.

1943  {
1944  ExpressionT value = this->EmptyExpression();
1945  bool is_get = false;
1946  bool is_set = false;
1947  bool name_is_static = false;
1949 
1950  Token::Value name_token = peek();
1951  int next_pos = peek_position();
1952  IdentifierT name =
1953  ParsePropertyName(&is_get, &is_set, &name_is_static,
1954  CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
1955 
1956  if (fni_ != NULL) this->PushLiteralName(fni_, name);
1957 
1958  if (!in_class && !is_generator && peek() == Token::COLON) {
1959  // PropertyDefinition : PropertyName ':' AssignmentExpression
1960  checker->CheckProperty(name_token, kValueProperty,
1961  CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
1962  Consume(Token::COLON);
1963  value = this->ParseAssignmentExpression(
1964  true, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
1965 
1966  } else if (is_generator ||
1967  (allow_harmony_object_literals_ && peek() == Token::LPAREN)) {
1968  // Concise Method
1969 
1970  if (is_static && this->IsPrototype(name)) {
1971  ReportMessageAt(scanner()->location(), "static_prototype");
1972  *ok = false;
1973  return this->EmptyObjectLiteralProperty();
1974  }
1975  if (is_generator && in_class && !is_static && this->IsConstructor(name)) {
1976  ReportMessageAt(scanner()->location(), "constructor_special_method");
1977  *ok = false;
1978  return this->EmptyObjectLiteralProperty();
1979  }
1980 
1981  checker->CheckProperty(name_token, kValueProperty,
1982  CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
1985 
1986  value = this->ParseFunctionLiteral(
1987  name, scanner()->location(),
1988  false, // reserved words are allowed here
1989  kind, RelocInfo::kNoPosition, FunctionLiteral::ANONYMOUS_EXPRESSION,
1990  FunctionLiteral::NORMAL_ARITY,
1991  CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
1992 
1993  } else if (in_class && name_is_static && !is_static) {
1994  // static MethodDefinition
1995  return ParsePropertyDefinition(checker, true, true, ok);
1996 
1997  } else if (is_get || is_set) {
1998  // Accessor
1999  bool dont_care = false;
2000  name_token = peek();
2001  name = ParsePropertyName(&dont_care, &dont_care, &dont_care,
2002  CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
2003 
2004  // Validate the property.
2005  if (is_static && this->IsPrototype(name)) {
2006  ReportMessageAt(scanner()->location(), "static_prototype");
2007  *ok = false;
2008  return this->EmptyObjectLiteralProperty();
2009  } else if (in_class && !is_static && this->IsConstructor(name)) {
2010  // ES6, spec draft rev 27, treats static get constructor as an error too.
2011  // https://bugs.ecmascript.org/show_bug.cgi?id=3223
2012  // TODO(arv): Update when bug is resolved.
2013  ReportMessageAt(scanner()->location(), "constructor_special_method");
2014  *ok = false;
2015  return this->EmptyObjectLiteralProperty();
2016  }
2017  checker->CheckProperty(name_token,
2018  is_get ? kGetterProperty : kSetterProperty,
2019  CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
2020 
2021  typename Traits::Type::FunctionLiteral value = this->ParseFunctionLiteral(
2022  name, scanner()->location(),
2023  false, // reserved words are allowed here
2025  FunctionLiteral::ANONYMOUS_EXPRESSION,
2026  is_get ? FunctionLiteral::GETTER_ARITY : FunctionLiteral::SETTER_ARITY,
2027  CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
2028  return factory()->NewObjectLiteralProperty(is_get, value, next_pos,
2029  is_static);
2030  } else {
2031  Token::Value next = Next();
2032  ReportUnexpectedToken(next);
2033  *ok = false;
2034  return this->EmptyObjectLiteralProperty();
2035  }
2036 
2037  uint32_t index;
2038  LiteralT key = this->IsArrayIndex(name, &index)
2039  ? factory()->NewNumberLiteral(index, next_pos)
2040  : factory()->NewStringLiteral(name, next_pos);
2041 
2042  return factory()->NewObjectLiteralProperty(key, value, is_static);
2043 }
IdentifierT ParsePropertyName(bool *is_get, bool *is_set, bool *is_static, bool *ok)
Definition: preparser.h:1919
Traits::Type::Literal LiteralT
Definition: preparser.h:68
@ kConciseGeneratorMethod
Definition: globals.h:780
@ kConciseMethod
Definition: globals.h:779

References CHECK_OK_CUSTOM, v8::internal::ParserBase< Traits >::ObjectLiteralChecker::CheckProperty(), v8::internal::kConciseGeneratorMethod, v8::internal::kConciseMethod, v8::internal::RelocInfo::kNoPosition, v8::internal::kNormalFunction, v8::internal::MUL, name, and NULL.

+ Here is the call graph for this function:

◆ ParsePropertyName()

template<class Traits >
ParserBase< Traits >::IdentifierT v8::internal::ParserBase< Traits >::ParsePropertyName ( bool is_get,
bool is_set,
bool is_static,
bool ok 
)
protected

Definition at line 1919 of file preparser.h.

1920  {
1921  Token::Value next = peek();
1922  switch (next) {
1923  case Token::STRING:
1925  return this->GetSymbol(scanner_);
1926  case Token::NUMBER:
1927  Consume(Token::NUMBER);
1928  return this->GetNumberAsSymbol(scanner_);
1929  case Token::STATIC:
1930  *is_static = true;
1931  // Fall through.
1932  default:
1933  return ParseIdentifierNameOrGetOrSet(is_get, is_set, ok);
1934  }
1935  UNREACHABLE();
1936  return this->EmptyIdentifier();
1937 }
IdentifierT ParseIdentifierNameOrGetOrSet(bool *is_get, bool *is_set, bool *ok)
Definition: preparser.h:1699
#define UNREACHABLE()
Definition: logging.h:30

References STRING, and UNREACHABLE.

◆ ParseRegExpLiteral()

template<class Traits >
ParserBase< Traits >::ExpressionT v8::internal::ParserBase< Traits >::ParseRegExpLiteral ( bool  seen_equal,
bool ok 
)
protected

Definition at line 1710 of file preparser.h.

1711  {
1712  int pos = peek_position();
1713  if (!scanner()->ScanRegExpPattern(seen_equal)) {
1714  Next();
1715  ReportMessage("unterminated_regexp");
1716  *ok = false;
1717  return Traits::EmptyExpression();
1718  }
1719 
1720  int literal_index = function_state_->NextMaterializedLiteralIndex();
1721 
1722  IdentifierT js_pattern = this->GetNextSymbol(scanner());
1723  if (!scanner()->ScanRegExpFlags()) {
1724  Next();
1725  ReportMessage("invalid_regexp_flags");
1726  *ok = false;
1727  return Traits::EmptyExpression();
1728  }
1729  IdentifierT js_flags = this->GetNextSymbol(scanner());
1730  Next();
1731  return factory()->NewRegExpLiteral(js_pattern, js_flags, literal_index, pos);
1732 }

◆ ParseUnaryExpression()

template<class Traits >
ParserBase< Traits >::ExpressionT v8::internal::ParserBase< Traits >::ParseUnaryExpression ( bool ok)
protected

Definition at line 2322 of file preparser.h.

2322  {
2323  // UnaryExpression ::
2324  // PostfixExpression
2325  // 'delete' UnaryExpression
2326  // 'void' UnaryExpression
2327  // 'typeof' UnaryExpression
2328  // '++' UnaryExpression
2329  // '--' UnaryExpression
2330  // '+' UnaryExpression
2331  // '-' UnaryExpression
2332  // '~' UnaryExpression
2333  // '!' UnaryExpression
2334 
2335  Token::Value op = peek();
2336  if (Token::IsUnaryOp(op)) {
2337  op = Next();
2338  int pos = position();
2340 
2341  // "delete identifier" is a syntax error in strict mode.
2342  if (op == Token::DELETE && strict_mode() == STRICT &&
2343  this->IsIdentifier(expression)) {
2344  ReportMessage("strict_delete");
2345  *ok = false;
2346  return this->EmptyExpression();
2347  }
2348 
2349  // Allow Traits do rewrite the expression.
2350  return this->BuildUnaryExpression(expression, op, pos, factory());
2351  } else if (Token::IsCountOp(op)) {
2352  op = Next();
2353  Scanner::Location lhs_location = scanner()->peek_location();
2354  ExpressionT expression = this->ParseUnaryExpression(CHECK_OK);
2355  expression = this->CheckAndRewriteReferenceExpression(
2356  expression, lhs_location, "invalid_lhs_in_prefix_op", CHECK_OK);
2357  this->MarkExpressionAsAssigned(expression);
2358 
2359  return factory()->NewCountOperation(op,
2360  true /* prefix */,
2361  expression,
2362  position());
2363 
2364  } else {
2365  return this->ParsePostfixExpression(ok);
2366  }
2367 }
ExpressionT ParsePostfixExpression(bool *ok)
Definition: preparser.h:2372
static bool IsUnaryOp(Value op)
Definition: token.h:261

References CHECK_OK, v8::internal::Token::IsCountOp(), v8::internal::Token::IsUnaryOp(), and v8::internal::STRICT.

+ Here is the call graph for this function:

◆ ParseYieldExpression()

template<class Traits >
ParserBase< Traits >::ExpressionT v8::internal::ParserBase< Traits >::ParseYieldExpression ( bool ok)
protected

Definition at line 2207 of file preparser.h.

2207  {
2208  // YieldExpression ::
2209  // 'yield' ([no line terminator] '*'? AssignmentExpression)?
2210  int pos = peek_position();
2212  ExpressionT generator_object =
2213  factory()->NewVariableProxy(function_state_->generator_object_variable());
2214  ExpressionT expression = Traits::EmptyExpression();
2215  Yield::Kind kind = Yield::kSuspend;
2216  if (!scanner()->HasAnyLineTerminatorBeforeNext()) {
2217  if (Check(Token::MUL)) kind = Yield::kDelegating;
2218  switch (peek()) {
2219  case Token::EOS:
2220  case Token::SEMICOLON:
2221  case Token::RBRACE:
2222  case Token::RBRACK:
2223  case Token::RPAREN:
2224  case Token::COLON:
2225  case Token::COMMA:
2226  // The above set of tokens is the complete set of tokens that can appear
2227  // after an AssignmentExpression, and none of them can start an
2228  // AssignmentExpression. This allows us to avoid looking for an RHS for
2229  // a Yield::kSuspend operation, given only one look-ahead token.
2230  if (kind == Yield::kSuspend)
2231  break;
2232  DCHECK_EQ(Yield::kDelegating, kind);
2233  // Delegating yields require an RHS; fall through.
2234  default:
2235  expression = ParseAssignmentExpression(false, CHECK_OK);
2236  break;
2237  }
2238  }
2239  if (kind == Yield::kDelegating) {
2240  // var iterator = subject[Symbol.iterator]();
2241  expression = this->GetIterator(expression, factory());
2242  }
2243  typename Traits::Type::YieldExpression yield =
2244  factory()->NewYield(generator_object, expression, kind, pos);
2245  if (kind == Yield::kDelegating) {
2246  yield->set_index(function_state_->NextHandlerIndex());
2247  }
2248  return yield;
2249 }
#define DCHECK_EQ(v1, v2)
Definition: logging.h:206

References CHECK_OK, COMMA, DCHECK_EQ, v8::internal::MUL, and v8::internal::YIELD.

◆ peek_any_identifier()

template<typename Traits >
bool v8::internal::ParserBase< Traits >::peek_any_identifier ( )
inlineprotected

Definition at line 352 of file preparser.h.

352  {
353  Token::Value next = peek();
354  return next == Token::IDENTIFIER ||
355  next == Token::FUTURE_RESERVED_WORD ||
356  next == Token::FUTURE_STRICT_RESERVED_WORD ||
357  next == Token::LET ||
358  next == Token::YIELD;
359  }

References v8::internal::LET, and v8::internal::YIELD.

◆ peek_position()

template<typename Traits >
int v8::internal::ParserBase< Traits >::peek_position ( )
inlineprotected

Definition at line 287 of file preparser.h.

References v8::internal::Scanner::Location::beg_pos, v8::internal::Scanner::peek_location(), and v8::internal::ParserBase< Traits >::scanner_.

+ Here is the call graph for this function:

◆ position()

template<typename Traits >
int v8::internal::ParserBase< Traits >::position ( )
inlineprotected

Definition at line 286 of file preparser.h.

286 { return scanner_->location().beg_pos; }

References v8::internal::Scanner::Location::beg_pos, v8::internal::Scanner::location(), and v8::internal::ParserBase< Traits >::scanner_.

+ Here is the call graph for this function:

◆ Precedence()

template<typename Traits >
static int v8::internal::ParserBase< Traits >::Precedence ( Token::Value  token,
bool  accept_IN 
)
inlinestaticprotected

Definition at line 430 of file preparser.h.

430  {
431  if (token == Token::IN && !accept_IN)
432  return 0; // 0 precedence will terminate binary expression parsing
433  return Token::Precedence(token);
434  }
static int Precedence(Value tok)
Definition: token.h:283
#define IN

References IN, and v8::internal::Token::Precedence().

+ Here is the call graph for this function:

◆ ReportMessage()

template<typename Traits >
void v8::internal::ParserBase< Traits >::ReportMessage ( const char *  message,
const char *  arg = NULL,
bool  is_reference_error = false 
)
inlineprotected

Definition at line 444 of file preparser.h.

445  {
446  Scanner::Location source_location = scanner()->location();
447  Traits::ReportMessageAt(source_location, message, arg, is_reference_error);
448  }

References v8::internal::Scanner::location(), and v8::internal::ParserBase< Traits >::scanner().

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

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

◆ ReportMessageAt()

template<typename Traits >
void v8::internal::ParserBase< Traits >::ReportMessageAt ( Scanner::Location  location,
const char *  message,
bool  is_reference_error = false 
)
inlineprotected

Definition at line 450 of file preparser.h.

451  {
452  Traits::ReportMessageAt(location, message,
453  reinterpret_cast<const char*>(NULL),
454  is_reference_error);
455  }

References NULL.

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

+ Here is the caller graph for this function:

◆ ReportUnexpectedToken()

template<class Traits >
void v8::internal::ParserBase< Traits >::ReportUnexpectedToken ( Token::Value  token)
protected

Definition at line 1608 of file preparser.h.

1608  {
1609  Scanner::Location source_location = scanner()->location();
1610 
1611  // Four of the tokens are treated specially
1612  switch (token) {
1613  case Token::EOS:
1614  return ReportMessageAt(source_location, "unexpected_eos");
1615  case Token::NUMBER:
1616  return ReportMessageAt(source_location, "unexpected_token_number");
1617  case Token::STRING:
1618  return ReportMessageAt(source_location, "unexpected_token_string");
1619  case Token::IDENTIFIER:
1620  return ReportMessageAt(source_location, "unexpected_token_identifier");
1621  case Token::FUTURE_RESERVED_WORD:
1622  return ReportMessageAt(source_location, "unexpected_reserved");
1623  case Token::LET:
1624  case Token::YIELD:
1625  case Token::FUTURE_STRICT_RESERVED_WORD:
1626  return ReportMessageAt(source_location, strict_mode() == SLOPPY
1627  ? "unexpected_token_identifier" : "unexpected_strict_reserved");
1628  default:
1629  const char* name = Token::String(token);
1630  DCHECK(name != NULL);
1631  Traits::ReportMessageAt(source_location, "unexpected_token", name);
1632  }
1633 }
static const char * String(Value tok)
Definition: token.h:276

References DCHECK, v8::internal::LET, name, NULL, v8::internal::SLOPPY, STRING, v8::internal::Token::String(), and v8::internal::YIELD.

Referenced by v8::internal::ParserBase< Traits >::Expect(), and v8::internal::ParserBase< Traits >::ExpectContextualKeyword().

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

◆ scanner()

template<typename Traits >
Scanner* v8::internal::ParserBase< Traits >::scanner ( ) const
inlineprotected

◆ set_allow_arrow_functions()

template<typename Traits >
void v8::internal::ParserBase< Traits >::set_allow_arrow_functions ( bool  allow)
inline

Definition at line 112 of file preparser.h.

112 { allow_arrow_functions_ = allow; }

References v8::internal::ParserBase< Traits >::allow_arrow_functions_.

Referenced by v8::internal::Parser::ParseLazyFunctionBodyWithPreParser().

+ Here is the caller graph for this function:

◆ set_allow_classes()

template<typename Traits >
void v8::internal::ParserBase< Traits >::set_allow_classes ( bool  allow)
inline

Definition at line 120 of file preparser.h.

120 { scanner()->SetHarmonyClasses(allow); }
void SetHarmonyClasses(bool classes)
Definition: scanner.h:444

References v8::internal::ParserBase< Traits >::scanner(), and v8::internal::Scanner::SetHarmonyClasses().

Referenced by v8::internal::Parser::ParseLazyFunctionBodyWithPreParser().

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

◆ set_allow_harmony_numeric_literals()

template<typename Traits >
void v8::internal::ParserBase< Traits >::set_allow_harmony_numeric_literals ( bool  allow)
inline

Definition at line 117 of file preparser.h.

117  {
119  }
void SetHarmonyNumericLiterals(bool numeric_literals)
Definition: scanner.h:438

References v8::internal::ParserBase< Traits >::scanner(), and v8::internal::Scanner::SetHarmonyNumericLiterals().

Referenced by v8::internal::Parser::ParseLazyFunctionBodyWithPreParser().

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

◆ set_allow_harmony_object_literals()

template<typename Traits >
void v8::internal::ParserBase< Traits >::set_allow_harmony_object_literals ( bool  allow)
inline

Definition at line 121 of file preparser.h.

121  {
123  }

References v8::internal::ParserBase< Traits >::allow_harmony_object_literals_.

Referenced by v8::internal::Parser::ParseLazyFunctionBodyWithPreParser().

+ Here is the caller graph for this function:

◆ set_allow_harmony_scoping()

template<typename Traits >
void v8::internal::ParserBase< Traits >::set_allow_harmony_scoping ( bool  allow)
inline

Definition at line 114 of file preparser.h.

114  {
115  scanner()->SetHarmonyScoping(allow);
116  }
void SetHarmonyScoping(bool scoping)
Definition: scanner.h:426

References v8::internal::ParserBase< Traits >::scanner(), and v8::internal::Scanner::SetHarmonyScoping().

Referenced by v8::internal::Parser::ParseLazyFunctionBodyWithPreParser().

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

◆ set_allow_lazy()

template<typename Traits >
void v8::internal::ParserBase< Traits >::set_allow_lazy ( bool  allow)
inline

Definition at line 110 of file preparser.h.

110 { allow_lazy_ = allow; }

References v8::internal::ParserBase< Traits >::allow_lazy_.

Referenced by v8::internal::Parser::Parse(), and v8::internal::Parser::ParseLazyFunctionBodyWithPreParser().

+ Here is the caller graph for this function:

◆ set_allow_modules()

template<typename Traits >
void v8::internal::ParserBase< Traits >::set_allow_modules ( bool  allow)
inline

Definition at line 113 of file preparser.h.

113 { scanner()->SetHarmonyModules(allow); }
void SetHarmonyModules(bool modules)
Definition: scanner.h:432

References v8::internal::ParserBase< Traits >::scanner(), and v8::internal::Scanner::SetHarmonyModules().

Referenced by v8::internal::Parser::ParseLazyFunctionBodyWithPreParser().

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

◆ set_allow_natives_syntax()

template<typename Traits >
void v8::internal::ParserBase< Traits >::set_allow_natives_syntax ( bool  allow)
inline

Definition at line 111 of file preparser.h.

111 { allow_natives_syntax_ = allow; }

References v8::internal::ParserBase< Traits >::allow_natives_syntax_.

Referenced by v8::internal::Parser::ParseLazyFunctionBodyWithPreParser().

+ Here is the caller graph for this function:

◆ set_stack_overflow()

template<typename Traits >
void v8::internal::ParserBase< Traits >::set_stack_overflow ( )
inlineprotected

Definition at line 289 of file preparser.h.

289 { stack_overflow_ = true; }

References v8::internal::ParserBase< Traits >::stack_overflow_.

◆ stack_overflow()

template<typename Traits >
bool v8::internal::ParserBase< Traits >::stack_overflow ( ) const
inlineprotected

Definition at line 288 of file preparser.h.

288 { return stack_overflow_; }

References v8::internal::ParserBase< Traits >::stack_overflow_.

Referenced by v8::internal::ParserTraits::ReportMessageAt().

+ Here is the caller graph for this function:

◆ strict_mode()

template<typename Traits >
StrictMode v8::internal::ParserBase< Traits >::strict_mode ( )
inlineprotected

Definition at line 440 of file preparser.h.

440 { return scope_->strict_mode(); }

References v8::internal::ParserBase< Traits >::scope_.

◆ zone()

template<typename Traits >
Traits::Type::Zone* v8::internal::ParserBase< Traits >::zone ( ) const
inlineprotected

Definition at line 291 of file preparser.h.

291 { return zone_; }

References v8::internal::ParserBase< Traits >::zone_.

Referenced by v8::internal::ParserTraits::GetIterator(), and v8::internal::ParserTraits::NewThrowError().

+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ Traits::Checkpoint

template<typename Traits >
friend class Traits::Checkpoint
friend

Definition at line 126 of file preparser.h.

Member Data Documentation

◆ allow_arrow_functions_

template<typename Traits >
bool v8::internal::ParserBase< Traits >::allow_arrow_functions_
private

◆ allow_harmony_object_literals_

template<typename Traits >
bool v8::internal::ParserBase< Traits >::allow_harmony_object_literals_
private

◆ allow_lazy_

template<typename Traits >
bool v8::internal::ParserBase< Traits >::allow_lazy_
private

◆ allow_natives_syntax_

template<typename Traits >
bool v8::internal::ParserBase< Traits >::allow_natives_syntax_
private

◆ ast_node_id_gen_

◆ extension_

template<typename Traits >
v8::Extension* v8::internal::ParserBase< Traits >::extension_
protected

Definition at line 579 of file preparser.h.

◆ fni_

◆ function_state_

◆ log_

template<typename Traits >
ParserRecorder* v8::internal::ParserBase< Traits >::log_
protected

Definition at line 581 of file preparser.h.

Referenced by v8::internal::PreParserTraits::ReportMessageAt().

◆ mode_

template<typename Traits >
Mode v8::internal::ParserBase< Traits >::mode_
protected

Definition at line 582 of file preparser.h.

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

◆ parenthesized_function_

template<typename Traits >
bool v8::internal::ParserBase< Traits >::parenthesized_function_
protected

Definition at line 575 of file preparser.h.

◆ scanner_

◆ scope_

template<typename Traits >
Traits::Type::Scope* v8::internal::ParserBase< Traits >::scope_
protected

◆ stack_limit_

template<typename Traits >
uintptr_t v8::internal::ParserBase< Traits >::stack_limit_
protected

Definition at line 583 of file preparser.h.

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

◆ stack_overflow_

◆ zone_

template<typename Traits >
Traits::Type::Zone* v8::internal::ParserBase< Traits >::zone_
private

Definition at line 594 of file preparser.h.

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


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