OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/ast.h" | 5 #include "src/ast.h" |
6 | 6 |
7 #include <cmath> // For isfinite. | 7 #include <cmath> // For isfinite. |
8 #include "src/builtins.h" | 8 #include "src/builtins.h" |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/contexts.h" | 10 #include "src/contexts.h" |
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 bool RegExpCapture::IsAnchoredAtEnd() { | 782 bool RegExpCapture::IsAnchoredAtEnd() { |
783 return body()->IsAnchoredAtEnd(); | 783 return body()->IsAnchoredAtEnd(); |
784 } | 784 } |
785 | 785 |
786 | 786 |
787 // Convert regular expression trees to a simple sexp representation. | 787 // Convert regular expression trees to a simple sexp representation. |
788 // This representation should be different from the input grammar | 788 // This representation should be different from the input grammar |
789 // in as many cases as possible, to make it more difficult for incorrect | 789 // in as many cases as possible, to make it more difficult for incorrect |
790 // parses to look as correct ones which is likely if the input and | 790 // parses to look as correct ones which is likely if the input and |
791 // output formats are alike. | 791 // output formats are alike. |
792 class RegExpUnparser FINAL : public RegExpVisitor { | 792 class RegExpUnparser final : public RegExpVisitor { |
793 public: | 793 public: |
794 RegExpUnparser(std::ostream& os, Zone* zone) : os_(os), zone_(zone) {} | 794 RegExpUnparser(std::ostream& os, Zone* zone) : os_(os), zone_(zone) {} |
795 void VisitCharacterRange(CharacterRange that); | 795 void VisitCharacterRange(CharacterRange that); |
796 #define MAKE_CASE(Name) virtual void* Visit##Name(RegExp##Name*, \ | 796 #define MAKE_CASE(Name) \ |
797 void* data) OVERRIDE; | 797 virtual void* Visit##Name(RegExp##Name*, void* data) override; |
798 FOR_EACH_REG_EXP_TREE_TYPE(MAKE_CASE) | 798 FOR_EACH_REG_EXP_TREE_TYPE(MAKE_CASE) |
799 #undef MAKE_CASE | 799 #undef MAKE_CASE |
800 private: | 800 private: |
801 std::ostream& os_; | 801 std::ostream& os_; |
802 Zone* zone_; | 802 Zone* zone_; |
803 }; | 803 }; |
804 | 804 |
805 | 805 |
806 void* RegExpUnparser::VisitDisjunction(RegExpDisjunction* that, void* data) { | 806 void* RegExpUnparser::VisitDisjunction(RegExpDisjunction* that, void* data) { |
807 os_ << "(|"; | 807 os_ << "(|"; |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1003 // static | 1003 // static |
1004 bool Literal::Match(void* literal1, void* literal2) { | 1004 bool Literal::Match(void* literal1, void* literal2) { |
1005 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); | 1005 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); |
1006 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); | 1006 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); |
1007 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || | 1007 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || |
1008 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); | 1008 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); |
1009 } | 1009 } |
1010 | 1010 |
1011 | 1011 |
1012 } } // namespace v8::internal | 1012 } } // namespace v8::internal |
OLD | NEW |