Untank compilation and fix JSON parse bug introduced in r8147.

Review URL: http://codereview.chromium.org/7020028

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8148 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
sandholm@chromium.org 2011-06-01 14:55:55 +00:00
parent 3ed8c2f520
commit f6901ea747
2 changed files with 11 additions and 10 deletions

View File

@ -167,6 +167,7 @@ Handle<Object> JsonParser::ParseJsonObject() {
AdvanceSkipWhitespace(); AdvanceSkipWhitespace();
if (c0_ != '}') { if (c0_ != '}') {
do { do {
if (c0_ != '"') return ReportUnexpectedCharacter();
Handle<String> key = ParseJsonSymbol(); Handle<String> key = ParseJsonSymbol();
if (key.is_null() || c0_ != ':') return ReportUnexpectedCharacter(); if (key.is_null() || c0_ != ':') return ReportUnexpectedCharacter();
AdvanceSkipWhitespace(); AdvanceSkipWhitespace();
@ -283,7 +284,7 @@ Handle<Object> JsonParser::ParseJsonNumber() {
return isolate()->factory()->NewNumber(number_); return isolate()->factory()->NewNumber(number_);
} }
Handle<Object> JsonParser::SlowScanJsonString() { Handle<String> JsonParser::SlowScanJsonString() {
// The currently scanned ascii characters. // The currently scanned ascii characters.
Handle<String> ascii(isolate()->factory()->NewSubString(source_, Handle<String> ascii(isolate()->factory()->NewSubString(source_,
beg_pos_, beg_pos_,
@ -312,7 +313,7 @@ Handle<Object> JsonParser::SlowScanJsonString() {
} }
// Check for control character (0x00-0x1f) or unterminated string (<0). // Check for control character (0x00-0x1f) or unterminated string (<0).
if (c0_ < 0x20) return ReportUnexpectedCharacter(); if (c0_ < 0x20) return Handle<String>::null();
if (c0_ != '\\') { if (c0_ != '\\') {
seq_two_byte->SeqTwoByteStringSet(count++, c0_); seq_two_byte->SeqTwoByteStringSet(count++, c0_);
Advance(); Advance();
@ -345,7 +346,7 @@ Handle<Object> JsonParser::SlowScanJsonString() {
Advance(); Advance();
int digit = HexValue(c0_); int digit = HexValue(c0_);
if (digit < 0) { if (digit < 0) {
return ReportUnexpectedCharacter(); return Handle<String>::null();
} }
value = value * 16 + digit; value = value * 16 + digit;
} }
@ -353,7 +354,7 @@ Handle<Object> JsonParser::SlowScanJsonString() {
break; break;
} }
default: default:
return ReportUnexpectedCharacter(); return Handle<String>::null();
} }
Advance(); Advance();
} }
@ -381,14 +382,14 @@ Handle<Object> JsonParser::SlowScanJsonString() {
template <bool is_symbol> template <bool is_symbol>
Handle<Object> JsonParser::ScanJsonString() { Handle<String> JsonParser::ScanJsonString() {
ASSERT_EQ('"', c0_); ASSERT_EQ('"', c0_);
Advance(); Advance();
beg_pos_ = position_; beg_pos_ = position_;
// Fast case for ascii only without escape characters. // Fast case for ascii only without escape characters.
while (c0_ != '"') { while (c0_ != '"') {
// Check for control character (0x00-0x1f) or unterminated string (<0). // Check for control character (0x00-0x1f) or unterminated string (<0).
if (c0_ < 0x20) return ReportUnexpectedCharacter(); if (c0_ < 0x20) return Handle<String>::null();
if (c0_ != '\\' && c0_ < kMaxAsciiCharCode) { if (c0_ != '\\' && c0_ < kMaxAsciiCharCode) {
Advance(); Advance();
} else { } else {

View File

@ -92,17 +92,17 @@ class JsonParser BASE_EMBEDDED {
// literals. The string must only be double-quoted (not single-quoted), and // literals. The string must only be double-quoted (not single-quoted), and
// the only allowed backslash-escapes are ", /, \, b, f, n, r, t and // the only allowed backslash-escapes are ", /, \, b, f, n, r, t and
// four-digit hex escapes (uXXXX). Any other use of backslashes is invalid. // four-digit hex escapes (uXXXX). Any other use of backslashes is invalid.
Handle<Object> ParseJsonString() { Handle<String> ParseJsonString() {
return ScanJsonString<false>(); return ScanJsonString<false>();
} }
Handle<Object> ParseJsonSymbol() { Handle<String> ParseJsonSymbol() {
return ScanJsonString<true>(); return ScanJsonString<true>();
} }
template <bool is_symbol> template <bool is_symbol>
Handle<Object> ScanJsonString(); Handle<String> ScanJsonString();
// Slow version for unicode support, uses the first ascii_count characters, // Slow version for unicode support, uses the first ascii_count characters,
// as first part of a ConsString // as first part of a ConsString
Handle<Object> SlowScanJsonString(); Handle<String> SlowScanJsonString();
// A JSON number (production JSONNumber) is a subset of the valid JavaScript // A JSON number (production JSONNumber) is a subset of the valid JavaScript
// decimal number literals. // decimal number literals.