V8 Project
v8::internal::ParserTraits Class Reference

#include <parser.h>

+ Inheritance diagram for v8::internal::ParserTraits:
+ Collaboration diagram for v8::internal::ParserTraits:

Classes

class  Checkpoint
 
struct  Type
 

Public Member Functions

 ParserTraits (Parser *parser)
 
bool IsEvalOrArguments (const AstRawString *identifier) const
 
bool IsFutureStrictReserved (const AstRawString *identifier) const
 
bool IsPrototype (const AstRawString *identifier) const
 
bool IsConstructor (const AstRawString *identifier) const
 
void PushPropertyName (FuncNameInferrer *fni, Expression *expression)
 
void CheckPossibleEvalCall (Expression *expression, Scope *scope)
 
bool ShortcutNumericLiteralBinaryExpression (Expression **x, Expression *y, Token::Value op, int pos, AstNodeFactory< AstConstructionVisitor > *factory)
 
ExpressionBuildUnaryExpression (Expression *expression, Token::Value op, int pos, AstNodeFactory< AstConstructionVisitor > *factory)
 
ExpressionNewThrowReferenceError (const char *type, int pos)
 
ExpressionNewThrowSyntaxError (const char *type, const AstRawString *arg, int pos)
 
ExpressionNewThrowTypeError (const char *type, const AstRawString *arg, int pos)
 
ExpressionNewThrowError (const AstRawString *constructor, const char *type, const AstRawString *arg, int pos)
 
void ReportMessageAt (Scanner::Location source_location, const char *message, const char *arg=NULL, bool is_reference_error=false)
 
void ReportMessage (const char *message, const char *arg=NULL, bool is_reference_error=false)
 
void ReportMessage (const char *message, const AstRawString *arg, bool is_reference_error=false)
 
void ReportMessageAt (Scanner::Location source_location, const char *message, const AstRawString *arg, bool is_reference_error=false)
 
const AstRawStringEmptyIdentifierString ()
 
Literal * GetLiteralTheHole (int position, AstNodeFactory< AstConstructionVisitor > *factory)
 
const AstRawStringGetSymbol (Scanner *scanner)
 
const AstRawStringGetNextSymbol (Scanner *scanner)
 
const AstRawStringGetNumberAsSymbol (Scanner *scanner)
 
ExpressionThisExpression (Scope *scope, AstNodeFactory< AstConstructionVisitor > *factory, int pos=RelocInfo::kNoPosition)
 
ExpressionSuperReference (Scope *scope, AstNodeFactory< AstConstructionVisitor > *factory, int pos=RelocInfo::kNoPosition)
 
ExpressionClassLiteral (const AstRawString *name, Expression *extends, Expression *constructor, ZoneList< ObjectLiteral::Property * > *properties, int pos, AstNodeFactory< AstConstructionVisitor > *factory)
 
Literal * ExpressionFromLiteral (Token::Value token, int pos, Scanner *scanner, AstNodeFactory< AstConstructionVisitor > *factory)
 
ExpressionExpressionFromIdentifier (const AstRawString *name, int pos, Scope *scope, AstNodeFactory< AstConstructionVisitor > *factory)
 
ExpressionExpressionFromString (int pos, Scanner *scanner, AstNodeFactory< AstConstructionVisitor > *factory)
 
ExpressionGetIterator (Expression *iterable, AstNodeFactory< AstConstructionVisitor > *factory)
 
ZoneList< v8::internal::Expression * > * NewExpressionList (int size, Zone *zone)
 
ZoneList< ObjectLiteral::Property * > * NewPropertyList (int size, Zone *zone)
 
ZoneList< v8::internal::Statement * > * NewStatementList (int size, Zone *zone)
 
ScopeNewScope (Scope *parent_scope, ScopeType scope_type)
 
int DeclareArrowParametersFromExpression (Expression *expression, Scope *scope, Scanner::Location *dupe_loc, bool *ok)
 
AstValueFactoryast_value_factory ()
 
ExpressionParseV8Intrinsic (bool *ok)
 
FunctionLiteral * ParseFunctionLiteral (const AstRawString *name, Scanner::Location function_name_location, bool name_is_strict_reserved, FunctionKind kind, int function_token_position, FunctionLiteral::FunctionType type, FunctionLiteral::ArityRestriction arity_restriction, bool *ok)
 
void SkipLazyFunctionBody (const AstRawString *name, int *materialized_literal_count, int *expected_property_count, bool *ok)
 
ZoneList< Statement * > * ParseEagerFunctionBody (const AstRawString *name, int pos, Variable *fvar, Token::Value fvar_init_op, bool is_generator, bool *ok)
 
void CheckConflictingVarDeclarations (v8::internal::Scope *scope, bool *ok)
 

Static Public Member Functions

template<typename FunctionState >
static void SetUpFunctionState (FunctionState *function_state)
 
template<typename FunctionState >
static void TearDownFunctionState (FunctionState *function_state)
 
static bool IsThisProperty (Expression *expression)
 
static bool IsIdentifier (Expression *expression)
 
static const AstRawStringAsIdentifier (Expression *expression)
 
static bool IsBoilerplateProperty (ObjectLiteral::Property *property)
 
static bool IsArrayIndex (const AstRawString *string, uint32_t *index)
 
static void PushLiteralName (FuncNameInferrer *fni, const AstRawString *id)
 
static void InferFunctionName (FuncNameInferrer *fni, FunctionLiteral *func_to_infer)
 
