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

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

Issue 100833005: Add Instance::ToUserCString. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years 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.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 "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 3944 matching lines...) Expand 10 before | Expand all | Expand 10 after
3955 // class implementing a 'call' method, return true and set the function 3955 // class implementing a 'call' method, return true and set the function
3956 // (if not NULL) to call and the context (if not NULL) to pass to the 3956 // (if not NULL) to call and the context (if not NULL) to pass to the
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
3966 // that is suitable for an end user.
3967 virtual const char* ToUserCString(intptr_t maxLen = 40) const;
3968
3965 static intptr_t InstanceSize() { 3969 static intptr_t InstanceSize() {
3966 return RoundedAllocationSize(sizeof(RawInstance)); 3970 return RoundedAllocationSize(sizeof(RawInstance));
3967 } 3971 }
3968 3972
3969 static RawInstance* New(const Class& cls, Heap::Space space = Heap::kNew); 3973 static RawInstance* New(const Class& cls, Heap::Space space = Heap::kNew);
3970 3974
3971 private: 3975 private:
3972 RawObject** FieldAddrAtOffset(intptr_t offset) const { 3976 RawObject** FieldAddrAtOffset(intptr_t offset) const {
3973 ASSERT(IsValidFieldOffset(offset)); 3977 ASSERT(IsValidFieldOffset(offset));
3974 return reinterpret_cast<RawObject**>(raw_value() - kHeapObjectTag + offset); 3978 return reinterpret_cast<RawObject**>(raw_value() - kHeapObjectTag + offset);
(...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after
4887 // Copies the string characters into the provided external array 4891 // Copies the string characters into the provided external array
4888 // and morphs the string object into an external string object. 4892 // and morphs the string object into an external string object.
4889 // The remaining unused part of the original string object is marked as 4893 // The remaining unused part of the original string object is marked as
4890 // an Array object or a regular Object so that it can be traversed during 4894 // an Array object or a regular Object so that it can be traversed during
4891 // garbage collection. 4895 // garbage collection.
4892 RawString* MakeExternal(void* array, 4896 RawString* MakeExternal(void* array,
4893 intptr_t length, 4897 intptr_t length,
4894 void* peer, 4898 void* peer,
4895 Dart_PeerFinalizer cback) const; 4899 Dart_PeerFinalizer cback) const;
4896 4900
4901 // Produces a quoted, escaped, (possibly) truncated string.
4902 const char* ToUserCString(intptr_t maxLen = 40) const;
4903
4897 // Creates a new String object from a C string that is assumed to contain 4904 // Creates a new String object from a C string that is assumed to contain
4898 // UTF-8 encoded characters and '\0' is considered a termination character. 4905 // UTF-8 encoded characters and '\0' is considered a termination character.
4899 // TODO(7123) - Rename this to FromCString(....). 4906 // TODO(7123) - Rename this to FromCString(....).
4900 static RawString* New(const char* cstr, Heap::Space space = Heap::kNew); 4907 static RawString* New(const char* cstr, Heap::Space space = Heap::kNew);
4901 4908
4902 // Creates a new String object from an array of UTF-8 encoded characters. 4909 // Creates a new String object from an array of UTF-8 encoded characters.
4903 static RawString* FromUTF8(const uint8_t* utf8_array, 4910 static RawString* FromUTF8(const uint8_t* utf8_array,
4904 intptr_t array_len, 4911 intptr_t array_len,
4905 Heap::Space space = Heap::kNew); 4912 Heap::Space space = Heap::kNew);
4906 4913
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
5011 } 5018 }
5012 5019
5013 template<typename HandleType, typename ElementType, typename CallbackType> 5020 template<typename HandleType, typename ElementType, typename CallbackType>
5014 static void ReadFromImpl(SnapshotReader* reader, 5021 static void ReadFromImpl(SnapshotReader* reader,
5015 String* str_obj, 5022 String* str_obj,
5016 intptr_t len, 5023 intptr_t len,
5017 intptr_t tags, 5024 intptr_t tags,
5018 CallbackType new_symbol, 5025 CallbackType new_symbol,
5019 Snapshot::Kind kind); 5026 Snapshot::Kind kind);
5020 5027
5028 intptr_t EscapedString(char* buffer, int maxLen) const;
5029 intptr_t EscapedStringLen(intptr_t tooLong) const;
5030
5021 FINAL_HEAP_OBJECT_IMPLEMENTATION(String, Instance); 5031 FINAL_HEAP_OBJECT_IMPLEMENTATION(String, Instance);
5022 5032
5023 friend class Class; 5033 friend class Class;
5024 friend class Symbols; 5034 friend class Symbols;
5025 friend class OneByteString; 5035 friend class OneByteString;
5026 friend class TwoByteString; 5036 friend class TwoByteString;
5027 friend class ExternalOneByteString; 5037 friend class ExternalOneByteString;
5028 friend class ExternalTwoByteString; 5038 friend class ExternalTwoByteString;
5029 // So that the MarkingVisitor can print a debug string from a NoHandleScope. 5039 // So that the MarkingVisitor can print a debug string from a NoHandleScope.
5030 friend class MarkingVisitor; 5040 friend class MarkingVisitor;
(...skipping 1406 matching lines...) Expand 10 before | Expand all | Expand 10 after
6437 6447
6438 6448
6439 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 6449 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
6440 intptr_t index) { 6450 intptr_t index) {
6441 return array.At((index * kEntryLength) + kTargetFunctionIndex); 6451 return array.At((index * kEntryLength) + kTargetFunctionIndex);
6442 } 6452 }
6443 6453
6444 } // namespace dart 6454 } // namespace dart
6445 6455
6446 #endif // VM_OBJECT_H_ 6456 #endif // VM_OBJECT_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698