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 | 4 |
5 #ifndef VM_OBJECT_H_ | 5 #ifndef VM_OBJECT_H_ |
6 #define VM_OBJECT_H_ | 6 #define VM_OBJECT_H_ |
7 | 7 |
8 #include "include/dart_api.h" | 8 #include "include/dart_api.h" |
9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
10 #include "platform/utils.h" | 10 #include "platform/utils.h" |
(...skipping 5384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5395 static intptr_t HashLatin1(const uint8_t* characters, intptr_t len); | 5395 static intptr_t HashLatin1(const uint8_t* characters, intptr_t len); |
5396 static intptr_t Hash(const uint16_t* characters, intptr_t len); | 5396 static intptr_t Hash(const uint16_t* characters, intptr_t len); |
5397 static intptr_t Hash(const int32_t* characters, intptr_t len); | 5397 static intptr_t Hash(const int32_t* characters, intptr_t len); |
5398 static intptr_t HashRawSymbol(const RawString* symbol) { | 5398 static intptr_t HashRawSymbol(const RawString* symbol) { |
5399 ASSERT(symbol->IsCanonical()); | 5399 ASSERT(symbol->IsCanonical()); |
5400 intptr_t result = Smi::Value(symbol->ptr()->hash_); | 5400 intptr_t result = Smi::Value(symbol->ptr()->hash_); |
5401 ASSERT(result != 0); | 5401 ASSERT(result != 0); |
5402 return result; | 5402 return result; |
5403 } | 5403 } |
5404 | 5404 |
| 5405 // Returns the hash of str1 + str2. |
| 5406 static intptr_t HashConcat(const String& str1, const String& str2); |
| 5407 |
5405 virtual RawObject* HashCode() const { return Integer::New(Hash()); } | 5408 virtual RawObject* HashCode() const { return Integer::New(Hash()); } |
5406 | 5409 |
5407 int32_t CharAt(intptr_t index) const; | 5410 int32_t CharAt(intptr_t index) const; |
5408 | 5411 |
5409 Scanner::CharAtFunc CharAtFunc() const; | 5412 Scanner::CharAtFunc CharAtFunc() const; |
5410 | 5413 |
5411 intptr_t CharSize() const; | 5414 intptr_t CharSize() const; |
5412 | 5415 |
5413 inline bool Equals(const String& str) const; | 5416 inline bool Equals(const String& str) const; |
5414 inline bool Equals(const String& str, | 5417 inline bool Equals(const String& str, |
5415 intptr_t begin_index, // begin index on 'str'. | 5418 intptr_t begin_index, // begin index on 'str'. |
5416 intptr_t len) const; // len on 'str'. | 5419 intptr_t len) const; // len on 'str'. |
5417 | 5420 |
5418 // Compares to a '\0' terminated array of UTF-8 encoded characters. | 5421 // Compares to a '\0' terminated array of UTF-8 encoded characters. |
5419 bool Equals(const char* cstr) const; | 5422 bool Equals(const char* cstr) const; |
5420 | 5423 |
5421 // Compares to an array of Latin-1 encoded characters. | 5424 // Compares to an array of Latin-1 encoded characters. |
5422 bool EqualsLatin1(const uint8_t* characters, intptr_t len) const { | 5425 bool EqualsLatin1(const uint8_t* characters, intptr_t len) const { |
5423 return Equals(characters, len); | 5426 return Equals(characters, len); |
5424 } | 5427 } |
5425 | 5428 |
5426 // Compares to an array of UTF-16 encoded characters. | 5429 // Compares to an array of UTF-16 encoded characters. |
5427 bool Equals(const uint16_t* characters, intptr_t len) const; | 5430 bool Equals(const uint16_t* characters, intptr_t len) const; |
5428 | 5431 |
5429 // Compares to an array of UTF-32 encoded characters. | 5432 // Compares to an array of UTF-32 encoded characters. |
5430 bool Equals(const int32_t* characters, intptr_t len) const; | 5433 bool Equals(const int32_t* characters, intptr_t len) const; |
5431 | 5434 |
| 5435 // True iff this string equals str1 + str2. |
| 5436 bool EqualsConcat(const String& str1, const String& str2) const; |
| 5437 |
5432 virtual bool OperatorEquals(const Instance& other) const { | 5438 virtual bool OperatorEquals(const Instance& other) const { |
5433 return Equals(other); | 5439 return Equals(other); |
5434 } | 5440 } |
5435 virtual bool CanonicalizeEquals(const Instance& other) const { | 5441 virtual bool CanonicalizeEquals(const Instance& other) const { |
5436 return Equals(other); | 5442 return Equals(other); |
5437 } | 5443 } |
5438 virtual bool Equals(const Instance& other) const; | 5444 virtual bool Equals(const Instance& other) const; |
5439 | 5445 |
5440 intptr_t CompareTo(const String& other) const; | 5446 intptr_t CompareTo(const String& other) const; |
5441 | 5447 |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5620 | 5626 |
5621 intptr_t EscapedString(char* buffer, int max_len) const; | 5627 intptr_t EscapedString(char* buffer, int max_len) const; |
5622 intptr_t EscapedStringLen(intptr_t tooLong) const; | 5628 intptr_t EscapedStringLen(intptr_t tooLong) const; |
5623 | 5629 |
5624 FINAL_HEAP_OBJECT_IMPLEMENTATION(String, Instance); | 5630 FINAL_HEAP_OBJECT_IMPLEMENTATION(String, Instance); |
5625 | 5631 |
5626 friend class Class; | 5632 friend class Class; |
5627 friend class Symbols; | 5633 friend class Symbols; |
5628 friend class StringSlice; // SetHash | 5634 friend class StringSlice; // SetHash |
5629 template<typename CharType> friend class CharArray; // SetHash | 5635 template<typename CharType> friend class CharArray; // SetHash |
| 5636 friend class ConcatString; // SetHash |
5630 friend class OneByteString; | 5637 friend class OneByteString; |
5631 friend class TwoByteString; | 5638 friend class TwoByteString; |
5632 friend class ExternalOneByteString; | 5639 friend class ExternalOneByteString; |
5633 friend class ExternalTwoByteString; | 5640 friend class ExternalTwoByteString; |
5634 // So that the MarkingVisitor can print a debug string from a NoHandleScope. | 5641 // So that the MarkingVisitor can print a debug string from a NoHandleScope. |
5635 friend class MarkingVisitor; | 5642 friend class MarkingVisitor; |
5636 }; | 5643 }; |
5637 | 5644 |
5638 | 5645 |
5639 class OneByteString : public AllStatic { | 5646 class OneByteString : public AllStatic { |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5754 | 5761 |
5755 static RawOneByteString* ReadFrom(SnapshotReader* reader, | 5762 static RawOneByteString* ReadFrom(SnapshotReader* reader, |
5756 intptr_t object_id, | 5763 intptr_t object_id, |
5757 intptr_t tags, | 5764 intptr_t tags, |
5758 Snapshot::Kind kind); | 5765 Snapshot::Kind kind); |
5759 | 5766 |
5760 friend class Class; | 5767 friend class Class; |
5761 friend class String; | 5768 friend class String; |
5762 friend class ExternalOneByteString; | 5769 friend class ExternalOneByteString; |
5763 friend class SnapshotReader; | 5770 friend class SnapshotReader; |
| 5771 friend class StringHasher; |
5764 }; | 5772 }; |
5765 | 5773 |
5766 | 5774 |
5767 class TwoByteString : public AllStatic { | 5775 class TwoByteString : public AllStatic { |
5768 public: | 5776 public: |
5769 static int32_t CharAt(const String& str, intptr_t index) { | 5777 static int32_t CharAt(const String& str, intptr_t index) { |
5770 return *CharAddr(str, index); | 5778 return *CharAddr(str, index); |
5771 } | 5779 } |
5772 | 5780 |
5773 static void SetCharAt(const String& str, intptr_t index, uint16_t ch) { | 5781 static void SetCharAt(const String& str, intptr_t index, uint16_t ch) { |
(...skipping 1531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7305 | 7313 |
7306 | 7314 |
7307 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 7315 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
7308 intptr_t index) { | 7316 intptr_t index) { |
7309 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 7317 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
7310 } | 7318 } |
7311 | 7319 |
7312 } // namespace dart | 7320 } // namespace dart |
7313 | 7321 |
7314 #endif // VM_OBJECT_H_ | 7322 #endif // VM_OBJECT_H_ |
OLD | NEW |