Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Side by Side Diff: src/jsregexp.h

Issue 11228: * No failures on our own tests.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/regexp2000/
Patch Set: Created 12 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 12 matching lines...) Expand all
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #ifndef V8_JSREGEXP_H_ 28 #ifndef V8_JSREGEXP_H_
29 #define V8_JSREGEXP_H_ 29 #define V8_JSREGEXP_H_
30 30
31 namespace v8 { namespace internal { 31 namespace v8 { namespace internal {
32 32
33
34 class RegExpMacroAssembler;
35
36
33 class RegExpImpl { 37 class RegExpImpl {
34 public: 38 public:
35 // Creates a regular expression literal in the old space. 39 // Creates a regular expression literal in the old space.
36 // This function calls the garbage collector if necessary. 40 // This function calls the garbage collector if necessary.
37 static Handle<Object> CreateRegExpLiteral(Handle<JSFunction> constructor, 41 static Handle<Object> CreateRegExpLiteral(Handle<JSFunction> constructor,
38 Handle<String> pattern, 42 Handle<String> pattern,
39 Handle<String> flags, 43 Handle<String> flags,
40 bool* has_pending_exception); 44 bool* has_pending_exception);
41 45
42 // Returns a string representation of a regular expression. 46 // Returns a string representation of a regular expression.
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 static Handle<Object> JscreExecOnce(Handle<JSRegExp> regexp, 148 static Handle<Object> JscreExecOnce(Handle<JSRegExp> regexp,
145 int num_captures, 149 int num_captures,
146 Handle<String> subject, 150 Handle<String> subject,
147 int previous_index, 151 int previous_index,
148 const uc16* utf8_subject, 152 const uc16* utf8_subject,
149 int* ovector, 153 int* ovector,
150 int ovector_length); 154 int ovector_length);
151 155
152 static Handle<Object> Re2kExecOnce(Handle<JSRegExp> regexp, 156 static Handle<Object> Re2kExecOnce(Handle<JSRegExp> regexp,
153 int num_captures, 157 int num_captures,
154 Handle<String> subject, 158 Handle<String> subject16,
155 int previous_index, 159 int previous_index,
156 const uc16* utf8_subject,
157 int* ovector, 160 int* ovector,
158 int ovector_length); 161 int ovector_length);
159 162
160 // Set the subject cache. The previous string buffer is not deleted, so the 163 // Set the subject cache. The previous string buffer is not deleted, so the
161 // caller should ensure that it doesn't leak. 164 // caller should ensure that it doesn't leak.
162 static void SetSubjectCache(String* subject, 165 static void SetSubjectCache(String* subject,
163 char* utf8_subject, 166 char* utf8_subject,
164 int uft8_length, 167 int uft8_length,
165 int character_position, 168 int character_position,
166 int utf8_position); 169 int utf8_position);
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 bool follows_word_interest: 1; 472 bool follows_word_interest: 1;
470 bool follows_newline_interest: 1; 473 bool follows_newline_interest: 1;
471 bool follows_start_interest: 1; 474 bool follows_start_interest: 1;
472 }; 475 };
473 476
474 477
475 STATIC_CHECK(sizeof(NodeInfo) <= sizeof(int)); // NOLINT 478 STATIC_CHECK(sizeof(NodeInfo) <= sizeof(int)); // NOLINT
476 479
477 480
478 class SiblingList { 481 class SiblingList {
479 public: 482 public:
480 SiblingList() : list_(NULL) { } 483 SiblingList() : list_(NULL) { }
481 int length() { 484 int length() {
482 return list_ == NULL ? 0 : list_->length(); 485 return list_ == NULL ? 0 : list_->length();
483 } 486 }
484 void Ensure(RegExpNode* parent) { 487 void Ensure(RegExpNode* parent) {
485 if (list_ == NULL) { 488 if (list_ == NULL) {
486 list_ = new ZoneList<RegExpNode*>(2); 489 list_ = new ZoneList<RegExpNode*>(2);
487 list_->Add(parent); 490 list_->Add(parent);
488 } 491 }
489 } 492 }
490 void Add(RegExpNode* node) { list_->Add(node); } 493 void Add(RegExpNode* node) { list_->Add(node); }
491 RegExpNode* Get(int index) { return list_->at(index); } 494 RegExpNode* Get(int index) { return list_->at(index); }
492 private: 495 private:
493 ZoneList<RegExpNode*>* list_; 496 ZoneList<RegExpNode*>* list_;
494 }; 497 };
495 498
496 499
497 class RegExpNode: public ZoneObject { 500 class RegExpNode: public ZoneObject {
498 public: 501 public:
499 virtual ~RegExpNode() { } 502 virtual ~RegExpNode() { }
500 virtual void Accept(NodeVisitor* visitor) = 0; 503 virtual void Accept(NodeVisitor* visitor) = 0;
501 // Generates a goto to this node or actually generates the code at this point. 504 // Generates a goto to this node or actually generates the code at this point.
502 // Until the implementation is complete we will return true for success and 505 // Until the implementation is complete we will return true for success and
503 // false for failure. 506 // false for failure.
504 bool GoTo(RegExpCompiler* compiler); 507 virtual bool GoTo(RegExpCompiler* compiler);
505 Label* label(); 508 Label* label();
506 509
507 // Until the implementation is complete we will return true for success and 510 // Until the implementation is complete we will return true for success and
508 // false for failure. 511 // false for failure.
509 virtual bool Emit(RegExpCompiler* compiler) = 0; 512 virtual bool Emit(RegExpCompiler* compiler) = 0;
510 virtual RegExpNode* PropagateInterest(NodeInfo* info) = 0; 513 virtual RegExpNode* PropagateInterest(NodeInfo* info) = 0;
511 NodeInfo* info() { return &info_; } 514 NodeInfo* info() { return &info_; }
512 virtual bool IsBacktrack() { return false; } 515 virtual bool IsBacktrack() { return false; }
513 RegExpNode* GetSibling(NodeInfo* info); 516 RegExpNode* GetSibling(NodeInfo* info);
514 void EnsureSiblings() { siblings_.Ensure(this); } 517 void EnsureSiblings() { siblings_.Ensure(this); }
515 void AddSibling(RegExpNode* node) { siblings_.Add(node); } 518 void AddSibling(RegExpNode* node) { siblings_.Add(node); }
519 protected:
520 inline void Bind(RegExpMacroAssembler* macro);
516 private: 521 private:
517 Label label_; 522 Label label_;
518 NodeInfo info_; 523 NodeInfo info_;
519 SiblingList siblings_; 524 SiblingList siblings_;
520 }; 525 };
521 526
522 527
523 class SeqRegExpNode: public RegExpNode { 528 class SeqRegExpNode: public RegExpNode {
524 public: 529 public:
525 explicit SeqRegExpNode(RegExpNode* on_success) 530 explicit SeqRegExpNode(RegExpNode* on_success)
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 581
577 class TextNode: public SeqRegExpNode { 582 class TextNode: public SeqRegExpNode {
578 public: 583 public:
579 TextNode(ZoneList<TextElement>* elms, 584 TextNode(ZoneList<TextElement>* elms,
580 RegExpNode* on_success, 585 RegExpNode* on_success,
581 RegExpNode* on_failure) 586 RegExpNode* on_failure)
582 : SeqRegExpNode(on_success), 587 : SeqRegExpNode(on_success),
583 on_failure_(on_failure), 588 on_failure_(on_failure),
584 elms_(elms) { } 589 elms_(elms) { }
585 virtual void Accept(NodeVisitor* visitor); 590 virtual void Accept(NodeVisitor* visitor);
586 virtual bool Emit(RegExpCompiler* compiler) { return false; }
587 virtual RegExpNode* PropagateInterest(NodeInfo* info); 591 virtual RegExpNode* PropagateInterest(NodeInfo* info);
588 RegExpNode* on_failure() { return on_failure_; } 592 RegExpNode* on_failure() { return on_failure_; }
593 virtual bool Emit(RegExpCompiler* compiler);
589 ZoneList<TextElement>* elements() { return elms_; } 594 ZoneList<TextElement>* elements() { return elms_; }
590 private: 595 private:
591 RegExpNode* on_failure_; 596 RegExpNode* on_failure_;
592 ZoneList<TextElement>* elms_; 597 ZoneList<TextElement>* elms_;
593 }; 598 };
594 599
595 600
596 class BackreferenceNode: public SeqRegExpNode { 601 class BackreferenceNode: public SeqRegExpNode {
597 public: 602 public:
598 BackreferenceNode(int start_reg, 603 BackreferenceNode(int start_reg,
(...skipping 18 matching lines...) Expand all
617 622
618 623
619 class EndNode: public RegExpNode { 624 class EndNode: public RegExpNode {
620 public: 625 public:
621 enum Action { ACCEPT, BACKTRACK }; 626 enum Action { ACCEPT, BACKTRACK };
622 explicit EndNode(Action action) : action_(action) { } 627 explicit EndNode(Action action) : action_(action) { }
623 virtual void Accept(NodeVisitor* visitor); 628 virtual void Accept(NodeVisitor* visitor);
624 virtual bool Emit(RegExpCompiler* compiler); 629 virtual bool Emit(RegExpCompiler* compiler);
625 virtual RegExpNode* PropagateInterest(NodeInfo* info); 630 virtual RegExpNode* PropagateInterest(NodeInfo* info);
626 virtual bool IsBacktrack() { return action_ == BACKTRACK; } 631 virtual bool IsBacktrack() { return action_ == BACKTRACK; }
632 virtual bool GoTo(RegExpCompiler* compiler);
627 private: 633 private:
628 Action action_; 634 Action action_;
629 }; 635 };
630 636
631 637
632 class Guard: public ZoneObject { 638 class Guard: public ZoneObject {
633 public: 639 public:
634 enum Relation { LT, GEQ }; 640 enum Relation { LT, GEQ };
635 Guard(int reg, Relation op, int value) 641 Guard(int reg, Relation op, int value)
636 : reg_(reg), 642 : reg_(reg),
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 ZoneList<GuardedAlternative>* alternatives() { return alternatives_; } 677 ZoneList<GuardedAlternative>* alternatives() { return alternatives_; }
672 DispatchTable* table() { return &table_; } 678 DispatchTable* table() { return &table_; }
673 RegExpNode* on_failure() { return on_failure_; } 679 RegExpNode* on_failure() { return on_failure_; }
674 virtual bool Emit(RegExpCompiler* compiler); 680 virtual bool Emit(RegExpCompiler* compiler);
675 virtual RegExpNode* PropagateInterest(NodeInfo* info); 681 virtual RegExpNode* PropagateInterest(NodeInfo* info);
676 bool table_calculated() { return table_calculated_; } 682 bool table_calculated() { return table_calculated_; }
677 void set_table_calculated(bool b) { table_calculated_ = b; } 683 void set_table_calculated(bool b) { table_calculated_ = b; }
678 bool being_calculated() { return being_calculated_; } 684 bool being_calculated() { return being_calculated_; }
679 void set_being_calculated(bool b) { being_calculated_ = b; } 685 void set_being_calculated(bool b) { being_calculated_ = b; }
680 private: 686 private:
681 void GenerateGuard(RegExpCompiler* compiler, 687 void GenerateGuard(RegExpMacroAssembler* macro_assembler,
682 Guard *guard, 688 Guard *guard,
683 Label* on_failure); 689 Label* on_failure);
684 RegExpNode* on_failure_; 690 RegExpNode* on_failure_;
685 ZoneList<GuardedAlternative>* alternatives_; 691 ZoneList<GuardedAlternative>* alternatives_;
686 DispatchTable table_; 692 DispatchTable table_;
687 bool table_calculated_; 693 bool table_calculated_;
688 bool being_calculated_; 694 bool being_calculated_;
689 }; 695 };
690 696
691 697
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 static Handle<FixedArray> Compile(RegExpParseResult* input, 759 static Handle<FixedArray> Compile(RegExpParseResult* input,
754 RegExpNode** node_return, 760 RegExpNode** node_return,
755 bool ignore_case); 761 bool ignore_case);
756 static void DotPrint(const char* label, RegExpNode* node); 762 static void DotPrint(const char* label, RegExpNode* node);
757 }; 763 };
758 764
759 765
760 } } // namespace v8::internal 766 } } // namespace v8::internal
761 767
762 #endif // V8_JSREGEXP_H_ 768 #endif // V8_JSREGEXP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698