V8 Project
v8::internal::RegExpBuilder Class Reference

#include <parser.h>

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

Public Member Functions

 RegExpBuilder (Zone *zone)
 
void AddCharacter (uc16 character)
 
void AddEmpty ()
 
void AddAtom (RegExpTree *tree)
 
void AddAssertion (RegExpTree *tree)
 
void NewAlternative ()
 
void AddQuantifierToAtom (int min, int max, RegExpQuantifier::QuantifierType type)
 
RegExpTreeToRegExp ()
 
- 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)
 

Private Member Functions

void FlushCharacters ()
 
void FlushText ()
 
void FlushTerms ()
 
Zonezone () const
 

Private Attributes

Zonezone_
 
bool pending_empty_
 
ZoneList< uc16 > * characters_
 
BufferedZoneList< RegExpTree, 2 > terms_
 
BufferedZoneList< RegExpTree, 2 > text_
 
BufferedZoneList< RegExpTree, 2 > alternatives_
 

Detailed Description

Definition at line 180 of file parser.h.

Constructor & Destructor Documentation

◆ RegExpBuilder()

v8::internal::RegExpBuilder::RegExpBuilder ( Zone zone)
explicit

Definition at line 26 of file parser.cc.

27  : zone_(zone),
28  pending_empty_(false),
30  terms_(),
32 #ifdef DEBUG
33  , last_added_(ADD_NONE)
34 #endif
35  {}
ZoneList< uc16 > * characters_
Definition: parser.h:202
Zone * zone() const
Definition: parser.h:198
BufferedZoneList< RegExpTree, 2 > alternatives_
Definition: parser.h:205
BufferedZoneList< RegExpTree, 2 > terms_
Definition: parser.h:203
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

◆ AddAssertion()

void v8::internal::RegExpBuilder::AddAssertion ( RegExpTree tree)

Definition at line 97 of file parser.cc.

97  {
98  FlushText();
99  terms_.Add(assert, zone());
100  LAST(ADD_ASSERT);
101 }
#define LAST(x)
Definition: parser.h:210

References FlushText(), LAST, terms_, and zone().

+ Here is the call graph for this function:

◆ AddAtom()

void v8::internal::RegExpBuilder::AddAtom ( RegExpTree tree)

Definition at line 81 of file parser.cc.

81  {
82  if (term->IsEmpty()) {
83  AddEmpty();
84  return;
85  }
86  if (term->IsTextElement()) {
88  text_.Add(term, zone());
89  } else {
90  FlushText();
91  terms_.Add(term, zone());
92  }
93  LAST(ADD_ATOM);
94 }
BufferedZoneList< RegExpTree, 2 > text_
Definition: parser.h:204

References AddEmpty(), FlushCharacters(), FlushText(), v8::internal::RegExpTree::IsTextElement(), LAST, terms_, text_, and zone().

+ Here is the call graph for this function:

◆ AddCharacter()

void v8::internal::RegExpBuilder::AddCharacter ( uc16  character)

Definition at line 66 of file parser.cc.

66  {
67  pending_empty_ = false;
68  if (characters_ == NULL) {
69  characters_ = new(zone()) ZoneList<uc16>(4, zone());
70  }
71  characters_->Add(c, zone());
72  LAST(ADD_CHAR);
73 }
void Add(const T &element, AllocationPolicy allocator=AllocationPolicy())
Definition: list-inl.h:17

References v8::internal::List< T, AllocationPolicy >::Add(), characters_, LAST, NULL, pending_empty_, and zone().

+ Here is the call graph for this function:

◆ AddEmpty()

void v8::internal::RegExpBuilder::AddEmpty ( )

Definition at line 76 of file parser.cc.

76  {
77  pending_empty_ = true;
78 }

References pending_empty_.

Referenced by AddAtom().

+ Here is the caller graph for this function:

◆ AddQuantifierToAtom()

void v8::internal::RegExpBuilder::AddQuantifierToAtom ( int  min,
int  max,
RegExpQuantifier::QuantifierType  type 
)

Definition at line 139 of file parser.cc.

140  {
141  if (pending_empty_) {
142  pending_empty_ = false;
143  return;
144  }
145  RegExpTree* atom;
146  if (characters_ != NULL) {
147  DCHECK(last_added_ == ADD_CHAR);
148  // Last atom was character.
149  Vector<const uc16> char_vector = characters_->ToConstVector();
150  int num_chars = char_vector.length();
151  if (num_chars > 1) {
152  Vector<const uc16> prefix = char_vector.SubVector(0, num_chars - 1);
153  text_.Add(new(zone()) RegExpAtom(prefix), zone());
154  char_vector = char_vector.SubVector(num_chars - 1, num_chars);
155  }
156  characters_ = NULL;
157  atom = new(zone()) RegExpAtom(char_vector);
158  FlushText();
159  } else if (text_.length() > 0) {
160  DCHECK(last_added_ == ADD_ATOM);
161  atom = text_.RemoveLast();
162  FlushText();
163  } else if (terms_.length() > 0) {
164  DCHECK(last_added_ == ADD_ATOM);
165  atom = terms_.RemoveLast();
166  if (atom->max_match() == 0) {
167  // Guaranteed to only match an empty string.
168  LAST(ADD_TERM);
169  if (min == 0) {
170  return;
171  }
172  terms_.Add(atom, zone());
173  return;
174  }
175  } else {
176  // Only call immediately after adding an atom or character!
177  UNREACHABLE();
178  return;
179  }
180  terms_.Add(
181  new(zone()) RegExpQuantifier(min, max, quantifier_type, atom), zone());
182  LAST(ADD_TERM);
183 }
Vector< const T > ToConstVector()
Definition: list.h:83
int length() const
Definition: vector.h:41
#define UNREACHABLE()
Definition: logging.h:30
#define DCHECK(condition)
Definition: logging.h:205
static int min(int a, int b)
Definition: liveedit.cc:273

