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" |
11 #include "vm/exceptions.h" | 11 #include "vm/exceptions.h" |
12 #include "vm/globals.h" | 12 #include "vm/globals.h" |
13 #include "vm/isolate.h" | 13 #include "vm/isolate.h" |
14 #include "third_party/jscre/pcre.h" | 14 #include "third_party/jscre/pcre.h" |
15 | 15 |
16 namespace dart { | 16 namespace dart { |
17 | 17 |
18 static uint16_t* GetTwoByteData(const String& str) { | 18 static uint16_t* GetTwoByteData(const String& str) { |
19 Zone* zone = Isolate::Current()->current_zone(); | 19 Zone* zone = Isolate::Current()->current_zone(); |
20 uint16_t* two_byte_str = zone->Alloc<uint16_t>(str.Length()); | 20 uint16_t* two_byte_str = zone->Alloc<uint16_t>(str.Length()); |
21 for (intptr_t i = 0; i < str.Length(); i++) { | 21 for (intptr_t i = 0; i < str.Length(); i++) { |
22 two_byte_str[i] = str.CharAt(i); | 22 two_byte_str[i] = str.CodeUnitAt(i); |
cshapiro
2012/11/15 20:14:51
Please do not change the name of this method on th
erikcorry
2012/11/15 23:47:05
The strings are now made up of UTF16 code units, n
| |
23 } | 23 } |
24 return two_byte_str; | 24 return two_byte_str; |
25 } | 25 } |
26 | 26 |
27 | 27 |
28 static void* JSREMalloc(size_t size) { | 28 static void* JSREMalloc(size_t size) { |
29 intptr_t regexp_size = static_cast<intptr_t>(size); | 29 intptr_t regexp_size = static_cast<intptr_t>(size); |
30 ASSERT(regexp_size > 0); | 30 ASSERT(regexp_size > 0); |
31 const JSRegExp& new_regex = JSRegExp::Handle(JSRegExp::New(size)); | 31 const JSRegExp& new_regex = JSRegExp::Handle(JSRegExp::New(size)); |
32 return new_regex.GetDataStartAddress(); | 32 return new_regex.GetDataStartAddress(); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
163 i += kMatchPair) { | 163 i += kMatchPair) { |
164 start = Smi::New(offsets[i]); | 164 start = Smi::New(offsets[i]); |
165 end = Smi::New(offsets[i + 1]); | 165 end = Smi::New(offsets[i + 1]); |
166 array.SetAt(i, start); | 166 array.SetAt(i, start); |
167 array.SetAt(i+1, end); | 167 array.SetAt(i+1, end); |
168 } | 168 } |
169 return array.raw(); | 169 return array.raw(); |
170 } | 170 } |
171 | 171 |
172 } // namespace dart | 172 } // namespace dart |
OLD | NEW |