OLD | NEW |
---|---|
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 // This file encapsulates all the interaction with the | 4 // This file encapsulates all the interaction with the |
5 // JSC regular expression library also referred to as pcre | 5 // JSC regular expression library also referred to as pcre |
6 | 6 |
7 #include "lib/regexp_jsc.h" | 7 #include "lib/regexp_jsc.h" |
8 | 8 |
9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
10 #include "vm/allocation.h" | 10 #include "vm/allocation.h" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
147 const String& pattern = String::Handle(regex.pattern()); | 147 const String& pattern = String::Handle(regex.pattern()); |
148 const int kErrorLength = 256; | 148 const int kErrorLength = 256; |
149 char error_msg[kErrorLength]; | 149 char error_msg[kErrorLength]; |
150 OS::SNPrint(error_msg, kErrorLength, | 150 OS::SNPrint(error_msg, kErrorLength, |
151 "jscre::jsRegExpExecute error : %d", retval); | 151 "jscre::jsRegExpExecute error : %d", retval); |
152 ThrowExceptionOnError(pattern, error_msg); | 152 ThrowExceptionOnError(pattern, error_msg); |
153 UNREACHABLE(); | 153 UNREACHABLE(); |
154 return Array::null(); | 154 return Array::null(); |
155 } | 155 } |
156 | 156 |
157 const int kMatchPair = 2; | 157 const int kMatchPair = 2; |
siva
2012/03/19 18:29:14
ASSERT(retval <= (num_bracket_expressions + 1));
| |
158 Array& array = | 158 Array& array = |
159 Array::Handle(Array::New(kMatchPair * (num_bracket_expressions + 1))); | 159 Array::Handle(Array::New(kMatchPair * retval)); |
160 // The matches come in (start, end + 1) pairs for each bracketted expression. | 160 // The matches come in (start, end + 1) pairs for each bracketted expression. |
161 Smi& start = Smi::Handle(); | 161 Smi& start = Smi::Handle(); |
162 Smi& end = Smi::Handle(); | 162 Smi& end = Smi::Handle(); |
163 for (intptr_t i = 0; | 163 for (intptr_t i = 0; i < (kMatchPair * retval); i += kMatchPair) { |
164 i < (kMatchPair * (num_bracket_expressions + 1)); | |
165 i += kMatchPair) { | |
166 start = Smi::New(offsets[i]); | 164 start = Smi::New(offsets[i]); |
167 end = Smi::New(offsets[i + 1]); | 165 end = Smi::New(offsets[i + 1]); |
168 array.SetAt(i, start); | 166 array.SetAt(i, start); |
169 array.SetAt(i+1, end); | 167 array.SetAt(i+1, end); |
170 } | 168 } |
171 return array.raw(); | 169 return array.raw(); |
172 } | 170 } |
173 | 171 |
174 } // namespace dart | 172 } // namespace dart |
OLD | NEW |