static void CheckFunctionLiteralInsideTopLevelObjectLiteral (Scope *scope, ObjectLiteralProperty *property, bool *has_function)
 
static void CheckAssigningFunctionLiteralToProperty (Expression *left, Expression *right)
 
static ExpressionMarkExpressionAsAssigned (Expression *expression)
 
static const AstRawStringEmptyIdentifier ()
 
static ExpressionEmptyExpression ()
 
static ExpressionEmptyArrowParamList ()
 
static Literal * EmptyLiteral ()
 
static ObjectLiteralProperty * EmptyObjectLiteralProperty ()
 
static FunctionLiteral * EmptyFunctionLiteral ()
 
static ZoneList< Expression * > * NullExpressionList ()
 

Private Attributes

Parserparser_
 

Detailed Description

Definition at line 345 of file parser.h.

Constructor & Destructor Documentation

◆ ParserTraits()

v8::internal::ParserTraits::ParserTraits ( Parser parser)
inlineexplicit

Definition at line 379 of file parser.h.

379 : parser_(parser) {}

Member Function Documentation

◆ AsIdentifier()

static const AstRawString* v8::internal::ParserTraits::AsIdentifier ( Expression expression)
inlinestatic

Definition at line 409 of file parser.h.

409  {
410  DCHECK(IsIdentifier(expression));
411  return expression->AsVariableProxy()->raw_name();
412  }
static bool IsIdentifier(Expression *expression)
Definition: parser.cc:389
#define DCHECK(condition)
Definition: logging.h:205

References DCHECK, and IsIdentifier().

+ Here is the call graph for this function:

◆ ast_value_factory()

AstValueFactory * v8::internal::ParserTraits::ast_value_factory ( )
inline

Definition at line 895 of file parser.h.

895  {
896  return parser_->ast_value_factory();
897 }
AstValueFactory * ast_value_factory() const
Definition: parser.h:682

References v8::internal::Parser::ast_value_factory(), and parser_.

Referenced by GetNumberAsSymbol().

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

◆ BuildUnaryExpression()

Expression * v8::internal::ParserTraits::BuildUnaryExpression ( Expression expression,
Token::Value  op,
int  pos,
AstNodeFactory< AstConstructionVisitor > *  factory 
)

Definition at line 494 of file parser.cc.

496  {
497  DCHECK(expression != NULL);
498  if (expression->IsLiteral()) {
499  const AstValue* literal = expression->AsLiteral()->raw_value();
500  if (op == Token::NOT) {
501  // Convert the literal to a boolean condition and negate it.
502  bool condition = literal->BooleanValue();
503  return factory->NewBooleanLiteral(!condition, pos);
504  } else if (literal->IsNumber()) {
505  // Compute some expressions involving only number literals.
506  double value = literal->AsNumber();
507  switch (op) {
508  case Token::ADD:
509  return expression;
510  case Token::SUB:
511  return factory->NewNumberLiteral(-value, pos);
512  case Token::BIT_NOT:
513  return factory->NewNumberLiteral(~DoubleToInt32(value), pos);
514  default:
515  break;
516  }
517  }
518  }
519  // Desugar '+foo' => 'foo*1'
520  if (op == Token::ADD) {
521  return factory->NewBinaryOperation(
522  Token::MUL, expression, factory->NewNumberLiteral(1, pos), pos);
523  }
524  // The same idea for '-foo' => 'foo*(-1)'.
525  if (op == Token::SUB) {
526  return factory->NewBinaryOperation(
527  Token::MUL, expression, factory->NewNumberLiteral(-1, pos), pos);
528  }
529  // ...and one more time for '~foo' => 'foo^(~0)'.
530  if (op == Token::BIT_NOT) {
531  return factory->NewBinaryOperation(
532  Token::BIT_XOR, expression, factory->NewNumberLiteral(~0, pos), pos);
533  }
534  return factory->NewUnaryOperation(op, expression, pos);
535 }
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
int32_t DoubleToInt32(double x)

References v8::internal::ADD, v8::internal::AstValue::AsNumber(), v8::internal::AstValue::BooleanValue(), DCHECK, v8::internal::DoubleToInt32(), v8::internal::AstValue::IsNumber(), v8::internal::MUL, v8::internal::NOT, NULL, and v8::internal::SUB.

+ Here is the call graph for this function:

◆ CheckAssigningFunctionLiteralToProperty()

void v8::internal::ParserTraits::CheckAssigningFunctionLiteralToProperty ( Expression left,
Expression right 
)
static

Definition at line 406 of file parser.cc.

407  {
408  DCHECK(left != NULL);
409  if (left->AsProperty() != NULL &&
410  right->AsFunctionLiteral() != NULL) {
411  right->AsFunctionLiteral()->set_pretenure();
412  }
413 }

References DCHECK, and NULL.

◆ CheckConflictingVarDeclarations()

void v8::internal::ParserTraits::CheckConflictingVarDeclarations ( v8::internal::Scope scope,
bool ok 
)
inline

Definition at line 889 of file parser.h.

890  {
892 }
void CheckConflictingVarDeclarations(Scope *scope, bool *ok)
Definition: parser.cc:3919

References v8::internal::Parser::CheckConflictingVarDeclarations(), and parser_.

+ Here is the call graph for this function:

◆ CheckFunctionLiteralInsideTopLevelObjectLiteral()

static void v8::internal::ParserTraits::CheckFunctionLiteralInsideTopLevelObjectLiteral ( Scope scope,
ObjectLiteralProperty *  property,
bool has_function 
)
inlinestatic

Definition at line 433 of file parser.h.

