| 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 4024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4035 // class implementing a 'call' method, return true and set the function | 4035 // class implementing a 'call' method, return true and set the function |
| 4036 // (if not NULL) to call and the context (if not NULL) to pass to the | 4036 // (if not NULL) to call and the context (if not NULL) to pass to the |
| 4037 // function. | 4037 // function. |
| 4038 bool IsCallable(Function* function, Context* context) const; | 4038 bool IsCallable(Function* function, Context* context) const; |
| 4039 | 4039 |
| 4040 // Evaluate the given expression as if it appeared in an instance | 4040 // Evaluate the given expression as if it appeared in an instance |
| 4041 // method of this instance and return the resulting value, or an | 4041 // method of this instance and return the resulting value, or an |
| 4042 // error object if evaluating the expression fails. | 4042 // error object if evaluating the expression fails. |
| 4043 RawObject* Evaluate(const String& expr) const; | 4043 RawObject* Evaluate(const String& expr) const; |
| 4044 | 4044 |
| 4045 // Returns a string representation of this instance in a form | |
| 4046 // that is suitable for an end user. | |
| 4047 // | |
| 4048 // max_len is advisory, and the returned string may exceed this max | |
| 4049 // length. | |
| 4050 virtual const char* ToUserCString(intptr_t max_len = 40, | |
| 4051 intptr_t nesting = 0) const; | |
| 4052 | |
| 4053 static intptr_t InstanceSize() { | 4045 static intptr_t InstanceSize() { |
| 4054 return RoundedAllocationSize(sizeof(RawInstance)); | 4046 return RoundedAllocationSize(sizeof(RawInstance)); |
| 4055 } | 4047 } |
| 4056 | 4048 |
| 4057 static RawInstance* New(const Class& cls, Heap::Space space = Heap::kNew); | 4049 static RawInstance* New(const Class& cls, Heap::Space space = Heap::kNew); |
| 4058 | 4050 |
| 4059 protected: | 4051 protected: |
| 4060 virtual void PrintSharedInstanceJSON(JSONObject* jsobj, bool ref) const; | 4052 virtual void PrintSharedInstanceJSON(JSONObject* jsobj, bool ref) const; |
| 4061 | 4053 |
| 4062 private: | 4054 private: |
| (...skipping 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5132 } | 5124 } |
| 5133 | 5125 |
| 5134 bool IsExternal() const { | 5126 bool IsExternal() const { |
| 5135 return RawObject::IsExternalStringClassId(raw()->GetClassId()); | 5127 return RawObject::IsExternalStringClassId(raw()->GetClassId()); |
| 5136 } | 5128 } |
| 5137 | 5129 |
| 5138 void* GetPeer() const; | 5130 void* GetPeer() const; |
| 5139 | 5131 |
| 5140 void ToUTF8(uint8_t* utf8_array, intptr_t array_len) const; | 5132 void ToUTF8(uint8_t* utf8_array, intptr_t array_len) const; |
| 5141 | 5133 |
| 5134 // Produces a quoted, escaped, (possibly) truncated string. |
| 5135 const char* ToUserCString(intptr_t max_len) const; |
| 5136 |
| 5142 // Copies the string characters into the provided external array | 5137 // Copies the string characters into the provided external array |
| 5143 // and morphs the string object into an external string object. | 5138 // and morphs the string object into an external string object. |
| 5144 // The remaining unused part of the original string object is marked as | 5139 // The remaining unused part of the original string object is marked as |
| 5145 // an Array object or a regular Object so that it can be traversed during | 5140 // an Array object or a regular Object so that it can be traversed during |
| 5146 // garbage collection. | 5141 // garbage collection. |
| 5147 RawString* MakeExternal(void* array, | 5142 RawString* MakeExternal(void* array, |
| 5148 intptr_t length, | 5143 intptr_t length, |
| 5149 void* peer, | 5144 void* peer, |
| 5150 Dart_PeerFinalizer cback) const; | 5145 Dart_PeerFinalizer cback) const; |
| 5151 | 5146 |
| 5152 // Produces a quoted, escaped, (possibly) truncated string. | |
| 5153 const char* ToUserCString(intptr_t max_len = 40, | |
| 5154 intptr_t nesting = 0) const; | |
| 5155 | |
| 5156 // Creates a new String object from a C string that is assumed to contain | 5147 // Creates a new String object from a C string that is assumed to contain |
| 5157 // UTF-8 encoded characters and '\0' is considered a termination character. | 5148 // UTF-8 encoded characters and '\0' is considered a termination character. |
| 5158 // TODO(7123) - Rename this to FromCString(....). | 5149 // TODO(7123) - Rename this to FromCString(....). |
| 5159 static RawString* New(const char* cstr, Heap::Space space = Heap::kNew); | 5150 static RawString* New(const char* cstr, Heap::Space space = Heap::kNew); |
| 5160 | 5151 |
| 5161 // Creates a new String object from an array of UTF-8 encoded characters. | 5152 // Creates a new String object from an array of UTF-8 encoded characters. |
| 5162 static RawString* FromUTF8(const uint8_t* utf8_array, | 5153 static RawString* FromUTF8(const uint8_t* utf8_array, |
| 5163 intptr_t array_len, | 5154 intptr_t array_len, |
| 5164 Heap::Space space = Heap::kNew); | 5155 Heap::Space space = Heap::kNew); |
| 5165 | 5156 |
| (...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5892 StorePointer(&raw_ptr()->type_arguments_, value.raw()); | 5883 StorePointer(&raw_ptr()->type_arguments_, value.raw()); |
| 5893 } | 5884 } |
| 5894 | 5885 |
| 5895 virtual bool Equals(const Instance& other) const; | 5886 virtual bool Equals(const Instance& other) const; |
| 5896 | 5887 |
| 5897 virtual RawInstance* CheckAndCanonicalize(const char** error_str) const { | 5888 virtual RawInstance* CheckAndCanonicalize(const char** error_str) const { |
| 5898 UNREACHABLE(); | 5889 UNREACHABLE(); |
| 5899 return Instance::null(); | 5890 return Instance::null(); |
| 5900 } | 5891 } |
| 5901 | 5892 |
| 5902 // Produces a readable representation of this array, e.g. '[1,2,3]', | |
| 5903 // subject to length limits. | |
| 5904 const char* ToUserCString(intptr_t max_len = 40, | |
| 5905 intptr_t nesting = 0) const; | |
| 5906 | |
| 5907 static intptr_t type_arguments_offset() { | 5893 static intptr_t type_arguments_offset() { |
| 5908 return OFFSET_OF(RawGrowableObjectArray, type_arguments_); | 5894 return OFFSET_OF(RawGrowableObjectArray, type_arguments_); |
| 5909 } | 5895 } |
| 5910 | 5896 |
| 5911 static intptr_t length_offset() { | 5897 static intptr_t length_offset() { |
| 5912 return OFFSET_OF(RawGrowableObjectArray, length_); | 5898 return OFFSET_OF(RawGrowableObjectArray, length_); |
| 5913 } | 5899 } |
| 5914 static intptr_t data_offset() { | 5900 static intptr_t data_offset() { |
| 5915 return OFFSET_OF(RawGrowableObjectArray, data_); | 5901 return OFFSET_OF(RawGrowableObjectArray, data_); |
| 5916 } | 5902 } |
| (...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6797 | 6783 |
| 6798 | 6784 |
| 6799 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 6785 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
| 6800 intptr_t index) { | 6786 intptr_t index) { |
| 6801 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 6787 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
| 6802 } | 6788 } |
| 6803 | 6789 |
| 6804 } // namespace dart | 6790 } // namespace dart |
| 6805 | 6791 |
| 6806 #endif // VM_OBJECT_H_ | 6792 #endif // VM_OBJECT_H_ |
| OLD | NEW |