| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_JSON_STRINGIFIER_H_ | 5 #ifndef V8_JSON_STRINGIFIER_H_ |
| 6 #define V8_JSON_STRINGIFIER_H_ | 6 #define V8_JSON_STRINGIFIER_H_ |
| 7 | 7 |
| 8 #include "src/v8.h" | 8 #include "src/v8.h" |
| 9 | 9 |
| 10 #include "src/conversions.h" | 10 #include "src/conversions.h" |
| 11 #include "src/messages.h" |
| 11 #include "src/string-builder.h" | 12 #include "src/string-builder.h" |
| 12 #include "src/utils.h" | 13 #include "src/utils.h" |
| 13 | 14 |
| 14 namespace v8 { | 15 namespace v8 { |
| 15 namespace internal { | 16 namespace internal { |
| 16 | 17 |
| 17 class BasicJsonStringifier BASE_EMBEDDED { | 18 class BasicJsonStringifier BASE_EMBEDDED { |
| 18 public: | 19 public: |
| 19 explicit BasicJsonStringifier(Isolate* isolate); | 20 explicit BasicJsonStringifier(Isolate* isolate); |
| 20 | 21 |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 return EXCEPTION; | 266 return EXCEPTION; |
| 266 } | 267 } |
| 267 | 268 |
| 268 int length = Smi::cast(stack_->length())->value(); | 269 int length = Smi::cast(stack_->length())->value(); |
| 269 { | 270 { |
| 270 DisallowHeapAllocation no_allocation; | 271 DisallowHeapAllocation no_allocation; |
| 271 FixedArray* elements = FixedArray::cast(stack_->elements()); | 272 FixedArray* elements = FixedArray::cast(stack_->elements()); |
| 272 for (int i = 0; i < length; i++) { | 273 for (int i = 0; i < length; i++) { |
| 273 if (elements->get(i) == *object) { | 274 if (elements->get(i) == *object) { |
| 274 AllowHeapAllocation allow_to_return_error; | 275 AllowHeapAllocation allow_to_return_error; |
| 275 Handle<Object> error = factory()->NewTypeError( | 276 Handle<Object> error = |
| 276 "circular_structure", HandleVector<Object>(NULL, 0)); | 277 factory()->NewTypeError(MessageTemplate::kCircularStructure); |
| 277 isolate_->Throw(*error); | 278 isolate_->Throw(*error); |
| 278 return EXCEPTION; | 279 return EXCEPTION; |
| 279 } | 280 } |
| 280 } | 281 } |
| 281 } | 282 } |
| 282 JSArray::EnsureSize(stack_, length + 1); | 283 JSArray::EnsureSize(stack_, length + 1); |
| 283 FixedArray::cast(stack_->elements())->set(length, *object); | 284 FixedArray::cast(stack_->elements())->set(length, *object); |
| 284 stack_->set_length(Smi::FromInt(length + 1)); | 285 stack_->set_length(Smi::FromInt(length + 1)); |
| 285 return SUCCESS; | 286 return SUCCESS; |
| 286 } | 287 } |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 SerializeString_<uint8_t, uc16>(object); | 681 SerializeString_<uint8_t, uc16>(object); |
| 681 } else { | 682 } else { |
| 682 SerializeString_<uc16, uc16>(object); | 683 SerializeString_<uc16, uc16>(object); |
| 683 } | 684 } |
| 684 } | 685 } |
| 685 } | 686 } |
| 686 | 687 |
| 687 } } // namespace v8::internal | 688 } } // namespace v8::internal |
| 688 | 689 |
| 689 #endif // V8_JSON_STRINGIFIER_H_ | 690 #endif // V8_JSON_STRINGIFIER_H_ |
| OLD | NEW |