434  {
435  Expression* value = property->value();
436  if (scope->DeclarationScope()->is_global_scope() &&
437  value->AsFunctionLiteral() != NULL) {
438  *has_function = true;
439  value->AsFunctionLiteral()->set_pretenure();
440  }
441  }

References v8::internal::Scope::DeclarationScope(), v8::internal::Scope::is_global_scope(), and NULL.

+ Here is the call graph for this function:

◆ CheckPossibleEvalCall()

void v8::internal::ParserTraits::CheckPossibleEvalCall ( Expression expression,
Scope scope 
)

Definition at line 416 of file parser.cc.

417  {
418  VariableProxy* callee = expression->AsVariableProxy();
419  if (callee != NULL &&
420  callee->raw_name() == parser_->ast_value_factory()->eval_string()) {
421  scope->DeclarationScope()->RecordEvalCall();
422  }
423 }

References v8::internal::Parser::ast_value_factory(), v8::internal::Scope::DeclarationScope(), NULL, parser_, and v8::internal::Scope::RecordEvalCall().

+ Here is the call graph for this function:

◆ ClassLiteral()

Expression * v8::internal::ParserTraits::ClassLiteral ( const AstRawString name,
Expression extends,
Expression constructor,
ZoneList< ObjectLiteral::Property * > *  properties,
int  pos,
AstNodeFactory< AstConstructionVisitor > *  factory 
)

Definition at line 668 of file parser.cc.

671  {
672  return factory->NewClassLiteral(name, extends, constructor, properties, pos);
673 }
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 name.

◆ DeclareArrowParametersFromExpression()

int v8::internal::ParserTraits::DeclareArrowParametersFromExpression ( Expression expression,
Scope scope,
Scanner::Location dupe_loc,
bool ok 
)

Definition at line 3426 of file parser.cc.

3428  {
3429  int num_params = 0;
3430  *ok = CheckAndDeclareArrowParameter(this, expression, scope, &num_params,
3431  dupe_loc);
3432  return num_params;
3433 }
bool CheckAndDeclareArrowParameter(ParserTraits *traits, Expression *expression, Scope *scope, int *num_params, Scanner::Location *dupe_loc)
Definition: parser.cc:3374

References v8::internal::CheckAndDeclareArrowParameter().

+ Here is the call graph for this function:

◆ EmptyArrowParamList()

static Expression* v8::internal::ParserTraits::EmptyArrowParamList ( )
inlinestatic

Definition at line 521 of file parser.h.

521 { return NULL; }

References NULL.

◆ EmptyExpression()

static Expression* v8::internal::ParserTraits::EmptyExpression ( )
inlinestatic

Definition at line 518 of file parser.h.

518  {
519  return NULL;
520  }

References NULL.

◆ EmptyFunctionLiteral()

static FunctionLiteral* v8::internal::ParserTraits::EmptyFunctionLiteral ( )
inlinestatic

Definition at line 526 of file parser.h.

526 { return NULL; }

References NULL.

◆ EmptyIdentifier()

static const AstRawString* v8::internal::ParserTraits::EmptyIdentifier ( )
inlinestatic

Definition at line 515 of file parser.h.

515  {
516  return NULL;
517  }

References NULL.

◆ EmptyIdentifierString()

const AstRawString * v8::internal::ParserTraits::EmptyIdentifierString ( )
inline

Definition at line 868 of file parser.h.

868  {
869  return parser_->ast_value_factory()->empty_string();
870 }

References v8::internal::Parser::ast_value_factory(), and parser_.

+ Here is the call graph for this function:

◆ EmptyLiteral()

static Literal* v8::internal::ParserTraits::EmptyLiteral ( )
inlinestatic

Definition at line 522 of file parser.h.

522  {
523  return NULL;
524  }

References NULL.

◆ EmptyObjectLiteralProperty()

static ObjectLiteralProperty* v8::internal::ParserTraits::EmptyObjectLiteralProperty ( )
inlinestatic

Definition at line 525 of file parser.h.

525 { return NULL; }

References NULL.

◆ ExpressionFromIdentifier()

Expression * v8::internal::ParserTraits::ExpressionFromIdentifier ( const AstRawString name,
int  pos,
Scope scope,
AstNodeFactory< AstConstructionVisitor > *  factory 
)

Definition at line 697 of file parser.cc.

699  {
701  // The name may refer to a module instance object, so its type is unknown.
702 #ifdef DEBUG
703  if (FLAG_print_interface_details)
704  PrintF("# Variable %.*s ", name->length(), name->raw_data());
705 #endif
706  Interface* interface = Interface::NewUnknown(parser_->zone());
707  return scope->NewUnresolved(factory, name, interface, pos);
708 }
void PushVariableName(const AstRawString *name)
static Interface * NewUnknown(Zone *zone)
Definition: interface.h:40
FuncNameInferrer * fni_
Definition: preparser.h:580
void PrintF(const char *format,...)
Definition: utils.cc:80

References v8::internal::ParserBase< Traits >::fni_, name, v8::internal::Interface::NewUnknown(), v8::internal::Scope::NewUnresolved(), NULL, parser_, v8::internal::PrintF(), and v8::internal::FuncNameInferrer::PushVariableName().

+ Here is the call graph for this function:

◆ ExpressionFromLiteral()

Literal * v8::internal::ParserTraits::ExpressionFromLiteral ( Token::Value  token,
int  pos,
Scanner scanner,
AstNodeFactory< AstConstructionVisitor > *  factory 
)

Definition at line 675 of file parser.cc.

