Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | List of all members
dart::RegExpCharacterClass Class Reference

#include <regexp_ast.h>

Inheritance diagram for dart::RegExpCharacterClass:
dart::RegExpTree dart::ZoneAllocated

Public Types

enum  Flag { NEGATED = 1 << 0 , CONTAINS_SPLIT_SURROGATE = 1 << 1 }
 
using CharacterClassFlags = intptr_t
 

Public Member Functions

 RegExpCharacterClass (ZoneGrowableArray< CharacterRange > *ranges, RegExpFlags flags, CharacterClassFlags character_class_flags=DefaultFlags())
 
 RegExpCharacterClass (uint16_t type, RegExpFlags flags)
 
virtual void * Accept (RegExpVisitor *visitor, void *data)
 
virtual RegExpNodeToNode (RegExpCompiler *compiler, RegExpNode *on_success)
 
virtual RegExpCharacterClassAsCharacterClass ()
 
virtual bool IsCharacterClass () const
 
virtual bool IsTextElement () const
 
virtual intptr_t min_match () const
 
virtual intptr_t max_match () const
 
virtual void AppendToText (RegExpText *text)
 
CharacterSet character_set () const
 
bool is_standard ()
 
uint16_t standard_type () const
 
ZoneGrowableArray< CharacterRange > * ranges ()
 
bool is_negated () const
 
RegExpFlags flags () const
 
bool contains_split_surrogate () const
 
- Public Member Functions inherited from dart::RegExpTree
virtual ~RegExpTree ()
 
virtual bool IsAnchoredAtStart () const
 
virtual bool IsAnchoredAtEnd () const
 
virtual Interval CaptureRegisters () const
 
void Print ()
 
- Public Member Functions inherited from dart::ZoneAllocated
 ZoneAllocated ()
 
void * operator new (size_t size)
 
void * operator new (size_t size, Zone *zone)
 
void operator delete (void *pointer)
 

Static Public Member Functions

static CharacterClassFlags DefaultFlags ()
 

Additional Inherited Members

- Static Public Attributes inherited from dart::RegExpTree
static constexpr intptr_t kInfinity = kMaxInt32
 

Detailed Description

Definition at line 153 of file regexp_ast.h.

Member Typedef Documentation

◆ CharacterClassFlags

Definition at line 163 of file regexp_ast.h.

Member Enumeration Documentation

◆ Flag

Enumerator
NEGATED 
CONTAINS_SPLIT_SURROGATE 

Definition at line 155 of file regexp_ast.h.

155 {
156 // The character class is negated and should match everything but the
157 // specified ranges.
158 NEGATED = 1 << 0,
159 // The character class contains part of a split surrogate and should not
160 // be unicode-desugared.
162 };

Constructor & Destructor Documentation

◆ RegExpCharacterClass() [1/2]

dart::RegExpCharacterClass::RegExpCharacterClass ( ZoneGrowableArray< CharacterRange > *  ranges,
RegExpFlags  flags,
CharacterClassFlags  character_class_flags = DefaultFlags() 
)
inline

Definition at line 166 of file regexp_ast.h.

170 : set_(ranges),
171 flags_(flags),
172 character_class_flags_(character_class_flags) {
173 // Convert the empty set of ranges to the negated Everything() range.
174 if (ranges->is_empty()) {
176 character_class_flags_ ^= NEGATED;
177 }
178 }
static CharacterRange Everything()
Definition regexp.h:44
RegExpFlags flags() const
Definition regexp_ast.h:208
ZoneGrowableArray< CharacterRange > * ranges()
Definition regexp_ast.h:206

◆ RegExpCharacterClass() [2/2]

dart::RegExpCharacterClass::RegExpCharacterClass ( uint16_t  type,
RegExpFlags  flags 
)
inline

Definition at line 179 of file regexp_ast.h.

180 : set_(type), flags_(flags), character_class_flags_(0) {}

Member Function Documentation

◆ Accept()

virtual void * dart::RegExpCharacterClass::Accept ( RegExpVisitor visitor,
void *  data 
)
virtual

Implements dart::RegExpTree.

◆ AppendToText()

void dart::RegExpCharacterClass::AppendToText ( RegExpText text)
virtual

Reimplemented from dart::RegExpTree.

Definition at line 216 of file regexp.cc.

216 {
217 text->AddElement(TextElement::CharClass(this));
218}
static TextElement CharClass(RegExpCharacterClass *char_class)
Definition regexp.cc:229
std::u16string text

◆ AsCharacterClass()

virtual RegExpCharacterClass * dart::RegExpCharacterClass::AsCharacterClass ( )
virtual

◆ character_set()

CharacterSet dart::RegExpCharacterClass::character_set ( ) const
inline

Definition at line 190 of file regexp_ast.h.

190{ return set_; }

◆ contains_split_surrogate()

bool dart::RegExpCharacterClass::contains_split_surrogate ( ) const
inline

Definition at line 209 of file regexp_ast.h.

209 {
210 return (character_class_flags_ & CONTAINS_SPLIT_SURROGATE) != 0;
211 }

◆ DefaultFlags()

static CharacterClassFlags dart::RegExpCharacterClass::DefaultFlags ( )
inlinestatic

Definition at line 164 of file regexp_ast.h.

164{ return 0; }

◆ flags()

RegExpFlags dart::RegExpCharacterClass::flags ( ) const
inline

Definition at line 208 of file regexp_ast.h.

208{ return flags_; }

◆ is_negated()

bool dart::RegExpCharacterClass::is_negated ( ) const
inline

Definition at line 207 of file regexp_ast.h.

207{ return (character_class_flags_ & NEGATED) != 0; }

◆ is_standard()

bool dart::RegExpCharacterClass::is_standard ( )

Definition at line 3861 of file regexp.cc.

3861 {
3862 // TODO(lrn): Remove need for this function, by not throwing away information
3863 // along the way.
3864 if (is_negated()) {
3865 return false;
3866 }
3867 if (set_.is_standard()) {
3868 return true;
3869 }
3871 set_.set_standard_set_type('s');
3872 return true;
3873 }
3875 set_.set_standard_set_type('S');
3876 return true;
3877 }
3880 set_.set_standard_set_type('.');
3881 return true;
3882 }
3885 set_.set_standard_set_type('n');
3886 return true;
3887 }
3889 set_.set_standard_set_type('w');
3890 return true;
3891 }
3893 set_.set_standard_set_type('W');
3894 return true;
3895 }
3896 return false;
3897}
void set_standard_set_type(uint16_t special_set_type)
Definition regexp_ast.h:140
ZoneGrowableArray< CharacterRange > * ranges()
Definition regexp.cc:4785
static constexpr intptr_t kWordRangeCount
Definition regexp.cc:2778
static constexpr int32_t kLineTerminatorRanges[]
Definition regexp.cc:2783
static bool CompareInverseRanges(ZoneGrowableArray< CharacterRange > *ranges, const int32_t *special_class, intptr_t length)
Definition regexp.cc:3813
static constexpr int32_t kSpaceRanges[]
Definition regexp.cc:2771
static constexpr int32_t kWordRanges[]
Definition regexp.cc:2776
static constexpr intptr_t kSpaceRangeCount
Definition regexp.cc:2775
static constexpr intptr_t kLineTerminatorRangeCount
Definition regexp.cc:2785
static bool CompareRanges(ZoneGrowableArray< CharacterRange > *ranges, const int32_t *special_class, intptr_t length)
Definition regexp.cc:3843

◆ IsCharacterClass()

virtual bool dart::RegExpCharacterClass::IsCharacterClass ( ) const
virtual

◆ IsTextElement()

virtual bool dart::RegExpCharacterClass::IsTextElement ( ) const
inlinevirtual

Reimplemented from dart::RegExpTree.

Definition at line 185 of file regexp_ast.h.

185{ return true; }

◆ max_match()

virtual intptr_t dart::RegExpCharacterClass::max_match ( ) const
inlinevirtual

Implements dart::RegExpTree.

Definition at line 188 of file regexp_ast.h.

188{ return 2; }

◆ min_match()

virtual intptr_t dart::RegExpCharacterClass::min_match ( ) const
inlinevirtual

Implements dart::RegExpTree.

