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

Unified Diff: src/parser.cc

Issue 5026005: Move static scanner fields to scanner-base.h (Closed)
Patch Set: Created 10 years, 1 month 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/objects.cc ('k') | src/scanner.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index a0f3b7147f20eda1457d4f41276c550d70b2b612..e6a57e313952c4ce57b4ff5169cc4b49c24e1ab6 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -36,6 +36,7 @@
#include "messages.h"
#include "parser.h"
#include "platform.h"
+#include "prescanner.h"
#include "preparser.h"
#include "runtime.h"
#include "scopeinfo.h"
@@ -4667,9 +4668,21 @@ ScriptDataImpl* ParserApi::PreParse(Handle<String> source,
unibrow::CharacterStream* stream,
v8::Extension* extension) {
Handle<Script> no_script;
- preparser::PreParser<Scanner, CompleteParserRecorder> parser;
- Scanner scanner;
- scanner.Initialize(source, stream, JAVASCRIPT);
+ int length = 0;
+ SafeStringInputBuffer safe_stream;
+ if (!source.is_null()) {
+ length = source->length();
+ safe_stream.Reset(source.location());
+ stream = &safe_stream;
+ } else {
+ length = stream->Length();
+ }
+ typedef preparser::Scanner<CharacterStreamUTF16Buffer, UTF8Buffer> PreScanner;
+ preparser::PreParser<PreScanner, CompleteParserRecorder> parser;
+ CharacterStreamUTF16Buffer buffer;
+ buffer.Initialize(source, stream, 0, length);
+ PreScanner scanner;
+ scanner.Initialize(&buffer);
bool allow_lazy = FLAG_lazy && (extension == NULL);
CompleteParserRecorder recorder;
if (!parser.PreParseProgram(&scanner, &recorder, allow_lazy)) {
« no previous file with comments | « src/objects.cc ('k') | src/scanner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698