OLD | NEW |
1 // Copyright 2007-2010 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2010 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 11 matching lines...) Expand all Loading... |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #ifndef V8_UNICODE_INL_H_ | 28 #ifndef V8_UNICODE_INL_H_ |
29 #define V8_UNICODE_INL_H_ | 29 #define V8_UNICODE_INL_H_ |
30 | 30 |
31 #include "unicode.h" | 31 #include "unicode.h" |
| 32 #include "checks.h" |
32 | 33 |
33 namespace unibrow { | 34 namespace unibrow { |
34 | 35 |
35 template <class T, int s> bool Predicate<T, s>::get(uchar code_point) { | 36 template <class T, int s> bool Predicate<T, s>::get(uchar code_point) { |
36 CacheEntry entry = entries_[code_point & kMask]; | 37 CacheEntry entry = entries_[code_point & kMask]; |
37 if (entry.code_point_ == code_point) return entry.value_; | 38 if (entry.code_point_ == code_point) return entry.value_; |
38 return CalculateValue(code_point); | 39 return CalculateValue(code_point); |
39 } | 40 } |
40 | 41 |
41 template <class T, int s> bool Predicate<T, s>::CalculateValue( | 42 template <class T, int s> bool Predicate<T, s>::CalculateValue( |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 } | 138 } |
138 | 139 |
139 uchar CharacterStream::GetNext() { | 140 uchar CharacterStream::GetNext() { |
140 uchar result = DecodeCharacter(buffer_, &cursor_); | 141 uchar result = DecodeCharacter(buffer_, &cursor_); |
141 if (remaining_ == 1) { | 142 if (remaining_ == 1) { |
142 cursor_ = 0; | 143 cursor_ = 0; |
143 FillBuffer(); | 144 FillBuffer(); |
144 } else { | 145 } else { |
145 remaining_--; | 146 remaining_--; |
146 } | 147 } |
| 148 ASSERT(BoundsCheck(cursor_)); |
147 return result; | 149 return result; |
148 } | 150 } |
149 | 151 |
150 #if __BYTE_ORDER == __LITTLE_ENDIAN | 152 #if __BYTE_ORDER == __LITTLE_ENDIAN |
151 #define IF_LITTLE(expr) expr | 153 #define IF_LITTLE(expr) expr |
152 #define IF_BIG(expr) ((void) 0) | 154 #define IF_BIG(expr) ((void) 0) |
153 #elif __BYTE_ORDER == __BIG_ENDIAN | 155 #elif __BYTE_ORDER == __BIG_ENDIAN |
154 #define IF_LITTLE(expr) ((void) 0) | 156 #define IF_LITTLE(expr) ((void) 0) |
155 #define IF_BIG(expr) expr | 157 #define IF_BIG(expr) expr |
156 #else | 158 #else |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 | 242 |
241 template <unsigned s> | 243 template <unsigned s> |
242 Utf8InputBuffer<s>::Utf8InputBuffer(const char* data, unsigned length) | 244 Utf8InputBuffer<s>::Utf8InputBuffer(const char* data, unsigned length) |
243 : InputBuffer<Utf8, Buffer<const char*>, s>(Buffer<const char*>(data, | 245 : InputBuffer<Utf8, Buffer<const char*>, s>(Buffer<const char*>(data, |
244 length)) { | 246 length)) { |
245 } | 247 } |
246 | 248 |
247 } // namespace unibrow | 249 } // namespace unibrow |
248 | 250 |
249 #endif // V8_UNICODE_INL_H_ | 251 #endif // V8_UNICODE_INL_H_ |
OLD | NEW |