V8 Project
v8::internal::AstRawString Class Reference

#include <ast-value-factory.h>

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

Public Member Functions

virtual int length () const OVERRIDE
 
virtual void Internalize (Isolate *isolate) OVERRIDE
 
bool AsArrayIndex (uint32_t *index) const
 
const unsigned char * raw_data () const
 
bool is_one_byte () const
 
bool IsOneByteEqualTo (const char *data) const
 
uint16_t FirstCharacter () const
 
uint32_t hash () const
 
- Public Member Functions inherited from v8::internal::AstString
virtual ~AstString ()
 
bool IsEmpty () const
 
Handle< Stringstring () const
 
- Public Member Functions inherited from v8::internal::ZoneObject
 INLINE (void *operator new(size_t size, Zone *zone))
 
void operator delete (void *, size_t)
 
void operator delete (void *pointer, Zone *zone)
 

Static Public Member Functions

static bool Compare (void *a, void *b)
 

Private Member Functions

 AstRawString (bool is_one_byte, const Vector< const byte > &literal_bytes, uint32_t hash)
 
 AstRawString ()
 

Private Attributes

bool is_one_byte_
 
Vector< const byteliteral_bytes_
 
uint32_t hash_
 

Friends

class AstValueFactory
 
class AstRawStringInternalizationKey
 

Additional Inherited Members

- Protected Attributes inherited from v8::internal::AstString
Handle< Stringstring_
 

Detailed Description

Definition at line 65 of file ast-value-factory.h.

Constructor & Destructor Documentation

◆ AstRawString() [1/2]

v8::internal::AstRawString::AstRawString ( bool  is_one_byte,
const Vector< const byte > &  literal_bytes,
uint32_t  hash 
)
inlineprivate

◆ AstRawString() [2/2]

v8::internal::AstRawString::AstRawString ( )
inlineprivate

Definition at line 105 of file ast-value-factory.h.

106  : is_one_byte_(true),
107  hash_(0) {}

Member Function Documentation

◆ AsArrayIndex()

bool v8::internal::AstRawString::AsArrayIndex ( uint32_t index) const

Definition at line 98 of file ast-value-factory.cc.