678  {
679  switch (token) {
680  case Token::NULL_LITERAL:
681  return factory->NewNullLiteral(pos);
682  case Token::TRUE_LITERAL:
683  return factory->NewBooleanLiteral(true, pos);
684  case Token::FALSE_LITERAL:
685  return factory->NewBooleanLiteral(false, pos);
686  case Token::NUMBER: {
687  double value = scanner->DoubleValue();
688  return factory->NewNumberLiteral(value, pos);
689  }
690  default:
691  DCHECK(false);
692  }
693  return NULL;
694 }

References DCHECK, v8::internal::Scanner::DoubleValue(), and NULL.

+ Here is the call graph for this function:

◆ ExpressionFromString()

Expression * v8::internal::ParserTraits::ExpressionFromString ( int  pos,
Scanner scanner,
AstNodeFactory< AstConstructionVisitor > *  factory 
)

Definition at line 711 of file parser.cc.

713  {
714  const AstRawString* symbol = GetSymbol(scanner);
715  if (parser_->fni_ != NULL) parser_->fni_->PushLiteralName(symbol);
716  return factory->NewStringLiteral(symbol, pos);
717 }
void PushLiteralName(const AstRawString *name)
const AstRawString * GetSymbol(Scanner *scanner)
Definition: parser.cc:634

References v8::internal::ParserBase< Traits >::fni_, GetSymbol(), NULL, parser_, and v8::internal::FuncNameInferrer::PushLiteralName().

+ Here is the call graph for this function:

◆ GetIterator()

Expression * v8::internal::ParserTraits::GetIterator ( Expression iterable,
AstNodeFactory< AstConstructionVisitor > *  factory 
)

Definition at line 720 of file parser.cc.

721  {
722  Expression* iterator_symbol_literal =
723  factory->NewSymbolLiteral("symbolIterator", RelocInfo::kNoPosition);
724  int pos = iterable->position();
725  Expression* prop =
726  factory->NewProperty(iterable, iterator_symbol_literal, pos);
727  Zone* zone = parser_->zone();
728  ZoneList<Expression*>* args = new (zone) ZoneList<Expression*>(0, zone);
729  return factory->NewCall(prop, args, pos);
730 }
Traits::Type::Zone * zone() const
Definition: preparser.h:291
static const int kNoPosition
Definition: assembler.h:317

References v8::internal::RelocInfo::kNoPosition, parser_, v8::internal::AstNode::position(), and v8::internal::ParserBase< Traits >::zone().

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

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

◆ GetLiteralTheHole()

Literal * v8::internal::ParserTraits::GetLiteralTheHole ( int  position,
AstNodeFactory< AstConstructionVisitor > *  factory 
)

Definition at line 733 of file parser.cc.

734  {
735  return factory->NewTheHoleLiteral(RelocInfo::kNoPosition);
736 }

References v8::internal::RelocInfo::kNoPosition.

◆ GetNextSymbol()

const AstRawString * v8::internal::ParserTraits::GetNextSymbol ( Scanner scanner)

Definition at line 651 of file parser.cc.

651  {
653 }
Scanner * scanner() const
Definition: preparser.h:285
const AstRawString * NextSymbol(AstValueFactory *ast_value_factory)
Definition: scanner.cc:1203

References v8::internal::Parser::ast_value_factory(), v8::internal::Scanner::NextSymbol(), parser_, and v8::internal::ParserBase< Traits >::scanner().

+ Here is the call graph for this function:

◆ GetNumberAsSymbol()

const AstRawString * v8::internal::ParserTraits::GetNumberAsSymbol ( Scanner scanner)

Definition at line 642 of file parser.cc.

642  {
643  double double_value = parser_->scanner()->DoubleValue();
644  char array[100];
645  const char* string =
646  DoubleToCString(double_value, Vector<char>(array, arraysize(array)));
647  return ast_value_factory()->GetOneByteString(string);
648 }
const AstRawString * GetOneByteString(Vector< const uint8_t > literal)
AstValueFactory * ast_value_factory()
Definition: parser.h:895
#define arraysize(array)
Definition: macros.h:86
const char * DoubleToCString(double v, Vector< char > buffer)
Definition: conversions.cc:121

References arraysize, ast_value_factory(), v8::internal::DoubleToCString(), v8::internal::Scanner::DoubleValue(), v8::internal::AstValueFactory::GetOneByteString(), parser_, and v8::internal::ParserBase< Traits >::scanner().

+ Here is the call graph for this function:

◆ GetSymbol()

const AstRawString * v8::internal::ParserTraits::GetSymbol ( Scanner scanner)

Definition at line 634 of file parser.cc.

634  {
635  const AstRawString* result =
637  DCHECK(result != NULL);
638  return result;
639 }
const AstRawString * CurrentSymbol(AstValueFactory *ast_value_factory)
Definition: scanner.cc:1195

References v8::internal::Parser::ast_value_factory(), v8::internal::Scanner::CurrentSymbol(), DCHECK, NULL, parser_, and v8::internal::ParserBase< Traits >::scanner().

Referenced by ExpressionFromString(), and v8::internal::Parser::ParseModuleUrl().

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

◆ InferFunctionName()

static void v8::internal::ParserTraits::InferFunctionName ( FuncNameInferrer fni,
FunctionLiteral *  func_to_infer 
)
inlinestatic

Definition at line 428 of file parser.h.

429  {
430  fni->AddFunction(func_to_infer);
431  }

References v8::internal::FuncNameInferrer::AddFunction().

+ Here is the call graph for this function:

