OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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_PARSER_H_ | 5 #ifndef V8_JSON_PARSER_H_ |
6 #define V8_JSON_PARSER_H_ | 6 #define V8_JSON_PARSER_H_ |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/char-predicates-inl.h" | 10 #include "src/char-predicates-inl.h" |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 } else { | 407 } else { |
408 transitioning = false; | 408 transitioning = false; |
409 } | 409 } |
410 } | 410 } |
411 | 411 |
412 // Commit the intermediate state to the object and stop transitioning. | 412 // Commit the intermediate state to the object and stop transitioning. |
413 JSObject::AllocateStorageForMap(json_object, map); | 413 JSObject::AllocateStorageForMap(json_object, map); |
414 int length = properties.length(); | 414 int length = properties.length(); |
415 for (int i = 0; i < length; i++) { | 415 for (int i = 0; i < length; i++) { |
416 Handle<Object> value = properties[i]; | 416 Handle<Object> value = properties[i]; |
417 FieldIndex index = FieldIndex::ForPropertyIndex(*map, i); | 417 json_object->FastPropertyAtPut(i, *value); |
418 json_object->FastPropertyAtPut(index, *value); | |
419 } | 418 } |
420 } else { | 419 } else { |
421 key = ParseJsonInternalizedString(); | 420 key = ParseJsonInternalizedString(); |
422 if (key.is_null() || c0_ != ':') return ReportUnexpectedCharacter(); | 421 if (key.is_null() || c0_ != ':') return ReportUnexpectedCharacter(); |
423 | 422 |
424 AdvanceSkipWhitespace(); | 423 AdvanceSkipWhitespace(); |
425 value = ParseJsonValue(); | 424 value = ParseJsonValue(); |
426 if (value.is_null()) return ReportUnexpectedCharacter(); | 425 if (value.is_null()) return ReportUnexpectedCharacter(); |
427 } | 426 } |
428 | 427 |
429 JSObject::SetOwnPropertyIgnoreAttributes( | 428 JSObject::SetOwnPropertyIgnoreAttributes( |
430 json_object, key, value, NONE).Assert(); | 429 json_object, key, value, NONE).Assert(); |
431 } while (MatchSkipWhiteSpace(',')); | 430 } while (MatchSkipWhiteSpace(',')); |
432 if (c0_ != '}') { | 431 if (c0_ != '}') { |
433 return ReportUnexpectedCharacter(); | 432 return ReportUnexpectedCharacter(); |
434 } | 433 } |
435 | 434 |
436 // If we transitioned until the very end, transition the map now. | 435 // If we transitioned until the very end, transition the map now. |
437 if (transitioning) { | 436 if (transitioning) { |
438 JSObject::AllocateStorageForMap(json_object, map); | 437 JSObject::AllocateStorageForMap(json_object, map); |
439 int length = properties.length(); | 438 int length = properties.length(); |
440 for (int i = 0; i < length; i++) { | 439 for (int i = 0; i < length; i++) { |
441 Handle<Object> value = properties[i]; | 440 Handle<Object> value = properties[i]; |
442 FieldIndex index = FieldIndex::ForPropertyIndex(*map, i); | 441 json_object->FastPropertyAtPut(i, *value); |
443 json_object->FastPropertyAtPut(index, *value); | |
444 } | 442 } |
445 } | 443 } |
446 } | 444 } |
447 AdvanceSkipWhitespace(); | 445 AdvanceSkipWhitespace(); |
448 return scope.CloseAndEscape(json_object); | 446 return scope.CloseAndEscape(json_object); |
449 } | 447 } |
450 | 448 |
451 // Parse a JSON array. Position must be right at '['. | 449 // Parse a JSON array. Position must be right at '['. |
452 template <bool seq_ascii> | 450 template <bool seq_ascii> |
453 Handle<Object> JsonParser<seq_ascii>::ParseJsonArray() { | 451 Handle<Object> JsonParser<seq_ascii>::ParseJsonArray() { |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
783 | 781 |
784 ASSERT_EQ('"', c0_); | 782 ASSERT_EQ('"', c0_); |
785 // Advance past the last '"'. | 783 // Advance past the last '"'. |
786 AdvanceSkipWhitespace(); | 784 AdvanceSkipWhitespace(); |
787 return result; | 785 return result; |
788 } | 786 } |
789 | 787 |
790 } } // namespace v8::internal | 788 } } // namespace v8::internal |
791 | 789 |
792 #endif // V8_JSON_PARSER_H_ | 790 #endif // V8_JSON_PARSER_H_ |
OLD | NEW |