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

Unified Diff: src/parser.cc

Issue 98863002: Experimental scanner: fix harmony flag setting. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 7 years 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/parser.h ('k') | src/preparser.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 08bc948f0b82067ef3a6c0e47199c579be103853..b56e1fd15dd3ae5e8342f35fe50d0f08b7f37414 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -553,12 +553,7 @@ Parser::Parser(CompilationInfo* info)
info_(info) {
ASSERT(!script_.is_null());
isolate_->set_ast_node_id(0);
- // FIXME: these can be done only when the ExperimentalScanner has been
- // created, and they need to be redone when it's recreated.
- // set_allow_harmony_scoping(!info->is_native() && FLAG_harmony_scoping);
- // set_allow_modules(!info->is_native() && FLAG_harmony_modules);
set_allow_natives_syntax(FLAG_allow_natives_syntax || info->is_native());
- // set_allow_harmony_numeric_literals(FLAG_harmony_numeric_literals);
set_allow_lazy(false); // Must be explicitly enabled.
set_allow_generators(FLAG_harmony_generators);
set_allow_for_of(FLAG_harmony_iteration);
@@ -581,19 +576,17 @@ FunctionLiteral* Parser::ParseProgram() {
FlattenString(source);
FunctionLiteral* result;
if (source->IsTwoByteRepresentation()) {
- // Notice that the stream is destroyed at the end of the branch block.
- // The last line of the blocks can't be moved outside, even though they're
- // identical calls. // FIXME
+ delete reusable_preparser_;
delete scanner_;
scanner_ = new ExperimentalScanner<uint16_t>(source, isolate());
- // FIXME: set flags
- result = DoParseProgram(info(), source);
} else {
+ delete reusable_preparser_;
delete scanner_;
scanner_ = new ExperimentalScanner<uint8_t>(source, isolate());
- // FIXME: set flags
- result = DoParseProgram(info(), source);
}
+ SetScannerFlags();
+ scanner_->Init();
+ result = DoParseProgram(info(), source);
if (FLAG_trace_parse && result != NULL) {
double ms = timer.Elapsed().InMillisecondsF();
@@ -725,15 +718,17 @@ FunctionLiteral* Parser::ParseLazy() {
FunctionLiteral* Parser::ParseLazy(Handle<String> source, int start, int end) {
+ delete reusable_preparser_;
delete scanner_;
if (source->IsTwoByteRepresentation()) {
scanner_ = new ExperimentalScanner<uint16_t>(source, isolate());
} else {
scanner_ = new ExperimentalScanner<uint8_t>(source, isolate());
}
+ SetScannerFlags();
+ // We don't need to Init() if we immediately SeekForward.
scanner_->SeekForward(start);
scanner_->SetEnd(end);
- // FIXME: set flags
Handle<SharedFunctionInfo> shared_info = info()->shared_info();
ASSERT(top_scope_ == NULL);
@@ -5674,4 +5669,11 @@ bool Parser::Parse() {
return (result != NULL);
}
+
+void Parser::SetScannerFlags() {
+ scanner_->SetHarmonyScoping(!info_->is_native() && FLAG_harmony_scoping);
+ scanner_->SetHarmonyModules(!info_->is_native() && FLAG_harmony_modules);
+ scanner_->SetHarmonyNumericLiterals(FLAG_harmony_numeric_literals);
+}
+
} } // namespace v8::internal
« no previous file with comments | « src/parser.h ('k') | src/preparser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698