◆ IsArrayIndex()

static bool v8::internal::ParserTraits::IsArrayIndex ( const AstRawString string,
uint32_t index 
)
inlinestatic

Definition at line 418 of file parser.h.

418  {
419  return string->AsArrayIndex(index);
420  }

◆ IsBoilerplateProperty()

static bool v8::internal::ParserTraits::IsBoilerplateProperty ( ObjectLiteral::Property *  property)
inlinestatic

Definition at line 414 of file parser.h.

414  {
415  return ObjectLiteral::IsBoilerplateProperty(property);
416  }

◆ IsConstructor()

bool v8::internal::ParserTraits::IsConstructor ( const AstRawString identifier) const

Definition at line 375 of file parser.cc.

375  {
376  return identifier == parser_->ast_value_factory()->constructor_string();
377 }

References v8::internal::Parser::ast_value_factory(), and parser_.

+ Here is the call graph for this function:

◆ IsEvalOrArguments()

bool v8::internal::ParserTraits::IsEvalOrArguments ( const AstRawString identifier) const

Definition at line 364 of file parser.cc.

364  {
365  return identifier == parser_->ast_value_factory()->eval_string() ||
366  identifier == parser_->ast_value_factory()->arguments_string();
367 }

References v8::internal::Parser::ast_value_factory(), and parser_.

Referenced by v8::internal::CheckAndDeclareArrowParameter(), and v8::internal::Parser::ParseFunctionLiteral().

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

◆ IsFutureStrictReserved()

bool v8::internal::ParserTraits::IsFutureStrictReserved ( const AstRawString identifier) const
inline

Definition at line 856 of file parser.h.

857  {
858  return identifier->IsOneByteEqualTo("yield") ||
860 }
bool IdentifierIsFutureStrictReserved(const AstRawString *string) const
Definition: scanner.cc:1017

References v8::internal::Scanner::IdentifierIsFutureStrictReserved(), v8::internal::AstRawString::IsOneByteEqualTo(), parser_, and v8::internal::ParserBase< Traits >::scanner().

Referenced by v8::internal::CheckAndDeclareArrowParameter().

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

◆ IsIdentifier()

bool v8::internal::ParserTraits::IsIdentifier ( Expression expression)
static

Definition at line 389 of file parser.cc.

389  {
390  VariableProxy* operand = expression->AsVariableProxy();
391  return operand != NULL && !operand->is_this();
392 }

References NULL.

Referenced by AsIdentifier().

+ Here is the caller graph for this function:

◆ IsPrototype()

bool v8::internal::ParserTraits::IsPrototype ( const AstRawString identifier) const

Definition at line 370 of file parser.cc.

370  {
371  return identifier == parser_->ast_value_factory()->prototype_string();
372 }

References v8::internal::Parser::ast_value_factory(), and parser_.

+ Here is the call graph for this function:

◆ IsThisProperty()

bool v8::internal::ParserTraits::IsThisProperty ( Expression expression)
static

Definition at line 380 of file parser.cc.

380  {
381  DCHECK(expression != NULL);
382  Property* property = expression->AsProperty();
383  return property != NULL &&
384  property->obj()->AsVariableProxy() != NULL &&
385  property->obj()->AsVariableProxy()->is_this();
386 }

References DCHECK, and NULL.

◆ MarkExpressionAsAssigned()

Expression * v8::internal::ParserTraits::MarkExpressionAsAssigned ( Expression expression)
static

Definition at line 426 of file parser.cc.

426  {
427  VariableProxy* proxy =
428  expression != NULL ? expression->AsVariableProxy() : NULL;
429  if (proxy != NULL) proxy->set_is_assigned();
430  return expression;
431 }

References NULL.

◆ NewExpressionList()

ZoneList<v8::internal::Expression*>* v8::internal::ParserTraits::NewExpressionList ( int  size,
Zone zone 
)
inline

Definition at line 568 of file parser.h.

568  {
569  return new(zone) ZoneList<v8::internal::Expression*>(size, zone);
570  }
enable harmony numeric enable harmony object literal extensions Optimize object size

References size.

◆ NewPropertyList()

ZoneList<ObjectLiteral::Property*>* v8::internal::ParserTraits::NewPropertyList ( int  size,
Zone zone 
)
inline

Definition at line 571 of file parser.h.

571  {
572  return new(zone) ZoneList<ObjectLiteral::Property*>(size, zone);
573  }

References size.

◆ NewScope()

Scope * v8::internal::ParserTraits::NewScope ( Scope parent_scope,
ScopeType  scope_type 
)
inline

Definition at line 863 of file parser.h.

863  {
864  return parser_->NewScope(parent_scope, scope_type);
865 }
Scope * NewScope(Scope *parent, ScopeType type)
Definition: parser.cc:269

References v8::internal::Parser::NewScope(), and parser_.

+ Here is the call graph for this function:

◆ NewStatementList()

ZoneList<v8::internal::Statement*>* v8::internal::ParserTraits::NewStatementList ( int  size,
Zone zone 
)
inline

Definition at line 574 of file parser.h.

574  {
575  return new(zone) ZoneList<v8::internal::Statement*>(size, zone);
576  }

References size.

◆ NewThrowError()

Expression * v8::internal::ParserTraits::NewThrowError ( const AstRawString constructor,
const char *  type,
const AstRawString arg,
int  pos 
)

Definition at line 559 of file parser.cc.

