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 5157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5168 negated_ranges->Add(CharacterRange(from + 1, range.from() - 1)); | 5168 negated_ranges->Add(CharacterRange(from + 1, range.from() - 1)); |
5169 from = range.to(); | 5169 from = range.to(); |
5170 i++; | 5170 i++; |
5171 } | 5171 } |
5172 if (from < String::kMaxUtf16CodeUnit) { | 5172 if (from < String::kMaxUtf16CodeUnit) { |
5173 negated_ranges->Add(CharacterRange(from + 1, String::kMaxUtf16CodeUnit)); | 5173 negated_ranges->Add(CharacterRange(from + 1, String::kMaxUtf16CodeUnit)); |
5174 } | 5174 } |
5175 } | 5175 } |
5176 | 5176 |
5177 | 5177 |
5178 | |
5179 // ------------------------------------------------------------------- | |
5180 // Interest propagation | |
5181 | |
5182 | |
5183 RegExpNode* RegExpNode::TryGetSibling(NodeInfo* info) { | |
5184 for (int i = 0; i < siblings_.length(); i++) { | |
5185 RegExpNode* sibling = siblings_.Get(i); | |
5186 if (sibling->info()->Matches(info)) | |
5187 return sibling; | |
5188 } | |
5189 return NULL; | |
5190 } | |
5191 | |
5192 | |
5193 RegExpNode* RegExpNode::EnsureSibling(NodeInfo* info, bool* cloned) { | |
5194 ASSERT_EQ(false, *cloned); | |
5195 siblings_.Ensure(this); | |
5196 RegExpNode* result = TryGetSibling(info); | |
5197 if (result != NULL) return result; | |
5198 result = this->Clone(); | |
5199 NodeInfo* new_info = result->info(); | |
5200 new_info->ResetCompilationState(); | |
5201 new_info->AddFromPreceding(info); | |
5202 AddSibling(result); | |
5203 *cloned = true; | |
5204 return result; | |
5205 } | |
5206 | |
5207 | |
5208 template <class C> | |
5209 static RegExpNode* PropagateToEndpoint(C* node, NodeInfo* info) { | |
5210 NodeInfo full_info(*node->info()); | |
5211 full_info.AddFromPreceding(info); | |
5212 bool cloned = false; | |
5213 return RegExpNode::EnsureSibling(node, &full_info, &cloned); | |
5214 } | |
5215 | |
5216 | |
5217 // ------------------------------------------------------------------- | 5178 // ------------------------------------------------------------------- |
5218 // Splay tree | 5179 // Splay tree |
5219 | 5180 |
5220 | 5181 |
5221 OutSet* OutSet::Extend(unsigned value) { | 5182 OutSet* OutSet::Extend(unsigned value) { |
5222 if (Get(value)) | 5183 if (Get(value)) |
5223 return this; | 5184 return this; |
5224 if (successors() != NULL) { | 5185 if (successors() != NULL) { |
5225 for (int i = 0; i < successors()->length(); i++) { | 5186 for (int i = 0; i < successors()->length(); i++) { |
5226 OutSet* successor = successors()->at(i); | 5187 OutSet* successor = successors()->at(i); |
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5771 } | 5732 } |
5772 | 5733 |
5773 return compiler.Assemble(¯o_assembler, | 5734 return compiler.Assemble(¯o_assembler, |
5774 node, | 5735 node, |
5775 data->capture_count, | 5736 data->capture_count, |
5776 pattern); | 5737 pattern); |
5777 } | 5738 } |
5778 | 5739 |
5779 | 5740 |
5780 }} // namespace v8::internal | 5741 }} // namespace v8::internal |
OLD | NEW |