| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 set_accumulator(factory_->NewConsString(accumulator(), result_string)); | 488 set_accumulator(factory_->NewConsString(accumulator(), result_string)); |
| 489 return SUCCESS; | 489 return SUCCESS; |
| 490 } | 490 } |
| 491 | 491 |
| 492 | 492 |
| 493 BasicJsonStringifier::Result BasicJsonStringifier::SerializeJSValue( | 493 BasicJsonStringifier::Result BasicJsonStringifier::SerializeJSValue( |
| 494 Handle<JSValue> object) { | 494 Handle<JSValue> object) { |
| 495 bool has_exception = false; | 495 bool has_exception = false; |
| 496 String* class_name = object->class_name(); | 496 String* class_name = object->class_name(); |
| 497 if (class_name == isolate_->heap()->String_string()) { | 497 if (class_name == isolate_->heap()->String_string()) { |
| 498 Handle<Object> value = Execution::ToString(object, &has_exception); | 498 Handle<Object> value = |
| 499 Execution::ToString(isolate_, object, &has_exception); |
| 499 if (has_exception) return EXCEPTION; | 500 if (has_exception) return EXCEPTION; |
| 500 SerializeString(Handle<String>::cast(value)); | 501 SerializeString(Handle<String>::cast(value)); |
| 501 } else if (class_name == isolate_->heap()->Number_string()) { | 502 } else if (class_name == isolate_->heap()->Number_string()) { |
| 502 Handle<Object> value = Execution::ToNumber(object, &has_exception); | 503 Handle<Object> value = |
| 504 Execution::ToNumber(isolate_, object, &has_exception); |
| 503 if (has_exception) return EXCEPTION; | 505 if (has_exception) return EXCEPTION; |
| 504 if (value->IsSmi()) return SerializeSmi(Smi::cast(*value)); | 506 if (value->IsSmi()) return SerializeSmi(Smi::cast(*value)); |
| 505 SerializeHeapNumber(Handle<HeapNumber>::cast(value)); | 507 SerializeHeapNumber(Handle<HeapNumber>::cast(value)); |
| 506 } else { | 508 } else { |
| 507 ASSERT(class_name == isolate_->heap()->Boolean_string()); | 509 ASSERT(class_name == isolate_->heap()->Boolean_string()); |
| 508 Object* value = JSValue::cast(*object)->value(); | 510 Object* value = JSValue::cast(*object)->value(); |
| 509 ASSERT(value->IsBoolean()); | 511 ASSERT(value->IsBoolean()); |
| 510 AppendAscii(value->IsTrue() ? "true" : "false"); | 512 AppendAscii(value->IsTrue() ? "true" : "false"); |
| 511 } | 513 } |
| 512 return SUCCESS; | 514 return SUCCESS; |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 843 SerializeString_<false, uint8_t>(object); | 845 SerializeString_<false, uint8_t>(object); |
| 844 } else { | 846 } else { |
| 845 SerializeString_<false, uc16>(object); | 847 SerializeString_<false, uc16>(object); |
| 846 } | 848 } |
| 847 } | 849 } |
| 848 } | 850 } |
| 849 | 851 |
| 850 } } // namespace v8::internal | 852 } } // namespace v8::internal |
| 851 | 853 |
| 852 #endif // V8_JSON_STRINGIFIER_H_ | 854 #endif // V8_JSON_STRINGIFIER_H_ |
| OLD | NEW |