561  {
562  Zone* zone = parser_->zone();
563  int argc = arg != NULL ? 1 : 0;
564  const AstRawString* type =
566  ZoneList<const AstRawString*>* array =
567  new (zone) ZoneList<const AstRawString*>(argc, zone);
568  if (arg != NULL) {
569  array->Add(arg, zone);
570  }
571  ZoneList<Expression*>* args = new (zone) ZoneList<Expression*>(2, zone);
572  args->Add(parser_->factory()->NewStringLiteral(type, pos), zone);
573  args->Add(parser_->factory()->NewStringListLiteral(array, pos), zone);
574  CallRuntime* call_constructor =
575  parser_->factory()->NewCallRuntime(constructor, NULL, args, pos);
576  return parser_->factory()->NewThrow(call_constructor, pos);
577 }
Traits::Type::Factory * factory()
Definition: preparser.h:436

References v8::internal::List< T, AllocationPolicy >::Add(), v8::internal::Parser::ast_value_factory(), v8::internal::ParserBase< Traits >::factory(), v8::internal::AstValueFactory::GetOneByteString(), NULL, parser_, and v8::internal::ParserBase< Traits >::zone().

Referenced by NewThrowReferenceError(), NewThrowSyntaxError(), and NewThrowTypeError().

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

◆ NewThrowReferenceError()

Expression * v8::internal::ParserTraits::NewThrowReferenceError ( const char *  type,
int  pos 
)

Definition at line 538 of file parser.cc.

538  {
539  return NewThrowError(
540  parser_->ast_value_factory()->make_reference_error_string(), message,
541  NULL, pos);
542 }
Expression * NewThrowError(const AstRawString *constructor, const char *type, const AstRawString *arg, int pos)
Definition: parser.cc:559

References v8::internal::Parser::ast_value_factory(), NewThrowError(), NULL, and parser_.

+ Here is the call graph for this function:

◆ NewThrowSyntaxError()

Expression * v8::internal::ParserTraits::NewThrowSyntaxError ( const char *  type,
const AstRawString arg,
int  pos 
)

Definition at line 545 of file parser.cc.

546  {
547  return NewThrowError(parser_->ast_value_factory()->make_syntax_error_string(),
548  message, arg, pos);
549 }

References v8::internal::Parser::ast_value_factory(), NewThrowError(), and parser_.

+ Here is the call graph for this function:

◆ NewThrowTypeError()

Expression * v8::internal::ParserTraits::NewThrowTypeError ( const char *  type,
const AstRawString arg,
int  pos 
)

Definition at line 552 of file parser.cc.

553  {
554  return NewThrowError(parser_->ast_value_factory()->make_type_error_string(),
555  message, arg, pos);
556 }

References v8::internal::Parser::ast_value_factory(), NewThrowError(), and parser_.

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

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

◆ NullExpressionList()

static ZoneList<Expression*>* v8::internal::ParserTraits::NullExpressionList ( )
inlinestatic

Definition at line 529 of file parser.h.

529  {
530  return NULL;
531  }

References NULL.

◆ ParseEagerFunctionBody()

ZoneList< Statement * > * v8::internal::ParserTraits::ParseEagerFunctionBody ( const AstRawString name,
int  pos,
Variable fvar,
Token::Value  fvar_init_op,
bool  is_generator,
bool ok 
)
inline

Definition at line 882 of file parser.h.

884  {
885  return parser_->ParseEagerFunctionBody(name, pos, fvar, fvar_init_op,
886  is_generator, ok);
887 }
ZoneList< Statement * > * ParseEagerFunctionBody(const AstRawString *function_name, int pos, Variable *fvar, Token::Value fvar_init_op, bool is_generator, bool *ok)
Definition: parser.cc:3767

References name, v8::internal::Parser::ParseEagerFunctionBody(), and parser_.

+ Here is the call graph for this function:

◆ ParseFunctionLiteral()

FunctionLiteral * v8::internal::ParserTraits::ParseFunctionLiteral ( const AstRawString name,
Scanner::Location  function_name_location,
bool  name_is_strict_reserved,
FunctionKind  kind,
int  function_token_position,
FunctionLiteral::FunctionType  type,
FunctionLiteral::ArityRestriction  arity_restriction,
bool ok 
)

Definition at line 744 of file parser.cc.

748  {
750  name, function_name_location, name_is_strict_reserved, kind,
751  function_token_position, type, arity_restriction, ok);
752 }
FunctionLiteral * ParseFunctionLiteral(const AstRawString *name, Scanner::Location function_name_location, bool name_is_strict_reserved, FunctionKind kind, int function_token_position, FunctionLiteral::FunctionType type, FunctionLiteral::ArityRestriction arity_restriction, bool *ok)
Definition: parser.cc:3436
kExpectedNofPropertiesOffset function_token_position
Definition: objects-inl.h:5513

References v8::internal::function_token_position, name, v8::internal::Parser::ParseFunctionLiteral(), and parser_.

+ Here is the call graph for this function:

◆ ParseV8Intrinsic()

Expression * v8::internal::ParserTraits::ParseV8Intrinsic ( bool ok)

Definition at line 739 of file parser.cc.

739  {
740  return parser_->ParseV8Intrinsic(ok);
741 }
Expression * ParseV8Intrinsic(bool *ok)
Definition: parser.cc:3859

References parser_, and v8::internal::Parser::ParseV8Intrinsic().

+ Here is the call graph for this function:

◆ PushLiteralName()

static void v8::internal::ParserTraits::PushLiteralName ( FuncNameInferrer fni,
const AstRawString id 
)
inlinestatic

Definition at line 424 of file parser.h.

