OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1568 private: | 1568 private: |
1569 int min_; | 1569 int min_; |
1570 int max_; | 1570 int max_; |
1571 bool is_greedy_; | 1571 bool is_greedy_; |
1572 RegExpTree* body_; | 1572 RegExpTree* body_; |
1573 int min_match_; | 1573 int min_match_; |
1574 int max_match_; | 1574 int max_match_; |
1575 }; | 1575 }; |
1576 | 1576 |
1577 | 1577 |
1578 enum CaptureAvailability { | |
1579 CAPTURE_AVAILABLE, | |
1580 CAPTURE_UNREACHABLE, | |
1581 CAPTURE_PERMANENTLY_UNREACHABLE | |
1582 }; | |
1583 | |
1584 class RegExpCapture: public RegExpTree { | 1578 class RegExpCapture: public RegExpTree { |
1585 public: | 1579 public: |
1586 explicit RegExpCapture(RegExpTree* body, int index) | 1580 explicit RegExpCapture(RegExpTree* body, int index) |
1587 : body_(body), index_(index), available_(CAPTURE_AVAILABLE) { } | 1581 : body_(body), index_(index) { } |
1588 virtual void* Accept(RegExpVisitor* visitor, void* data); | 1582 virtual void* Accept(RegExpVisitor* visitor, void* data); |
1589 virtual RegExpNode* ToNode(RegExpCompiler* compiler, | 1583 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
1590 RegExpNode* on_success); | 1584 RegExpNode* on_success); |
1591 static RegExpNode* ToNode(RegExpTree* body, | 1585 static RegExpNode* ToNode(RegExpTree* body, |
1592 int index, | 1586 int index, |
1593 RegExpCompiler* compiler, | 1587 RegExpCompiler* compiler, |
1594 RegExpNode* on_success); | 1588 RegExpNode* on_success); |
1595 virtual RegExpCapture* AsCapture(); | 1589 virtual RegExpCapture* AsCapture(); |
1596 virtual bool IsAnchored(); | 1590 virtual bool IsAnchored(); |
1597 virtual Interval CaptureRegisters(); | 1591 virtual Interval CaptureRegisters(); |
1598 virtual bool IsCapture(); | 1592 virtual bool IsCapture(); |
1599 virtual int min_match() { return body_->min_match(); } | 1593 virtual int min_match() { return body_->min_match(); } |
1600 virtual int max_match() { return body_->max_match(); } | 1594 virtual int max_match() { return body_->max_match(); } |
1601 RegExpTree* body() { return body_; } | 1595 RegExpTree* body() { return body_; } |
1602 int index() { return index_; } | 1596 int index() { return index_; } |
1603 inline CaptureAvailability available() { return available_; } | |
1604 inline void set_available(CaptureAvailability availability) { | |
1605 available_ = availability; | |
1606 } | |
1607 static int StartRegister(int index) { return index * 2; } | 1597 static int StartRegister(int index) { return index * 2; } |
1608 static int EndRegister(int index) { return index * 2 + 1; } | 1598 static int EndRegister(int index) { return index * 2 + 1; } |
1609 private: | 1599 private: |
1610 RegExpTree* body_; | 1600 RegExpTree* body_; |
1611 int index_; | 1601 int index_; |
1612 CaptureAvailability available_; | |
1613 }; | 1602 }; |
1614 | 1603 |
1615 | 1604 |
1616 class RegExpLookahead: public RegExpTree { | 1605 class RegExpLookahead: public RegExpTree { |
1617 public: | 1606 public: |
1618 RegExpLookahead(RegExpTree* body, | 1607 RegExpLookahead(RegExpTree* body, |
1619 bool is_positive, | 1608 bool is_positive, |
1620 int capture_count, | 1609 int capture_count, |
1621 int capture_from) | 1610 int capture_from) |
1622 : body_(body), | 1611 : body_(body), |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1717 #undef DEF_VISIT | 1706 #undef DEF_VISIT |
1718 | 1707 |
1719 private: | 1708 private: |
1720 bool stack_overflow_; | 1709 bool stack_overflow_; |
1721 }; | 1710 }; |
1722 | 1711 |
1723 | 1712 |
1724 } } // namespace v8::internal | 1713 } } // namespace v8::internal |
1725 | 1714 |
1726 #endif // V8_AST_H_ | 1715 #endif // V8_AST_H_ |
OLD | NEW |