98  {
99  if (!string_.is_null())
100  return string_->AsArrayIndex(index);
101  if (!is_one_byte_ || literal_bytes_.length() == 0 ||
103  return false;
104  OneByteStringStream stream(literal_bytes_);
105  return StringToArrayIndex(&stream, index);
106 }
Handle< String > string_
static const int kMaxArrayIndexSize
Definition: objects.h:8807
int length() const
Definition: vector.h:41
bool StringToArrayIndex(Stream *stream, uint32_t *index)
Definition: utils.h:1431

References is_one_byte_, v8::internal::String::kMaxArrayIndexSize, v8::internal::Vector< T >::length(), literal_bytes_, v8::internal::AstString::string_, and v8::internal::StringToArrayIndex().

Referenced by v8::internal::AstValue::IsPropertyName().

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

◆ Compare()

bool v8::internal::AstRawString::Compare ( void *  a,
void *  b 
)
static

Definition at line 119 of file ast-value-factory.cc.

119  {
120  AstRawString* string1 = reinterpret_cast<AstRawString*>(a);
121  AstRawString* string2 = reinterpret_cast<AstRawString*>(b);
122  if (string1->is_one_byte_ != string2->is_one_byte_) return false;
123  if (string1->hash_ != string2->hash_) return false;
124  int length = string1->literal_bytes_.length();
125  if (string2->literal_bytes_.length() != length) return false;
126  return memcmp(string1->literal_bytes_.start(),
127  string2->literal_bytes_.start(), length) == 0;
128 }
virtual int length() const OVERRIDE

References hash_, is_one_byte_, v8::internal::Vector< T >::length(), length(), literal_bytes_, and v8::internal::Vector< T >::start().

+ Here is the call graph for this function:

◆ FirstCharacter()

uint16_t v8::internal::AstRawString::FirstCharacter ( ) const
inline

Definition at line 83 of file ast-value-factory.h.

83  {
84  if (is_one_byte_)
85  return literal_bytes_[0];
86  const uint16_t* c =
87  reinterpret_cast<const uint16_t*>(literal_bytes_.start());
88  return *c;
89  }
T * start() const
Definition: vector.h:47
unsigned short uint16_t
Definition: unicode.cc:23

References is_one_byte_, literal_bytes_, and v8::internal::Vector< T >::start().

+ Here is the call graph for this function:

◆ hash()

uint32_t v8::internal::AstRawString::hash ( ) const
inline

Definition at line 92 of file ast-value-factory.h.

92  {
93  return hash_;
94  }

References hash_.

Referenced by v8::internal::AstRawStringInternalizationKey::AsHandle(), and v8::internal::AstRawStringInternalizationKey::Hash().

+ Here is the caller graph for this function:

◆ Internalize()

void v8::internal::AstRawString::Internalize ( Isolate isolate)
virtual

Implements v8::internal::AstString.

Definition at line 87 of file ast-value-factory.cc.

87  {
88  if (!string_.is_null()) return;
89  if (literal_bytes_.length() == 0) {
90  string_ = isolate->factory()->empty_string();
91  } else {
93  string_ = StringTable::LookupKey(isolate, &key);
94  }
95 }
friend class AstRawStringInternalizationKey
static Handle< String > LookupKey(Isolate *isolate, HashTableKey *key)
Definition: objects.cc:14713

References v8::internal::Isolate::factory(), v8::internal::Vector< T >::length(), literal_bytes_, v8::internal::StringTable::LookupKey(), and v8::internal::AstString::string_.

Referenced by v8::internal::AstValueFactory::GetString().

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

◆ is_one_byte()

bool v8::internal::AstRawString::is_one_byte ( ) const
inline

Definition at line 81 of file ast-value-factory.h.

81 { return is_one_byte_; }

References is_one_byte_.

◆ IsOneByteEqualTo()

bool v8::internal::AstRawString::IsOneByteEqualTo ( const char *  data) const

Definition at line 109 of file ast-value-factory.cc.

109  {
110  int length = static_cast<int>(strlen(data));
112  const char* token = reinterpret_cast<const char*>(literal_bytes_.start());
113  return !strncmp(token, data, length);
114  }
115  return false;
116 }

References is_one_byte_, v8::internal::Vector< T >::length(), length(), literal_bytes_, and v8::internal::Vector< T >::start().

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

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

◆ length()

virtual int v8::internal::AstRawString::length ( ) const
inlinevirtual

Implements v8::internal::AstString.

Definition at line 67 of file ast-value-factory.h.

67  {
68  if (is_one_byte_)
69  return literal_bytes_.length();
70  return literal_bytes_.length() / 2;
71  }

References is_one_byte_, v8::internal::Vector< T >::length(), and literal_bytes_.

Referenced by v8::internal::CheckAndDeclareArrowParameter(), Compare(), v8::internal::Parser::Declare(), v8::internal::Interface::DoAdd(), v8::internal::Scanner::IdentifierIsFutureStrictReserved(), IsOneByteEqualTo(), and v8::internal::Scope::ResolveVariable().

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

◆ raw_data()

const unsigned char* v8::internal::AstRawString::raw_data ( ) const
inline

Definition at line 78 of file ast-value-factory.h.

78  {
79  return literal_bytes_.start();
80  }

References literal_bytes_, and v8::internal::Vector< T >::start().

Referenced by v8::internal::Parser::Declare(), v8::internal::Interface::DoAdd(), v8::internal::Scanner::IdentifierIsFutureStrictReserved(), and v8::internal::Scope::ResolveVariable().

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

Friends And Related Function Documentation

◆ AstRawStringInternalizationKey

friend class AstRawStringInternalizationKey
friend

Definition at line 99 of file ast-value-factory.h.

◆ AstValueFactory

friend class AstValueFactory
friend

Definition at line 98 of file ast-value-factory.h.

Member Data Documentation

◆ hash_

uint32_t v8::internal::AstRawString::hash_
private

Definition at line 113 of file ast-value-factory.h.

Referenced by Compare(), and hash().

◆ is_one_byte_

◆ literal_bytes_


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