424  {
425  fni->PushLiteralName(id);
426  }

References v8::internal::FuncNameInferrer::PushLiteralName().

+ Here is the call graph for this function:

◆ PushPropertyName()

void v8::internal::ParserTraits::PushPropertyName ( FuncNameInferrer fni,
Expression expression 
)

Definition at line 395 of file parser.cc.

396  {
397  if (expression->IsPropertyName()) {
398  fni->PushLiteralName(expression->AsLiteral()->AsRawPropertyName());
399  } else {
400  fni->PushLiteralName(
401  parser_->ast_value_factory()->anonymous_function_string());
402  }
403 }

References v8::internal::Parser::ast_value_factory(), v8::internal::Expression::IsPropertyName(), parser_, and v8::internal::FuncNameInferrer::PushLiteralName().

+ Here is the call graph for this function:

◆ ReportMessage() [1/2]

void v8::internal::ParserTraits::ReportMessage ( const char *  message,
const AstRawString arg,
bool  is_reference_error = false 
)

Definition at line 607 of file parser.cc.

609  {
610  Scanner::Location source_location = parser_->scanner()->location();
611  ReportMessageAt(source_location, message, arg, is_reference_error);
612 }
void ReportMessageAt(Scanner::Location source_location, const char *message, const char *arg=NULL, bool is_reference_error=false)
Definition: parser.cc:580
Location location() const
Definition: scanner.h:356

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

+ Here is the call graph for this function:

◆ ReportMessage() [2/2]

void v8::internal::ParserTraits::ReportMessage ( const char *  message,
const char *  arg = NULL,
bool  is_reference_error = false 
)

Definition at line 599 of file parser.cc.

601  {
602  Scanner::Location source_location = parser_->scanner()->location();
603  ReportMessageAt(source_location, message, arg, is_reference_error);
604 }

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

Referenced by v8::internal::Parser::Declare(), v8::internal::Parser::ParseBreakStatement(), v8::internal::Parser::ParseContinueStatement(), v8::internal::Parser::ParseExpressionOrLabelledStatement(), v8::internal::Parser::ParseImportDeclaration(), v8::internal::Parser::ParseModuleLiteral(), v8::internal::Parser::ParseModulePath(), and v8::internal::Parser::ParseV8Intrinsic().

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

◆ ReportMessageAt() [1/2]

void v8::internal::ParserTraits::ReportMessageAt ( Scanner::Location  source_location,
const char *  message,
const AstRawString arg,
bool  is_reference_error = false 
)

Definition at line 615 of file parser.cc.

618  {
619  if (parser_->stack_overflow()) {
620  // Suppress the error message (syntax error or such) in the presence of a
621  // stack overflow. The isolate allows only one pending exception at at time
622  // and we want to report the stack overflow later.
623  return;
624  }
625  parser_->has_pending_error_ = true;
626  parser_->pending_error_location_ = source_location;
627  parser_->pending_error_message_ = message;
630  parser_->pending_error_is_reference_error_ = is_reference_error;
631 }
bool stack_overflow() const
Definition: preparser.h:288
bool pending_error_is_reference_error_
Definition: parser.h:846
const AstRawString * pending_error_arg_
Definition: parser.h:844
bool has_pending_error_
Definition: parser.h:841
const char * pending_error_char_arg_
Definition: parser.h:845
Scanner::Location pending_error_location_
Definition: parser.h:842
const char * pending_error_message_
Definition: parser.h:843

References v8::internal::Parser::has_pending_error_, NULL, parser_, v8::internal::Parser::pending_error_arg_, v8::internal::Parser::pending_error_char_arg_, v8::internal::Parser::pending_error_is_reference_error_, v8::internal::Parser::pending_error_location_, v8::internal::Parser::pending_error_message_, and v8::internal::ParserBase< Traits >::stack_overflow().

+ Here is the call graph for this function:

◆ ReportMessageAt() [2/2]

void v8::internal::ParserTraits::ReportMessageAt ( Scanner::Location  source_location,
const char *  message,
const char *  arg = NULL,
bool  is_reference_error = false 
)

Definition at line 580 of file parser.cc.

583  {
584  if (parser_->stack_overflow()) {
585  // Suppress the error message (syntax error or such) in the presence of a
586  // stack overflow. The isolate allows only one pending exception at at time
587  // and we want to report the stack overflow later.
588  return;
589  }
590  parser_->has_pending_error_ = true;
591  parser_->pending_error_location_ = source_location;
592  parser_->pending_error_message_ = message;
595  parser_->pending_error_is_reference_error_ = is_reference_error;
596 }

References v8::internal::Parser::has_pending_error_, NULL, parser_, v8::internal::Parser::pending_error_arg_, v8::internal::Parser::pending_error_char_arg_, v8::internal::Parser::pending_error_is_reference_error_, v8::internal::Parser::pending_error_location_, v8::internal::Parser::pending_error_message_, and v8::internal::ParserBase< Traits >::stack_overflow().

Referenced by v8::internal::Parser::CheckConflictingVarDeclarations(), ReportMessage(), and v8::internal::Parser::SkipLazyFunctionBody().

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

◆ SetUpFunctionState()

template<typename FunctionState >
static void v8::internal::ParserTraits::SetUpFunctionState ( FunctionState *  function_state)
inlinestatic

Definition at line 383 of file parser.h.

383  {
384  function_state->saved_id_gen_ = *function_state->ast_node_id_gen_;
385  *function_state->ast_node_id_gen_ =
386  AstNode::IdGen(BailoutId::FirstUsable().ToInt());
387  }
static BailoutId FirstUsable()
Definition: utils.h:963

