V8 Project
v8::internal::PreParserExpression Class Reference

#include <preparser.h>

+ Collaboration diagram for v8::internal::PreParserExpression:

Public Member Functions

bool IsIdentifier () const
 
PreParserIdentifier AsIdentifier () const
 
bool IsStringLiteral () const
 
bool IsUseStrictLiteral () const
 
bool IsThis () const
 
bool IsThisProperty () const
 
bool IsProperty () const
 
bool IsCall () const
 
bool IsValidReferenceExpression () const
 
bool IsValidArrowParamList () const
 
bool IsFunctionLiteral () const
 
bool IsCallNew () const
 
PreParserExpression AsFunctionLiteral ()
 
bool IsBinaryOperation () const
 
bool is_parenthesized () const
 
void increase_parenthesization_level ()
 
PreParserExpressionoperator-> ()
 
void set_index (int index)
 
void set_parenthesized ()
 
int position () const
 
void set_function_token_position (int position)
 
void set_ast_properties (int *ast_properties)
 
void set_dont_optimize_reason (BailoutReason dont_optimize_reason)
 
bool operator== (const PreParserExpression &other) const
 
bool operator!= (const PreParserExpression &other) const
 

Static Public Member Functions

static PreParserExpression Default ()
 
static PreParserExpression FromIdentifier (PreParserIdentifier id)
 
static PreParserExpression BinaryOperation (PreParserExpression left, Token::Value op, PreParserExpression right)
 
static PreParserExpression EmptyArrowParamList ()
 
static PreParserExpression StringLiteral ()
 
static PreParserExpression UseStrictStringLiteral ()
 
static PreParserExpression This ()
 
static PreParserExpression Super ()
 
static PreParserExpression ThisProperty ()
 
static PreParserExpression Property ()
 
static PreParserExpression Call ()
 

Private Types

enum  {
  kUnknownExpression = 0 , kTypeMask = 1 | 2 , kParenthesizedExpression = (1 << 2) , kMultiParenthesizedExpression = (1 << 3) ,
  kTypeIdentifier = 1 , kIdentifierShift = 5 , kTypeStringLiteral = 2 , kUnknownStringLiteral = kTypeStringLiteral ,
  kUseStrictString = kTypeStringLiteral | 32 , kStringLiteralMask = kUseStrictString , kTypeBinaryOperation = 3 , kBinaryOperationArrowParamList = (1 << 4) ,
  kThisExpression = (1 << 4) , kThisPropertyExpression = (2 << 4) , kPropertyExpression = (3 << 4) , kCallExpression = (4 << 4) ,
  kSuperExpression = (5 << 4)
}
 

Private Member Functions

 PreParserExpression (int expression_code)
 
int ArrowParamListBit () const
 

Private Attributes

int code_
 

Detailed Description

Definition at line 676 of file preparser.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
kUnknownExpression 
kTypeMask 
kParenthesizedExpression 
kMultiParenthesizedExpression 
kTypeIdentifier 
kIdentifierShift 
kTypeStringLiteral 
kUnknownStringLiteral 
kUseStrictString 
kStringLiteralMask 
kTypeBinaryOperation 
kBinaryOperationArrowParamList 
kThisExpression 
kThisPropertyExpression 
kPropertyExpression 
kCallExpression 
kSuperExpression 

Definition at line 815 of file preparser.h.

815  {
816  kUnknownExpression = 0,
817  kTypeMask = 1 | 2,
818  kParenthesizedExpression = (1 << 2),
820 
821  // Identifiers
822  kTypeIdentifier = 1, // Used to detect labels.
823  kIdentifierShift = 5,
824  kTypeStringLiteral = 2, // Used to detect directive prologue.
828 
829  // Binary operations. Those are needed to detect certain keywords and
830  // duplicated identifier in parameter lists for arrow functions, because
831  // they are initially parsed as comma-separated expressions.
834 
835  // Below here applies if neither identifier nor string literal. Reserve the
836  // 2 least significant bits for flags.
837  kThisExpression = (1 << 4),
838  kThisPropertyExpression = (2 << 4),
839  kPropertyExpression = (3 << 4),
840  kCallExpression = (4 << 4),
841  kSuperExpression = (5 << 4)
842  };

Constructor & Destructor Documentation

◆ PreParserExpression()

v8::internal::PreParserExpression::PreParserExpression ( int  expression_code)
inlineexplicitprivate

Definition at line 844 of file preparser.h.

844 : code_(expression_code) {}

Referenced by BinaryOperation(), Call(), Default(), FromIdentifier(), Property(), StringLiteral(), Super(), This(), ThisProperty(), and UseStrictStringLiteral().

