OLD | NEW |
---|---|
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
230 | 230 |
231 bool StringShape::IsSymbol() { | 231 bool StringShape::IsSymbol() { |
232 ASSERT(valid()); | 232 ASSERT(valid()); |
233 ASSERT(kSymbolTag != 0); | 233 ASSERT(kSymbolTag != 0); |
234 return (type_ & kIsSymbolMask) != 0; | 234 return (type_ & kIsSymbolMask) != 0; |
235 } | 235 } |
236 | 236 |
237 | 237 |
238 bool String::IsAsciiRepresentation() { | 238 bool String::IsAsciiRepresentation() { |
239 uint32_t type = map()->instance_type(); | 239 uint32_t type = map()->instance_type(); |
240 if ((type & kStringRepresentationMask) == kConsStringTag && | |
241 ConsString::cast(this)->second()->length() == 0) { | |
242 return ConsString::cast(this)->first()->IsAsciiRepresentation(); | |
243 } | |
244 return (type & kStringEncodingMask) == kAsciiStringTag; | 240 return (type & kStringEncodingMask) == kAsciiStringTag; |
245 } | 241 } |
246 | 242 |
247 | 243 |
248 bool String::IsTwoByteRepresentation() { | 244 bool String::IsTwoByteRepresentation() { |
249 uint32_t type = map()->instance_type(); | 245 uint32_t type = map()->instance_type(); |
250 if ((type & kStringRepresentationMask) == kConsStringTag && | |
251 ConsString::cast(this)->second()->length() == 0) { | |
252 return ConsString::cast(this)->first()->IsTwoByteRepresentation(); | |
253 } | |
254 return (type & kStringEncodingMask) == kTwoByteStringTag; | 246 return (type & kStringEncodingMask) == kTwoByteStringTag; |
255 } | 247 } |
256 | 248 |
257 | 249 |
258 bool String::IsExternalTwoByteStringWithAsciiChars() { | 250 bool String::HasAsciiChars() { |
Søren Thygesen Gjesse
2010/06/10 13:55:46
HasAsciiChars() -> HasOnlyAsciiChars()?
| |
259 if (!IsExternalTwoByteString()) return false; | 251 uint32_t type = map()->instance_type(); |
260 const uc16* data = ExternalTwoByteString::cast(this)->resource()->data(); | 252 return (type & kStringEncodingMask) == kAsciiStringTag || |
261 for (int i = 0, len = length(); i < len; i++) { | 253 (type & kAsciiDataHintMask) == kAsciiDataHintTag; |
262 if (data[i] > kMaxAsciiCharCode) return false; | |
263 } | |
264 return true; | |
265 } | 254 } |
266 | 255 |
267 | 256 |
268 bool StringShape::IsCons() { | 257 bool StringShape::IsCons() { |
269 return (type_ & kStringRepresentationMask) == kConsStringTag; | 258 return (type_ & kStringRepresentationMask) == kConsStringTag; |
270 } | 259 } |
271 | 260 |
272 | 261 |
273 bool StringShape::IsExternal() { | 262 bool StringShape::IsExternal() { |
274 return (type_ & kStringRepresentationMask) == kExternalStringTag; | 263 return (type_ & kStringRepresentationMask) == kExternalStringTag; |
(...skipping 2955 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3230 #undef WRITE_INT_FIELD | 3219 #undef WRITE_INT_FIELD |
3231 #undef READ_SHORT_FIELD | 3220 #undef READ_SHORT_FIELD |
3232 #undef WRITE_SHORT_FIELD | 3221 #undef WRITE_SHORT_FIELD |
3233 #undef READ_BYTE_FIELD | 3222 #undef READ_BYTE_FIELD |
3234 #undef WRITE_BYTE_FIELD | 3223 #undef WRITE_BYTE_FIELD |
3235 | 3224 |
3236 | 3225 |
3237 } } // namespace v8::internal | 3226 } } // namespace v8::internal |
3238 | 3227 |
3239 #endif // V8_OBJECTS_INL_H_ | 3228 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |