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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 int length = expected->length(); | 101 int length = expected->length(); |
102 if (source_->length() - position_ - 1 > length) { | 102 if (source_->length() - position_ - 1 > length) { |
103 DisallowHeapAllocation no_gc; | 103 DisallowHeapAllocation no_gc; |
104 String::FlatContent content = expected->GetFlatContent(); | 104 String::FlatContent content = expected->GetFlatContent(); |
105 if (content.IsOneByte()) { | 105 if (content.IsOneByte()) { |
106 DCHECK_EQ('"', c0_); | 106 DCHECK_EQ('"', c0_); |
107 const uint8_t* input_chars = seq_source_->GetChars() + position_ + 1; | 107 const uint8_t* input_chars = seq_source_->GetChars() + position_ + 1; |
108 const uint8_t* expected_chars = content.ToOneByteVector().start(); | 108 const uint8_t* expected_chars = content.ToOneByteVector().start(); |
109 for (int i = 0; i < length; i++) { | 109 for (int i = 0; i < length; i++) { |
110 uint8_t c0 = input_chars[i]; | 110 uint8_t c0 = input_chars[i]; |
111 // The expected string has to be free of \, " and characters < 0x20. | 111 if (c0 != expected_chars[i] || c0 == '"' || c0 < 0x20 || c0 == '\\') { |
112 if (c0 != expected_chars[i]) return false; | 112 return false; |
| 113 } |
113 } | 114 } |
114 if (input_chars[length] == '"') { | 115 if (input_chars[length] == '"') { |
115 position_ = position_ + length + 1; | 116 position_ = position_ + length + 1; |
116 AdvanceSkipWhitespace(); | 117 AdvanceSkipWhitespace(); |
117 return true; | 118 return true; |
118 } | 119 } |
119 } | 120 } |
120 } | 121 } |
121 return false; | 122 return false; |
122 } | 123 } |
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
808 | 809 |
809 DCHECK_EQ('"', c0_); | 810 DCHECK_EQ('"', c0_); |
810 // Advance past the last '"'. | 811 // Advance past the last '"'. |
811 AdvanceSkipWhitespace(); | 812 AdvanceSkipWhitespace(); |
812 return result; | 813 return result; |
813 } | 814 } |
814 | 815 |
815 } } // namespace v8::internal | 816 } } // namespace v8::internal |
816 | 817 |
817 #endif // V8_JSON_PARSER_H_ | 818 #endif // V8_JSON_PARSER_H_ |
OLD | NEW |