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

Unified Diff: src/parsing/parser.cc

Issue 2314663002: Rework scanner-character-streams. (Closed)
Patch Set: Marja's feedback. Created 4 years, 3 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/compiler-dispatcher/compiler-dispatcher-job.cc ('k') | src/parsing/scanner.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/parser.cc
diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc
index ea9282bf70995f172253943ca86ec2fcc2b3d22b..f5c4632bc29907e5a8b216da7b57f3e6f45361ce 100644
--- a/src/parsing/parser.cc
+++ b/src/parsing/parser.cc
@@ -616,17 +616,7 @@ FunctionLiteral* Parser::ParseProgram(Isolate* isolate, ParseInfo* info) {
FunctionLiteral* result;
{
- std::unique_ptr<Utf16CharacterStream> stream;
- if (source->IsExternalTwoByteString()) {
- stream.reset(new ExternalTwoByteStringUtf16CharacterStream(
- Handle<ExternalTwoByteString>::cast(source), 0, source->length()));
- } else if (source->IsExternalOneByteString()) {
- stream.reset(new ExternalOneByteStringUtf16CharacterStream(
- Handle<ExternalOneByteString>::cast(source), 0, source->length()));
- } else {
- stream.reset(
- new GenericStringUtf16CharacterStream(source, 0, source->length()));
- }
+ std::unique_ptr<Utf16CharacterStream> stream(ScannerStream::For(source));
scanner_.Initialize(stream.get());
result = DoParseProgram(info);
}
@@ -773,19 +763,8 @@ FunctionLiteral* Parser::ParseLazy(Isolate* isolate, ParseInfo* info) {
source = String::Flatten(source);
FunctionLiteral* result;
{
- std::unique_ptr<Utf16CharacterStream> stream;
- if (source->IsExternalTwoByteString()) {
- stream.reset(new ExternalTwoByteStringUtf16CharacterStream(
- Handle<ExternalTwoByteString>::cast(source),
- shared_info->start_position(), shared_info->end_position()));
- } else if (source->IsExternalOneByteString()) {
- stream.reset(new ExternalOneByteStringUtf16CharacterStream(
- Handle<ExternalOneByteString>::cast(source),
- shared_info->start_position(), shared_info->end_position()));
- } else {
- stream.reset(new GenericStringUtf16CharacterStream(
- source, shared_info->start_position(), shared_info->end_position()));
- }
+ std::unique_ptr<Utf16CharacterStream> stream(ScannerStream::For(
+ source, shared_info->start_position(), shared_info->end_position()));
Handle<String> name(String::cast(shared_info->name()));
result =
DoParseLazy(info, ast_value_factory()->GetString(name), stream.get());
@@ -4922,8 +4901,8 @@ void Parser::ParseOnBackground(ParseInfo* info) {
stream_ptr = info->character_stream();
} else {
DCHECK(info->character_stream() == nullptr);
- stream.reset(new ExternalStreamingStream(info->source_stream(),
- info->source_stream_encoding()));
+ stream.reset(ScannerStream::For(info->source_stream(),
+ info->source_stream_encoding()));
stream_ptr = stream.get();
}
DCHECK(info->context().is_null() || info->context()->IsNativeContext());
« no previous file with comments | « src/compiler-dispatcher/compiler-dispatcher-job.cc ('k') | src/parsing/scanner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698