Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(232)

Side by Side Diff: runtime/vm/object.h

Issue 400493002: Hide dangerous interface String::Equals/Hash(uint8_t*,... (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/object_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <limits> 8 #include <limits>
9 #include "include/dart_api.h" 9 #include "include/dart_api.h"
10 #include "platform/assert.h" 10 #include "platform/assert.h"
(...skipping 5339 matching lines...) Expand 10 before | Expand all | Expand 10 after
5350 if (result != 0) { 5350 if (result != 0) {
5351 return result; 5351 return result;
5352 } 5352 }
5353 result = String::Hash(*this, 0, this->Length()); 5353 result = String::Hash(*this, 0, this->Length());
5354 this->SetHash(result); 5354 this->SetHash(result);
5355 return result; 5355 return result;
5356 } 5356 }
5357 5357
5358 static intptr_t hash_offset() { return OFFSET_OF(RawString, hash_); } 5358 static intptr_t hash_offset() { return OFFSET_OF(RawString, hash_); }
5359 static intptr_t Hash(const String& str, intptr_t begin_index, intptr_t len); 5359 static intptr_t Hash(const String& str, intptr_t begin_index, intptr_t len);
5360 static intptr_t Hash(const uint8_t* characters, intptr_t len); 5360 static intptr_t HashLatin1(const uint8_t* characters, intptr_t len);
5361 static intptr_t Hash(const uint16_t* characters, intptr_t len); 5361 static intptr_t Hash(const uint16_t* characters, intptr_t len);
5362 static intptr_t Hash(const int32_t* characters, intptr_t len); 5362 static intptr_t Hash(const int32_t* characters, intptr_t len);
5363 5363
5364 virtual RawObject* HashCode() const { return Integer::New(Hash()); } 5364 virtual RawObject* HashCode() const { return Integer::New(Hash()); }
5365 5365
5366 int32_t CharAt(intptr_t index) const; 5366 int32_t CharAt(intptr_t index) const;
5367 5367
5368 Scanner::CharAtFunc CharAtFunc() const; 5368 Scanner::CharAtFunc CharAtFunc() const;
5369 5369
5370 intptr_t CharSize() const; 5370 intptr_t CharSize() const;
5371 5371
5372 inline bool Equals(const String& str) const; 5372 inline bool Equals(const String& str) const;
5373 inline bool Equals(const String& str, 5373 inline bool Equals(const String& str,
5374 intptr_t begin_index, // begin index on 'str'. 5374 intptr_t begin_index, // begin index on 'str'.
5375 intptr_t len) const; // len on 'str'. 5375 intptr_t len) const; // len on 'str'.
5376 5376
5377 // Compares to a '\0' terminated array of UTF-8 encoded characters. 5377 // Compares to a '\0' terminated array of UTF-8 encoded characters.
5378 bool Equals(const char* cstr) const; 5378 bool Equals(const char* cstr) const;
5379 5379
5380 // Compares to an array of UTF-8 encoded characters. 5380 // Compares to an array of Latin-1 encoded characters.
5381 bool Equals(const uint8_t* characters, intptr_t len) const; 5381 bool EqualsLatin1(const uint8_t* characters, intptr_t len) const {
5382 return Equals(characters, len);
5383 }
5382 5384
5383 // Compares to an array of UTF-16 encoded characters. 5385 // Compares to an array of UTF-16 encoded characters.
5384 bool Equals(const uint16_t* characters, intptr_t len) const; 5386 bool Equals(const uint16_t* characters, intptr_t len) const;
5385 5387
5386 // Compares to an array of UTF-32 encoded characters. 5388 // Compares to an array of UTF-32 encoded characters.
5387 bool Equals(const int32_t* characters, intptr_t len) const; 5389 bool Equals(const int32_t* characters, intptr_t len) const;
5388 5390
5389 virtual bool OperatorEquals(const Instance& other) const { 5391 virtual bool OperatorEquals(const Instance& other) const {
5390 return Equals(other); 5392 return Equals(other);
5391 } 5393 }
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
5537 static RawString* NewFormatted(const char* format, ...) 5539 static RawString* NewFormatted(const char* format, ...)
5538 PRINTF_ATTRIBUTE(1, 2); 5540 PRINTF_ATTRIBUTE(1, 2);
5539 static RawString* NewFormattedV(const char* format, va_list args); 5541 static RawString* NewFormattedV(const char* format, va_list args);
5540 5542
5541 static bool ParseDouble(const String& str, 5543 static bool ParseDouble(const String& str,
5542 intptr_t start, 5544 intptr_t start,
5543 intptr_t end, 5545 intptr_t end,
5544 double* result); 5546 double* result);
5545 5547
5546 protected: 5548 protected:
5549 // These two operate on an array of Latin-1 encoded characters.
5550 // They are protected to avoid mistaking Latin-1 for UTF-8, but used
5551 // by friendly templated code (e.g., Symbols).
5552 bool Equals(const uint8_t* characters, intptr_t len) const;
5553 static intptr_t Hash(const uint8_t* characters, intptr_t len);
5554
5547 bool HasHash() const { 5555 bool HasHash() const {
5548 ASSERT(Smi::New(0) == NULL); 5556 ASSERT(Smi::New(0) == NULL);
5549 return (raw_ptr()->hash_ != NULL); 5557 return (raw_ptr()->hash_ != NULL);
5550 } 5558 }
5551 5559
5552 void SetLength(intptr_t value) const { 5560 void SetLength(intptr_t value) const {
5553 // This is only safe because we create a new Smi, which does not cause 5561 // This is only safe because we create a new Smi, which does not cause
5554 // heap allocation. 5562 // heap allocation.
5555 raw_ptr()->length_ = Smi::New(value); 5563 raw_ptr()->length_ = Smi::New(value);
5556 } 5564 }
(...skipping 1628 matching lines...) Expand 10 before | Expand all | Expand 10 after
7185 7193
7186 7194
7187 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 7195 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
7188 intptr_t index) { 7196 intptr_t index) {
7189 return array.At((index * kEntryLength) + kTargetFunctionIndex); 7197 return array.At((index * kEntryLength) + kTargetFunctionIndex);
7190 } 7198 }
7191 7199
7192 } // namespace dart 7200 } // namespace dart
7193 7201
7194 #endif // VM_OBJECT_H_ 7202 #endif // VM_OBJECT_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/object_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698