Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(191)

Side by Side Diff: src/json-stringifier.h

Issue 1178893002: Introduce LookupIterator::PropertyOrElement which converts name to index if possible. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/api-natives.cc ('k') | src/lookup.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 for (int i = 0; i < contents->length(); i++) { 573 for (int i = 0; i < contents->length(); i++) {
574 Object* key = contents->get(i); 574 Object* key = contents->get(i);
575 Handle<String> key_handle; 575 Handle<String> key_handle;
576 MaybeHandle<Object> maybe_property; 576 MaybeHandle<Object> maybe_property;
577 if (key->IsString()) { 577 if (key->IsString()) {
578 key_handle = Handle<String>(String::cast(key), isolate_); 578 key_handle = Handle<String>(String::cast(key), isolate_);
579 maybe_property = Object::GetPropertyOrElement(object, key_handle); 579 maybe_property = Object::GetPropertyOrElement(object, key_handle);
580 } else { 580 } else {
581 DCHECK(key->IsNumber()); 581 DCHECK(key->IsNumber());
582 key_handle = factory()->NumberToString(Handle<Object>(key, isolate_)); 582 key_handle = factory()->NumberToString(Handle<Object>(key, isolate_));
583 uint32_t index;
584 if (key->IsSmi()) { 583 if (key->IsSmi()) {
585 maybe_property = Object::GetElement( 584 maybe_property = Object::GetElement(
586 isolate_, object, Smi::cast(key)->value()); 585 isolate_, object, Smi::cast(key)->value());
587 } else if (key_handle->AsArrayIndex(&index)) {
588 maybe_property = Object::GetElement(isolate_, object, index);
589 } else { 586 } else {
590 maybe_property = Object::GetPropertyOrElement(object, key_handle); 587 maybe_property = Object::GetPropertyOrElement(object, key_handle);
591 } 588 }
592 } 589 }
593 Handle<Object> property; 590 Handle<Object> property;
594 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 591 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
595 isolate_, property, maybe_property, EXCEPTION); 592 isolate_, property, maybe_property, EXCEPTION);
596 Result result = SerializeProperty(property, comma, key_handle); 593 Result result = SerializeProperty(property, comma, key_handle);
597 if (!comma && result == SUCCESS) comma = true; 594 if (!comma && result == SUCCESS) comma = true;
598 if (result == EXCEPTION) return result; 595 if (result == EXCEPTION) return result;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 SerializeString_<uint8_t, uc16>(object); 678 SerializeString_<uint8_t, uc16>(object);
682 } else { 679 } else {
683 SerializeString_<uc16, uc16>(object); 680 SerializeString_<uc16, uc16>(object);
684 } 681 }
685 } 682 }
686 } 683 }
687 684
688 } } // namespace v8::internal 685 } } // namespace v8::internal
689 686
690 #endif // V8_JSON_STRINGIFIER_H_ 687 #endif // V8_JSON_STRINGIFIER_H_
OLDNEW
« no previous file with comments | « src/api-natives.cc ('k') | src/lookup.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698