References v8::internal::BailoutId::FirstUsable().

+ Here is the call graph for this function:

◆ ShortcutNumericLiteralBinaryExpression()

bool v8::internal::ParserTraits::ShortcutNumericLiteralBinaryExpression ( Expression **  x,
Expression y,
Token::Value  op,
int  pos,
AstNodeFactory< AstConstructionVisitor > *  factory 
)

Definition at line 434 of file parser.cc.

436  {
437  if ((*x)->AsLiteral() && (*x)->AsLiteral()->raw_value()->IsNumber() &&
438  y->AsLiteral() && y->AsLiteral()->raw_value()->IsNumber()) {
439  double x_val = (*x)->AsLiteral()->raw_value()->AsNumber();
440  double y_val = y->AsLiteral()->raw_value()->AsNumber();
441  switch (op) {
442  case Token::ADD:
443  *x = factory->NewNumberLiteral(x_val + y_val, pos);
444  return true;
445  case Token::SUB:
446  *x = factory->NewNumberLiteral(x_val - y_val, pos);
447  return true;
448  case Token::MUL:
449  *x = factory->NewNumberLiteral(x_val * y_val, pos);
450  return true;
451  case Token::DIV:
452  *x = factory->NewNumberLiteral(x_val / y_val, pos);
453  return true;
454  case Token::BIT_OR: {
455  int value = DoubleToInt32(x_val) | DoubleToInt32(y_val);
456  *x = factory->NewNumberLiteral(value, pos);
457  return true;
458  }
459  case Token::BIT_AND: {
460  int value = DoubleToInt32(x_val) & DoubleToInt32(y_val);
461  *x = factory->NewNumberLiteral(value, pos);
462  return true;
463  }
464  case Token::BIT_XOR: {
465  int value = DoubleToInt32(x_val) ^ DoubleToInt32(y_val);
466  *x = factory->NewNumberLiteral(value, pos);
467  return true;
468  }
469  case Token::SHL: {
470  int value = DoubleToInt32(x_val) << (DoubleToInt32(y_val) & 0x1f);
471  *x = factory->NewNumberLiteral(value, pos);
472  return true;
473  }
474  case Token::SHR: {
475  uint32_t shift = DoubleToInt32(y_val) & 0x1f;
476  uint32_t value = DoubleToUint32(x_val) >> shift;
477  *x = factory->NewNumberLiteral(value, pos);
478  return true;
479  }
480  case Token::SAR: {
481  uint32_t shift = DoubleToInt32(y_val) & 0x1f;
482  int value = ArithmeticShiftRight(DoubleToInt32(x_val), shift);
483  *x = factory->NewNumberLiteral(value, pos);
484  return true;
485  }
486  default:
487  break;
488  }
489  }
490  return false;
491 }
enable harmony numeric enable harmony object literal extensions Optimize object Array shift
uint32_t DoubleToUint32(double x)
Definition: conversions.h:93
int ArithmeticShiftRight(int x, int s)
Definition: utils.h:90

References v8::internal::ADD, v8::internal::ArithmeticShiftRight(), v8::internal::DIV, v8::internal::DoubleToInt32(), v8::internal::DoubleToUint32(), v8::internal::MUL, shift, v8::internal::SUB, and v8::base::internal::y.

+ Here is the call graph for this function:

◆ SkipLazyFunctionBody()

void v8::internal::ParserTraits::SkipLazyFunctionBody ( const AstRawString name,
int materialized_literal_count,
int expected_property_count,
bool ok 
)
inline

Definition at line 873 of file parser.h.

876  {
878  function_name, materialized_literal_count, expected_property_count, ok);
879 }
void SkipLazyFunctionBody(const AstRawString *function_name, int *materialized_literal_count, int *expected_property_count, bool *ok)
Definition: parser.cc:3701

References parser_, and v8::internal::Parser::SkipLazyFunctionBody().

+ Here is the call graph for this function:

◆ SuperReference()

Expression * v8::internal::ParserTraits::SuperReference ( Scope scope,
AstNodeFactory< AstConstructionVisitor > *  factory,
int  pos = RelocInfo::kNoPosition 
)

Definition at line 661 of file parser.cc.

662  {
663  return factory->NewSuperReference(
664  ThisExpression(scope, factory, pos)->AsVariableProxy(),
665  pos);
666 }
Expression * ThisExpression(Scope *scope, AstNodeFactory< AstConstructionVisitor > *factory, int pos=RelocInfo::kNoPosition)
Definition: parser.cc:656

References ThisExpression().

+ Here is the call graph for this function:

◆ TearDownFunctionState()

template<typename FunctionState >
static void v8::internal::ParserTraits::TearDownFunctionState ( FunctionState *  function_state)
inlinestatic

Definition at line 390 of file parser.h.

390  {
391  if (function_state->outer_function_state_ != NULL) {
392  *function_state->ast_node_id_gen_ = function_state->saved_id_gen_;
393  }
394  }

References NULL.

◆ ThisExpression()

Expression * v8::internal::ParserTraits::ThisExpression ( Scope scope,
AstNodeFactory< AstConstructionVisitor > *  factory,
int  pos = RelocInfo::kNoPosition 
)

Definition at line 656 of file parser.cc.

657  {
658  return factory->NewVariableProxy(scope->receiver(), pos);
659 }

References v8::internal::Scope::receiver().

Referenced by SuperReference().

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

Member Data Documentation

◆ parser_


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