| 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 3946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3957 // function. | 3957 // function. |
| 3958 bool IsCallable(Function* function, Context* context) const; | 3958 bool IsCallable(Function* function, Context* context) const; |
| 3959 | 3959 |
| 3960 // Evaluate the given expression as if it appeared in an instance | 3960 // Evaluate the given expression as if it appeared in an instance |
| 3961 // method of this instance and return the resulting value, or an | 3961 // method of this instance and return the resulting value, or an |
| 3962 // error object if evaluating the expression fails. | 3962 // error object if evaluating the expression fails. |
| 3963 RawObject* Evaluate(const String& expr) const; | 3963 RawObject* Evaluate(const String& expr) const; |
| 3964 | 3964 |
| 3965 // Returns a string representation of this instance in a form | 3965 // Returns a string representation of this instance in a form |
| 3966 // that is suitable for an end user. | 3966 // that is suitable for an end user. |
| 3967 virtual const char* ToUserCString(intptr_t maxLen = 40) const; | 3967 // |
| 3968 // max_len is advisory, and the returned string may exceed this max |
| 3969 // length. |
| 3970 virtual const char* ToUserCString(intptr_t max_len = 40, |
| 3971 intptr_t nesting = 0) const; |
| 3968 | 3972 |
| 3969 static intptr_t InstanceSize() { | 3973 static intptr_t InstanceSize() { |
| 3970 return RoundedAllocationSize(sizeof(RawInstance)); | 3974 return RoundedAllocationSize(sizeof(RawInstance)); |
| 3971 } | 3975 } |
| 3972 | 3976 |
| 3973 static RawInstance* New(const Class& cls, Heap::Space space = Heap::kNew); | 3977 static RawInstance* New(const Class& cls, Heap::Space space = Heap::kNew); |
| 3974 | 3978 |
| 3975 private: | 3979 private: |
| 3976 RawObject** FieldAddrAtOffset(intptr_t offset) const { | 3980 RawObject** FieldAddrAtOffset(intptr_t offset) const { |
| 3977 ASSERT(IsValidFieldOffset(offset)); | 3981 ASSERT(IsValidFieldOffset(offset)); |
| (...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4892 // and morphs the string object into an external string object. | 4896 // and morphs the string object into an external string object. |
| 4893 // The remaining unused part of the original string object is marked as | 4897 // The remaining unused part of the original string object is marked as |
| 4894 // an Array object or a regular Object so that it can be traversed during | 4898 // an Array object or a regular Object so that it can be traversed during |
| 4895 // garbage collection. | 4899 // garbage collection. |
| 4896 RawString* MakeExternal(void* array, | 4900 RawString* MakeExternal(void* array, |
| 4897 intptr_t length, | 4901 intptr_t length, |
| 4898 void* peer, | 4902 void* peer, |
| 4899 Dart_PeerFinalizer cback) const; | 4903 Dart_PeerFinalizer cback) const; |
| 4900 | 4904 |
| 4901 // Produces a quoted, escaped, (possibly) truncated string. | 4905 // Produces a quoted, escaped, (possibly) truncated string. |
| 4902 const char* ToUserCString(intptr_t maxLen = 40) const; | 4906 const char* ToUserCString(intptr_t max_len = 40, |
| 4907 intptr_t nesting = 0) const; |
| 4903 | 4908 |
| 4904 // Creates a new String object from a C string that is assumed to contain | 4909 // Creates a new String object from a C string that is assumed to contain |
| 4905 // UTF-8 encoded characters and '\0' is considered a termination character. | 4910 // UTF-8 encoded characters and '\0' is considered a termination character. |
| 4906 // TODO(7123) - Rename this to FromCString(....). | 4911 // TODO(7123) - Rename this to FromCString(....). |
| 4907 static RawString* New(const char* cstr, Heap::Space space = Heap::kNew); | 4912 static RawString* New(const char* cstr, Heap::Space space = Heap::kNew); |
| 4908 | 4913 |
| 4909 // Creates a new String object from an array of UTF-8 encoded characters. | 4914 // Creates a new String object from an array of UTF-8 encoded characters. |
| 4910 static RawString* FromUTF8(const uint8_t* utf8_array, | 4915 static RawString* FromUTF8(const uint8_t* utf8_array, |
| 4911 intptr_t array_len, | 4916 intptr_t array_len, |
| 4912 Heap::Space space = Heap::kNew); | 4917 Heap::Space space = Heap::kNew); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5018 } | 5023 } |
| 5019 | 5024 |
| 5020 template<typename HandleType, typename ElementType, typename CallbackType> | 5025 template<typename HandleType, typename ElementType, typename CallbackType> |
| 5021 static void ReadFromImpl(SnapshotReader* reader, | 5026 static void ReadFromImpl(SnapshotReader* reader, |
| 5022 String* str_obj, | 5027 String* str_obj, |
| 5023 intptr_t len, | 5028 intptr_t len, |
| 5024 intptr_t tags, | 5029 intptr_t tags, |
| 5025 CallbackType new_symbol, | 5030 CallbackType new_symbol, |
| 5026 Snapshot::Kind kind); | 5031 Snapshot::Kind kind); |
| 5027 | 5032 |
| 5028 intptr_t EscapedString(char* buffer, int maxLen) const; | 5033 intptr_t EscapedString(char* buffer, int max_len) const; |
| 5029 intptr_t EscapedStringLen(intptr_t tooLong) const; | 5034 intptr_t EscapedStringLen(intptr_t tooLong) const; |
| 5030 | 5035 |
| 5031 FINAL_HEAP_OBJECT_IMPLEMENTATION(String, Instance); | 5036 FINAL_HEAP_OBJECT_IMPLEMENTATION(String, Instance); |
| 5032 | 5037 |
| 5033 friend class Class; | 5038 friend class Class; |
| 5034 friend class Symbols; | 5039 friend class Symbols; |
| 5035 friend class OneByteString; | 5040 friend class OneByteString; |
| 5036 friend class TwoByteString; | 5041 friend class TwoByteString; |
| 5037 friend class ExternalOneByteString; | 5042 friend class ExternalOneByteString; |
| 5038 friend class ExternalTwoByteString; | 5043 friend class ExternalTwoByteString; |
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5620 StorePointer(&raw_ptr()->type_arguments_, value.raw()); | 5625 StorePointer(&raw_ptr()->type_arguments_, value.raw()); |
| 5621 } | 5626 } |
| 5622 | 5627 |
| 5623 virtual bool Equals(const Instance& other) const; | 5628 virtual bool Equals(const Instance& other) const; |
| 5624 | 5629 |
| 5625 virtual RawInstance* CheckAndCanonicalize(const char** error_str) const { | 5630 virtual RawInstance* CheckAndCanonicalize(const char** error_str) const { |
| 5626 UNREACHABLE(); | 5631 UNREACHABLE(); |
| 5627 return Instance::null(); | 5632 return Instance::null(); |
| 5628 } | 5633 } |
| 5629 | 5634 |
| 5635 // Produces a readable representation of this array, e.g. '[1,2,3]', |
| 5636 // subject to length limits. |
| 5637 const char* ToUserCString(intptr_t max_len = 40, |
| 5638 intptr_t nesting = 0) const; |
| 5639 |
| 5630 static intptr_t type_arguments_offset() { | 5640 static intptr_t type_arguments_offset() { |
| 5631 return OFFSET_OF(RawGrowableObjectArray, type_arguments_); | 5641 return OFFSET_OF(RawGrowableObjectArray, type_arguments_); |
| 5632 } | 5642 } |
| 5633 | 5643 |
| 5634 static intptr_t length_offset() { | 5644 static intptr_t length_offset() { |
| 5635 return OFFSET_OF(RawGrowableObjectArray, length_); | 5645 return OFFSET_OF(RawGrowableObjectArray, length_); |
| 5636 } | 5646 } |
| 5637 static intptr_t data_offset() { | 5647 static intptr_t data_offset() { |
| 5638 return OFFSET_OF(RawGrowableObjectArray, data_); | 5648 return OFFSET_OF(RawGrowableObjectArray, data_); |
| 5639 } | 5649 } |
| (...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6447 | 6457 |
| 6448 | 6458 |
| 6449 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 6459 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
| 6450 intptr_t index) { | 6460 intptr_t index) { |
| 6451 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 6461 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
| 6452 } | 6462 } |
| 6453 | 6463 |
| 6454 } // namespace dart | 6464 } // namespace dart |
| 6455 | 6465 |
| 6456 #endif // VM_OBJECT_H_ | 6466 #endif // VM_OBJECT_H_ |
| OLD | NEW |