| 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/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/api.h" | 7 #include "src/api.h" |
| 8 #include "src/ast.h" | 8 #include "src/ast.h" |
| 9 #include "src/bailout-reason.h" | 9 #include "src/bailout-reason.h" |
| 10 #include "src/base/platform/platform.h" | 10 #include "src/base/platform/platform.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 void RegExpBuilder::NewAlternative() { | 104 void RegExpBuilder::NewAlternative() { |
| 105 FlushTerms(); | 105 FlushTerms(); |
| 106 } | 106 } |
| 107 | 107 |
| 108 | 108 |
| 109 void RegExpBuilder::FlushTerms() { | 109 void RegExpBuilder::FlushTerms() { |
| 110 FlushText(); | 110 FlushText(); |
| 111 int num_terms = terms_.length(); | 111 int num_terms = terms_.length(); |
| 112 RegExpTree* alternative; | 112 RegExpTree* alternative; |
| 113 if (num_terms == 0) { | 113 if (num_terms == 0) { |
| 114 alternative = RegExpEmpty::GetInstance(); | 114 alternative = new (zone()) RegExpEmpty(); |
| 115 } else if (num_terms == 1) { | 115 } else if (num_terms == 1) { |
| 116 alternative = terms_.last(); | 116 alternative = terms_.last(); |
| 117 } else { | 117 } else { |
| 118 alternative = new(zone()) RegExpAlternative(terms_.GetList(zone())); | 118 alternative = new(zone()) RegExpAlternative(terms_.GetList(zone())); |
| 119 } | 119 } |
| 120 alternatives_.Add(alternative, zone()); | 120 alternatives_.Add(alternative, zone()); |
| 121 terms_.Clear(); | 121 terms_.Clear(); |
| 122 LAST(ADD_NONE); | 122 LAST(ADD_NONE); |
| 123 } | 123 } |
| 124 | 124 |
| 125 | 125 |
| 126 RegExpTree* RegExpBuilder::ToRegExp() { | 126 RegExpTree* RegExpBuilder::ToRegExp() { |
| 127 FlushTerms(); | 127 FlushTerms(); |
| 128 int num_alternatives = alternatives_.length(); | 128 int num_alternatives = alternatives_.length(); |
| 129 if (num_alternatives == 0) { | 129 if (num_alternatives == 0) return new (zone()) RegExpEmpty(); |
| 130 return RegExpEmpty::GetInstance(); | 130 if (num_alternatives == 1) return alternatives_.last(); |
| 131 } | |
| 132 if (num_alternatives == 1) { | |
| 133 return alternatives_.last(); | |
| 134 } | |
| 135 return new(zone()) RegExpDisjunction(alternatives_.GetList(zone())); | 131 return new(zone()) RegExpDisjunction(alternatives_.GetList(zone())); |
| 136 } | 132 } |
| 137 | 133 |
| 138 | 134 |
| 139 void RegExpBuilder::AddQuantifierToAtom( | 135 void RegExpBuilder::AddQuantifierToAtom( |
| 140 int min, int max, RegExpQuantifier::QuantifierType quantifier_type) { | 136 int min, int max, RegExpQuantifier::QuantifierType quantifier_type) { |
| 141 if (pending_empty_) { | 137 if (pending_empty_) { |
| 142 pending_empty_ = false; | 138 pending_empty_ = false; |
| 143 return; | 139 return; |
| 144 } | 140 } |
| (...skipping 4883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5028 | 5024 |
| 5029 // We cannot internalize on a background thread; a foreground task will take | 5025 // We cannot internalize on a background thread; a foreground task will take |
| 5030 // care of calling Parser::Internalize just before compilation. | 5026 // care of calling Parser::Internalize just before compilation. |
| 5031 | 5027 |
| 5032 if (compile_options() == ScriptCompiler::kProduceParserCache) { | 5028 if (compile_options() == ScriptCompiler::kProduceParserCache) { |
| 5033 if (result != NULL) *info_->cached_data() = recorder.GetScriptData(); | 5029 if (result != NULL) *info_->cached_data() = recorder.GetScriptData(); |
| 5034 log_ = NULL; | 5030 log_ = NULL; |
| 5035 } | 5031 } |
| 5036 } | 5032 } |
| 5037 } } // namespace v8::internal | 5033 } } // namespace v8::internal |
| OLD | NEW |