| Index: runtime/vm/regexp_ast.cc
|
| diff --git a/runtime/vm/regexp_ast.cc b/runtime/vm/regexp_ast.cc
|
| index 7e0cbc7e47f8f9ba53b3f2b016f9883587abbd30..2edfe080b7a8201b0aea6423b4ccdd3ce31e8627 100644
|
| --- a/runtime/vm/regexp_ast.cc
|
| +++ b/runtime/vm/regexp_ast.cc
|
| @@ -28,7 +28,6 @@ FOR_EACH_REG_EXP_TREE_TYPE(MAKE_TYPE_CASE)
|
| FOR_EACH_REG_EXP_TREE_TYPE(MAKE_TYPE_CASE)
|
| #undef MAKE_TYPE_CASE
|
|
|
| -
|
| static Interval ListCaptureRegisters(ZoneGrowableArray<RegExpTree*>* children) {
|
| Interval result = Interval::Empty();
|
| for (intptr_t i = 0; i < children->length(); i++)
|
| @@ -36,43 +35,35 @@ static Interval ListCaptureRegisters(ZoneGrowableArray<RegExpTree*>* children) {
|
| return result;
|
| }
|
|
|
| -
|
| Interval RegExpAlternative::CaptureRegisters() const {
|
| return ListCaptureRegisters(nodes());
|
| }
|
|
|
| -
|
| Interval RegExpDisjunction::CaptureRegisters() const {
|
| return ListCaptureRegisters(alternatives());
|
| }
|
|
|
| -
|
| Interval RegExpLookahead::CaptureRegisters() const {
|
| return body()->CaptureRegisters();
|
| }
|
|
|
| -
|
| Interval RegExpCapture::CaptureRegisters() const {
|
| Interval self(StartRegister(index()), EndRegister(index()));
|
| return self.Union(body()->CaptureRegisters());
|
| }
|
|
|
| -
|
| Interval RegExpQuantifier::CaptureRegisters() const {
|
| return body()->CaptureRegisters();
|
| }
|
|
|
| -
|
| bool RegExpAssertion::IsAnchoredAtStart() const {
|
| return assertion_type() == RegExpAssertion::START_OF_INPUT;
|
| }
|
|
|
| -
|
| bool RegExpAssertion::IsAnchoredAtEnd() const {
|
| return assertion_type() == RegExpAssertion::END_OF_INPUT;
|
| }
|
|
|
| -
|
| bool RegExpAlternative::IsAnchoredAtStart() const {
|
| ZoneGrowableArray<RegExpTree*>* nodes = this->nodes();
|
| for (intptr_t i = 0; i < nodes->length(); i++) {
|
| @@ -87,7 +78,6 @@ bool RegExpAlternative::IsAnchoredAtStart() const {
|
| return false;
|
| }
|
|
|
| -
|
| bool RegExpAlternative::IsAnchoredAtEnd() const {
|
| ZoneGrowableArray<RegExpTree*>* nodes = this->nodes();
|
| for (intptr_t i = nodes->length() - 1; i >= 0; i--) {
|
| @@ -102,7 +92,6 @@ bool RegExpAlternative::IsAnchoredAtEnd() const {
|
| return false;
|
| }
|
|
|
| -
|
| bool RegExpDisjunction::IsAnchoredAtStart() const {
|
| ZoneGrowableArray<RegExpTree*>* alternatives = this->alternatives();
|
| for (intptr_t i = 0; i < alternatives->length(); i++) {
|
| @@ -111,7 +100,6 @@ bool RegExpDisjunction::IsAnchoredAtStart() const {
|
| return true;
|
| }
|
|
|
| -
|
| bool RegExpDisjunction::IsAnchoredAtEnd() const {
|
| ZoneGrowableArray<RegExpTree*>* alternatives = this->alternatives();
|
| for (intptr_t i = 0; i < alternatives->length(); i++) {
|
| @@ -120,22 +108,18 @@ bool RegExpDisjunction::IsAnchoredAtEnd() const {
|
| return true;
|
| }
|
|
|
| -
|
| bool RegExpLookahead::IsAnchoredAtStart() const {
|
| return is_positive() && body()->IsAnchoredAtStart();
|
| }
|
|
|
| -
|
| bool RegExpCapture::IsAnchoredAtStart() const {
|
| return body()->IsAnchoredAtStart();
|
| }
|
|
|
| -
|
| bool RegExpCapture::IsAnchoredAtEnd() const {
|
| return body()->IsAnchoredAtEnd();
|
| }
|
|
|
| -
|
| // Convert regular expression trees to a simple sexp representation.
|
| // This representation should be different from the input grammar
|
| // in as many cases as possible, to make it more difficult for incorrect
|
| @@ -149,7 +133,6 @@ class RegExpUnparser : public RegExpVisitor {
|
| #undef MAKE_CASE
|
| };
|
|
|
| -
|
| void* RegExpUnparser::VisitDisjunction(RegExpDisjunction* that, void* data) {
|
| OS::Print("(|");
|
| for (intptr_t i = 0; i < that->alternatives()->length(); i++) {
|
| @@ -160,7 +143,6 @@ void* RegExpUnparser::VisitDisjunction(RegExpDisjunction* that, void* data) {
|
| return NULL;
|
| }
|
|
|
| -
|
| void* RegExpUnparser::VisitAlternative(RegExpAlternative* that, void* data) {
|
| OS::Print("(:");
|
| for (intptr_t i = 0; i < that->nodes()->length(); i++) {
|
| @@ -171,7 +153,6 @@ void* RegExpUnparser::VisitAlternative(RegExpAlternative* that, void* data) {
|
| return NULL;
|
| }
|
|
|
| -
|
| void RegExpUnparser::VisitCharacterRange(CharacterRange that) {
|
| PrintUtf16(that.from());
|
| if (!that.IsSingleton()) {
|
| @@ -180,7 +161,6 @@ void RegExpUnparser::VisitCharacterRange(CharacterRange that) {
|
| }
|
| }
|
|
|
| -
|
| void* RegExpUnparser::VisitCharacterClass(RegExpCharacterClass* that,
|
| void* data) {
|
| if (that->is_negated()) OS::Print("^");
|
| @@ -193,7 +173,6 @@ void* RegExpUnparser::VisitCharacterClass(RegExpCharacterClass* that,
|
| return NULL;
|
| }
|
|
|
| -
|
| void* RegExpUnparser::VisitAssertion(RegExpAssertion* that, void* data) {
|
| switch (that->assertion_type()) {
|
| case RegExpAssertion::START_OF_INPUT:
|
| @@ -218,7 +197,6 @@ void* RegExpUnparser::VisitAssertion(RegExpAssertion* that, void* data) {
|
| return NULL;
|
| }
|
|
|
| -
|
| void* RegExpUnparser::VisitAtom(RegExpAtom* that, void* data) {
|
| OS::Print("'");
|
| ZoneGrowableArray<uint16_t>* chardata = that->data();
|
| @@ -229,7 +207,6 @@ void* RegExpUnparser::VisitAtom(RegExpAtom* that, void* data) {
|
| return NULL;
|
| }
|
|
|
| -
|
| void* RegExpUnparser::VisitText(RegExpText* that, void* data) {
|
| if (that->elements()->length() == 1) {
|
| (*that->elements())[0].tree()->Accept(this, data);
|
| @@ -244,7 +221,6 @@ void* RegExpUnparser::VisitText(RegExpText* that, void* data) {
|
| return NULL;
|
| }
|
|
|
| -
|
| void* RegExpUnparser::VisitQuantifier(RegExpQuantifier* that, void* data) {
|
| OS::Print("(# %" Pd " ", that->min());
|
| if (that->max() == RegExpTree::kInfinity) {
|
| @@ -258,7 +234,6 @@ void* RegExpUnparser::VisitQuantifier(RegExpQuantifier* that, void* data) {
|
| return NULL;
|
| }
|
|
|
| -
|
| void* RegExpUnparser::VisitCapture(RegExpCapture* that, void* data) {
|
| OS::Print("(^ ");
|
| that->body()->Accept(this, data);
|
| @@ -266,7 +241,6 @@ void* RegExpUnparser::VisitCapture(RegExpCapture* that, void* data) {
|
| return NULL;
|
| }
|
|
|
| -
|
| void* RegExpUnparser::VisitLookahead(RegExpLookahead* that, void* data) {
|
| OS::Print("(-> %s", (that->is_positive() ? "+ " : "- "));
|
| that->body()->Accept(this, data);
|
| @@ -274,25 +248,21 @@ void* RegExpUnparser::VisitLookahead(RegExpLookahead* that, void* data) {
|
| return NULL;
|
| }
|
|
|
| -
|
| void* RegExpUnparser::VisitBackReference(RegExpBackReference* that, void*) {
|
| OS::Print("(<- %" Pd ")", that->index());
|
| return NULL;
|
| }
|
|
|
| -
|
| void* RegExpUnparser::VisitEmpty(RegExpEmpty*, void*) {
|
| OS::Print("%%");
|
| return NULL;
|
| }
|
|
|
| -
|
| void RegExpTree::Print() {
|
| RegExpUnparser unparser;
|
| Accept(&unparser, NULL);
|
| }
|
|
|
| -
|
| RegExpDisjunction::RegExpDisjunction(
|
| ZoneGrowableArray<RegExpTree*>* alternatives)
|
| : alternatives_(alternatives) {
|
| @@ -307,7 +277,6 @@ RegExpDisjunction::RegExpDisjunction(
|
| }
|
| }
|
|
|
| -
|
| static intptr_t IncreaseBy(intptr_t previous, intptr_t increase) {
|
| if (RegExpTree::kInfinity - previous < increase) {
|
| return RegExpTree::kInfinity;
|
|
|