OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 return isolate->factory()->NewOneByteInternalizedString( | 75 return isolate->factory()->NewOneByteInternalizedString( |
76 string_->literal_bytes_, string_->hash()); | 76 string_->literal_bytes_, string_->hash()); |
77 return isolate->factory()->NewTwoByteInternalizedString( | 77 return isolate->factory()->NewTwoByteInternalizedString( |
78 Vector<const uint16_t>::cast(string_->literal_bytes_), string_->hash()); | 78 Vector<const uint16_t>::cast(string_->literal_bytes_), string_->hash()); |
79 } | 79 } |
80 | 80 |
81 private: | 81 private: |
82 const AstRawString* string_; | 82 const AstRawString* string_; |
83 }; | 83 }; |
84 | 84 |
| 85 int AstString::length() const { |
| 86 if (is_raw_) { |
| 87 return reinterpret_cast<const AstRawString*>(this)->length(); |
| 88 } |
| 89 return reinterpret_cast<const AstConsString*>(this)->length(); |
| 90 } |
| 91 |
| 92 void AstString::Internalize(Isolate* isolate) { |
| 93 if (is_raw_) { |
| 94 return reinterpret_cast<AstRawString*>(this)->Internalize(isolate); |
| 95 } |
| 96 return reinterpret_cast<AstConsString*>(this)->Internalize(isolate); |
| 97 } |
85 | 98 |
86 void AstRawString::Internalize(Isolate* isolate) { | 99 void AstRawString::Internalize(Isolate* isolate) { |
87 if (!string_.is_null()) return; | 100 if (!string_.is_null()) return; |
88 if (literal_bytes_.length() == 0) { | 101 if (literal_bytes_.length() == 0) { |
89 string_ = isolate->factory()->empty_string(); | 102 string_ = isolate->factory()->empty_string(); |
90 } else { | 103 } else { |
91 AstRawStringInternalizationKey key(this); | 104 AstRawStringInternalizationKey key(this); |
92 string_ = StringTable::LookupKey(isolate, &key); | 105 string_ = StringTable::LookupKey(isolate, &key); |
93 } | 106 } |
94 } | 107 } |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 length) == 0; | 419 length) == 0; |
407 } else { | 420 } else { |
408 return CompareCharsUnsigned(reinterpret_cast<const uint16_t*>(l), | 421 return CompareCharsUnsigned(reinterpret_cast<const uint16_t*>(l), |
409 reinterpret_cast<const uint16_t*>(r), | 422 reinterpret_cast<const uint16_t*>(r), |
410 length) == 0; | 423 length) == 0; |
411 } | 424 } |
412 } | 425 } |
413 } | 426 } |
414 } // namespace internal | 427 } // namespace internal |
415 } // namespace v8 | 428 } // namespace v8 |
OLD | NEW |