Definition at line 186 of file regexp_ast.h.

186{ return 1; }

◆ ranges()

ZoneGrowableArray< CharacterRange > * dart::RegExpCharacterClass::ranges ( )
inline

Definition at line 206 of file regexp_ast.h.

206{ return set_.ranges(); }

◆ standard_type()

uint16_t dart::RegExpCharacterClass::standard_type ( ) const
inline

Definition at line 205 of file regexp_ast.h.

205{ return set_.standard_set_type(); }
uint16_t standard_set_type() const
Definition regexp_ast.h:139

◆ ToNode()

RegExpNode * dart::RegExpCharacterClass::ToNode ( RegExpCompiler compiler,
RegExpNode on_success 
)
virtual

Implements dart::RegExpTree.

Definition at line 4166 of file regexp.cc.

4167 {
4168 set_.Canonicalize();
4169 ZoneGrowableArray<CharacterRange>* ranges = this->ranges();
4170 if (flags_.NeedsUnicodeCaseEquivalents()) {
4172 }
4173 if (flags_.IsUnicode() && !compiler->one_byte() &&
4175 if (is_negated()) {
4176 ZoneGrowableArray<CharacterRange>* negated =
4177 new ZoneGrowableArray<CharacterRange>(2);
4179 ranges = negated;
4180 }
4181 if (ranges->length() == 0) {
4183 new RegExpCharacterClass(ranges, RegExpFlags());
4184 return new TextNode(fail, compiler->read_backward(), on_success);
4185 }
4186 if (standard_type() == '*') {
4187 return UnanchoredAdvance(compiler, on_success);
4188 } else {
4189 ChoiceNode* result = new (OZ) ChoiceNode(2, OZ);
4190 UnicodeRangeSplitter splitter(OZ, ranges);
4191 AddBmpCharacters(compiler, result, on_success, &splitter);
4192 AddNonBmpSurrogatePairs(compiler, result, on_success, &splitter);
4193 AddLoneLeadSurrogates(compiler, result, on_success, &splitter);
4194 AddLoneTrailSurrogates(compiler, result, on_success, &splitter);
4195 return result;
4196 }
4197 } else {
4198 return new TextNode(this, compiler->read_backward(), on_success);
4199 }
4200 return new (OZ) TextNode(this, compiler->read_backward(), on_success);
4201}
static void fail(const SkString &err)
Definition DM.cpp:234
static void Negate(ZoneGrowableArray< CharacterRange > *src, ZoneGrowableArray< CharacterRange > *dst)
Definition regexp.cc:4912
uint16_t standard_type() const
Definition regexp_ast.h:205
RegExpCharacterClass(ZoneGrowableArray< CharacterRange > *ranges, RegExpFlags flags, CharacterClassFlags character_class_flags=DefaultFlags())
Definition regexp_ast.h:166
bool contains_split_surrogate() const
Definition regexp_ast.h:209
bool NeedsUnicodeCaseEquivalents()
Definition object.h:12702
bool IsUnicode() const
Definition object.h:12699
GAsyncResult * result
void AddBmpCharacters(RegExpCompiler *compiler, ChoiceNode *result, RegExpNode *on_success, UnicodeRangeSplitter *splitter)
Definition regexp.cc:3959
void AddLoneLeadSurrogates(RegExpCompiler *compiler, ChoiceNode *result, RegExpNode *on_success, UnicodeRangeSplitter *splitter)
Definition regexp.cc:4065
void AddNonBmpSurrogatePairs(RegExpCompiler *compiler, ChoiceNode *result, RegExpNode *on_success, UnicodeRangeSplitter *splitter)
Definition regexp.cc:3969
void AddUnicodeCaseEquivalents(ZoneGrowableArray< CharacterRange > *ranges)
Definition regexp.cc:4135
void AddLoneTrailSurrogates(RegExpCompiler *compiler, ChoiceNode *result, RegExpNode *on_success, UnicodeRangeSplitter *splitter)
Definition regexp.cc:4093
RegExpNode * UnanchoredAdvance(RegExpCompiler *compiler, RegExpNode *on_success)
Definition regexp.cc:4121
#define OZ
Definition regexp.cc:3793

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