OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 } | 316 } |
317 | 317 |
318 | 318 |
319 // Parse a JSON object. Position must be right at '{'. | 319 // Parse a JSON object. Position must be right at '{'. |
320 template <bool seq_ascii> | 320 template <bool seq_ascii> |
321 Handle<Object> JsonParser<seq_ascii>::ParseJsonObject() { | 321 Handle<Object> JsonParser<seq_ascii>::ParseJsonObject() { |
322 HandleScope scope(isolate()); | 322 HandleScope scope(isolate()); |
323 Handle<JSObject> json_object = | 323 Handle<JSObject> json_object = |
324 factory()->NewJSObject(object_constructor(), pretenure_); | 324 factory()->NewJSObject(object_constructor(), pretenure_); |
325 Handle<Map> map(json_object->map()); | 325 Handle<Map> map(json_object->map()); |
326 ZoneScope zone_scope(zone(), DELETE_ON_EXIT); | 326 ZoneScope zone_scope(zone()); |
327 ZoneList<Handle<Object> > properties(8, zone()); | 327 ZoneList<Handle<Object> > properties(8, zone()); |
328 ASSERT_EQ(c0_, '{'); | 328 ASSERT_EQ(c0_, '{'); |
329 | 329 |
330 bool transitioning = true; | 330 bool transitioning = true; |
331 | 331 |
332 AdvanceSkipWhitespace(); | 332 AdvanceSkipWhitespace(); |
333 if (c0_ != '}') { | 333 if (c0_ != '}') { |
334 do { | 334 do { |
335 if (c0_ != '"') return ReportUnexpectedCharacter(); | 335 if (c0_ != '"') return ReportUnexpectedCharacter(); |
336 | 336 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 } | 462 } |
463 } | 463 } |
464 AdvanceSkipWhitespace(); | 464 AdvanceSkipWhitespace(); |
465 return scope.CloseAndEscape(json_object); | 465 return scope.CloseAndEscape(json_object); |
466 } | 466 } |
467 | 467 |
468 // Parse a JSON array. Position must be right at '['. | 468 // Parse a JSON array. Position must be right at '['. |
469 template <bool seq_ascii> | 469 template <bool seq_ascii> |
470 Handle<Object> JsonParser<seq_ascii>::ParseJsonArray() { | 470 Handle<Object> JsonParser<seq_ascii>::ParseJsonArray() { |
471 HandleScope scope(isolate()); | 471 HandleScope scope(isolate()); |
472 ZoneScope zone_scope(zone(), DELETE_ON_EXIT); | 472 ZoneScope zone_scope(zone()); |
473 ZoneList<Handle<Object> > elements(4, zone()); | 473 ZoneList<Handle<Object> > elements(4, zone()); |
474 ASSERT_EQ(c0_, '['); | 474 ASSERT_EQ(c0_, '['); |
475 | 475 |
476 AdvanceSkipWhitespace(); | 476 AdvanceSkipWhitespace(); |
477 if (c0_ != ']') { | 477 if (c0_ != ']') { |
478 do { | 478 do { |
479 Handle<Object> element = ParseJsonValue(); | 479 Handle<Object> element = ParseJsonValue(); |
480 if (element.is_null()) return ReportUnexpectedCharacter(); | 480 if (element.is_null()) return ReportUnexpectedCharacter(); |
481 elements.Add(element, zone()); | 481 elements.Add(element, zone()); |
482 } while (MatchSkipWhiteSpace(',')); | 482 } while (MatchSkipWhiteSpace(',')); |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 | 801 |
802 ASSERT_EQ('"', c0_); | 802 ASSERT_EQ('"', c0_); |
803 // Advance past the last '"'. | 803 // Advance past the last '"'. |
804 AdvanceSkipWhitespace(); | 804 AdvanceSkipWhitespace(); |
805 return result; | 805 return result; |
806 } | 806 } |
807 | 807 |
808 } } // namespace v8::internal | 808 } } // namespace v8::internal |
809 | 809 |
810 #endif // V8_JSON_PARSER_H_ | 810 #endif // V8_JSON_PARSER_H_ |
OLD | NEW |