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

View File

@ -92,17 +92,17 @@ class JsonParser BASE_EMBEDDED {
// literals. The string must only be double-quoted (not single-quoted), 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.
Handle<Object> ParseJsonString() {
Handle<String> ParseJsonString() {
return ScanJsonString<false>();
}
Handle<Object> ParseJsonSymbol() {
Handle<String> ParseJsonSymbol() {
return ScanJsonString<true>();
}
template <bool is_symbol>
Handle<Object> ScanJsonString();
Handle<String> ScanJsonString();
// Slow version for unicode support, uses the first ascii_count characters,
// as first part of a ConsString
Handle<Object> SlowScanJsonString();
Handle<String> SlowScanJsonString();
// A JSON number (production JSONNumber) is a subset of the valid JavaScript
// decimal number literals.