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

Unified Diff: src/json-parser.h

Issue 1681513002: [json parser] add position to error message. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix BUILD.gn Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/api.cc ('k') | src/messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/json-parser.h
diff --git a/src/parsing/json-parser.h b/src/json-parser.h
similarity index 97%
rename from src/parsing/json-parser.h
rename to src/json-parser.h
index 096e18801cabf4978886ee10683391ced7f6d3ad..fa46cf098ec3c6ae6017d12c94ecb4278f898981 100644
--- a/src/parsing/json-parser.h
+++ b/src/json-parser.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef V8_PARSING_JSON_PARSER_H_
-#define V8_PARSING_JSON_PARSER_H_
+#ifndef V8_JSON_PARSER_H_
+#define V8_JSON_PARSER_H_
#include "src/char-predicates.h"
#include "src/conversions.h"
@@ -217,11 +217,12 @@ MaybeHandle<Object> JsonParser<seq_one_byte>::ParseJson() {
// Parse failed. Current character is the unexpected token.
Factory* factory = this->factory();
MessageTemplate::Template message;
- Handle<String> argument;
+ Handle<Object> arg1 = Handle<Smi>(Smi::FromInt(position_), isolate());
+ Handle<Object> arg2;
switch (c0_) {
case kEndOfString:
- message = MessageTemplate::kUnexpectedEOS;
+ message = MessageTemplate::kJsonParseUnexpectedEOS;
break;
case '-':
case '0':
@@ -234,14 +235,15 @@ MaybeHandle<Object> JsonParser<seq_one_byte>::ParseJson() {
case '7':
case '8':
case '9':
- message = MessageTemplate::kUnexpectedTokenNumber;
+ message = MessageTemplate::kJsonParseUnexpectedTokenNumber;
break;
case '"':
- message = MessageTemplate::kUnexpectedTokenString;
+ message = MessageTemplate::kJsonParseUnexpectedTokenString;
break;
default:
- message = MessageTemplate::kUnexpectedToken;
- argument = factory->LookupSingleCharacterStringFromCode(c0_);
+ message = MessageTemplate::kJsonParseUnexpectedToken;
+ arg2 = arg1;
+ arg1 = factory->LookupSingleCharacterStringFromCode(c0_);
break;
}
@@ -250,7 +252,7 @@ MaybeHandle<Object> JsonParser<seq_one_byte>::ParseJson() {
// separated source file.
isolate()->debug()->OnCompileError(script);
MessageLocation location(script, position_, position_ + 1);
- Handle<Object> error = factory->NewSyntaxError(message, argument);
+ Handle<Object> error = factory->NewSyntaxError(message, arg1, arg2);
return isolate()->template Throw<Object>(error, &location);
}
return result;
@@ -839,4 +841,4 @@ Handle<String> JsonParser<seq_one_byte>::ScanJsonString() {
} // namespace internal
} // namespace v8
-#endif // V8_PARSING_JSON_PARSER_H_
+#endif // V8_JSON_PARSER_H_
« no previous file with comments | « src/api.cc ('k') | src/messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698