References characters_, DCHECK, FlushText(), LAST, v8::internal::Vector< T >::length(), v8::internal::RegExpTree::max_match(), v8::internal::min(), NULL, pending_empty_, v8::internal::Vector< T >::SubVector(), terms_, text_, v8::internal::List< T, AllocationPolicy >::ToConstVector(), UNREACHABLE, and zone().

+ Here is the call graph for this function:

◆ FlushCharacters()

void v8::internal::RegExpBuilder::FlushCharacters ( )
private

Definition at line 38 of file parser.cc.

38  {
39  pending_empty_ = false;
40  if (characters_ != NULL) {
41  RegExpTree* atom = new(zone()) RegExpAtom(characters_->ToConstVector());
42  characters_ = NULL;
43  text_.Add(atom, zone());
44  LAST(ADD_ATOM);
45  }
46 }

References characters_, LAST, NULL, pending_empty_, text_, v8::internal::List< T, AllocationPolicy >::ToConstVector(), and zone().

Referenced by AddAtom(), and FlushText().

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

◆ FlushTerms()

void v8::internal::RegExpBuilder::FlushTerms ( )
private

Definition at line 109 of file parser.cc.

109  {
110  FlushText();
111  int num_terms = terms_.length();
112  RegExpTree* alternative;
113  if (num_terms == 0) {
114  alternative = RegExpEmpty::GetInstance();
115  } else if (num_terms == 1) {
116  alternative = terms_.last();
117  } else {
118  alternative = new(zone()) RegExpAlternative(terms_.GetList(zone()));
119  }
120  alternatives_.Add(alternative, zone());
121  terms_.Clear();
122  LAST(ADD_NONE);
123 }

References alternatives_, FlushText(), LAST, terms_, and zone().

Referenced by NewAlternative(), and ToRegExp().

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

◆ FlushText()

void v8::internal::RegExpBuilder::FlushText ( )
private

Definition at line 49 of file parser.cc.

49  {
51  int num_text = text_.length();
52  if (num_text == 0) {
53  return;
54  } else if (num_text == 1) {
55  terms_.Add(text_.last(), zone());
56  } else {
57  RegExpText* text = new(zone()) RegExpText(zone());
58  for (int i = 0; i < num_text; i++)
59  text_.Get(i)->AppendToText(text, zone());
60  terms_.Add(text, zone());
61  }
62  text_.Clear();
63 }

References FlushCharacters(), terms_, text_, and zone().

Referenced by AddAssertion(), AddAtom(), AddQuantifierToAtom(), and FlushTerms().

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

◆ NewAlternative()

void v8::internal::RegExpBuilder::NewAlternative ( )

Definition at line 104 of file parser.cc.

104  {
105  FlushTerms();
106 }

References FlushTerms().

+ Here is the call graph for this function:

◆ ToRegExp()

RegExpTree * v8::internal::RegExpBuilder::ToRegExp ( )

Definition at line 126 of file parser.cc.

126  {
127  FlushTerms();
128  int num_alternatives = alternatives_.length();
129  if (num_alternatives == 0) {
130  return RegExpEmpty::GetInstance();
131  }
132  if (num_alternatives == 1) {
133  return alternatives_.last();
134  }
135  return new(zone()) RegExpDisjunction(alternatives_.GetList(zone()));
136 }

References alternatives_, FlushTerms(), and zone().

+ Here is the call graph for this function:

◆ zone()

Zone* v8::internal::RegExpBuilder::zone ( ) const
inlineprivate

Definition at line 198 of file parser.h.

198 { return zone_; }

References zone_.

Referenced by AddAssertion(), AddAtom(), AddCharacter(), AddQuantifierToAtom(), FlushCharacters(), FlushTerms(), FlushText(), and ToRegExp().

+ Here is the caller graph for this function:

Member Data Documentation

◆ alternatives_

BufferedZoneList<RegExpTree, 2> v8::internal::RegExpBuilder::alternatives_
private

Definition at line 205 of file parser.h.

Referenced by FlushTerms(), and ToRegExp().

◆ characters_

ZoneList<uc16>* v8::internal::RegExpBuilder::characters_
private

Definition at line 202 of file parser.h.

Referenced by AddCharacter(), AddQuantifierToAtom(), and FlushCharacters().

◆ pending_empty_

bool v8::internal::RegExpBuilder::pending_empty_
private

Definition at line 201 of file parser.h.

Referenced by AddCharacter(), AddEmpty(), AddQuantifierToAtom(), and FlushCharacters().

◆ terms_

BufferedZoneList<RegExpTree, 2> v8::internal::RegExpBuilder::terms_
private

Definition at line 203 of file parser.h.

Referenced by AddAssertion(), AddAtom(), AddQuantifierToAtom(), FlushTerms(), and FlushText().

◆ text_

BufferedZoneList<RegExpTree, 2> v8::internal::RegExpBuilder::text_
private

Definition at line 204 of file parser.h.

Referenced by AddAtom(), AddQuantifierToAtom(), FlushCharacters(), and FlushText().

◆ zone_

Zone* v8::internal::RegExpBuilder::zone_
private

Definition at line 200 of file parser.h.

Referenced by zone().


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