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 924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
935 | 935 |
936 // Convert regular expression trees to a simple sexp representation. | 936 // Convert regular expression trees to a simple sexp representation. |
937 // This representation should be different from the input grammar | 937 // This representation should be different from the input grammar |
938 // in as many cases as possible, to make it more difficult for incorrect | 938 // in as many cases as possible, to make it more difficult for incorrect |
939 // parses to look as correct ones which is likely if the input and | 939 // parses to look as correct ones which is likely if the input and |
940 // output formats are alike. | 940 // output formats are alike. |
941 class RegExpUnparser final : public RegExpVisitor { | 941 class RegExpUnparser final : public RegExpVisitor { |
942 public: | 942 public: |
943 RegExpUnparser(std::ostream& os, Zone* zone) : os_(os), zone_(zone) {} | 943 RegExpUnparser(std::ostream& os, Zone* zone) : os_(os), zone_(zone) {} |
944 void VisitCharacterRange(CharacterRange that); | 944 void VisitCharacterRange(CharacterRange that); |
945 #define MAKE_CASE(Name) \ | 945 #define MAKE_CASE(Name) void* Visit##Name(RegExp##Name*, void* data) override; |
946 virtual void* Visit##Name(RegExp##Name*, void* data) override; | |
947 FOR_EACH_REG_EXP_TREE_TYPE(MAKE_CASE) | 946 FOR_EACH_REG_EXP_TREE_TYPE(MAKE_CASE) |
948 #undef MAKE_CASE | 947 #undef MAKE_CASE |
949 private: | 948 private: |
950 std::ostream& os_; | 949 std::ostream& os_; |
951 Zone* zone_; | 950 Zone* zone_; |
952 }; | 951 }; |
953 | 952 |
954 | 953 |
955 void* RegExpUnparser::VisitDisjunction(RegExpDisjunction* that, void* data) { | 954 void* RegExpUnparser::VisitDisjunction(RegExpDisjunction* that, void* data) { |
956 os_ << "(|"; | 955 os_ << "(|"; |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1153 bool Literal::Match(void* literal1, void* literal2) { | 1152 bool Literal::Match(void* literal1, void* literal2) { |
1154 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); | 1153 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); |
1155 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); | 1154 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); |
1156 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || | 1155 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || |
1157 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); | 1156 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); |
1158 } | 1157 } |
1159 | 1158 |
1160 | 1159 |
1161 } // namespace internal | 1160 } // namespace internal |
1162 } // namespace v8 | 1161 } // namespace v8 |
OLD | NEW |