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 <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 4230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4241 | 4241 |
4242 // Evaluate the given expression as if it appeared in an instance | 4242 // Evaluate the given expression as if it appeared in an instance |
4243 // method of this instance and return the resulting value, or an | 4243 // method of this instance and return the resulting value, or an |
4244 // error object if evaluating the expression fails. The method has | 4244 // error object if evaluating the expression fails. The method has |
4245 // the formal parameters given in param_names, and is invoked with | 4245 // the formal parameters given in param_names, and is invoked with |
4246 // the argument values given in param_values. | 4246 // the argument values given in param_values. |
4247 RawObject* Evaluate(const String& expr, | 4247 RawObject* Evaluate(const String& expr, |
4248 const Array& param_names, | 4248 const Array& param_names, |
4249 const Array& param_values) const; | 4249 const Array& param_values) const; |
4250 | 4250 |
| 4251 // Equivalent to invoking hashCode on this instance. |
| 4252 virtual RawObject* HashCode() const; |
| 4253 |
4251 static intptr_t InstanceSize() { | 4254 static intptr_t InstanceSize() { |
4252 return RoundedAllocationSize(sizeof(RawInstance)); | 4255 return RoundedAllocationSize(sizeof(RawInstance)); |
4253 } | 4256 } |
4254 | 4257 |
4255 static RawInstance* New(const Class& cls, Heap::Space space = Heap::kNew); | 4258 static RawInstance* New(const Class& cls, Heap::Space space = Heap::kNew); |
4256 | 4259 |
4257 // Array/list element address computations. | 4260 // Array/list element address computations. |
4258 static intptr_t DataOffsetFor(intptr_t cid); | 4261 static intptr_t DataOffsetFor(intptr_t cid); |
4259 static intptr_t ElementSizeFor(intptr_t cid); | 4262 static intptr_t ElementSizeFor(intptr_t cid); |
4260 | 4263 |
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4939 return Equals(other); | 4942 return Equals(other); |
4940 } | 4943 } |
4941 virtual bool CanonicalizeEquals(const Instance& other) const { | 4944 virtual bool CanonicalizeEquals(const Instance& other) const { |
4942 return Equals(other); | 4945 return Equals(other); |
4943 } | 4946 } |
4944 virtual bool Equals(const Instance& other) const { | 4947 virtual bool Equals(const Instance& other) const { |
4945 UNREACHABLE(); | 4948 UNREACHABLE(); |
4946 return false; | 4949 return false; |
4947 } | 4950 } |
4948 | 4951 |
| 4952 virtual RawObject* HashCode() const { return raw(); } |
| 4953 |
4949 // Integer is an abstract class. | 4954 // Integer is an abstract class. |
4950 virtual bool IsZero() const { | 4955 virtual bool IsZero() const { |
4951 UNREACHABLE(); | 4956 UNREACHABLE(); |
4952 return false; | 4957 return false; |
4953 } | 4958 } |
4954 virtual bool IsNegative() const { | 4959 virtual bool IsNegative() const { |
4955 // Number is an abstract class. | 4960 // Number is an abstract class. |
4956 UNREACHABLE(); | 4961 UNREACHABLE(); |
4957 return false; | 4962 return false; |
4958 } | 4963 } |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5310 this->SetHash(result); | 5315 this->SetHash(result); |
5311 return result; | 5316 return result; |
5312 } | 5317 } |
5313 | 5318 |
5314 static intptr_t hash_offset() { return OFFSET_OF(RawString, hash_); } | 5319 static intptr_t hash_offset() { return OFFSET_OF(RawString, hash_); } |
5315 static intptr_t Hash(const String& str, intptr_t begin_index, intptr_t len); | 5320 static intptr_t Hash(const String& str, intptr_t begin_index, intptr_t len); |
5316 static intptr_t Hash(const uint8_t* characters, intptr_t len); | 5321 static intptr_t Hash(const uint8_t* characters, intptr_t len); |
5317 static intptr_t Hash(const uint16_t* characters, intptr_t len); | 5322 static intptr_t Hash(const uint16_t* characters, intptr_t len); |
5318 static intptr_t Hash(const int32_t* characters, intptr_t len); | 5323 static intptr_t Hash(const int32_t* characters, intptr_t len); |
5319 | 5324 |
| 5325 virtual RawObject* HashCode() const { return Integer::New(Hash()); } |
| 5326 |
5320 int32_t CharAt(intptr_t index) const; | 5327 int32_t CharAt(intptr_t index) const; |
5321 | 5328 |
5322 Scanner::CharAtFunc CharAtFunc() const; | 5329 Scanner::CharAtFunc CharAtFunc() const; |
5323 | 5330 |
5324 intptr_t CharSize() const; | 5331 intptr_t CharSize() const; |
5325 | 5332 |
5326 inline bool Equals(const String& str) const; | 5333 inline bool Equals(const String& str) const; |
5327 inline bool Equals(const String& str, | 5334 inline bool Equals(const String& str, |
5328 intptr_t begin_index, // begin index on 'str'. | 5335 intptr_t begin_index, // begin index on 'str'. |
5329 intptr_t len) const; // len on 'str'. | 5336 intptr_t len) const; // len on 'str'. |
(...skipping 1802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7132 | 7139 |
7133 | 7140 |
7134 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 7141 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
7135 intptr_t index) { | 7142 intptr_t index) { |
7136 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 7143 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
7137 } | 7144 } |
7138 | 7145 |
7139 } // namespace dart | 7146 } // namespace dart |
7140 | 7147 |
7141 #endif // VM_OBJECT_H_ | 7148 #endif // VM_OBJECT_H_ |
OLD | NEW |