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

#include <regexp_ast.h>

Inheritance diagram for dart::RegExpAssertion:
dart::RegExpTree dart::ZoneAllocated

Public Types

enum  AssertionType {
  START_OF_LINE , START_OF_INPUT , END_OF_LINE , END_OF_INPUT ,
  BOUNDARY , NON_BOUNDARY
}
 

Public Member Functions

 RegExpAssertion (AssertionType type, RegExpFlags flags)
 
virtual void * Accept (RegExpVisitor *visitor, void *data)
 
virtual RegExpNodeToNode (RegExpCompiler *compiler, RegExpNode *on_success)
 
virtual RegExpAssertionAsAssertion ()
 
virtual bool IsAssertion () const
 
virtual bool IsAnchoredAtStart () const
 
virtual bool IsAnchoredAtEnd () const
 
virtual intptr_t min_match () const
 
virtual intptr_t max_match () const
 
AssertionType assertion_type () const
 
- Public Member Functions inherited from dart::RegExpTree
virtual ~RegExpTree ()
 
virtual bool IsTextElement () const
 
virtual Interval CaptureRegisters () const
 
virtual void AppendToText (RegExpText *text)
 
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)
 

Additional Inherited Members

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

Detailed Description

Definition at line 101 of file regexp_ast.h.

Member Enumeration Documentation

◆ AssertionType

Enumerator
START_OF_LINE 
START_OF_INPUT 
END_OF_LINE 
END_OF_INPUT 
BOUNDARY 
NON_BOUNDARY 

Definition at line 103 of file regexp_ast.h.

Constructor & Destructor Documentation

◆ RegExpAssertion()

dart::RegExpAssertion::RegExpAssertion ( AssertionType  type,
RegExpFlags  flags 
)
inline

Definition at line 111 of file regexp_ast.h.

112 : assertion_type_(type), flags_(flags) {}
FlutterSemanticsFlag flags

Member Function Documentation

◆ Accept()

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

Implements dart::RegExpTree.

◆ AsAssertion()

virtual RegExpAssertion * dart::RegExpAssertion::AsAssertion ( )
virtual

◆ assertion_type()

AssertionType dart::RegExpAssertion::assertion_type ( ) const
inline

Definition at line 121 of file regexp_ast.h.

121{ return assertion_type_; }

◆ IsAnchoredAtEnd()

bool dart::RegExpAssertion::IsAnchoredAtEnd ( ) const
virtual

Reimplemented from dart::RegExpTree.

Definition at line 71 of file regexp_ast.cc.

71 {
73}
AssertionType assertion_type() const
Definition regexp_ast.h:121

◆ IsAnchoredAtStart()

bool dart::RegExpAssertion::IsAnchoredAtStart ( ) const
virtual

Reimplemented from dart::RegExpTree.

Definition at line 67 of file regexp_ast.cc.

◆ IsAssertion()

virtual bool dart::RegExpAssertion::IsAssertion ( ) const
virtual

◆ max_match()

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

Implements dart::RegExpTree.

Definition at line 120 of file regexp_ast.h.

120{ return 0; }

◆ min_match()

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

Implements dart::RegExpTree.

Definition at line 119 of file regexp_ast.h.

119{ return 0; }

◆ ToNode()

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

Implements dart::RegExpTree.

Definition at line 4433 of file regexp.cc.

4434 {
4435 switch (assertion_type()) {
4436 case START_OF_LINE:
4437 return AssertionNode::AfterNewline(on_success);
4438 case START_OF_INPUT:
4439 return AssertionNode::AtStart(on_success);
4440 case BOUNDARY:
4441 return flags_.NeedsUnicodeCaseEquivalents()
4442 ? BoundaryAssertionAsLookaround(compiler, on_success, BOUNDARY,
4443 flags_)
4444 : AssertionNode::AtBoundary(on_success);
4445 case NON_BOUNDARY:
4446 return flags_.NeedsUnicodeCaseEquivalents()
4447 ? BoundaryAssertionAsLookaround(compiler, on_success,
4448 NON_BOUNDARY, flags_)
4449 : AssertionNode::AtNonBoundary(on_success);
4450 case END_OF_INPUT:
4451 return AssertionNode::AtEnd(on_success);
4452 case END_OF_LINE: {
4453 // Compile $ in multiline regexps as an alternation with a positive
4454 // lookahead in one side and an end-of-input on the other side.
4455 // We need two registers for the lookahead.
4456 intptr_t stack_pointer_register = compiler->AllocateRegister();
4457 intptr_t position_register = compiler->AllocateRegister();
4458 // The ChoiceNode to distinguish between a newline and end-of-input.
4459 ChoiceNode* result = new ChoiceNode(2, on_success->zone());
4460 // Create a newline atom.
4461 ZoneGrowableArray<CharacterRange>* newline_ranges =
4462 new ZoneGrowableArray<CharacterRange>(3);
4463 CharacterRange::AddClassEscape('n', newline_ranges);
4464 RegExpCharacterClass* newline_atom =
4465 new RegExpCharacterClass('n', RegExpFlags());
4466 TextNode* newline_matcher =
4467 new TextNode(newline_atom, /*read_backwards=*/false,
4469 stack_pointer_register, position_register,
4470 0, // No captures inside.
4471 -1, // Ignored if no captures.
4472 on_success));
4473 // Create an end-of-input matcher.
4474 RegExpNode* end_of_line = ActionNode::BeginSubmatch(
4475 stack_pointer_register, position_register, newline_matcher);
4476 // Add the two alternatives to the ChoiceNode.
4477 GuardedAlternative eol_alternative(end_of_line);
4478 result->AddAlternative(eol_alternative);
4479 GuardedAlternative end_alternative(AssertionNode::AtEnd(on_success));
4480 result->AddAlternative(end_alternative);
4481 return result;
4482 }
4483 default:
4484 UNREACHABLE();
4485 }
4486 return on_success;
4487}
#define UNREACHABLE()
Definition assert.h:248
static ActionNode * BeginSubmatch(intptr_t stack_pointer_reg, intptr_t position_reg, RegExpNode *on_success)
Definition regexp.cc:792
static ActionNode * PositiveSubmatchSuccess(intptr_t stack_pointer_reg, intptr_t restore_reg, intptr_t clear_capture_count, intptr_t clear_capture_from, RegExpNode *on_success)
Definition regexp.cc:802
static AssertionNode * AfterNewline(RegExpNode *on_success)
Definition regexp.h:742
static AssertionNode * AtStart(RegExpNode *on_success)
Definition regexp.h:733
static AssertionNode * AtEnd(RegExpNode *on_success)
Definition regexp.h:730
static void AddClassEscape(uint16_t type, ZoneGrowableArray< CharacterRange > *ranges)
Definition regexp.cc:4651
bool NeedsUnicodeCaseEquivalents()
Definition object.h:12702
GAsyncResult * result

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