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

#include <regexp.h>

Classes

struct  Position
 

Public Member Functions

 QuickCheckDetails ()
 
 QuickCheckDetails (intptr_t characters)
 
bool Rationalize (bool one_byte)
 
void Merge (QuickCheckDetails *other, intptr_t from_index)
 
void Advance (intptr_t by, bool one_byte)
 
void Clear ()
 
bool cannot_match ()
 
void set_cannot_match ()
 
intptr_t characters ()
 
void set_characters (intptr_t characters)
 
Positionpositions (intptr_t index)
 
uint32_t mask ()
 
uint32_t value ()
 

Detailed Description

Definition at line 339 of file regexp.h.

Constructor & Destructor Documentation

◆ QuickCheckDetails() [1/2]

dart::QuickCheckDetails::QuickCheckDetails ( )
inline

Definition at line 341 of file regexp.h.

342 : characters_(0), mask_(0), value_(0), cannot_match_(false) {}

◆ QuickCheckDetails() [2/2]

dart::QuickCheckDetails::QuickCheckDetails ( intptr_t  characters)
inlineexplicit

Definition at line 343 of file regexp.h.

344 : characters_(characters), mask_(0), value_(0), cannot_match_(false) {}
intptr_t characters()
Definition regexp.h:359

Member Function Documentation

◆ Advance()

void dart::QuickCheckDetails::Advance ( intptr_t  by,
bool  one_byte 
)

Definition at line 1871 of file regexp.cc.

1871 {
1872 if (by >= characters_ || by < 0) {
1873 // check that by < 0 => characters_ == 0
1874 ASSERT(by >= 0 || characters_ == 0);
1875 Clear();
1876 return;
1877 }
1878 for (intptr_t i = 0; i < characters_ - by; i++) {
1879 positions_[i] = positions_[by + i];
1880 }
1881 for (intptr_t i = characters_ - by; i < characters_; i++) {
1882 positions_[i].mask = 0;
1883 positions_[i].value = 0;
1884 positions_[i].determines_perfectly = false;
1885 }
1886 characters_ -= by;
1887 // We could change mask_ and value_ here but we would never advance unless
1888 // they had already been used in a check and they won't be used again because
1889 // it would gain us nothing. So there's no point.
1890}
#define ASSERT(E)

◆ cannot_match()

bool dart::QuickCheckDetails::cannot_match ( )
inline

Definition at line 351 of file regexp.h.

351{ return cannot_match_; }

◆ characters()

intptr_t dart::QuickCheckDetails::characters ( )
inline

Definition at line 359 of file regexp.h.

359{ return characters_; }

◆ Clear()

void dart::QuickCheckDetails::Clear ( )

Definition at line 1862 of file regexp.cc.

1862 {
1863 for (int i = 0; i < characters_; i++) {
1864 positions_[i].mask = 0;
1865 positions_[i].value = 0;
1866 positions_[i].determines_perfectly = false;
1867 }
1868 characters_ = 0;
1869}

◆ mask()

uint32_t dart::QuickCheckDetails::mask ( )
inline

Definition at line 366 of file regexp.h.

366{ return mask_; }

◆ Merge()

void dart::QuickCheckDetails::Merge ( QuickCheckDetails other,
intptr_t  from_index 
)

Definition at line 1892 of file regexp.cc.

1892 {
1893 ASSERT(characters_ == other->characters_);
1894 if (other->cannot_match_) {
1895 return;
1896 }
1897 if (cannot_match_) {
1898 *this = *other;
1899 return;
1900 }
1901 for (intptr_t i = from_index; i < characters_; i++) {
1902 QuickCheckDetails::Position* pos = positions(i);
1903 QuickCheckDetails::Position* other_pos = other->positions(i);
1904 if (pos->mask != other_pos->mask || pos->value != other_pos->value ||
1905 !other_pos->determines_perfectly) {
1906 // Our mask-compare operation will be approximate unless we have the
1907 // exact same operation on both sides of the alternation.
1908 pos->determines_perfectly = false;
1909 }
1910 pos->mask &= other_pos->mask;
1911 pos->value &= pos->mask;
1912 other_pos->value &= pos->mask;
1913 uint16_t differing_bits = (pos->value ^ other_pos->value);
1914 pos->mask &= ~differing_bits;
1915 pos->value &= pos->mask;
1916 }
1917}
SkPoint pos
Position * positions(intptr_t index)
Definition regexp.h:361

◆ positions()

Position * dart::QuickCheckDetails::positions ( intptr_t  index)
inline

Definition at line 361 of file regexp.h.

361 {
362 ASSERT(index >= 0);
363 ASSERT(index < characters_);
364 return positions_ + index;
365 }

◆ Rationalize()

bool dart::QuickCheckDetails::Rationalize ( bool  one_byte)

Definition at line 1598 of file regexp.cc.

1598 {
1599 bool found_useful_op = false;
1600 uint32_t char_mask;
1601 if (asc) {
1603 } else {
1604 char_mask = Utf16::kMaxCodeUnit;
1605 }
1606 mask_ = 0;
1607 value_ = 0;
1608 intptr_t char_shift = 0;
1609 for (intptr_t i = 0; i < characters_; i++) {
1610 Position* pos = &positions_[i];
1611 if ((pos->mask & Symbols::kMaxOneCharCodeSymbol) != 0) {
1612 found_useful_op = true;
1613 }
1614 mask_ |= (pos->mask & char_mask) << char_shift;
1615 value_ |= (pos->value & char_mask) << char_shift;
1616 char_shift += asc ? 8 : 16;
1617 }
1618 return found_useful_op;
1619}
@ kMaxOneCharCodeSymbol
Definition symbols.h:576
static constexpr int32_t kMaxCodeUnit
Definition unicode.h:158

◆ set_cannot_match()

void dart::QuickCheckDetails::set_cannot_match ( )
inline

Definition at line 352 of file regexp.h.

352{ cannot_match_ = true; }

◆ set_characters()

void dart::QuickCheckDetails::set_characters ( intptr_t  characters)
inline

Definition at line 360 of file regexp.h.

360{ characters_ = characters; }

◆ value()

uint32_t dart::QuickCheckDetails::value ( )
inline

Definition at line 367 of file regexp.h.

367{ return value_; }

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