+ Here is the caller graph for this function:

Member Function Documentation

◆ ArrowParamListBit()

int v8::internal::PreParserExpression::ArrowParamListBit ( ) const
inlineprivate

Definition at line 846 of file preparser.h.

846  {
848  if (IsIdentifier()) {
849  const PreParserIdentifier ident = AsIdentifier();
850  // A valid identifier can be an arrow function parameter list
851  // except for eval, arguments, yield, and reserved keywords.
852  if (ident.IsEval() || ident.IsArguments() || ident.IsYield() ||
853  ident.IsFutureStrictReserved())
854  return 0;
856  }
857  return 0;
858  }
PreParserIdentifier AsIdentifier() const
Definition: preparser.h:733

References AsIdentifier(), code_, v8::internal::PreParserIdentifier::IsArguments(), IsBinaryOperation(), v8::internal::PreParserIdentifier::IsEval(), v8::internal::PreParserIdentifier::IsFutureStrictReserved(), IsIdentifier(), v8::internal::PreParserIdentifier::IsYield(), and kBinaryOperationArrowParamList.

Referenced by BinaryOperation(), and IsValidArrowParamList().

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

◆ AsFunctionLiteral()

PreParserExpression v8::internal::PreParserExpression::AsFunctionLiteral ( )
inline

Definition at line 773 of file preparser.h.

773 { return *this; }

◆ AsIdentifier()

PreParserIdentifier v8::internal::PreParserExpression::AsIdentifier ( ) const
inline

Definition at line 733 of file preparser.h.

733  {
734  DCHECK(IsIdentifier());
735  return PreParserIdentifier(
737  }
#define DCHECK(condition)
Definition: logging.h:205

References code_, DCHECK, IsIdentifier(), and kIdentifierShift.

Referenced by ArrowParamListBit(), v8::internal::PreParserTraits::AsIdentifier(), and v8::internal::PreParser::ParseExpressionOrLabelledStatement().

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

◆ BinaryOperation()

static PreParserExpression v8::internal::PreParserExpression::BinaryOperation ( PreParserExpression  left,
Token::Value  op,
PreParserExpression  right 
)
inlinestatic

Definition at line 687 of file preparser.h.

689  {
690  int code = ((op == Token::COMMA) && !left.is_parenthesized() &&
691  !right.is_parenthesized())
692  ? left.ArrowParamListBit() & right.ArrowParamListBit()
693  : 0;
695  }
PreParserExpression(int expression_code)
Definition: preparser.h:844
#define COMMA

References ArrowParamListBit(), COMMA, is_parenthesized(), kTypeBinaryOperation, and PreParserExpression().

Referenced by v8::internal::PreParserFactory::NewBinaryOperation().

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

◆ Call()

static PreParserExpression v8::internal::PreParserExpression::Call ( )
inlinestatic

Definition at line 727 of file preparser.h.

727  {
729  }

References kCallExpression, and PreParserExpression().

Referenced by v8::internal::PreParserFactory::NewCall().

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

◆ Default()

static PreParserExpression v8::internal::PreParserExpression::Default ( )
inlinestatic

Definition at line 678 of file preparser.h.

678  {
680  }

References kUnknownExpression, and PreParserExpression().

Referenced by v8::internal::PreParserTraits::BuildUnaryExpression(), v8::internal::PreParserTraits::ClassLiteral(), v8::internal::PreParserTraits::EmptyExpression(), v8::internal::PreParserTraits::EmptyFunctionLiteral(), v8::internal::PreParserTraits::EmptyLiteral(), v8::internal::PreParserTraits::EmptyObjectLiteralProperty(), v8::internal::PreParserTraits::ExpressionFromLiteral(), v8::internal::PreParserTraits::GetIterator(), v8::internal::PreParserTraits::GetLiteralTheHole(), v8::internal::PreParserFactory::NewArrayLiteral(), v8::internal::PreParserFactory::NewAssignment(), v8::internal::PreParserFactory::NewCallNew(), v8::internal::PreParserFactory::NewClassLiteral(), v8::internal::PreParserFactory::NewCompareOperation(), v8::internal::PreParserFactory::NewConditional(), v8::internal::PreParserFactory::NewCountOperation(), v8::internal::PreParserFactory::NewFunctionLiteral(), v8::internal::PreParserFactory::NewNumberLiteral(), v8::internal::PreParserFactory::NewObjectLiteral(), v8::internal::PreParserFactory::NewObjectLiteralProperty(), v8::internal::PreParserFactory::NewRegExpLiteral(), v8::internal::PreParserFactory::NewStringLiteral(), v8::internal::PreParserTraits::NewThrowReferenceError(), v8::internal::PreParserTraits::NewThrowSyntaxError(), v8::internal::PreParserTraits::NewThrowTypeError(), v8::internal::PreParserFactory::NewUnaryOperation(), v8::internal::PreParserFactory::NewVariableProxy(), v8::internal::PreParserFactory::NewYield(), v8::internal::PreParser::ParseFunctionLiteral(), and v8::internal::PreParser::ParseV8Intrinsic().

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

◆ EmptyArrowParamList()

static PreParserExpression v8::internal::PreParserExpression::EmptyArrowParamList ( )
inlinestatic

Definition at line 697 of file preparser.h.

697  {
698  // Any expression for which IsValidArrowParamList() returns true
699  // will work here.
701  }
static PreParserExpression FromIdentifier(PreParserIdentifier id)
Definition: preparser.h:682
static PreParserIdentifier Default()
Definition: preparser.h:602

References v8::internal::PreParserIdentifier::Default(), and FromIdentifier().

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

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

◆ FromIdentifier()

static PreParserExpression v8::internal::PreParserExpression::FromIdentifier ( PreParserIdentifier  id)
inlinestatic

Definition at line 682 of file preparser.h.

682  {
684  (id.type_ << kIdentifierShift));
685  }

