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

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

Issue 225283005: Return MaybeHandle from SetProperty. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comments Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « src/isolate.cc ('k') | src/liveedit.cc » ('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 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 25 matching lines...) Expand all
36 #include "spaces-inl.h" 36 #include "spaces-inl.h"
37 #include "token.h" 37 #include "token.h"
38 38
39 namespace v8 { 39 namespace v8 {
40 namespace internal { 40 namespace internal {
41 41
42 // A simple json parser. 42 // A simple json parser.
43 template <bool seq_ascii> 43 template <bool seq_ascii>
44 class JsonParser BASE_EMBEDDED { 44 class JsonParser BASE_EMBEDDED {
45 public: 45 public:
46 static MaybeHandle<Object> Parse(Handle<String> source) { 46 MUST_USE_RESULT static MaybeHandle<Object> Parse(Handle<String> source) {
47 return JsonParser(source).ParseJson(); 47 return JsonParser(source).ParseJson();
48 } 48 }
49 49
50 static const int kEndOfString = -1; 50 static const int kEndOfString = -1;
51 51
52 private: 52 private:
53 explicit JsonParser(Handle<String> source) 53 explicit JsonParser(Handle<String> source)
54 : source_(source), 54 : source_(source),
55 source_length_(source->length()), 55 source_length_(source->length()),
56 isolate_(source->map()->GetHeap()->isolate()), 56 isolate_(source->map()->GetHeap()->isolate()),
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 } else { 435 } else {
436 key = ParseJsonInternalizedString(); 436 key = ParseJsonInternalizedString();
437 if (key.is_null() || c0_ != ':') return ReportUnexpectedCharacter(); 437 if (key.is_null() || c0_ != ':') return ReportUnexpectedCharacter();
438 438
439 AdvanceSkipWhitespace(); 439 AdvanceSkipWhitespace();
440 value = ParseJsonValue(); 440 value = ParseJsonValue();
441 if (value.is_null()) return ReportUnexpectedCharacter(); 441 if (value.is_null()) return ReportUnexpectedCharacter();
442 } 442 }
443 443
444 JSObject::SetLocalPropertyIgnoreAttributes( 444 JSObject::SetLocalPropertyIgnoreAttributes(
445 json_object, key, value, NONE); 445 json_object, key, value, NONE).Assert();
446 } while (MatchSkipWhiteSpace(',')); 446 } while (MatchSkipWhiteSpace(','));
447 if (c0_ != '}') { 447 if (c0_ != '}') {
448 return ReportUnexpectedCharacter(); 448 return ReportUnexpectedCharacter();
449 } 449 }
450 450
451 // If we transitioned until the very end, transition the map now. 451 // If we transitioned until the very end, transition the map now.
452 if (transitioning) { 452 if (transitioning) {
453 JSObject::AllocateStorageForMap(json_object, map); 453 JSObject::AllocateStorageForMap(json_object, map);
454 int length = properties.length(); 454 int length = properties.length();
455 for (int i = 0; i < length; i++) { 455 for (int i = 0; i < length; i++) {
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 798
799 ASSERT_EQ('"', c0_); 799 ASSERT_EQ('"', c0_);
800 // Advance past the last '"'. 800 // Advance past the last '"'.
801 AdvanceSkipWhitespace(); 801 AdvanceSkipWhitespace();
802 return result; 802 return result;
803 } 803 }
804 804
805 } } // namespace v8::internal 805 } } // namespace v8::internal
806 806
807 #endif // V8_JSON_PARSER_H_ 807 #endif // V8_JSON_PARSER_H_
OLDNEW
« no previous file with comments | « src/isolate.cc ('k') | src/liveedit.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698