| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 962 | 962 |
| 963 // Convert regular expression trees to a simple sexp representation. | 963 // Convert regular expression trees to a simple sexp representation. |
| 964 // This representation should be different from the input grammar | 964 // This representation should be different from the input grammar |
| 965 // in as many cases as possible, to make it more difficult for incorrect | 965 // in as many cases as possible, to make it more difficult for incorrect |
| 966 // parses to look as correct ones which is likely if the input and | 966 // parses to look as correct ones which is likely if the input and |
| 967 // output formats are alike. | 967 // output formats are alike. |
| 968 class RegExpUnparser: public RegExpVisitor { | 968 class RegExpUnparser: public RegExpVisitor { |
| 969 public: | 969 public: |
| 970 RegExpUnparser(); | 970 RegExpUnparser(); |
| 971 void VisitCharacterRange(CharacterRange that); | 971 void VisitCharacterRange(CharacterRange that); |
| 972 SmartPointer<const char> ToString() { return stream_.ToCString(); } | 972 SmartArrayPointer<const char> ToString() { return stream_.ToCString(); } |
| 973 #define MAKE_CASE(Name) virtual void* Visit##Name(RegExp##Name*, void* data); | 973 #define MAKE_CASE(Name) virtual void* Visit##Name(RegExp##Name*, void* data); |
| 974 FOR_EACH_REG_EXP_TREE_TYPE(MAKE_CASE) | 974 FOR_EACH_REG_EXP_TREE_TYPE(MAKE_CASE) |
| 975 #undef MAKE_CASE | 975 #undef MAKE_CASE |
| 976 private: | 976 private: |
| 977 StringStream* stream() { return &stream_; } | 977 StringStream* stream() { return &stream_; } |
| 978 HeapStringAllocator alloc_; | 978 HeapStringAllocator alloc_; |
| 979 StringStream stream_; | 979 StringStream stream_; |
| 980 }; | 980 }; |
| 981 | 981 |
| 982 | 982 |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1117 return NULL; | 1117 return NULL; |
| 1118 } | 1118 } |
| 1119 | 1119 |
| 1120 | 1120 |
| 1121 void* RegExpUnparser::VisitEmpty(RegExpEmpty* that, void* data) { | 1121 void* RegExpUnparser::VisitEmpty(RegExpEmpty* that, void* data) { |
| 1122 stream()->Put('%'); | 1122 stream()->Put('%'); |
| 1123 return NULL; | 1123 return NULL; |
| 1124 } | 1124 } |
| 1125 | 1125 |
| 1126 | 1126 |
| 1127 SmartPointer<const char> RegExpTree::ToString() { | 1127 SmartArrayPointer<const char> RegExpTree::ToString() { |
| 1128 RegExpUnparser unparser; | 1128 RegExpUnparser unparser; |
| 1129 Accept(&unparser, NULL); | 1129 Accept(&unparser, NULL); |
| 1130 return unparser.ToString(); | 1130 return unparser.ToString(); |
| 1131 } | 1131 } |
| 1132 | 1132 |
| 1133 | 1133 |
| 1134 RegExpDisjunction::RegExpDisjunction(ZoneList<RegExpTree*>* alternatives) | 1134 RegExpDisjunction::RegExpDisjunction(ZoneList<RegExpTree*>* alternatives) |
| 1135 : alternatives_(alternatives) { | 1135 : alternatives_(alternatives) { |
| 1136 ASSERT(alternatives->length() > 1); | 1136 ASSERT(alternatives->length() > 1); |
| 1137 RegExpTree* first_alternative = alternatives->at(0); | 1137 RegExpTree* first_alternative = alternatives->at(0); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1169 int pos) | 1169 int pos) |
| 1170 : label_(label), | 1170 : label_(label), |
| 1171 statements_(statements), | 1171 statements_(statements), |
| 1172 position_(pos), | 1172 position_(pos), |
| 1173 compare_type_(NONE), | 1173 compare_type_(NONE), |
| 1174 compare_id_(AstNode::GetNextId(isolate)), | 1174 compare_id_(AstNode::GetNextId(isolate)), |
| 1175 entry_id_(AstNode::GetNextId(isolate)) { | 1175 entry_id_(AstNode::GetNextId(isolate)) { |
| 1176 } | 1176 } |
| 1177 | 1177 |
| 1178 } } // namespace v8::internal | 1178 } } // namespace v8::internal |
| OLD | NEW |