| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 } | 83 } |
| 84 FmtElm(const Vector<const uc16>& value) : type_(LC_STR) { // NOLINT | 84 FmtElm(const Vector<const uc16>& value) : type_(LC_STR) { // NOLINT |
| 85 data_.u_lc_str_ = &value; | 85 data_.u_lc_str_ = &value; |
| 86 } | 86 } |
| 87 FmtElm(Object* value) : type_(OBJ) { // NOLINT | 87 FmtElm(Object* value) : type_(OBJ) { // NOLINT |
| 88 data_.u_obj_ = value; | 88 data_.u_obj_ = value; |
| 89 } | 89 } |
| 90 FmtElm(Handle<Object> value) : type_(HANDLE) { // NOLINT | 90 FmtElm(Handle<Object> value) : type_(HANDLE) { // NOLINT |
| 91 data_.u_handle_ = value.location(); | 91 data_.u_handle_ = value.location(); |
| 92 } | 92 } |
| 93 FmtElm(void* value) : type_(INT) { // NOLINT | 93 FmtElm(void* value) : type_(POINTER) { // NOLINT |
| 94 #if V8_HOST_ARCH_64_BIT | 94 data_.u_pointer_ = value; |
| 95 // TODO(x64): FmtElm needs to treat pointers as pointers, and not as | |
| 96 // ints. This will require adding a pointer type, etc. For now just | |
| 97 // hack it and truncate the pointer. | |
| 98 // http://code.google.com/p/v8/issues/detail?id=335 | |
| 99 data_.u_int_ = 0; | |
| 100 UNIMPLEMENTED(); | |
| 101 #else | |
| 102 data_.u_int_ = reinterpret_cast<int>(value); | |
| 103 #endif | |
| 104 } | 95 } |
| 105 private: | 96 private: |
| 106 friend class StringStream; | 97 friend class StringStream; |
| 107 enum Type { INT, DOUBLE, C_STR, LC_STR, OBJ, HANDLE }; | 98 enum Type { INT, DOUBLE, C_STR, LC_STR, OBJ, HANDLE, POINTER }; |
| 108 Type type_; | 99 Type type_; |
| 109 union { | 100 union { |
| 110 int u_int_; | 101 int u_int_; |
| 111 double u_double_; | 102 double u_double_; |
| 112 const char* u_c_str_; | 103 const char* u_c_str_; |
| 113 const Vector<const uc16>* u_lc_str_; | 104 const Vector<const uc16>* u_lc_str_; |
| 114 Object* u_obj_; | 105 Object* u_obj_; |
| 115 Object** u_handle_; | 106 Object** u_handle_; |
| 107 void* u_pointer_; |
| 116 } data_; | 108 } data_; |
| 117 }; | 109 }; |
| 118 | 110 |
| 119 | 111 |
| 120 class StringStream { | 112 class StringStream { |
| 121 public: | 113 public: |
| 122 explicit StringStream(StringAllocator* allocator): | 114 explicit StringStream(StringAllocator* allocator): |
| 123 allocator_(allocator), | 115 allocator_(allocator), |
| 124 capacity_(kInitialCapacity), | 116 capacity_(kInitialCapacity), |
| 125 length_(0), | 117 length_(0), |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 bool full() const { return (capacity_ - length_) == 1; } | 180 bool full() const { return (capacity_ - length_) == 1; } |
| 189 int space() const { return capacity_ - length_; } | 181 int space() const { return capacity_ - length_; } |
| 190 | 182 |
| 191 DISALLOW_IMPLICIT_CONSTRUCTORS(StringStream); | 183 DISALLOW_IMPLICIT_CONSTRUCTORS(StringStream); |
| 192 }; | 184 }; |
| 193 | 185 |
| 194 | 186 |
| 195 } } // namespace v8::internal | 187 } } // namespace v8::internal |
| 196 | 188 |
| 197 #endif // V8_STRING_STREAM_H_ | 189 #endif // V8_STRING_STREAM_H_ |
| OLD | NEW |