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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 // literals. The string must only be double-quoted (not single-quoted), and | 99 // literals. The string must only be double-quoted (not single-quoted), and |
100 // the only allowed backslash-escapes are ", /, \, b, f, n, r, t and | 100 // the only allowed backslash-escapes are ", /, \, b, f, n, r, t and |
101 // four-digit hex escapes (uXXXX). Any other use of backslashes is invalid. | 101 // four-digit hex escapes (uXXXX). Any other use of backslashes is invalid. |
102 Handle<String> ParseJsonString() { | 102 Handle<String> ParseJsonString() { |
103 return ScanJsonString<false>(); | 103 return ScanJsonString<false>(); |
104 } | 104 } |
105 | 105 |
106 bool ParseJsonString(Handle<String> expected) { | 106 bool ParseJsonString(Handle<String> expected) { |
107 int length = expected->length(); | 107 int length = expected->length(); |
108 if (source_->length() - position_ - 1 > length) { | 108 if (source_->length() - position_ - 1 > length) { |
109 AssertNoAllocation no_gc; | 109 DisallowHeapAllocation no_gc; |
110 String::FlatContent content = expected->GetFlatContent(); | 110 String::FlatContent content = expected->GetFlatContent(); |
111 if (content.IsAscii()) { | 111 if (content.IsAscii()) { |
112 ASSERT_EQ('"', c0_); | 112 ASSERT_EQ('"', c0_); |
113 const uint8_t* input_chars = seq_source_->GetChars() + position_ + 1; | 113 const uint8_t* input_chars = seq_source_->GetChars() + position_ + 1; |
114 const uint8_t* expected_chars = content.ToOneByteVector().start(); | 114 const uint8_t* expected_chars = content.ToOneByteVector().start(); |
115 for (int i = 0; i < length; i++) { | 115 for (int i = 0; i < length; i++) { |
116 uint8_t c0 = input_chars[i]; | 116 uint8_t c0 = input_chars[i]; |
117 if (c0 != expected_chars[i] || | 117 if (c0 != expected_chars[i] || |
118 c0 == '"' || c0 < 0x20 || c0 == '\\') { | 118 c0 == '"' || c0 < 0x20 || c0 == '\\') { |
119 return false; | 119 return false; |
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 | 811 |
812 ASSERT_EQ('"', c0_); | 812 ASSERT_EQ('"', c0_); |
813 // Advance past the last '"'. | 813 // Advance past the last '"'. |
814 AdvanceSkipWhitespace(); | 814 AdvanceSkipWhitespace(); |
815 return result; | 815 return result; |
816 } | 816 } |
817 | 817 |
818 } } // namespace v8::internal | 818 } } // namespace v8::internal |
819 | 819 |
820 #endif // V8_JSON_PARSER_H_ | 820 #endif // V8_JSON_PARSER_H_ |
OLD | NEW |