| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 char* grow(unsigned* bytes); | 66 char* grow(unsigned* bytes); |
| 67 private: | 67 private: |
| 68 unsigned size_; | 68 unsigned size_; |
| 69 char* space_; | 69 char* space_; |
| 70 }; | 70 }; |
| 71 | 71 |
| 72 | 72 |
| 73 class FmtElm { | 73 class FmtElm { |
| 74 public: | 74 public: |
| 75 FmtElm(int value) : type_(INT) { data_.u_int_ = value; } // NOLINT | 75 FmtElm(int value) : type_(INT) { data_.u_int_ = value; } // NOLINT |
| 76 explicit FmtElm(double value) : type_(DOUBLE) { data_.u_double_ = value; } //
NOLINT |
| 76 FmtElm(const char* value) : type_(C_STR) { data_.u_c_str_ = value; } // NOLIN
T | 77 FmtElm(const char* value) : type_(C_STR) { data_.u_c_str_ = value; } // NOLIN
T |
| 77 FmtElm(Object* value) : type_(OBJ) { data_.u_obj_ = value; } // NOLINT | 78 FmtElm(Object* value) : type_(OBJ) { data_.u_obj_ = value; } // NOLINT |
| 78 FmtElm(Handle<Object> value) : type_(HANDLE) { data_.u_handle_ = value.locatio
n(); } // NOLINT | 79 FmtElm(Handle<Object> value) : type_(HANDLE) { data_.u_handle_ = value.locatio
n(); } // NOLINT |
| 79 FmtElm(void* value) : type_(INT) { data_.u_int_ = reinterpret_cast<int>(value)
; } // NOLINT | 80 FmtElm(void* value) : type_(INT) { data_.u_int_ = reinterpret_cast<int>(value)
; } // NOLINT |
| 80 private: | 81 private: |
| 81 friend class StringStream; | 82 friend class StringStream; |
| 82 enum Type { INT, C_STR, OBJ, HANDLE }; | 83 enum Type { INT, DOUBLE, C_STR, OBJ, HANDLE }; |
| 83 Type type_; | 84 Type type_; |
| 84 union { | 85 union { |
| 85 int u_int_; | 86 int u_int_; |
| 87 double u_double_; |
| 86 const char* u_c_str_; | 88 const char* u_c_str_; |
| 87 Object* u_obj_; | 89 Object* u_obj_; |
| 88 Object** u_handle_; | 90 Object** u_handle_; |
| 89 } data_; | 91 } data_; |
| 90 }; | 92 }; |
| 91 | 93 |
| 92 | 94 |
| 93 class StringStream { | 95 class StringStream { |
| 94 public: | 96 public: |
| 95 explicit StringStream(StringAllocator* allocator): | 97 explicit StringStream(StringAllocator* allocator): |
| (...skipping 13 matching lines...) Expand all Loading... |
| 109 void Add(const char* format, Vector<FmtElm> elms); | 111 void Add(const char* format, Vector<FmtElm> elms); |
| 110 void Add(const char* format); | 112 void Add(const char* format); |
| 111 void Add(const char* format, FmtElm arg0); | 113 void Add(const char* format, FmtElm arg0); |
| 112 void Add(const char* format, FmtElm arg0, FmtElm arg1); | 114 void Add(const char* format, FmtElm arg0, FmtElm arg1); |
| 113 void Add(const char* format, FmtElm arg0, FmtElm arg1, FmtElm arg2); | 115 void Add(const char* format, FmtElm arg0, FmtElm arg1, FmtElm arg2); |
| 114 | 116 |
| 115 // Getting the message out. | 117 // Getting the message out. |
| 116 void OutputToStdOut(); | 118 void OutputToStdOut(); |
| 117 void Log(); | 119 void Log(); |
| 118 Handle<String> ToString(); | 120 Handle<String> ToString(); |
| 119 SmartPointer<char> ToCString(); | 121 SmartPointer<const char> ToCString(); |
| 120 | 122 |
| 121 // Object printing support. | 123 // Object printing support. |
| 122 void PrintName(Object* o); | 124 void PrintName(Object* o); |
| 123 void PrintFixedArray(FixedArray* array, unsigned int limit); | 125 void PrintFixedArray(FixedArray* array, unsigned int limit); |
| 124 void PrintByteArray(ByteArray* ba); | 126 void PrintByteArray(ByteArray* ba); |
| 125 void PrintUsingMap(JSObject* js_object); | 127 void PrintUsingMap(JSObject* js_object); |
| 126 void PrintPrototype(JSFunction* fun, Object* receiver); | 128 void PrintPrototype(JSFunction* fun, Object* receiver); |
| 127 void PrintSecurityTokenIfChanged(Object* function); | 129 void PrintSecurityTokenIfChanged(Object* function); |
| 128 // NOTE: Returns the code in the output parameter. | 130 // NOTE: Returns the code in the output parameter. |
| 129 void PrintFunction(Object* function, Object* receiver, Code** code); | 131 void PrintFunction(Object* function, Object* receiver, Code** code); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 155 int space() const { return capacity_ - length_; } | 157 int space() const { return capacity_ - length_; } |
| 156 char* cursor() const { return buffer_ + length_; } | 158 char* cursor() const { return buffer_ + length_; } |
| 157 | 159 |
| 158 DISALLOW_IMPLICIT_CONSTRUCTORS(StringStream); | 160 DISALLOW_IMPLICIT_CONSTRUCTORS(StringStream); |
| 159 }; | 161 }; |
| 160 | 162 |
| 161 | 163 |
| 162 } } // namespace v8::internal | 164 } } // namespace v8::internal |
| 163 | 165 |
| 164 #endif // V8_STRING_STREAM_H_ | 166 #endif // V8_STRING_STREAM_H_ |
| OLD | NEW |