References kIdentifierShift, kTypeIdentifier, and PreParserExpression().

Referenced by EmptyArrowParamList(), and v8::internal::PreParserTraits::ExpressionFromIdentifier().

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

◆ increase_parenthesization_level()

void v8::internal::PreParserExpression::increase_parenthesization_level ( )
inline

Definition at line 783 of file preparser.h.

References code_, is_parenthesized(), kMultiParenthesizedExpression, and kParenthesizedExpression.

+ Here is the call graph for this function:

◆ is_parenthesized()

bool v8::internal::PreParserExpression::is_parenthesized ( ) const
inline

Definition at line 779 of file preparser.h.

779  {
780  return (code_ & kParenthesizedExpression) != 0;
781  }

References code_, and kParenthesizedExpression.

Referenced by BinaryOperation(), and increase_parenthesization_level().

+ Here is the caller graph for this function:

◆ IsBinaryOperation()

bool v8::internal::PreParserExpression::IsBinaryOperation ( ) const
inline

Definition at line 775 of file preparser.h.

775  {
776  return (code_ & kTypeMask) == kTypeBinaryOperation;
777  }

References code_, kTypeBinaryOperation, and kTypeMask.

Referenced by ArrowParamListBit().

+ Here is the caller graph for this function:

◆ IsCall()

bool v8::internal::PreParserExpression::IsCall ( ) const
inline

Definition at line 758 of file preparser.h.

758 { return (code_ & kCallExpression) == kCallExpression; }

References code_, and kCallExpression.

◆ IsCallNew()

bool v8::internal::PreParserExpression::IsCallNew ( ) const
inline

Definition at line 771 of file preparser.h.

771 { return false; }

◆ IsFunctionLiteral()

bool v8::internal::PreParserExpression::IsFunctionLiteral ( ) const
inline

Definition at line 770 of file preparser.h.

770 { return false; }

◆ IsIdentifier()

bool v8::internal::PreParserExpression::IsIdentifier ( ) const
inline

Definition at line 731 of file preparser.h.

731 { return (code_ & kTypeMask) == kTypeIdentifier; }

References code_, kTypeIdentifier, and kTypeMask.

Referenced by ArrowParamListBit(), AsIdentifier(), v8::internal::PreParserTraits::IsIdentifier(), IsValidReferenceExpression(), v8::internal::PreParser::ParseExpressionOrLabelledStatement(), and v8::internal::PreParser::ParseForStatement().

+ Here is the caller graph for this function:

◆ IsProperty()

bool v8::internal::PreParserExpression::IsProperty ( ) const
inline

Definition at line 753 of file preparser.h.

References code_, kPropertyExpression, and kThisPropertyExpression.

Referenced by IsValidReferenceExpression().

+ Here is the caller graph for this function:

◆ IsStringLiteral()

bool v8::internal::PreParserExpression::IsStringLiteral ( ) const
inline

Definition at line 739 of file preparser.h.

739  {
740  return (code_ & kTypeMask) == kTypeStringLiteral;
741  }

References code_, kTypeMask, and kTypeStringLiteral.

Referenced by v8::internal::PreParserStatement::ExpressionStatement().

+ Here is the caller graph for this function:

◆ IsThis()

bool v8::internal::PreParserExpression::IsThis ( ) const
inline

Definition at line 747 of file preparser.h.

747 { return (code_ & kThisExpression) == kThisExpression; }

References code_, and kThisExpression.

