12#define MAKE_ACCEPT(Name) \
13 void* RegExp##Name::Accept(RegExpVisitor* visitor, void* data) { \
14 return visitor->Visit##Name(this, data); \
19#define MAKE_TYPE_CASE(Name) \
20 RegExp##Name* RegExpTree::As##Name() { \
23 bool RegExpTree::Is##Name() const { \
29#define MAKE_TYPE_CASE(Name) \
30 RegExp##Name* RegExp##Name::As##Name() { \
33 bool RegExp##Name::Is##Name() const { \
41 for (intptr_t
i = 0;
i < children->
length();
i++)
77 for (intptr_t
i = 0;
i <
nodes->length();
i++) {
91 for (intptr_t
i =
nodes->length() - 1;
i >= 0;
i--) {
139#define MAKE_CASE(Name) virtual void* Visit##Name(RegExp##Name*, void* data);
144void* RegExpUnparser::VisitDisjunction(RegExpDisjunction* that,
void*
data) {
146 for (intptr_t
i = 0;
i < that->alternatives()->
length();
i++) {
148 (*that->alternatives())[
i]->Accept(
this,
data);
154void* RegExpUnparser::VisitAlternative(RegExpAlternative* that,
void*
data) {
156 for (intptr_t
i = 0;
i < that->nodes()->
length();
i++) {
158 (*that->nodes())[
i]->Accept(
this,
data);
184void* RegExpUnparser::VisitAssertion(RegExpAssertion* that,
void*
data) {
185 switch (that->assertion_type()) {
208void* RegExpUnparser::VisitAtom(RegExpAtom* that,
void*
data) {
210 ZoneGrowableArray<uint16_t>* chardata = that->data();
211 for (intptr_t
i = 0;
i < chardata->length();
i++) {
218void* RegExpUnparser::VisitText(RegExpText* that,
void*
data) {
219 if (that->elements()->length() == 1) {
220 (*that->elements())[0].tree()->Accept(
this,
data);
223 for (intptr_t
i = 0;
i < that->elements()->
length();
i++) {
225 (*that->elements())[
i].tree()->Accept(
this,
data);
232void* RegExpUnparser::VisitQuantifier(RegExpQuantifier* that,
void*
data) {
239 OS::PrintErr(that->is_greedy() ?
"g " : that->is_possessive() ?
"p " :
"n ");
240 that->body()->Accept(
this,
data);
245void* RegExpUnparser::VisitCapture(RegExpCapture* that,
void*
data) {
247 that->body()->Accept(
this,
data);
252void* RegExpUnparser::VisitLookaround(RegExpLookaround* that,
void*
data) {
256 (that->is_positive() ?
"+ " :
"- "));
257 that->body()->Accept(
this,
data);
262void* RegExpUnparser::VisitBackReference(RegExpBackReference* that,
void*) {
267void* RegExpUnparser::VisitEmpty(RegExpEmpty*,
void*) {
274 Accept(&unparser,
nullptr);
279 : alternatives_(alternatives) {
282 min_match_ = first_alternative->
min_match();
283 max_match_ = first_alternative->
max_match();
291static intptr_t
IncreaseBy(intptr_t previous, intptr_t increase) {
295 return previous + increase;
304 for (intptr_t
i = 0;
i <
nodes->length();
i++) {
306 intptr_t node_min_match = node->
min_match();
307 min_match_ =
IncreaseBy(min_match_, node_min_match);
308 intptr_t node_max_match = node->
max_match();
309 max_match_ =
IncreaseBy(max_match_, node_max_match);
const T & At(intptr_t index) const
static void static void PrintErr(const char *format,...) PRINTF_ATTRIBUTE(1
virtual Interval CaptureRegisters() const
ZoneGrowableArray< RegExpTree * > * nodes() const
virtual bool IsAnchoredAtStart() const
virtual bool IsAnchoredAtEnd() const
RegExpAlternative(ZoneGrowableArray< RegExpTree * > *nodes)
virtual bool IsAnchoredAtEnd() const
virtual bool IsAnchoredAtStart() const
AssertionType assertion_type() const
virtual Interval CaptureRegisters() const
RegExpTree * body() const
virtual bool IsAnchoredAtEnd() const
static intptr_t EndRegister(intptr_t index)
static intptr_t StartRegister(intptr_t index)
virtual bool IsAnchoredAtStart() const
ZoneGrowableArray< CharacterRange > * ranges()
RegExpDisjunction(ZoneGrowableArray< RegExpTree * > *alternatives)
virtual bool IsAnchoredAtStart() const
ZoneGrowableArray< RegExpTree * > * alternatives() const
virtual bool IsAnchoredAtEnd() const
virtual Interval CaptureRegisters() const
virtual bool IsAnchoredAtStart() const
RegExpTree * body() const
virtual Interval CaptureRegisters() const
RegExpTree * body() const
virtual Interval CaptureRegisters() const
virtual intptr_t min_match() const =0
virtual bool IsAnchoredAtEnd() const
virtual Interval CaptureRegisters() const
virtual void * Accept(RegExpVisitor *visitor, void *data)=0
virtual intptr_t max_match() const =0
static constexpr intptr_t kInfinity
virtual bool IsAnchoredAtStart() const
void VisitCharacterRange(CharacterRange that)
static constexpr T Maximum(T x, T y)
static T Minimum(T x, T y)
static intptr_t IncreaseBy(intptr_t previous, intptr_t increase)
void PrintUtf16(uint16_t c)
static Interval ListCaptureRegisters(ZoneGrowableArray< RegExpTree * > *children)
static int8_t data[kExtLength]
#define FOR_EACH_REG_EXP_TREE_TYPE(VISIT)
#define MAKE_ACCEPT(Name)
#define MAKE_TYPE_CASE(Name)