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 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 switch (object->GetElementsKind()) { | 406 switch (object->GetElementsKind()) { |
407 case FAST_SMI_ELEMENTS: { | 407 case FAST_SMI_ELEMENTS: { |
408 Handle<FixedArray> elements = Handle<FixedArray>( | 408 Handle<FixedArray> elements = Handle<FixedArray>( |
409 FixedArray::cast(object->elements())); | 409 FixedArray::cast(object->elements())); |
410 for (int i = 0; i < length; i++) { | 410 for (int i = 0; i < length; i++) { |
411 if (i > 0) Append(','); | 411 if (i > 0) Append(','); |
412 SerializeSmi(Smi::cast(elements->get(i))); | 412 SerializeSmi(Smi::cast(elements->get(i))); |
413 } | 413 } |
414 break; | 414 break; |
415 } | 415 } |
416 case FAST_HOLEY_SMI_ELEMENTS: { | |
417 Handle<FixedArray> elements = Handle<FixedArray>( | |
418 FixedArray::cast(object->elements())); | |
419 for (int i = 0; i < length; i++) { | |
420 if (i > 0) Append(','); | |
421 if (elements->is_the_hole(i)) { | |
422 Append("null"); | |
423 } else { | |
424 SerializeSmi(Smi::cast(elements->get(i))); | |
425 } | |
426 } | |
427 break; | |
428 } | |
429 case FAST_HOLEY_DOUBLE_ELEMENTS: | |
430 case FAST_DOUBLE_ELEMENTS: { | 416 case FAST_DOUBLE_ELEMENTS: { |
431 Handle<FixedDoubleArray> elements = Handle<FixedDoubleArray>( | 417 Handle<FixedDoubleArray> elements = Handle<FixedDoubleArray>( |
432 FixedDoubleArray::cast(object->elements())); | 418 FixedDoubleArray::cast(object->elements())); |
433 for (int i = 0; i < length; i++) { | 419 for (int i = 0; i < length; i++) { |
434 if (i > 0) Append(','); | 420 if (i > 0) Append(','); |
435 SerializeDouble(elements->get_scalar(i)); | 421 SerializeDouble(elements->get_scalar(i)); |
436 } | 422 } |
437 break; | 423 break; |
438 } | 424 } |
439 case FAST_HOLEY_ELEMENTS: | |
440 case FAST_ELEMENTS: { | 425 case FAST_ELEMENTS: { |
441 Handle<FixedArray> elements = Handle<FixedArray>( | 426 Handle<FixedArray> elements = Handle<FixedArray>( |
442 FixedArray::cast(object->elements())); | 427 FixedArray::cast(object->elements())); |
443 for (int i = 0; i < length; i++) { | 428 for (int i = 0; i < length; i++) { |
444 if (i > 0) Append(','); | 429 if (i > 0) Append(','); |
445 Result result = Serialize(Handle<Object>(elements->get(i))); | 430 Result result = Serialize(Handle<Object>(elements->get(i))); |
446 if (result == SUCCESS) continue; | 431 if (result == SUCCESS) continue; |
447 if (result == UNCHANGED) { | 432 if (result == UNCHANGED) { |
448 Append("null"); | 433 Append("null"); |
449 } else { | 434 } else { |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 SerializeString_<false, char>(flat.ToAsciiVector(), object); | 662 SerializeString_<false, char>(flat.ToAsciiVector(), object); |
678 } else { | 663 } else { |
679 SerializeString_<false, uc16>(flat.ToUC16Vector(), object); | 664 SerializeString_<false, uc16>(flat.ToUC16Vector(), object); |
680 } | 665 } |
681 } | 666 } |
682 } | 667 } |
683 | 668 |
684 } } // namespace v8::internal | 669 } } // namespace v8::internal |
685 | 670 |
686 #endif // V8_JSON_STRINGIFIER_H_ | 671 #endif // V8_JSON_STRINGIFIER_H_ |
OLD | NEW |