Flutter Engine
The Flutter Engine
Classes | Public Member Functions | List of all members
dart::ChoiceTable Class Reference

#include <regexp.h>

Inheritance diagram for dart::ChoiceTable:
dart::ValueObject

Classes

class  Config
 
class  Entry
 

Public Member Functions

 ChoiceTable (Zone *zone)
 
void AddRange (CharacterRange range, int32_t value, Zone *zone)
 
OutSetGet (int32_t value)
 
void Dump ()
 
template<typename Callback >
void ForEach (Callback *callback)
 
- Public Member Functions inherited from dart::ValueObject
 ValueObject ()
 
 ~ValueObject ()
 

Detailed Description

Definition at line 120 of file regexp.h.

Constructor & Destructor Documentation

◆ ChoiceTable()

dart::ChoiceTable::ChoiceTable ( Zone zone)
inlineexplicit

Definition at line 122 of file regexp.h.

122: tree_(zone) {}

Member Function Documentation

◆ AddRange()

void dart::ChoiceTable::AddRange ( CharacterRange  range,
int32_t  value,
Zone zone 
)

Definition at line 4989 of file regexp.cc.

4991 {
4992 CharacterRange current = full_range;
4993 if (tree()->is_empty()) {
4994 // If this is the first range we just insert into the table.
4995 ZoneSplayTree<Config>::Locator loc;
4996 bool inserted = tree()->Insert(current.from(), &loc);
4997 ASSERT(inserted);
4998 USE(inserted);
4999 loc.set_value(
5000 Entry(current.from(), current.to(), empty()->Extend(value, zone)));
5001 return;
5002 }
5003 // First see if there is a range to the left of this one that
5004 // overlaps.
5005 ZoneSplayTree<Config>::Locator loc;
5006 if (tree()->FindGreatestLessThan(current.from(), &loc)) {
5007 Entry* entry = &loc.value();
5008 // If we've found a range that overlaps with this one, and it
5009 // starts strictly to the left of this one, we have to fix it
5010 // because the following code only handles ranges that start on
5011 // or after the start point of the range we're adding.
5012 if (entry->from() < current.from() && entry->to() >= current.from()) {
5013 // Snap the overlapping range in half around the start point of
5014 // the range we're adding.
5015 CharacterRange left =
5016 CharacterRange::Range(entry->from(), current.from() - 1);
5017 CharacterRange right = CharacterRange::Range(current.from(), entry->to());
5018 // The left part of the overlapping range doesn't overlap.
5019 // Truncate the whole entry to be just the left part.
5020 entry->set_to(left.to());
5021 // The right part is the one that overlaps. We add this part
5022 // to the map and let the next step deal with merging it with
5023 // the range we're adding.
5024 ZoneSplayTree<Config>::Locator loc;
5025 bool inserted = tree()->Insert(right.from(), &loc);
5026 ASSERT(inserted);
5027 USE(inserted);
5028 loc.set_value(Entry(right.from(), right.to(), entry->out_set()));
5029 }
5030 }
5031 while (current.is_valid()) {
5032 if (tree()->FindLeastGreaterThan(current.from(), &loc) &&
5033 (loc.value().from() <= current.to()) &&
5034 (loc.value().to() >= current.from())) {
5035 Entry* entry = &loc.value();
5036 // We have overlap. If there is space between the start point of
5037 // the range we're adding and where the overlapping range starts
5038 // then we have to add a range covering just that space.
5039 if (current.from() < entry->from()) {
5040 ZoneSplayTree<Config>::Locator ins;
5041 bool inserted = tree()->Insert(current.from(), &ins);
5042 ASSERT(inserted);
5043 USE(inserted);
5044 ins.set_value(Entry(current.from(), entry->from() - 1,
5045 empty()->Extend(value, zone)));
5046 current.set_from(entry->from());
5047 }
5048 ASSERT(current.from() == entry->from());
5049 // If the overlapping range extends beyond the one we want to add
5050 // we have to snap the right part off and add it separately.
5051 if (entry->to() > current.to()) {
5052 ZoneSplayTree<Config>::Locator ins;
5053 bool inserted = tree()->Insert(current.to() + 1, &ins);
5054 ASSERT(inserted);
5055 USE(inserted);
5056 ins.set_value(Entry(current.to() + 1, entry->to(), entry->out_set()));
5057 entry->set_to(current.to());
5058 }
5059 ASSERT(entry->to() <= current.to());
5060 // The overlapping range is now completely contained by the range
5061 // we're adding so we can just update it and move the start point
5062 // of the range we're adding just past it.
5063 entry->AddValue(value, zone);
5064 ASSERT(entry->to() + 1 > current.from());
5065 current.set_from(entry->to() + 1);
5066 } else {
5067 // There is no overlap so we can just add the range
5068 ZoneSplayTree<Config>::Locator ins;
5069 bool inserted = tree()->Insert(current.from(), &ins);
5070 ASSERT(inserted);
5071 USE(inserted);
5072 ins.set_value(
5073 Entry(current.from(), current.to(), empty()->Extend(value, zone)));
5074 break;
5075 }
5076 }
5077}
static void is_empty(skiatest::Reporter *reporter, const SkPath &p)
static CharacterRange Range(int32_t from, int32_t to)
Definition: regexp.h:40
#define ASSERT(E)
uint8_t value
static void USE(T &&)
Definition: globals.h:618

◆ Dump()

void dart::ChoiceTable::Dump ( )

◆ ForEach()

template<typename Callback >
void dart::ChoiceTable::ForEach ( Callback *  callback)
inline

Definition at line 166 of file regexp.h.

166 {
167 return tree()->ForEach(callback);
168 }
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback

◆ Get()

OutSet * dart::ChoiceTable::Get ( int32_t  value)

Definition at line 5079 of file regexp.cc.

5079 {
5080 ZoneSplayTree<Config>::Locator loc;
5081 if (!tree()->FindGreatestLessThan(value, &loc)) return empty();
5082 Entry* entry = &loc.value();
5083 if (value <= entry->to())
5084 return entry->out_set();
5085 else
5086 return empty();
5087}

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