Referenced by v8::internal::PreParserFactory::NewProperty().

+ Here is the caller graph for this function:

◆ IsThisProperty()

bool v8::internal::PreParserExpression::IsThisProperty ( ) const
inline

Definition at line 749 of file preparser.h.

749  {
751  }

References code_, and kThisPropertyExpression.

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

+ Here is the caller graph for this function:

◆ IsUseStrictLiteral()

bool v8::internal::PreParserExpression::IsUseStrictLiteral ( ) const
inline

Definition at line 743 of file preparser.h.

743  {
745  }

References code_, and kUseStrictString.

Referenced by v8::internal::PreParserStatement::ExpressionStatement().

+ Here is the caller graph for this function:

◆ IsValidArrowParamList()

bool v8::internal::PreParserExpression::IsValidArrowParamList ( ) const
inline

Definition at line 764 of file preparser.h.

764  {
767  }

References ArrowParamListBit(), code_, kBinaryOperationArrowParamList, and kMultiParenthesizedExpression.

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

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

◆ IsValidReferenceExpression()

bool v8::internal::PreParserExpression::IsValidReferenceExpression ( ) const
inline

Definition at line 760 of file preparser.h.

760  {
761  return IsIdentifier() || IsProperty();
762  }

References IsIdentifier(), and IsProperty().

+ Here is the call graph for this function:

◆ operator!=()

bool v8::internal::PreParserExpression::operator!= ( const PreParserExpression other) const
inline

Definition at line 804 of file preparser.h.

804  {
805  return code_ != other.code_;
806  }

References code_.

◆ operator->()

PreParserExpression* v8::internal::PreParserExpression::operator-> ( )
inline

Definition at line 790 of file preparser.h.

790 { return this; }

◆ operator==()

bool v8::internal::PreParserExpression::operator== ( const PreParserExpression other) const
inline

Definition at line 801 of file preparser.h.

801  {
802  return code_ == other.code_;
803  }

References code_.

◆ position()

int v8::internal::PreParserExpression::position ( ) const
inline

Definition at line 796 of file preparser.h.

796 { return RelocInfo::kNoPosition; }
static const int kNoPosition
Definition: assembler.h:317

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

◆ Property()

static PreParserExpression v8::internal::PreParserExpression::Property ( )
inlinestatic

Definition at line 723 of file preparser.h.

723  {
725  }

References kPropertyExpression, and PreParserExpression().

Referenced by v8::internal::PreParserFactory::NewProperty().

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

◆ set_ast_properties()

void v8::internal::PreParserExpression::set_ast_properties ( int ast_properties)
inline

Definition at line 798 of file preparser.h.

798 {}

◆ set_dont_optimize_reason()

void v8::internal::PreParserExpression::set_dont_optimize_reason ( BailoutReason  dont_optimize_reason)
inline

Definition at line 799 of file preparser.h.

799 {}

◆ set_function_token_position()

void v8::internal::PreParserExpression::set_function_token_position ( int  position)
inline

Definition at line 797 of file preparser.h.

797 {}

◆ set_index()

void v8::internal::PreParserExpression::set_index ( int  index)
inline

Definition at line 793 of file preparser.h.

793 {} // For YieldExpressions

◆ set_parenthesized()

void v8::internal::PreParserExpression::set_parenthesized ( )
inline

Definition at line 794 of file preparser.h.

794 {}

◆ StringLiteral()

static PreParserExpression v8::internal::PreParserExpression::StringLiteral ( )
inlinestatic

Definition at line 703 of file preparser.h.

703  {
705  }

References kUnknownStringLiteral, and PreParserExpression().

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

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

◆ Super()

static PreParserExpression v8::internal::PreParserExpression::Super ( )
inlinestatic

Definition at line 715 of file preparser.h.

715  {
717  }

References kSuperExpression, and PreParserExpression().

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

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

◆ This()

static PreParserExpression v8::internal::PreParserExpression::This ( )
inlinestatic

Definition at line 711 of file preparser.h.

711  {
713  }

References kThisExpression, and PreParserExpression().

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

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

◆ ThisProperty()

static PreParserExpression v8::internal::PreParserExpression::ThisProperty ( )
inlinestatic

Definition at line 719 of file preparser.h.

719  {
721  }

References kThisPropertyExpression, and PreParserExpression().

Referenced by v8::internal::PreParserFactory::NewProperty().

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

◆ UseStrictStringLiteral()

static PreParserExpression v8::internal::PreParserExpression::UseStrictStringLiteral ( )
inlinestatic

Definition at line 707 of file preparser.h.

707  {
709  }

References kUseStrictString, and PreParserExpression().

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

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

Member Data Documentation

◆ code_


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